Skip to content

Commit 491085b

Browse files
Automatically clone based on the ZSH_HISTORY_GIT_REMOTE var
1 parent 8932f16 commit 491085b

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

history-sync.plugin.zsh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,21 @@ function history_sync_pull() {
151151
cp -av "$ZSH_HISTORY_FILE" "$ZSH_HISTORY_FILE.backup" 1>&2
152152
fi
153153

154+
155+
# Clone if not exist
156+
if [[ ! -d "$ZSH_HISTORY_PROJ" ]]; then
157+
if [[ ! -v ZSH_HISTORY_GIT_REMOTE ]]; then
158+
_print_git_error_msg
159+
return
160+
fi
161+
162+
"$GIT" clone "$ZSH_HISTORY_GIT_REMOTE" "$ZSH_HISTORY_PROJ"
163+
if [[ "$?" != 0 ]]; then
164+
_print_git_error_msg
165+
return
166+
fi
167+
fi
168+
154169
# Pull
155170
cd "$ZSH_HISTORY_PROJ" && "$GIT" pull
156171
if [[ "$?" != 0 ]]; then

0 commit comments

Comments
 (0)