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
|
status is-interactive; or exit
|
||||||
|
|
||||||
# necessary because we want to use fish's
|
# Ensure original cd is saved once
|
||||||
# cd wrapper function, _not_ the builtin cd!
|
functions -q __cd_orig; or functions --copy cd __cd_orig
|
||||||
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."
|
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.
|
# Skip history in subshells.
|
||||||
if status --is-command-substitution
|
if status --is-command-substitution
|
||||||
builtin cd $argv
|
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
|
if not test (pwd) = $root
|
||||||
__cd_orig $root
|
__cd_orig $root
|
||||||
else if set -q dirprev
|
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]"
|
if string match -q "$root*" "$dirprev[-1]"
|
||||||
echo We out here
|
|
||||||
__cd_orig -
|
__cd_orig -
|
||||||
else
|
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
|
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
|
switch $response
|
||||||
case y Y
|
case y Y
|
||||||
__cd_orig -
|
__cd_orig -
|
||||||
break
|
break
|
||||||
case n N
|
case n N
|
||||||
break
|
break
|
||||||
case '*'
|
|
||||||
continue
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue