dotfiles/.config/fish/custom_cd.fish

13 lines
393 B
Fish

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