Initial commit
This commit is contained in:
58
.zsh_aliases
Normal file
58
.zsh_aliases
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
# Turn on interactive mode for dangerous commands
|
||||||
|
alias cp='cp -iv'
|
||||||
|
alias mv='mv -iv'
|
||||||
|
alias rm='rm -iv'
|
||||||
|
|
||||||
|
# File sizes should always be human-readable
|
||||||
|
alias df='df -h'
|
||||||
|
alias du='du -h'
|
||||||
|
|
||||||
|
# Greps
|
||||||
|
alias egrep='egrep --color=auto' # show differences in colour
|
||||||
|
alias fgrep='fgrep --color=auto' # show differences in colour
|
||||||
|
alias grep='grep --color' # show differences in colour
|
||||||
|
|
||||||
|
# File Listing
|
||||||
|
alias l='ls -CF' # list with Columns
|
||||||
|
alias la='ls -CFA' # l with . and ..
|
||||||
|
alias ll='ls -l' # long list
|
||||||
|
alias lla='ls -al' # ll with . and ..
|
||||||
|
alias ls='ls -hF --color=tty' # classify files in colour
|
||||||
|
|
||||||
|
# Extras
|
||||||
|
alias ping='ping -c 5' # Stop pinging after 5 pings
|
||||||
|
alias vi='vim' # use vim instead of vi
|
||||||
|
alias less='less -r' # repaint screen
|
||||||
|
|
||||||
|
# type 'warp' once to set the PWD,
|
||||||
|
# CD to other dirs then type 'warp' again to warp back
|
||||||
|
alias warp='if [[ "$w" == "" ]]; then w="$(pwd)"; else cd "$w"; unset w; fi'
|
||||||
|
|
||||||
|
# Misc Shit
|
||||||
|
alias LISTEN='netstat -pant | grep LISTEN' # a quicker way to see what services are listening
|
||||||
|
alias fuck='sudo $(history -p \!\!)' # runs the last command as sudo
|
||||||
|
|
||||||
|
# Terminal Pastebin
|
||||||
|
alias tb='nc termbin.com 9999'
|
||||||
|
|
||||||
|
# between head and less
|
||||||
|
alias page="head -n $(stty size | awk '{print $1 -2}')"
|
||||||
|
|
||||||
|
# Terminal Pastebin
|
||||||
|
alias pb='nc phaedrus.planethawleywood.com 9999'
|
||||||
|
|
||||||
|
# Get Ext IP
|
||||||
|
alias extip='curl -s -4 icanhazip.com'
|
||||||
|
|
||||||
|
# Remote Desktop
|
||||||
|
alias remadmin='/usr/bin/rdesktop -u "zion\\chawley2" -p -g 1280x750 remadmin.precisiondialogue.com'
|
||||||
|
|
||||||
|
alias usedips='nmap -v -sn -n 192.168.0.0/24 -oG - | grep Up'
|
||||||
|
alias openips='nmap -v -sn -n 192.168.0.0/24 -oG - | grep Down'
|
||||||
|
|
||||||
|
# webthis - create asimple HTTP server in the current directory serving on port 8000
|
||||||
|
alias webthis='python -m SimpleHTTPServer 8000'
|
||||||
|
|
||||||
|
# For cheating at DCSS (using git)
|
||||||
|
alias crawlrestore='git reset --hard && git clean -fd'
|
||||||
|
|
||||||
90
.zsh_functions
Normal file
90
.zsh_functions
Normal file
@@ -0,0 +1,90 @@
|
|||||||
|
# BASH Functions
|
||||||
|
|
||||||
|
# Shell note pad
|
||||||
|
note () {
|
||||||
|
# if file doesn't exist, create it
|
||||||
|
if [[ ! -f $HOME/.notes ]]; then
|
||||||
|
touch "$HOME/.notes"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! (($#)); then
|
||||||
|
# no arguments, print file
|
||||||
|
cat "$HOME/.notes"
|
||||||
|
elif [[ "$1" == "-c" ]]; then
|
||||||
|
# clear file
|
||||||
|
echo -n "Clear notes file? [Y/N] "
|
||||||
|
read replace
|
||||||
|
if [ "${replace}" = "Y" ] || [ "${replace}" = "y" ]; then
|
||||||
|
echo "Emptying notes file..."
|
||||||
|
printf "%s" > "$HOME/.notes"
|
||||||
|
echo "Done."
|
||||||
|
else
|
||||||
|
echo "Notes file preserved."
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
# add all arguments to file
|
||||||
|
echo -n $(date +"%F %T | ") >> "$HOME/.notes"
|
||||||
|
printf "%s\n" "$*" >> "$HOME/.notes"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# tar/gzip a directory
|
||||||
|
# I use this before 'rm -rf'ing a directory I think is useless
|
||||||
|
# if nothing breaks after a predetermined amount of time, then the tar file is safe to delete
|
||||||
|
tardir() {
|
||||||
|
#ensure $1 is a directory
|
||||||
|
if [ ! -d "${1}" ]; then
|
||||||
|
echo "$1 is not a directory. Aborting."
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
#strip trailing slash
|
||||||
|
target="${1%/}"
|
||||||
|
echo "Dir size: $(du -hs ${target})"
|
||||||
|
tar czf "${target}".tar.gz "${target}"
|
||||||
|
echo "Archive size: $(du -hs ${target}.tar.gz)"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Replacement for 'for i in $(ls); do du -hs $i; done' that handles spaces
|
||||||
|
function dudir() {
|
||||||
|
if ! (($#)); then
|
||||||
|
dir=$(pwd)
|
||||||
|
else
|
||||||
|
dir="${1}"
|
||||||
|
fi
|
||||||
|
# redefine $IFS
|
||||||
|
o=$IFS
|
||||||
|
IFS=$(echo -en "\n\b")
|
||||||
|
for i in $(ls "${dir}"); do
|
||||||
|
du -hs "${i}"
|
||||||
|
done
|
||||||
|
# reset $IFS
|
||||||
|
IFS=$o
|
||||||
|
}
|
||||||
|
|
||||||
|
# HAHA! Weather in the terminal
|
||||||
|
weather() {
|
||||||
|
if [ $(command -v curl) ]; then
|
||||||
|
if ! (($#)); then
|
||||||
|
curl wttr.in/44113
|
||||||
|
else
|
||||||
|
curl wttr.in/$1
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "curl not installed. Aborting."
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Replaces "ps aux | grep <something>" with "psaux <something>". Shorter to type, more informational and doesn't include the command itself in the output.
|
||||||
|
psaux () { pgrep -f "$@" | xargs ps -fp 2>/dev/null; }
|
||||||
|
|
||||||
|
# mail a file
|
||||||
|
email() {
|
||||||
|
if ! (($#)); then
|
||||||
|
echo "USAGE: email {filename} {email-address}"
|
||||||
|
return 1
|
||||||
|
else
|
||||||
|
efile=${1}
|
||||||
|
eaddr=${2}
|
||||||
|
echo "See Attached" | mail -s "File: ${efile}" -a ${efile} ${2}
|
||||||
|
fi
|
||||||
|
}
|
||||||
94
.zshrc
Normal file
94
.zshrc
Normal file
@@ -0,0 +1,94 @@
|
|||||||
|
# If you come from bash you might have to change your $PATH.
|
||||||
|
# export PATH=$HOME/bin:/usr/local/bin:$PATH
|
||||||
|
|
||||||
|
# Path to your oh-my-zsh installation.
|
||||||
|
export ZSH=$HOME/.oh-my-zsh
|
||||||
|
|
||||||
|
# Set name of the theme to load. Optionally, if you set this to "random"
|
||||||
|
# it'll load a random theme each time that oh-my-zsh is loaded.
|
||||||
|
# See https://github.com/robbyrussell/oh-my-zsh/wiki/Themes
|
||||||
|
#ZSH_THEME="robbyrussell"
|
||||||
|
ZSH_THEME="avit"
|
||||||
|
|
||||||
|
# Uncomment the following line to use case-sensitive completion.
|
||||||
|
# CASE_SENSITIVE="true"
|
||||||
|
|
||||||
|
# Uncomment the following line to use hyphen-insensitive completion. Case
|
||||||
|
# sensitive completion must be off. _ and - will be interchangeable.
|
||||||
|
# HYPHEN_INSENSITIVE="true"
|
||||||
|
|
||||||
|
# Uncomment the following line to disable bi-weekly auto-update checks.
|
||||||
|
# DISABLE_AUTO_UPDATE="true"
|
||||||
|
|
||||||
|
# Uncomment the following line to change how often to auto-update (in days).
|
||||||
|
# export UPDATE_ZSH_DAYS=13
|
||||||
|
|
||||||
|
# Uncomment the following line to disable colors in ls.
|
||||||
|
# DISABLE_LS_COLORS="true"
|
||||||
|
|
||||||
|
# Uncomment the following line to disable auto-setting terminal title.
|
||||||
|
# DISABLE_AUTO_TITLE="true"
|
||||||
|
|
||||||
|
# Uncomment the following line to enable command auto-correction.
|
||||||
|
ENABLE_CORRECTION="true"
|
||||||
|
|
||||||
|
# Uncomment the following line to display red dots whilst waiting for completion.
|
||||||
|
COMPLETION_WAITING_DOTS="true"
|
||||||
|
|
||||||
|
# Uncomment the following line if you want to disable marking untracked files
|
||||||
|
# under VCS as dirty. This makes repository status check for large repositories
|
||||||
|
# much, much faster.
|
||||||
|
# DISABLE_UNTRACKED_FILES_DIRTY="true"
|
||||||
|
|
||||||
|
# Uncomment the following line if you want to change the command execution time
|
||||||
|
# stamp shown in the history command output.
|
||||||
|
# The optional three formats: "mm/dd/yyyy"|"dd.mm.yyyy"|"yyyy-mm-dd"
|
||||||
|
# HIST_STAMPS="mm/dd/yyyy"
|
||||||
|
|
||||||
|
# Would you like to use another custom folder than $ZSH/custom?
|
||||||
|
# ZSH_CUSTOM=/path/to/new-custom-folder
|
||||||
|
|
||||||
|
# Which plugins would you like to load? (plugins can be found in ~/.oh-my-zsh/plugins/*)
|
||||||
|
# Custom plugins may be added to ~/.oh-my-zsh/custom/plugins/
|
||||||
|
# Example format: plugins=(rails git textmate ruby lighthouse)
|
||||||
|
# Add wisely, as too many plugins slow down shell startup.
|
||||||
|
plugins=(git)
|
||||||
|
|
||||||
|
source $ZSH/oh-my-zsh.sh
|
||||||
|
|
||||||
|
# User configuration
|
||||||
|
|
||||||
|
# export MANPATH="/usr/local/man:$MANPATH"
|
||||||
|
|
||||||
|
# You may need to manually set your language environment
|
||||||
|
# export LANG=en_US.UTF-8
|
||||||
|
|
||||||
|
# Preferred editor for local and remote sessions
|
||||||
|
# if [[ -n $SSH_CONNECTION ]]; then
|
||||||
|
# export EDITOR='vim'
|
||||||
|
# else
|
||||||
|
# export EDITOR='mvim'
|
||||||
|
# fi
|
||||||
|
|
||||||
|
# Compilation flags
|
||||||
|
# export ARCHFLAGS="-arch x86_64"
|
||||||
|
|
||||||
|
# ssh
|
||||||
|
# export SSH_KEY_PATH="~/.ssh/rsa_id"
|
||||||
|
|
||||||
|
# Set personal aliases, overriding those provided by oh-my-zsh libs,
|
||||||
|
# plugins, and themes. Aliases can be placed here, though oh-my-zsh
|
||||||
|
# users are encouraged to define aliases within the ZSH_CUSTOM folder.
|
||||||
|
# For a full list of active aliases, run `alias`.
|
||||||
|
#
|
||||||
|
# Example aliases
|
||||||
|
# alias zshconfig="mate ~/.zshrc"
|
||||||
|
# alias ohmyzsh="mate ~/.oh-my-zsh"
|
||||||
|
|
||||||
|
# Source zsh aliases
|
||||||
|
#
|
||||||
|
source $HOME/.zsh_aliases
|
||||||
|
|
||||||
|
# Source zsh functions
|
||||||
|
#
|
||||||
|
source $HOME/.zsh_functions
|
||||||
@@ -1,2 +1,9 @@
|
|||||||
# dotfiles-zsh
|
# dotfiles-zsh
|
||||||
zsh-specific dotfiles
|
|
||||||
|
A dotfile repo for zsh-specific dotfiles. I've not yet put zsh on all my machines and I want to start segregating bash
|
||||||
|
and zsh configs so I can switch back and forth if need be.
|
||||||
|
|
||||||
|
The setup script will check for the presence of the `~/.oh-my-zsh/` directory and if not found will install oh-my-zsh
|
||||||
|
from the [ohmyz.sh](http://ohmyz.sh/) website.
|
||||||
|
|
||||||
|
If oh-my-zsh needs to be installed the script will end after the installation. Re-run it to then link the dotfiles.
|
||||||
|
|||||||
167
setup.sh
Executable file
167
setup.sh
Executable file
@@ -0,0 +1,167 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
#===============================================================================
|
||||||
|
#
|
||||||
|
# FILE: setup.sh
|
||||||
|
# USAGE: ./setup.sh
|
||||||
|
# DESCRIPTION: after pulling/cloning dotfiles repo, this script will check/create
|
||||||
|
# symlinks for for dotfiles. It checks for the presence of installed
|
||||||
|
# software (i.e. won't symlink a dotfile for applications that aren't
|
||||||
|
# installed) and will remove links for applications that are no longer
|
||||||
|
# installed. Safe to run after every git pull
|
||||||
|
# OPTIONS:
|
||||||
|
# REQUIREMENTS: This script replies on the 'command' command. Basically, it will run
|
||||||
|
# `command -v <dotfile>` and if there is no output, it assumes the app
|
||||||
|
# isn't installed. So this won't work for apps that aren't in your $PATH
|
||||||
|
# reference: http://www.cyberciti.biz/faq/unix-linux-shell-find-out-posixcommand-exists-or-not/
|
||||||
|
# NOTES:
|
||||||
|
# AUTHOR: C Hawley
|
||||||
|
# CREATED: 2015-10
|
||||||
|
# REVISION: Mon 09 Oct 2017 04:14:39 PM EDT
|
||||||
|
#
|
||||||
|
#===============================================================================
|
||||||
|
|
||||||
|
set -o nounset # Treat unset variables as an error
|
||||||
|
|
||||||
|
# specify where your dotfiles live
|
||||||
|
dotfiledir="$HOME/dotfiles-zsh"
|
||||||
|
|
||||||
|
# function to handle checking for existings links/files and updating
|
||||||
|
link() {
|
||||||
|
echo "symlinking ${1}"
|
||||||
|
# check for existing symlinks
|
||||||
|
if [ -h "${HOME}"/"${1}" ]; then
|
||||||
|
echo " - There's already a symlink named ${1}. Diff'ing."
|
||||||
|
# If there's an existing sylink, check if it's different than the dotfile
|
||||||
|
if [[ $(diff --brief "${HOME}"/"${1}" "${dotfiledir}"/"${1}") ]]; then
|
||||||
|
# If the links are different, ask if it should be replaced
|
||||||
|
echo " - Old link and new link are different:"
|
||||||
|
echo -n " - Replace existing symlink "${1}"? [Y/N] "
|
||||||
|
read replace
|
||||||
|
if [ "${replace}" = "Y" ] || [ "${replace}" = "y" ]; then
|
||||||
|
# If yes, unlink the old file and link the new one and exit
|
||||||
|
echo " - Unlinking old file and linking new file"
|
||||||
|
unlink "${HOME}"/"${1}"
|
||||||
|
ln -s "${dotfiledir}"/"${1}" "${HOME}"/"${1}"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
# If the link is the same, just exit function
|
||||||
|
echo " - Old link and new link are the same."
|
||||||
|
fi
|
||||||
|
# check for existing file/directory
|
||||||
|
elif [ -f "${HOME}"/"${1}" ] || [ -d "${HOME}"/"${1}" ]; then
|
||||||
|
echo " - There's already a file or directory named ${1}. Diff'ing."
|
||||||
|
if [[ $(diff --brief "${HOME}"/"${1}" "${dotfiledir}"/"${1}") ]]; then
|
||||||
|
echo " - Old file/dir and new link are different:"
|
||||||
|
echo -n " - Rename "${1}" and create new link? [Y/N] "
|
||||||
|
read replace
|
||||||
|
if [ "${replace}" = "Y" ] || [ "${replace}" = "y" ]; then
|
||||||
|
echo " - Renaming old file/dir and linking new file"
|
||||||
|
mv "${HOME}"/"${1}" "${HOME}"/"${1}"_original
|
||||||
|
ln -s "${dotfiledir}"/"${1}" "${HOME}"/"${1}"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
# If there is no existing file, create one and exit
|
||||||
|
echo " - Creating link for ${1}"
|
||||||
|
ln -s "${dotfiledir}"/"${1}" "${HOME}"/"${1}"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# function to handle checking for existings links/files and updating
|
||||||
|
copy() {
|
||||||
|
echo "copying ${1}"
|
||||||
|
# check for existing symlinks
|
||||||
|
if [ -h "${HOME}"/"${1}" ]; then
|
||||||
|
echo " - There's already a symlink named ${1}. Diff'ing."
|
||||||
|
# If there's an existing sylink, check if it's different than the dotfile
|
||||||
|
if [[ $(diff --brief "${HOME}"/"${1}" "${dotfiledir}"/"${1}") ]]; then
|
||||||
|
# If the links are different, ask if it should be replaced
|
||||||
|
echo " - Old link and new link are different:"
|
||||||
|
echo -n " - Replace existing symlink "${1}"? [Y/N] "
|
||||||
|
read replace
|
||||||
|
if [ "${replace}" = "Y" ] || [ "${replace}" = "y" ]; then
|
||||||
|
# If yes, unlink the old file and link the new one and exit
|
||||||
|
echo " - Unlinking old file and copying new file"
|
||||||
|
unlink "${HOME}"/"${1}"
|
||||||
|
cp -rv "${dotfiledir}"/"${1}" "${HOME}"/"${1}"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
# If the link is the same, just exit function
|
||||||
|
echo " - Old link and new link are the same."
|
||||||
|
fi
|
||||||
|
# check for existing file/directory
|
||||||
|
elif [ -f "${HOME}"/"${1}" ] || [ -d "${HOME}"/"${1}" ]; then
|
||||||
|
echo " - There's already a file or directory named ${1}. Diff'ing."
|
||||||
|
if [[ $(diff --brief "${HOME}"/"${1}" "${dotfiledir}"/"${1}") ]]; then
|
||||||
|
echo " - Old file/dir and new link are different:"
|
||||||
|
echo -n " - Rename "${1}" and copy newer? [Y/N] "
|
||||||
|
read replace
|
||||||
|
if [ "${replace}" = "Y" ] || [ "${replace}" = "y" ]; then
|
||||||
|
echo " - Renaming old file/dir and copying new file"
|
||||||
|
mv "${HOME}"/"${1}" "${HOME}"/"${1}"_original
|
||||||
|
cp -rv "${dotfiledir}"/"${1}" "${HOME}"/"${1}"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
# If there is no existing file, create one and exit
|
||||||
|
echo " - Copying ${1}"
|
||||||
|
cp -rv "${dotfiledir}"/"${1}" "${HOME}"/"${1}"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
clear
|
||||||
|
|
||||||
|
echo "------------------------------------------"
|
||||||
|
echo " dotfiles repo setup script "
|
||||||
|
echo "------------------------------------------"
|
||||||
|
echo " Setting up symlinks "
|
||||||
|
echo "------------------------------------------"
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
|
||||||
|
# Check/Install Oh-My-ZSH!
|
||||||
|
#-------------------------------------------------------------------------------
|
||||||
|
if [ ! -d $HOME/.oh-my-zsh ]; then
|
||||||
|
echo "OH NO! You don't have Oh-my-ZSH installed! I'll do it now!"
|
||||||
|
echo ""
|
||||||
|
echo ""
|
||||||
|
echo "When install is finished, re-run this setup script to symlink your dotfiles"
|
||||||
|
echo ""
|
||||||
|
echo "Press a key when ready"
|
||||||
|
read anykey
|
||||||
|
sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
|
||||||
|
exit 0
|
||||||
|
else
|
||||||
|
echo "... nevermind - oh-my-zsh already installed!"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# link .zshrc
|
||||||
|
#-------------------------------------------------------------------------------
|
||||||
|
link .zshrc
|
||||||
|
|
||||||
|
# link .zsh_aliases
|
||||||
|
#-------------------------------------------------------------------------------
|
||||||
|
link .zsh_aliases
|
||||||
|
|
||||||
|
# link .zsh_functions
|
||||||
|
#-------------------------------------------------------------------------------
|
||||||
|
link .zsh_functions
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# Report on backed up files
|
||||||
|
#-------------------------------------------------------------------------------
|
||||||
|
echo "These original files were backed up as '*_original'"
|
||||||
|
ofiles=$(find "${HOME}" -maxdepth 1 -regex ".*_original$" | wc -l)
|
||||||
|
if [ "${ofiles}" -gt 0 ]; then
|
||||||
|
find "${HOME}" -maxdepth 1 -regex ".*_original$"
|
||||||
|
else
|
||||||
|
echo "<No Files Were Backed Up>"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "------------------------------------------"
|
||||||
|
echo "Done. "
|
||||||
|
echo "source ${HOME}/.zshrc "
|
||||||
|
echo "or "
|
||||||
|
echo "logout and login to enable .zshrc changes "
|
||||||
|
echo "------------------------------------------"
|
||||||
Reference in New Issue
Block a user