Update 05.04.2026
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
per-directory-history plugin
|
||||
----------------------------
|
||||
# per-directory-history plugin
|
||||
|
||||
This plugin adds per-directory history for zsh, as well as a global history,
|
||||
and the ability to toggle between them with a keyboard shortcut. This is a
|
||||
@@ -34,6 +33,9 @@ toggle set the `PER_DIRECTORY_HISTORY_TOGGLE` environment variable.
|
||||
and global histories.
|
||||
* `PER_DIRECTORY_HISTORY_TOGGLE` is the key binding used to run the toggle-history
|
||||
function above (default `^G`)
|
||||
* `PER_DIRECTORY_HISTORY_PRINT_MODE_CHANGE` is a variable which toggles whether
|
||||
the current mode is printed to the screen following a mode change (default `true`)
|
||||
* `HISTORY_START_WITH_GLOBAL` is a global variable that defines how to start the plugin: global or local (default `false`)
|
||||
|
||||
## History
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
#-------------------------------------------------------------------------------
|
||||
#
|
||||
# The idea/inspiration for a per directory history is from Stewart MacArthur[1]
|
||||
# and Dieter[2], the implementation idea is from Bart Schaefer on the the zsh
|
||||
# and Dieter[2], the implementation idea is from Bart Schaefer on the zsh
|
||||
# mailing list[3]. The implementation is by Jim Hester in September 2012.
|
||||
#
|
||||
# [1]: http://www.compbiome.com/2010/07/bash-per-directory-bash-history.html
|
||||
@@ -59,6 +59,7 @@
|
||||
[[ -z $HISTORY_BASE ]] && HISTORY_BASE="$HOME/.directory_history"
|
||||
[[ -z $HISTORY_START_WITH_GLOBAL ]] && HISTORY_START_WITH_GLOBAL=false
|
||||
[[ -z $PER_DIRECTORY_HISTORY_TOGGLE ]] && PER_DIRECTORY_HISTORY_TOGGLE='^G'
|
||||
[[ -z $PER_DIRECTORY_HISTORY_PRINT_MODE_CHANGE ]] && PER_DIRECTORY_HISTORY_PRINT_MODE_CHANGE=true
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# toggle global/directory history used for searching - ctrl-G by default
|
||||
@@ -68,19 +69,22 @@ function per-directory-history-toggle-history() {
|
||||
if [[ $_per_directory_history_is_global == true ]]; then
|
||||
_per-directory-history-set-directory-history
|
||||
_per_directory_history_is_global=false
|
||||
print -n "\nusing local history"
|
||||
if [[ $PER_DIRECTORY_HISTORY_PRINT_MODE_CHANGE == true ]]; then
|
||||
zle -M "using local history"
|
||||
fi
|
||||
else
|
||||
_per-directory-history-set-global-history
|
||||
_per_directory_history_is_global=true
|
||||
print -n "\nusing global history"
|
||||
if [[ $PER_DIRECTORY_HISTORY_PRINT_MODE_CHANGE == true ]]; then
|
||||
zle -M "using global history"
|
||||
fi
|
||||
fi
|
||||
zle .push-line
|
||||
zle .accept-line
|
||||
}
|
||||
|
||||
autoload per-directory-history-toggle-history
|
||||
zle -N per-directory-history-toggle-history
|
||||
bindkey $PER_DIRECTORY_HISTORY_TOGGLE per-directory-history-toggle-history
|
||||
bindkey -M vicmd $PER_DIRECTORY_HISTORY_TOGGLE per-directory-history-toggle-history
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# implementation details
|
||||
|
||||
Reference in New Issue
Block a user