diff --git a/.config/fish/functions/cd.fish b/.config/fish/functions/cd.fish new file mode 100644 index 00000000..e1b9dd0c --- /dev/null +++ b/.config/fish/functions/cd.fish @@ -0,0 +1,11 @@ +# Defined via `source` +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 + else + source $cdfunc + cd (git rev-parse --show-toplevel) + end +end