From 5423273822520dba570393a7fd4b1007015a2369 Mon Sep 17 00:00:00 2001 From: ShadowKyogre Date: Tue, 3 May 2016 11:29:16 -0700 Subject: [PATCH 1/5] Use md5sum if md5 if not available --- src/histrefs.zsh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/histrefs.zsh b/src/histrefs.zsh index 42346d1..00d5b25 100644 --- a/src/histrefs.zsh +++ b/src/histrefs.zsh @@ -6,7 +6,11 @@ # Prints to STDOUT the name of the histrefs file to use for current # working directory _zsh_prioritize_cwd_history_histrefs_for_cwd() { - local md5=$(echo "${PWD:A}" | md5 -q) + if ! type md5 > /dev/null;then + local md5=$(echo "${PWD:A}" | md5sum | cut -d' ' -f1) + else + local md5=$(echo "${PWD:A}" | md5 -q) + fi echo "$ZSH_PRIORITIZE_CWD_HISTORY_DIR/.histrefs-$md5" } From 0d2317a5ff157e451083e264f5bcbdfa1a36147f Mon Sep 17 00:00:00 2001 From: ShadowKyogre Date: Tue, 3 May 2016 11:29:33 -0700 Subject: [PATCH 2/5] No clobber ZSH_PRIORITIZE_CWD_HISTORY_DIR w/source --- src/config.zsh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/config.zsh b/src/config.zsh index 0ca23b0..658504d 100644 --- a/src/config.zsh +++ b/src/config.zsh @@ -3,4 +3,7 @@ # Global Config Variables # #--------------------------------------------------------------------# -ZSH_PRIORITIZE_CWD_HISTORY_DIR="$HOME/.zsh_prioritize_cwd_history" +if [ -z "$ZSH_PRIORITIZE_CWD_HISTORY_DIR" ];then + # only override if there's no variable + ZSH_PRIORITIZE_CWD_HISTORY_DIR="$HOME/.zsh_prioritize_cwd_history" +fi From 22503d460c9a9a28b09fa45b40c20a7984bb62d5 Mon Sep 17 00:00:00 2001 From: ShadowKyogre Date: Tue, 3 May 2016 11:29:43 -0700 Subject: [PATCH 3/5] Update built copy with fixes --- zsh-prioritize-cwd-history.zsh | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/zsh-prioritize-cwd-history.zsh b/zsh-prioritize-cwd-history.zsh index 0fe6c1d..067161e 100644 --- a/zsh-prioritize-cwd-history.zsh +++ b/zsh-prioritize-cwd-history.zsh @@ -41,7 +41,10 @@ setopt INC_APPEND_HISTORY # Global Config Variables # #--------------------------------------------------------------------# -ZSH_PRIORITIZE_CWD_HISTORY_DIR="$HOME/.zsh_prioritize_cwd_history" +if [ -z "$ZSH_PRIORITIZE_CWD_HISTORY_DIR" ];then + # only override if there's no variable + ZSH_PRIORITIZE_CWD_HISTORY_DIR="$HOME/.zsh_prioritize_cwd_history" +fi #--------------------------------------------------------------------# # Histrefs files store timestamp references to entries in HISTFILE # @@ -50,7 +53,11 @@ ZSH_PRIORITIZE_CWD_HISTORY_DIR="$HOME/.zsh_prioritize_cwd_history" # Prints to STDOUT the name of the histrefs file to use for current # working directory _zsh_prioritize_cwd_history_histrefs_for_cwd() { - local md5=$(echo "${PWD:A}" | md5 -q) + if ! type md5 > /dev/null;then + local md5=$(echo "${PWD:A}" | md5sum | cut -d' ' -f1) + else + local md5=$(echo "${PWD:A}" | md5 -q) + fi echo "$ZSH_PRIORITIZE_CWD_HISTORY_DIR/.histrefs-$md5" } From 9ca171d78f283a6b8a48cfc27cd5e84074ae727d Mon Sep 17 00:00:00 2001 From: ShadowKyogre Date: Tue, 3 May 2016 11:39:51 -0700 Subject: [PATCH 4/5] Don't use too few X's --- src/histrefs.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/histrefs.zsh b/src/histrefs.zsh index 00d5b25..3cd4fda 100644 --- a/src/histrefs.zsh +++ b/src/histrefs.zsh @@ -53,7 +53,7 @@ _zsh_prioritize_cwd_history_load_cwd_history() { # [ (valid_histrefs) ] || return # Create a tmp file for use with `fc -R` - local template="$ZSH_PRIORITIZE_CWD_HISTORY_DIR/.tmphistXX" + local template="$ZSH_PRIORITIZE_CWD_HISTORY_DIR/.tmphistXXXX" local tmp_histfile=$(mktemp "$template") # Copy history entries executed in this directory to tmp file From 69f8d446684c099554a4f518fe76e8ff6635bcfd Mon Sep 17 00:00:00 2001 From: ShadowKyogre Date: Wed, 4 May 2016 15:59:17 -0700 Subject: [PATCH 5/5] Revert "No clobber ZSH_PRIORITIZE_CWD_HISTORY_DIR w/source" This reverts commit 0d2317a5ff157e451083e264f5bcbdfa1a36147f. I noticed this is a common thing in zsh plugins. --- src/config.zsh | 5 +---- zsh-prioritize-cwd-history.zsh | 7 ++----- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/src/config.zsh b/src/config.zsh index 658504d..0ca23b0 100644 --- a/src/config.zsh +++ b/src/config.zsh @@ -3,7 +3,4 @@ # Global Config Variables # #--------------------------------------------------------------------# -if [ -z "$ZSH_PRIORITIZE_CWD_HISTORY_DIR" ];then - # only override if there's no variable - ZSH_PRIORITIZE_CWD_HISTORY_DIR="$HOME/.zsh_prioritize_cwd_history" -fi +ZSH_PRIORITIZE_CWD_HISTORY_DIR="$HOME/.zsh_prioritize_cwd_history" diff --git a/zsh-prioritize-cwd-history.zsh b/zsh-prioritize-cwd-history.zsh index 067161e..64fb207 100644 --- a/zsh-prioritize-cwd-history.zsh +++ b/zsh-prioritize-cwd-history.zsh @@ -41,10 +41,7 @@ setopt INC_APPEND_HISTORY # Global Config Variables # #--------------------------------------------------------------------# -if [ -z "$ZSH_PRIORITIZE_CWD_HISTORY_DIR" ];then - # only override if there's no variable - ZSH_PRIORITIZE_CWD_HISTORY_DIR="$HOME/.zsh_prioritize_cwd_history" -fi +ZSH_PRIORITIZE_CWD_HISTORY_DIR="$HOME/.zsh_prioritize_cwd_history" #--------------------------------------------------------------------# # Histrefs files store timestamp references to entries in HISTFILE # @@ -100,7 +97,7 @@ _zsh_prioritize_cwd_history_load_cwd_history() { # [ (valid_histrefs) ] || return # Create a tmp file for use with `fc -R` - local template="$ZSH_PRIORITIZE_CWD_HISTORY_DIR/.tmphistXX" + local template="$ZSH_PRIORITIZE_CWD_HISTORY_DIR/.tmphistXXXX" local tmp_histfile=$(mktemp "$template") # Copy history entries executed in this directory to tmp file