Skip to content

Commit 2c901fb

Browse files
committed
Fixed optarg specifier and updated usage function to unclude new force option
1 parent 1e12ef8 commit 2c901fb

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

history-sync.plugin.zsh

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,12 @@ function _print_gpg_decrypt_error_msg() {
4545
}
4646

4747
function _usage() {
48-
echo "$bold_color${fg[red]}Usage: $0 [-r <string> -r <string>...]$reset_color" 1>&2
48+
echo "Usage: [ [-r <string> ...] [-y] ]" 1>&2
49+
echo
50+
echo "Optional args:"
51+
echo
52+
echo " -r receipients"
53+
echo " -y force"
4954
return
5055
}
5156

@@ -80,10 +85,10 @@ function history_sync_pull() {
8085

8186
# Encrypt and push current history to master
8287
function history_sync_push() {
83-
# Get option recipients
88+
# Get options recipients, force
8489
local recipients=()
8590
local force=false
86-
while getopts yr: opt; do
91+
while getopts r:y opt; do
8792
case "$opt" in
8893
r)
8994
recipients+="$OPTARG"
@@ -104,10 +109,12 @@ function history_sync_push() {
104109
read name
105110
recipients+="$name"
106111
fi
112+
107113
ENCRYPT_CMD="$GPG --yes -v "
108114
for r in "${recipients[@]}"; do
109115
ENCRYPT_CMD+="-r \"$r\" "
110116
done
117+
111118
if [[ "$ENCRYPT_CMD" =~ '.(-r).+.' ]]; then
112119
ENCRYPT_CMD+="--encrypt --sign --armor --output $ZSH_HISTORY_FILE_ENC $ZSH_HISTORY_FILE"
113120
eval "$ENCRYPT_CMD"
@@ -150,6 +157,7 @@ function history_sync_push() {
150157
;;
151158
esac
152159
fi
160+
153161
if [[ "$?" != 0 ]]; then
154162
_print_git_error_msg
155163
cd "$DIR"

0 commit comments

Comments
 (0)