From 6e29950368b5db690de1a074372a710aeec3eb9b Mon Sep 17 00:00:00 2001 From: xeruf <27jf@pm.me> Date: Sat, 11 Dec 2021 01:22:58 +0000 Subject: [PATCH] config/shell/functions: fix all bash errors --- .config/shell/functions | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/.config/shell/functions b/.config/shell/functions index 0e36e07..f0266bc 100644 --- a/.config/shell/functions +++ b/.config/shell/functions @@ -1,5 +1,5 @@ # Shell aliases & functions for Zsh, almost all work for Bash too -# data directory aliases {{{1 +# zsh helpers {{{1 if test "$ZSH_NAME" = "zsh" then alias -g ___='"$(eval "$(fc -ln -1)" | tail -n 1)"' @@ -8,10 +8,24 @@ then alias -g X1="| xargs -d '\n' -n 1" alias -g XC="| xclip -selection clipboard" alias -g L="--color=always | ${PAGER:-less}" + + # Edit zsh completion + edcomp() { + file=$(echo "$1" | sed 's/^\([^_]\)/_\1/') + $EDITOR "${fpath[-1]}/$file" + unfunction "$file" && compinit + } + compdef "_files -W ${fpath[-1]}/" edcomp + + writecompletion() { + echo "#compdef $1" > "_$1" + $EDITOR "_$1" + } else - local compdef() { } + compdef() { true; } fi +# data directory aliases {{{1 xdh="$XDG_DATA_HOME" xch="$XDG_CONFIG_HOME" xsh="$XDG_STATE_HOME" @@ -98,19 +112,6 @@ edbin() { edit "$HOME/.local/bin/scripts/$1" } -# Edit zsh completion -edcomp() { - file=$(echo "$1" | sed 's/^\([^_]\)/_\1/') - $EDITOR "${fpath[-1]}/$file" - unfunction "$file" && compinit -} -compdef "_files -W ${fpath[-1]}/" edcomp - -writecompletion() { - echo "#compdef $1" > "_$1" - $EDITOR "_$1" -} - # Task management & time tracking {{{1 t() { if test "$#" -eq 0 && which tn >/dev/null