diff --git a/.config/fish/config.fish b/.config/fish/config.fish index 992b635d..c5048602 100644 --- a/.config/fish/config.fish +++ b/.config/fish/config.fish @@ -1,4 +1,17 @@ if status is-interactive + + 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." + if test (count $argv) -ne 0; or not git rev-parse --is-inside-work-tree &>/dev/null + __cd_orig $argv + else + __cd_orig (git rev-parse --show-toplevel) + end + end + starship init fish | source direnv hook fish | source zoxide init fish | source diff --git a/.config/fish/functions/cd.fish b/.config/fish/functions/cd.fish deleted file mode 100644 index 9c97c8cb..00000000 --- a/.config/fish/functions/cd.fish +++ /dev/null @@ -1,12 +0,0 @@ -# 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." - if test (count $argv) -ne 0; or not git rev-parse --is-inside-work-tree &>/dev/null - __cd_orig $argv - else - __cd_orig (git rev-parse --show-toplevel) - end -end diff --git a/.config/fish/functions/gcd.fish b/.config/fish/functions/gcd.fish deleted file mode 100644 index b25baad5..00000000 --- a/.config/fish/functions/gcd.fish +++ /dev/null @@ -1,3 +0,0 @@ -function gcd --description 'cd to the root of current git repo' - cd (git rev-parse --show-toplevel) -end