12 lines
394 B
Fish
12 lines
394 B
Fish
# 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
|