mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2024-11-29 01:00:08 +00:00
dircycle: keep switch until a directory is found
This fixes the use case where a directory in the dir stack doesn't exist anymore, so the keystroke doesn't appear to do anything. It will keep trying to switch to the n-est directory in the stack until it founds an available directory or the dirstack has no more directories to switch to.
This commit is contained in:
parent
7c1ca0e4d8
commit
251bc2d380
1 changed files with 12 additions and 2 deletions
|
@ -8,11 +8,21 @@
|
||||||
# pushd +N: start counting from left of `dirs' output
|
# pushd +N: start counting from left of `dirs' output
|
||||||
# pushd -N: start counting from right of `dirs' output
|
# pushd -N: start counting from right of `dirs' output
|
||||||
|
|
||||||
|
switch-to-dir () {
|
||||||
|
while ! builtin pushd -q $1 &>/dev/null; do
|
||||||
|
# We found a missing directory: pop it out of the dir stack
|
||||||
|
builtin popd -q $1
|
||||||
|
|
||||||
|
# Stop trying if there are no more directories in the dir stack
|
||||||
|
[[ ${#dirstack} -eq 0 ]] && break
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
insert-cycledleft () {
|
insert-cycledleft () {
|
||||||
emulate -L zsh
|
emulate -L zsh
|
||||||
setopt nopushdminus
|
setopt nopushdminus
|
||||||
|
|
||||||
builtin pushd -q +1 &>/dev/null || true
|
switch-to-dir +1
|
||||||
zle reset-prompt
|
zle reset-prompt
|
||||||
}
|
}
|
||||||
zle -N insert-cycledleft
|
zle -N insert-cycledleft
|
||||||
|
@ -21,7 +31,7 @@ insert-cycledright () {
|
||||||
emulate -L zsh
|
emulate -L zsh
|
||||||
setopt nopushdminus
|
setopt nopushdminus
|
||||||
|
|
||||||
builtin pushd -q -0 &>/dev/null || true
|
switch-to-dir -0
|
||||||
zle reset-prompt
|
zle reset-prompt
|
||||||
}
|
}
|
||||||
zle -N insert-cycledright
|
zle -N insert-cycledright
|
||||||
|
|
Loading…
Reference in a new issue