From 85716b085ac0a3abef8ffbb1f7794ff11a48c9e4 Mon Sep 17 00:00:00 2001 From: xeruf <27jf@pm.me> Date: Tue, 24 May 2022 09:24:51 +0200 Subject: [PATCH] config/shell: add zsh compdefs --- .bash_aliases | 4 ++-- .config/shell/functions | 9 ++++++--- .config/zsh/completion/_yc | 2 +- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/.bash_aliases b/.bash_aliases index 937c999..9e40d15 100644 --- a/.bash_aliases +++ b/.bash_aliases @@ -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 diff --git a/.config/shell/functions b/.config/shell/functions index dfcba79..1b11f12 100644 --- a/.config/shell/functions +++ b/.config/shell/functions @@ -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 diff --git a/.config/zsh/completion/_yc b/.config/zsh/completion/_yc index 87498fe..522b704 100644 --- a/.config/zsh/completion/_yc +++ b/.config/zsh/completion/_yc @@ -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