diff --git a/.config/fish/config.fish b/.config/fish/config.fish index c5048602..e8d7ce81 100644 --- a/.config/fish/config.fish +++ b/.config/fish/config.fish @@ -1,16 +1,6 @@ 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 + source ~/.config/fish/custom_cd.fish starship init fish | source direnv hook fish | source diff --git a/.config/fish/custom_cd.fish b/.config/fish/custom_cd.fish new file mode 100644 index 00000000..cf830a63 --- /dev/null +++ b/.config/fish/custom_cd.fish @@ -0,0 +1,13 @@ +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." + git rev-parse --is-inside-work-tree &>/dev/null + set -l is_git $status + if test (count $argv) -ne 0; or not test $is_git -eq 0 + __cd_orig $argv + else + __cd_orig (git rev-parse --show-toplevel) + end +end