AutoYADM commit: 2025-04-18 15:30:05
This commit is contained in:
parent
49aa56f959
commit
68789e68c9
1 changed files with 7 additions and 13 deletions
|
@ -1,12 +1,10 @@
|
|||
status is-interactive; or exit
|
||||
|
||||
# necessary because we want to use fish's
|
||||
# cd wrapper function, _not_ the builtin cd!
|
||||
if not functions -q __cd_orig
|
||||
functions --copy cd __cd_orig
|
||||
end
|
||||
# Ensure original cd is saved once
|
||||
functions -q __cd_orig; or functions --copy cd __cd_orig
|
||||
|
||||
function cd --wraps=cd --description "Change directory. No args goes to git root or $HOME. If already there, return to previous location."
|
||||
|
||||
# Skip history in subshells.
|
||||
if status --is-command-substitution
|
||||
builtin cd $argv
|
||||
|
@ -25,24 +23,20 @@ function cd --wraps=cd --description "Change directory. No args goes to git root
|
|||
if not test (pwd) = $root
|
||||
__cd_orig $root
|
||||
else if set -q dirprev
|
||||
echo "prev: $dirprev[-1]
|
||||
root: $root"
|
||||
set -x smartdirprev $dirprev[-1]
|
||||
set -x smartroot $root
|
||||
if string match -q "$root*" "$dirprev[-1]"
|
||||
echo We out here
|
||||
__cd_orig -
|
||||
else
|
||||
set -l prompt "This would take you to $dirprev[-1], which is outside $root, are you sure? (y/n): "
|
||||
set -l prompt "$dirprev[-1], is outside $root, are you sure? (y/n): "
|
||||
while read --nchars 1 -l response --prompt-str="$prompt" or return 1
|
||||
# clear prompt
|
||||
printf "\033[1A\033[2K"
|
||||
# printf "\033[1A\033[2K"
|
||||
switch $response
|
||||
case y Y
|
||||
__cd_orig -
|
||||
break
|
||||
case n N
|
||||
break
|
||||
case '*'
|
||||
continue
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue