config/shell: add zsh compdefs
This commit is contained in:
parent
7aaa7ebabc
commit
85716b085a
|
@ -16,9 +16,9 @@ eval "$(dircolors)"
|
||||||
alias ls='ls --color=auto'
|
alias ls='ls --color=auto'
|
||||||
alias ll='ls $LS_OPTIONS -l --all'
|
alias ll='ls $LS_OPTIONS -l --all'
|
||||||
alias l='ls $LS_OPTIONS --color=always --almost-all'
|
alias l='ls $LS_OPTIONS --color=always --almost-all'
|
||||||
which bat >/dev/null || alias bat="$(which batcat >/dev/null && echo batcat || echo less -FX)"
|
which bat >/dev/null 2>&1 || alias bat="$(which batcat >/dev/null 2>&1 && echo batcat || echo less -FX)"
|
||||||
b() { test -d "${1:-.}" && l "$@" || bat "$@"; }
|
b() { test -d "${1:-.}" && l "$@" || bat "$@"; }
|
||||||
alias v="$(which nvim >/dev/null && echo nvim || echo ${EDITOR:-vi})"
|
alias v="$(which nvim >/dev/null 2>&1 && echo nvim || echo ${EDITOR:-vi})"
|
||||||
|
|
||||||
# Grep aliases
|
# Grep aliases
|
||||||
|
|
||||||
|
|
|
@ -366,8 +366,6 @@ then fn() { $(which fd >/dev/null && echo fd || echo fdfind) --hidden --no-ignor
|
||||||
else
|
else
|
||||||
alias ff='find -not -path "*.sync*" -and -not \( -name daten -prune \)'
|
alias ff='find -not -path "*.sync*" -and -not \( -name daten -prune \)'
|
||||||
alias f1='find -mindepth 1 -maxdepth 1'
|
alias f1='find -mindepth 1 -maxdepth 1'
|
||||||
compdef ff=find
|
|
||||||
compdef f1=find
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
lowercase_transliterate="y/A-Z /a-z-/"
|
lowercase_transliterate="y/A-Z /a-z-/"
|
||||||
|
@ -386,6 +384,7 @@ alias dsync='rc --delete --specials'
|
||||||
alias move='rc --remove-source-files'
|
alias move='rc --remove-source-files'
|
||||||
alias rdiff='rsync --recursive --progress --delete --links --dry-run'
|
alias rdiff='rsync --recursive --progress --delete --links --dry-run'
|
||||||
alias rdiffe='rdiff --existing --size-only'
|
alias rdiffe='rdiff --existing --size-only'
|
||||||
|
compdef rcd=rsync
|
||||||
|
|
||||||
# Swap the names of two files
|
# Swap the names of two files
|
||||||
swap() {
|
swap() {
|
||||||
|
@ -394,11 +393,13 @@ swap() {
|
||||||
mv -n $2 $1
|
mv -n $2 $1
|
||||||
mv -n $1.tmp $2
|
mv -n $1.tmp $2
|
||||||
}
|
}
|
||||||
|
compdef swap=mv
|
||||||
|
|
||||||
# mv with automatic sudo if neccessary
|
# mv with automatic sudo if neccessary
|
||||||
smv() {
|
smv() {
|
||||||
test -w "$1" && test -w "$(dirname $2)" && mv "$@" || sudo mv "$@"
|
test -w "$1" && test -w "$(dirname $2)" && mv "$@" || sudo mv "$@"
|
||||||
}
|
}
|
||||||
|
compdef smv=mv
|
||||||
|
|
||||||
# Rename the file inside its directory
|
# Rename the file inside its directory
|
||||||
mvf() {
|
mvf() {
|
||||||
|
@ -417,8 +418,9 @@ mvln() {
|
||||||
[ $file -gt 0 -a -d $2 ] && 2="$2/$(basename $1)"
|
[ $file -gt 0 -a -d $2 ] && 2="$2/$(basename $1)"
|
||||||
echo -n "Linking: " && ln -vsr "$2" "$1"
|
echo -n "Linking: " && ln -vsr "$2" "$1"
|
||||||
}
|
}
|
||||||
|
compdef mvln=mv
|
||||||
|
|
||||||
# Move into an xdg dir (default XDG_DATA_HOME) and create a symlink
|
# Move the given file into an xdg dir (default XDG_DATA_HOME) and create a symlink
|
||||||
mvx() {
|
mvx() {
|
||||||
mvln "$1" "${2:-$XDG_DATA_HOME}/${1#.}"
|
mvln "$1" "${2:-$XDG_DATA_HOME}/${1#.}"
|
||||||
yadm add "$1" ".config/$1" 2>/dev/null
|
yadm add "$1" ".config/$1" 2>/dev/null
|
||||||
|
@ -428,6 +430,7 @@ mvx() {
|
||||||
mkcd() {
|
mkcd() {
|
||||||
mkdir -p "$1" && cd "$1"
|
mkdir -p "$1" && cd "$1"
|
||||||
}
|
}
|
||||||
|
compdef mkcd=mkdir
|
||||||
|
|
||||||
# Other stuff {{{1
|
# Other stuff {{{1
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#compdef yc
|
#compdef yc
|
||||||
compadd $(git diff-index HEAD --name-only --relative=${XDG_CONFIG_HOME/$HOME\/} | sed 's/\.[^.]\+$//')
|
compadd $(yadm diff-index HEAD --name-only --relative=${XDG_CONFIG_HOME/$HOME\/} | sed 's/\.[^.]\+$//')
|
||||||
#_files -W $XDG_CONFIG_HOME -g "git*"
|
#_files -W $XDG_CONFIG_HOME -g "git*"
|
||||||
# xargs _files -W $XDG_CONFIG_HOME -g
|
# xargs _files -W $XDG_CONFIG_HOME -g
|
||||||
# yadm diff HEAD --name-only -- $XDG_CONFIG_HOME
|
# yadm diff HEAD --name-only -- $XDG_CONFIG_HOME
|
||||||
|
|
Loading…
Reference in New Issue