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 1 commit
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
20 changes: 10 additions & 10 deletions per-directory-history.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -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 @@ -123,9 +123,9 @@ function _per-directory-history-addhistory() {
[[ -o inc_append_history ]] || \
[[ -o inc_append_history_time ]]; then
fc -AI $HISTFILE
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to quote here as well?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had overlooked them, thanks. Fixed. There are still a few variables that are not quoted, but I can assume they are safe.

fc -AI $_per_directory_history_directory
fc -AI "$_per_directory_history_directory"
fi
fc -p $_per_directory_history_directory
fc -p "$_per_directory_history_directory"
fi
}

Expand Down Expand Up @@ -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