Use HISTFILE evironment variable directly rather than copying it
Use the HISTFILE environment variable in place of copying it to _per_directory_history_global so that users can change the environment variable after sourcing per-directory-history and have the global variable set correctly
This commit is contained in:
parent
baa187e4b9
commit
cc831508d7
|
@ -81,7 +81,6 @@ bindkey '^G' per-directory-history-toggle-history
|
||||||
# implementation details
|
# implementation details
|
||||||
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
|
|
||||||
_per_directory_history_global=$HISTFILE
|
|
||||||
_per_directory_history_directory="$HISTORY_BASE${PWD:A}/history"
|
_per_directory_history_directory="$HISTORY_BASE${PWD:A}/history"
|
||||||
|
|
||||||
function _per-directory-history-change-directory() {
|
function _per-directory-history-change-directory() {
|
||||||
|
@ -89,7 +88,7 @@ function _per-directory-history-change-directory() {
|
||||||
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 $_per_directory_history_global
|
fc -AI $HISTFILE
|
||||||
#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}
|
||||||
|
@ -115,7 +114,7 @@ function _per-directory-history-addhistory() {
|
||||||
|
|
||||||
function _per-directory-history-set-directory-history() {
|
function _per-directory-history-set-directory-history() {
|
||||||
if [[ $_per_directory_history_is_global == true ]]; then
|
if [[ $_per_directory_history_is_global == true ]]; then
|
||||||
fc -AI $_per_directory_history_global
|
fc -AI $HISTFILE
|
||||||
local original_histsize=$HISTSIZE
|
local original_histsize=$HISTSIZE
|
||||||
HISTSIZE=0
|
HISTSIZE=0
|
||||||
HISTSIZE=$original_histsize
|
HISTSIZE=$original_histsize
|
||||||
|
@ -131,8 +130,8 @@ 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 "$_per_directory_history_global" ]]; then
|
if [[ -e "$HISTFILE" ]]; then
|
||||||
fc -R "$_per_directory_history_global"
|
fc -R "$HISTFILE"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
_per_directory_history_is_global=true
|
_per_directory_history_is_global=true
|
||||||
|
|
Loading…
Reference in New Issue