diff --git a/.config/fish/functions/cd.fish b/.config/fish/functions/cd.fish index e1b9dd0c..9c97c8cb 100644 --- a/.config/fish/functions/cd.fish +++ b/.config/fish/functions/cd.fish @@ -1,11 +1,12 @@ -# Defined via `source` +# One-time setup, preserve original cd definition +if not functions -q __cd_orig + functions --copy cd __cd_orig +end + function cd --wraps=cd --description "Change directory. No args goes to git root or $HOME." - set -l cdfunc /usr/share/fish/functions/cd.fish if test (count $argv) -ne 0; or not git rev-parse --is-inside-work-tree &>/dev/null - source $cdfunc - cd $argv + __cd_orig $argv else - source $cdfunc - cd (git rev-parse --show-toplevel) + __cd_orig (git rev-parse --show-toplevel) end end