From 0ab5401a149941489ca84b14ed0919b9b4ec69a3 Mon Sep 17 00:00:00 2001 From: "Aoyama, Shotaro" Date: Sun, 14 Jul 2024 10:41:01 +0900 Subject: [PATCH 1/2] Quote directory names --- per-directory-history.zsh | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/per-directory-history.zsh b/per-directory-history.zsh index cfc4535..dbeb89b 100644 --- a/per-directory-history.zsh +++ b/per-directory-history.zsh @@ -91,14 +91,14 @@ _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 @@ -106,8 +106,8 @@ function _per-directory-history-change-directory() { 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 } @@ -123,9 +123,9 @@ function _per-directory-history-addhistory() { [[ -o inc_append_history ]] || \ [[ -o inc_append_history_time ]]; then fc -AI $HISTFILE - 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 } @@ -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 @@ -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 From 1c2a8fc68a0914a15ccd1f500b726b09e34edc1a Mon Sep 17 00:00:00 2001 From: aoyama Date: Fri, 19 Jul 2024 10:18:49 +0900 Subject: [PATCH 2/2] Add more quotes --- per-directory-history.zsh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/per-directory-history.zsh b/per-directory-history.zsh index dbeb89b..36723bb 100644 --- a/per-directory-history.zsh +++ b/per-directory-history.zsh @@ -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 @@ -122,7 +122,7 @@ function _per-directory-history-addhistory() { if [[ -o share_history ]] || \ [[ -o inc_append_history ]] || \ [[ -o inc_append_history_time ]]; then - fc -AI $HISTFILE + fc -AI "$HISTFILE" fc -AI "$_per_directory_history_directory" fi fc -p "$_per_directory_history_directory" @@ -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