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

Compatibility fixes #2

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
8 changes: 6 additions & 2 deletions src/histrefs.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand Down Expand Up @@ -49,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
Expand Down
8 changes: 6 additions & 2 deletions zsh-prioritize-cwd-history.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,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"
}
Expand Down Expand Up @@ -93,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
Expand Down