Update 05.04.2026
This commit is contained in:
@@ -11,23 +11,26 @@ dirhistory_past=($PWD)
|
||||
dirhistory_future=()
|
||||
export dirhistory_past
|
||||
export dirhistory_future
|
||||
|
||||
export DIRHISTORY_SIZE=30
|
||||
|
||||
alias cde='dirhistory_cd'
|
||||
|
||||
# Pop the last element of dirhistory_past.
|
||||
# Pass the name of the variable to return the result in.
|
||||
# Returns the element if the array was not empty,
|
||||
# otherwise returns empty string.
|
||||
function pop_past() {
|
||||
typeset -g $1="${dirhistory_past[$#dirhistory_past]}"
|
||||
setopt localoptions no_ksh_arrays
|
||||
if [[ $#dirhistory_past -gt 0 ]]; then
|
||||
typeset -g $1="${dirhistory_past[$#dirhistory_past]}"
|
||||
dirhistory_past[$#dirhistory_past]=()
|
||||
fi
|
||||
}
|
||||
|
||||
function pop_future() {
|
||||
typeset -g $1="${dirhistory_future[$#dirhistory_future]}"
|
||||
setopt localoptions no_ksh_arrays
|
||||
if [[ $#dirhistory_future -gt 0 ]]; then
|
||||
typeset -g $1="${dirhistory_future[$#dirhistory_future]}"
|
||||
dirhistory_future[$#dirhistory_future]=()
|
||||
fi
|
||||
}
|
||||
@@ -35,6 +38,7 @@ function pop_future() {
|
||||
# Push a new element onto the end of dirhistory_past. If the size of the array
|
||||
# is >= DIRHISTORY_SIZE, the array is shifted
|
||||
function push_past() {
|
||||
setopt localoptions no_ksh_arrays
|
||||
if [[ $#dirhistory_past -ge $DIRHISTORY_SIZE ]]; then
|
||||
shift dirhistory_past
|
||||
fi
|
||||
@@ -44,6 +48,7 @@ function push_past() {
|
||||
}
|
||||
|
||||
function push_future() {
|
||||
setopt localoptions no_ksh_arrays
|
||||
if [[ $#dirhistory_future -ge $DIRHISTORY_SIZE ]]; then
|
||||
shift dirhistory_future
|
||||
fi
|
||||
@@ -132,7 +137,11 @@ for keymap in emacs vicmd viins; do
|
||||
|
||||
case "$TERM_PROGRAM" in
|
||||
Apple_Terminal) bindkey -M $keymap "^[b" dirhistory_zle_dirhistory_back ;; # Terminal.app
|
||||
iTerm.app) bindkey -M $keymap "^[^[[D" dirhistory_zle_dirhistory_back ;; # iTerm2
|
||||
ghostty) bindkey -M $keymap "^[b" dirhistory_zle_dirhistory_back ;; # ghostty
|
||||
iTerm.app)
|
||||
bindkey -M $keymap "^[^[[D" dirhistory_zle_dirhistory_back
|
||||
bindkey -M $keymap "^[b" dirhistory_zle_dirhistory_back
|
||||
;;
|
||||
esac
|
||||
|
||||
if (( ${+terminfo[kcub1]} )); then
|
||||
@@ -147,7 +156,11 @@ for keymap in emacs vicmd viins; do
|
||||
|
||||
case "$TERM_PROGRAM" in
|
||||
Apple_Terminal) bindkey -M $keymap "^[f" dirhistory_zle_dirhistory_future ;; # Terminal.app
|
||||
iTerm.app) bindkey -M $keymap "^[^[[C" dirhistory_zle_dirhistory_future ;; # iTerm2
|
||||
ghostty) bindkey -M $keymap "^[f" dirhistory_zle_dirhistory_future ;; # ghostty
|
||||
iTerm.app)
|
||||
bindkey -M $keymap "^[^[[C" dirhistory_zle_dirhistory_future
|
||||
bindkey -M $keymap "^[f" dirhistory_zle_dirhistory_future
|
||||
;;
|
||||
esac
|
||||
|
||||
if (( ${+terminfo[kcuf1]} )); then
|
||||
@@ -196,6 +209,7 @@ for keymap in emacs vicmd viins; do
|
||||
case "$TERM_PROGRAM" in
|
||||
Apple_Terminal) bindkey -M $keymap "^[[A" dirhistory_zle_dirhistory_up ;; # Terminal.app
|
||||
iTerm.app) bindkey -M $keymap "^[^[[A" dirhistory_zle_dirhistory_up ;; # iTerm2
|
||||
ghostty) bindkey -M $keymap "^[[1;3A" dirhistory_zle_dirhistory_up ;; # ghostty
|
||||
esac
|
||||
|
||||
if (( ${+terminfo[kcuu1]} )); then
|
||||
@@ -211,6 +225,7 @@ for keymap in emacs vicmd viins; do
|
||||
case "$TERM_PROGRAM" in
|
||||
Apple_Terminal) bindkey -M $keymap "^[[B" dirhistory_zle_dirhistory_down ;; # Terminal.app
|
||||
iTerm.app) bindkey -M $keymap "^[^[[B" dirhistory_zle_dirhistory_down ;; # iTerm2
|
||||
ghostty) bindkey -M $keymap "^[[1;3B" dirhistory_zle_dirhistory_down ;; # ghostty
|
||||
esac
|
||||
|
||||
if (( ${+terminfo[kcud1]} )); then
|
||||
|
||||
Reference in New Issue
Block a user