AutoYADM commit: 2025-04-17 22:30:05
This commit is contained in:
parent
77038e03e1
commit
78861505ed
3 changed files with 23 additions and 14 deletions
22
.config/fish/conf.d/smart_cd.fish
Normal file
22
.config/fish/conf.d/smart_cd.fish
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
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 already there, return to previous location."
|
||||||
|
git rev-parse --is-inside-work-tree &>/dev/null
|
||||||
|
set -l is_git $status
|
||||||
|
if test (count $argv) -ne 0
|
||||||
|
__cd_orig $argv
|
||||||
|
else
|
||||||
|
if test $is_git -eq 0
|
||||||
|
set root (git rev-parse --show-toplevel)
|
||||||
|
else
|
||||||
|
set root ~
|
||||||
|
end
|
||||||
|
if not test (pwd) = $root
|
||||||
|
__cd_orig $root
|
||||||
|
else
|
||||||
|
__cd_orig -
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -1,6 +1,6 @@
|
||||||
if status is-interactive
|
if status is-interactive
|
||||||
|
|
||||||
source ~/.config/fish/custom_cd.fish
|
# source ~/.config/fish/custom_cd.fish
|
||||||
|
|
||||||
starship init fish | source
|
starship init fish | source
|
||||||
direnv hook fish | source
|
direnv hook fish | source
|
||||||
|
|
|
@ -1,13 +0,0 @@
|
||||||
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
|
|
Loading…
Add table
Add a link
Reference in a new issue