zshrc: Clean up a little
This commit is contained in:
parent
9c142c87b6
commit
1fca49fa40
1 changed files with 57 additions and 46 deletions
83
zshrc
83
zshrc
|
@ -59,8 +59,20 @@ compinit -C
|
||||||
# Ignore case on completion
|
# Ignore case on completion
|
||||||
zstyle ':completion:*' matcher-list 'm:{A-Z}={a-z} m:{a-z}={A-Z}'
|
zstyle ':completion:*' matcher-list 'm:{A-Z}={a-z} m:{a-z}={A-Z}'
|
||||||
|
|
||||||
|
__has_command() {
|
||||||
|
for i in $@; do
|
||||||
|
which $i &>/dev/null && return 0
|
||||||
|
done
|
||||||
|
return 1
|
||||||
|
}
|
||||||
__find_command() {
|
__find_command() {
|
||||||
which "$1" &>/dev/null && echo "$1" || echo "$2"
|
for i in $@; do
|
||||||
|
if __has_command $i; then
|
||||||
|
echo $i
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
if [ -n "$grep" -o -n "$grep_color" ]; then
|
if [ -n "$grep" -o -n "$grep_color" ]; then
|
||||||
|
@ -198,8 +210,8 @@ do
|
||||||
alias -s "$ext=extr"
|
alias -s "$ext=extr"
|
||||||
done
|
done
|
||||||
|
|
||||||
[ "$EDITOR" = vim ] && alias vi=vim
|
__has_command vim && alias vi=vim
|
||||||
which gpg2 &>/dev/null && alias gpg=gpg2
|
__has_command gpg2 && alias gpg=gpg2
|
||||||
|
|
||||||
make() {
|
make() {
|
||||||
case "$PWD" in
|
case "$PWD" in
|
||||||
|
@ -213,22 +225,23 @@ make() {
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
alias tmux="tmux -f $XDG_CONFIG_HOME/tmux/tmux.conf"
|
__has_command tmux && alias tmux="tmux -f $XDG_CONFIG_HOME/tmux/tmux.conf"
|
||||||
|
|
||||||
if which fossil &>/dev/null; then
|
if ! __has_command colordiff; then
|
||||||
|
colordiff() {
|
||||||
|
red="$(tput setaf 1)"
|
||||||
|
green="$(tput setaf 2)"
|
||||||
|
reset="$(tput sgr0)"
|
||||||
|
sed "s/^+.*$/$green&$reset/" | sed "s/^-.*$/$red&$reset/"
|
||||||
|
}
|
||||||
|
fi
|
||||||
|
|
||||||
|
if __has_command fossil; then
|
||||||
alias fl="fossil"
|
alias fl="fossil"
|
||||||
alias flc="fossil changes --differ"
|
alias flc="fossil changes --differ"
|
||||||
|
|
||||||
fld() {
|
fld() {
|
||||||
if which colordiff &>/dev/null; then
|
|
||||||
fossil diff -N "$@" | colordiff | less -FRX
|
fossil diff -N "$@" | colordiff | less -FRX
|
||||||
else
|
|
||||||
red="$(tput setaf 1)"
|
|
||||||
green="$(tput setaf 2)"
|
|
||||||
reset="$(tput sgr0)"
|
|
||||||
fossil diff -N "$@" | sed "s/^+.*$/$green&$reset/" |
|
|
||||||
sed "s/^-.*$/$red&$reset/" | less -FRX
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
flgrep() {
|
flgrep() {
|
||||||
|
@ -299,38 +312,35 @@ if which fossil &>/dev/null; then
|
||||||
}
|
}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if which cvs &>/dev/null; then
|
if __has_command cvs; then
|
||||||
cvsd() {
|
cvsd() {
|
||||||
if which colordiff &>/dev/null; then
|
|
||||||
cvs diff -uN "$@" | colordiff | less -FRX
|
cvs diff -uN "$@" | colordiff | less -FRX
|
||||||
else
|
|
||||||
red="$(tput setaf 1)"
|
|
||||||
green="$(tput setaf 2)"
|
|
||||||
reset="$(tput sgr0)"
|
|
||||||
cvs diff -uN "$@" | sed "s/^+.*$/$green&$reset/" |
|
|
||||||
sed "s/^-.*$/$red&$reset/" | less -FRX
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# pkgsrc does not like MAKEFLAGS including -j
|
# pkgsrc does not like MAKEFLAGS including -j
|
||||||
which pkg_chk &>/dev/null && alias pkg_chk="MAKEFLAGS= pkg_chk"
|
__has_command pkg_chk &&
|
||||||
which pkg_rolling-replace &>/dev/null &&
|
alias pkg_chk="MAKEFLAGS= pkg_chk"
|
||||||
|
__has_command pkg_rolling-replace &&
|
||||||
alias pkg_rolling-replace="MAKEFLAGS= pkg_rolling-replace"
|
alias pkg_rolling-replace="MAKEFLAGS= pkg_rolling-replace"
|
||||||
which url2pkg &>/dev/null && alias url2pkg="MAKEFLAGS= url2pkg"
|
__has_command url2pkg &&
|
||||||
|
alias url2pkg="MAKEFLAGS= url2pkg"
|
||||||
|
|
||||||
# mpv does not like locales that use , as decimal point.
|
# mpv does not like locales that use , as decimal point.
|
||||||
alias mpv="LC_ALL=C mpv"
|
__has_command mpv && alias mpv="LC_ALL=C mpv"
|
||||||
|
|
||||||
alias gpg-ssh="SSH_AUTH_SOCK=$GNUPGHOME/S.gpg-agent.ssh ssh"
|
if __has_command gpg gpg2; then
|
||||||
alias gpg-ssh-add="SSH_AUTH_SOCK=$GNUPGHOME/S.gpg-agent.ssh ssh-add"
|
alias gpg-ssh="SSH_AUTH_SOCK=$GNUPGHOME/S.gpg-agent.ssh ssh"
|
||||||
alias gpg-sftp="SSH_AUTH_SOCK=$GNUPGHOME/S.gpg-agent.ssh sftp"
|
alias gpg-ssh-add="SSH_AUTH_SOCK=$GNUPGHOME/S.gpg-agent.ssh ssh-add"
|
||||||
|
alias gpg-sftp="SSH_AUTH_SOCK=$GNUPGHOME/S.gpg-agent.ssh sftp"
|
||||||
|
fi
|
||||||
|
|
||||||
pwnk() {
|
if __has_command cryptopassphrase; then
|
||||||
|
pwnk() {
|
||||||
local clipboard
|
local clipboard
|
||||||
if which pbcopy &>/dev/null; then
|
if __has_command pbcopy; then
|
||||||
clipboard=pbcopy
|
clipboard=pbcopy
|
||||||
elif which xclip &>/dev/null; then
|
elif __has_command xclip; then
|
||||||
clipboard=xclip
|
clipboard=xclip
|
||||||
else
|
else
|
||||||
echo "No clipboard handler found!"
|
echo "No clipboard handler found!"
|
||||||
|
@ -338,9 +348,10 @@ pwnk() {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cryptopassphrase $@ | tr -d '\n' | $clipboard
|
cryptopassphrase $@ | tr -d '\n' | $clipboard
|
||||||
}
|
}
|
||||||
alias pw="pwnk -k ~/.cryptopassphrase.key"
|
alias pw="pwnk -k ~/.cryptopassphrase.key"
|
||||||
alias pws="pwnk -k ~/.cryptopassphrase-server.key"
|
alias pws="pwnk -k ~/.cryptopassphrase-server.key"
|
||||||
|
fi
|
||||||
|
|
||||||
ixio() { curl -F 'f:1=<-' ix.io }
|
ixio() { curl -F 'f:1=<-' ix.io }
|
||||||
0x0st() { curl -F'file=@-' https://0x0.st }
|
0x0st() { curl -F'file=@-' https://0x0.st }
|
||||||
|
@ -397,7 +408,7 @@ cross() {
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
ios | iossim)
|
ios | iossim)
|
||||||
if ! which xcrun &>/dev/null; then
|
if ! __has_command xcrun; then
|
||||||
echo -n "Can only cross-compile for iOS " 1>&2
|
echo -n "Can only cross-compile for iOS " 1>&2
|
||||||
echo "on a Mac with Xcode!" 1>&2
|
echo "on a Mac with Xcode!" 1>&2
|
||||||
return 1
|
return 1
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue