mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2026-08-07 06:08:39 +02:00
fix(per-directory-history): prevent fc -p from clearing preexec (#13815)
Co-authored-by: Carlo Sala <carlosalag@protonmail.com>
This commit is contained in:
parent
7e2aa2c8cb
commit
076d692dac
1 changed files with 8 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,10 +126,9 @@ 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
|
||||||
fc -p $_per_directory_history_directory
|
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -147,12 +147,13 @@ 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
|
||||||
if [[ -e "$_per_directory_history_directory" ]]; then
|
if [[ -e "$_per_directory_history_directory" ]]; then
|
||||||
fc -R "$_per_directory_history_directory"
|
fc -R "$_per_directory_history_directory"
|
||||||
|
fc -p "$_per_directory_history_directory"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -161,8 +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 "$_per_directory_history_global"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue