mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2026-08-07 06:08:39 +02:00
fix(per-directory-history): preserve global history path
This commit is contained in:
parent
18e1124c3d
commit
dc1cf09a47
1 changed files with 7 additions and 6 deletions
|
|
@ -91,13 +91,14 @@ bindkey -M vicmd $PER_DIRECTORY_HISTORY_TOGGLE per-directory-history-toggle-hist
|
||||||
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
|
|
||||||
_per_directory_history_directory="$HISTORY_BASE${PWD:A}/history"
|
_per_directory_history_directory="$HISTORY_BASE${PWD:A}/history"
|
||||||
|
_per_directory_history_global="$HISTFILE"
|
||||||
|
|
||||||
function _per-directory-history-change-directory() {
|
function _per-directory-history-change-directory() {
|
||||||
_per_directory_history_directory="$HISTORY_BASE${PWD:A}/history"
|
_per_directory_history_directory="$HISTORY_BASE${PWD:A}/history"
|
||||||
mkdir -p ${_per_directory_history_directory:h}
|
mkdir -p ${_per_directory_history_directory:h}
|
||||||
if [[ $_per_directory_history_is_global == false ]]; then
|
if [[ $_per_directory_history_is_global == false ]]; then
|
||||||
#save to the global history
|
#save to the global history
|
||||||
fc -AI $HISTFILE
|
fc -AI "$_per_directory_history_global"
|
||||||
#save history to previous file
|
#save history to previous file
|
||||||
local prev="$HISTORY_BASE${OLDPWD:A}/history"
|
local prev="$HISTORY_BASE${OLDPWD:A}/history"
|
||||||
mkdir -p ${prev:h}
|
mkdir -p ${prev:h}
|
||||||
|
|
@ -125,7 +126,7 @@ function _per-directory-history-addhistory() {
|
||||||
if [[ -o share_history ]] || \
|
if [[ -o share_history ]] || \
|
||||||
[[ -o inc_append_history ]] || \
|
[[ -o inc_append_history ]] || \
|
||||||
[[ -o inc_append_history_time ]]; then
|
[[ -o inc_append_history_time ]]; then
|
||||||
fc -AI $HISTFILE
|
fc -AI "$_per_directory_history_global"
|
||||||
fc -AI $_per_directory_history_directory
|
fc -AI $_per_directory_history_directory
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
@ -146,7 +147,7 @@ function _per-directory-history-precmd() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function _per-directory-history-set-directory-history() {
|
function _per-directory-history-set-directory-history() {
|
||||||
fc -AI $HISTFILE
|
fc -AI "$_per_directory_history_global"
|
||||||
local original_histsize=$HISTSIZE
|
local original_histsize=$HISTSIZE
|
||||||
HISTSIZE=0
|
HISTSIZE=0
|
||||||
HISTSIZE=$original_histsize
|
HISTSIZE=$original_histsize
|
||||||
|
|
@ -161,9 +162,9 @@ function _per-directory-history-set-global-history() {
|
||||||
local original_histsize=$HISTSIZE
|
local original_histsize=$HISTSIZE
|
||||||
HISTSIZE=0
|
HISTSIZE=0
|
||||||
HISTSIZE=$original_histsize
|
HISTSIZE=$original_histsize
|
||||||
if [[ -e "$HISTFILE" ]]; then
|
if [[ -e "$_per_directory_history_global" ]]; then
|
||||||
fc -R "$HISTFILE"
|
fc -R "$_per_directory_history_global"
|
||||||
fc -p "$HISTFILE"
|
fc -p "$_per_directory_history_global"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue