config/shell: add zsh compdefs

This commit is contained in:
xeruf 2022-05-24 09:24:51 +02:00
parent 7aaa7ebabc
commit 85716b085a
3 changed files with 9 additions and 6 deletions

View File

@ -16,9 +16,9 @@ eval "$(dircolors)"
alias ls='ls --color=auto'
alias ll='ls $LS_OPTIONS -l --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 "$@"; }
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

View File

@ -366,8 +366,6 @@ then fn() { $(which fd >/dev/null && echo fd || echo fdfind) --hidden --no-ignor
else
alias ff='find -not -path "*.sync*" -and -not \( -name daten -prune \)'
alias f1='find -mindepth 1 -maxdepth 1'
compdef ff=find
compdef f1=find
fi
lowercase_transliterate="y/A-Z /a-z-/"
@ -386,6 +384,7 @@ alias dsync='rc --delete --specials'
alias move='rc --remove-source-files'
alias rdiff='rsync --recursive --progress --delete --links --dry-run'
alias rdiffe='rdiff --existing --size-only'
compdef rcd=rsync
# Swap the names of two files
swap() {
@ -394,11 +393,13 @@ swap() {
mv -n $2 $1
mv -n $1.tmp $2
}
compdef swap=mv
# mv with automatic sudo if neccessary
smv() {
test -w "$1" && test -w "$(dirname $2)" && mv "$@" || sudo mv "$@"
}
compdef smv=mv
# Rename the file inside its directory
mvf() {
@ -417,8 +418,9 @@ mvln() {
[ $file -gt 0 -a -d $2 ] && 2="$2/$(basename $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() {
mvln "$1" "${2:-$XDG_DATA_HOME}/${1#.}"
yadm add "$1" ".config/$1" 2>/dev/null
@ -428,6 +430,7 @@ mvx() {
mkcd() {
mkdir -p "$1" && cd "$1"
}
compdef mkcd=mkdir
# Other stuff {{{1

View File

@ -1,5 +1,5 @@
#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*"
# xargs _files -W $XDG_CONFIG_HOME -g
# yadm diff HEAD --name-only -- $XDG_CONFIG_HOME