diff --git a/.config/shell/functions b/.config/shell/functions index 33776f2..859fa31 100644 --- a/.config/shell/functions +++ b/.config/shell/functions @@ -64,7 +64,7 @@ xtrace() { # Shows source code for command, resolving nested aliases wh() { - res=$(which "$@") + res=$(which "$@") || return $? if expr "$res" : "${@:$#}: aliased to" >/dev/null && ! expr "$res" : ".*builtin" >/dev/null then echo "$res" | bat --style=plain --language=sh && tool="$(echo "$res" | head -1 | cut -d' ' -f$(expr 5 '&' "$res" : ".*to \(sudo\|noglob\) " '|' 4) | cut -d'(' -f2)" @@ -105,7 +105,7 @@ edshell() { (*) file="$(find $CONFIG_SHELLS -name "$1*" | head -1 | grep . || echo "$CONFIG_SHELLS/$1")";; esac test -f "$file" && checksum="$(md5sum "$file")" - $EDITOR "$(test "$line" && case "$EDITOR" in (nvim) echo "+normal! ${line}ggzx";; (*vi*) echo "+$line";; (emacs*) echo "+${line}";; esac || echo "--")" "${file%:*}" + $EDITOR "$(test "$line" && case "$EDITOR" in (nvim) echo "+normal! ${line}ggzx";; (*vi*) echo "+$line";; (emacs*|*/emacs*) echo "+${line}";; esac || echo "--")" "${file%:*}" test -s "$file" || return 1 test "$checksum" != "$(md5sum $file)" && rs }