Skip to content

Commit

Permalink
Allow environment variables to be overridden
Browse files Browse the repository at this point in the history
  • Loading branch information
jrolfs authored and wulfgarpro committed Apr 30, 2022
1 parent 9d52a3d commit a580719
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
16 changes: 8 additions & 8 deletions history-sync.plugin.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ alias zhsync="history_sync_pull && history_sync_push"
GIT=$(which git)
GPG=$(which gpg)

ZSH_HISTORY_PROJ="${HOME}/.zsh_history_proj"
ZSH_HISTORY_FILE_NAME=".zsh_history"
ZSH_HISTORY_FILE="${HOME}/${ZSH_HISTORY_FILE_NAME}"
ZSH_HISTORY_FILE_ENC_NAME="zsh_history"
ZSH_HISTORY_FILE_ENC="${ZSH_HISTORY_PROJ}/${ZSH_HISTORY_FILE_ENC_NAME}"
ZSH_HISTORY_FILE_DECRYPT_NAME="zsh_history_decrypted"
GIT_COMMIT_MSG="latest $(date)"
ZSH_HISTORY_PROJ="${ZSH_HISTORY_PROJ:-${HOME}/.zsh_history_proj}"
ZSH_HISTORY_FILE_NAME="${ZSH_HISTORY_FILE_NAME:-.zsh_history}"
ZSH_HISTORY_FILE="${ZSH_HISTORY_FILE:-${HOME}/${ZSH_HISTORY_FILE_NAME}}"
ZSH_HISTORY_FILE_ENC_NAME="${ZSH_HISTORY_FILE_ENC_NAME:-zsh_history}"
ZSH_HISTORY_FILE_ENC="${ZSH_HISTORY_FILE_ENC:-${ZSH_HISTORY_PROJ}/${ZSH_HISTORY_FILE_ENC_NAME}}"
ZSH_HISTORY_FILE_DECRYPT_NAME="${ZSH_HISTORY_FILE_DECRYPT_NAME:-zsh_history_decrypted}"
ZSH_HISTORY_COMMIT_MSG="${ZSH_HISTORY_COMMIT_MSG:-latest $(date)}"

function _print_git_error_msg() {
echo "$bold_color${fg[red]}There's a problem with git repository: ${ZSH_HISTORY_PROJ}.$reset_color"
Expand Down Expand Up @@ -146,7 +146,7 @@ function history_sync_push() {
case "$commit" in
[Yy]* )
DIR=$(pwd)
cd "$ZSH_HISTORY_PROJ" && "$GIT" add * && "$GIT" commit -m "$GIT_COMMIT_MSG"
cd "$ZSH_HISTORY_PROJ" && "$GIT" add * && "$GIT" commit -m "$ZSH_HISTORY_COMMIT_MSG"

if [[ $force = false ]]; then
echo -n "$bold_color${fg[yellow]}Do you want to push to remote (y/N)?$reset_color "
Expand Down
2 changes: 1 addition & 1 deletion test/test.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ echo "TEST ENVIRONMENT VARIABLES EXIST"
check_env_exists ZSH_HISTORY_FILE
check_env_exists ZSH_HISTORY_PROJ
check_env_exists ZSH_HISTORY_FILE_ENC
check_env_exists GIT_COMMIT_MSG
check_env_exists ZSH_HISTORY_COMMIT_MSG
echo "SUCCESS"

echo "TEST SYNC HISTORY"
Expand Down

0 comments on commit a580719

Please sign in to comment.