Major zsh overhaul. Check commands before aliasing, afci won't clobber a git dir

This commit is contained in:
Austen Adler 2016-09-28 12:54:47 -04:00
parent e1c9de5840
commit 813b963e77
No known key found for this signature in database
GPG Key ID: 7ECEE590CCDFE3F1

View File

@ -18,6 +18,13 @@ setopt APPEND_HISTORY SHARE_HISTORY HISTIGNOREALLDUPS
export DISABLE_AUTO_TITLE=true
export EDITOR='vim'
export FZF_COMPLETION_OPTS='--no-mouse -m -1 -x'
zstyle ':completion:*' use-cache on
zstyle ':completion:*' cache-path ~/.cache/zsh
# Check if a command exists
ex(){
command -v "$1" >/dev/null
return $?
}
# For pasting in commands that start with $
$ () {
$*
@ -95,14 +102,22 @@ run(){
gcc -Wall -std=c99 "${1:r}.c" -o "${1:r}" && (echo "Running..." >&2;./"${1:r}")
}
alias nmrestart='nmcli radio wifi off;nmcli radio wifi on'
alias mtr='mtr -t'
alias tg='telegram-cli -NWA'
if ex mtr; then
alias mtr='mtr -t'
fi
if ex telegram-cli; then
alias tg='telegram-cli -NWA'
fi
alias perm='stat -c "%a %n"'
alias afci='git x ./autoformat.sh;git add --all;git commit -m "Autoformatted"'
alias eix="eix -F"
alias afci='git x ./autoformat.sh;git commit -am "Autoformatted"'
if ex eix; then
alias eix="eix -F"
fi
alias mouse1="xmodmap <(echo pointer = 1 2 3)"
alias mouse2="xmodmap <(echo pointer = 3 2 1)"
alias ocp="ocp -vs0 -dcurses"
if ex ocp; then
alias ocp="ocp -vs0 -dcurses"
fi
alias con='git x php app/console'
alias srm='shred -uzv'
alias disphost='export DISPLAY=:0.0'
@ -110,20 +125,27 @@ alias ll='ls -AlhF'
alias la='ls -A'
alias l='ls -CF'
alias logout='sudo pkill -u $USER'
alias tmux='tmux -2'
if ex tmux; then
alias tmux='tmux -2'
fi
alias less='less -R'
alias tree='tree -C'
alias skim="(head -5; tail -5) <"
alias cp='rsync --partial -ha --info=progress2 "$@"'
if ex tree; then
alias tree='tree -C'
fi
alias resource='. ~/.zshrc'
if [ "$(uname)" != "Darwin" ]; then
# Not Mac
export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:$(readlink -e ~/bin)"
export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:~/bin"
alias ls='ls --color=always -F'
alias matlab='matlab -glnx86'
alias where="readlink -m"
else
# It is a mac
# Prepend macports directories in /opt/local
if ex greadlink; then
alias readlink='greadlink'
alias where="greadlink -m"
fi
export PATH="/opt/local/sbin:/opt/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:~/bin"
fi
if test -f /etc/gentoo-release; then
@ -192,22 +214,40 @@ alias ............='k ../../../../../../../../../../..'
alias .............='k ../../../../../../../../../../../..'
alias ..............='k ../../../../../../../../../../../../..'
alias ...............='k ../../../../../../../../../../../../../..'
alias ytdl="youtube-dl $@ -x --audio-format mp3 --audio-quality 0 -c -o '%(title)s.%(ext)s'"
alias tux="wemux"
alias g="git"
if ex youtube-dl; then
alias ytdl="youtube-dl $@ -x --audio-format mp3 --audio-quality 0 -c -o '%(title)s.%(ext)s'"
fi
if ex wemux; then
alias tux="wemux"
elif ex tmux; then
alias tux="tmux a || tmux"
fi
if ex git; then
alias g="git"
fi
alias stdns="sudo sh -c 'echo nameserver 8.8.8.8 > /etc/resolv.conf'"
alias fvim="vim -u NONE +\"so ~/.vim/plugged/flappyvird-vim/plugin/flappyvird.vim\" +\"so ~/.vim/plugged/flappyvird-vim/autoload/flappyvird.vim\" +\":FlappyVird\" +\":q\""
alias fk='k `fzf --no-mouse -m -1 -x`'
alias susp="sudo true&&((slock;sleep 2;nmcli radio wifi off;nmcli radio wifi on)&echo mem | sudo tee /sys/power/state >/dev/null)"
alias s='sudo -Hu'
if ex sudo; then
alias s='sudo -Hu'
fi
alias -g PA='2>&1 | paste'
alias -g c='rsync --partial -ha --info=progress2 "$@"'
alias -g cfat='rsync --partial -hrlc --info=progress2 "$@"'
if ex rsync; then
alias -g c='rsync --partial -ha --info=progress2 "$@"'
alias -g cfat='rsync --partial -hrlc --info=progress2 "$@"'
alias cp='rsync --partial -ha --info=progress2 "$@"'
fi
alias -g nify=" > /dev/null 2>&1 &"
alias -g nifyd=" > /dev/null 2>&1 & disown"
alias -g L="2>&1|less"
alias -g G='|& ag'
alias -g GA='|& ag --pager less'
if ex ag; then
alias -g G='|& ag'
elif ex egrep; then
alias -g G='|& egrep'
elif ex grep; then
alias -g G='|& grep'
fi
timer() {
for i in {1.."$1"}; do
sleep 1
@ -482,10 +522,13 @@ k(){
vim "$@"
fi
}
(( $+TMUX )) && unset zle_bracketed_paste
if (( $+TMUX )) || [[ "$TERM" = "screen-256color" ]] || [[ "$TERM" = "screen.xterm-256color" ]]; then
unset zle_bracketed_paste
fi
#(( $+TMUX )) && unset zle_bracketed_paste
[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh
if command -v fasd 2>&1 >/dev/null; then
if ex fasd; then
eval "$(fasd --init auto)"
fi