Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix sh_word_split and whitespace issue #53

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions per-directory-history.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ function per-directory-history-toggle-history() {

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
bindkey "$PER_DIRECTORY_HISTORY_TOGGLE" per-directory-history-toggle-history
bindkey -M vicmd "$PER_DIRECTORY_HISTORY_TOGGLE" per-directory-history-toggle-history

#-------------------------------------------------------------------------------
# implementation details
Expand All @@ -91,23 +91,23 @@ _per_directory_history_directory="$HISTORY_BASE${PWD:A}/history"

function _per-directory-history-change-directory() {
_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
#save to the global history
fc -AI $HISTFILE
fc -AI "$HISTFILE"
#save history to previous file
local prev="$HISTORY_BASE${OLDPWD:A}/history"
mkdir -p ${prev:h}
fc -AI $prev
mkdir -p "${prev:h}"
fc -AI "$prev"

#discard previous directory's history
local original_histsize=$HISTSIZE
HISTSIZE=0
HISTSIZE=$original_histsize

#read history in new file
if [[ -e $_per_directory_history_directory ]]; then
fc -R $_per_directory_history_directory
if [[ -e "$_per_directory_history_directory" ]]; then
fc -R "$_per_directory_history_directory"
fi
fi
}
Expand All @@ -122,10 +122,10 @@ function _per-directory-history-addhistory() {
if [[ -o share_history ]] || \
[[ -o inc_append_history ]] || \
[[ -o inc_append_history_time ]]; then
fc -AI $HISTFILE
fc -AI $_per_directory_history_directory
fc -AI "$HISTFILE"
fc -AI "$_per_directory_history_directory"
fi
fc -p $_per_directory_history_directory
fc -p "$_per_directory_history_directory"
fi
}

Expand All @@ -144,7 +144,7 @@ function _per-directory-history-precmd() {
}

function _per-directory-history-set-directory-history() {
fc -AI $HISTFILE
fc -AI "$HISTFILE"
local original_histsize=$HISTSIZE
HISTSIZE=0
HISTSIZE=$original_histsize
Expand All @@ -154,7 +154,7 @@ function _per-directory-history-set-directory-history() {
}

function _per-directory-history-set-global-history() {
fc -AI $_per_directory_history_directory
fc -AI "$_per_directory_history_directory"
local original_histsize=$HISTSIZE
HISTSIZE=0
HISTSIZE=$original_histsize
Expand All @@ -163,7 +163,7 @@ function _per-directory-history-set-global-history() {
fi
}

mkdir -p ${_per_directory_history_directory:h}
mkdir -p "${_per_directory_history_directory:h}"

#add functions to the exec list for chpwd and zshaddhistory
autoload -U add-zsh-hook
Expand Down