-
Notifications
You must be signed in to change notification settings - Fork 92
/
Copy pathtoggle-dotfiles
53 lines (49 loc) · 1016 Bytes
/
toggle-dotfiles
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# No emulate zsh here because it calls reset-prompt.
if (( ARGC == 0 )); then
case "${GIT_DIR-}" in
'')
export GIT_DIR=~/.dotfiles-public
export GIT_WORK_TREE=~
;;
~/.dotfiles-public)
export GIT_DIR=~/.dotfiles-private
export GIT_WORK_TREE=~
;;
*)
unset GIT_DIR
unset GIT_WORK_TREE
;;
esac
elif (( ARGC == 1 )); then
case "$1" in
public)
export GIT_DIR=~/.dotfiles-public
export GIT_WORK_TREE=~
;;
private)
export GIT_DIR=~/.dotfiles-private
export GIT_WORK_TREE=~
;;
'')
unset GIT_DIR
unset GIT_WORK_TREE
;;
*)
print -ru2 -- "toggle-dotfiles: invalid argument: ${(qqq)1}"
return 1
;;
esac
else
print -ru2 -- "toggle-dotfiles: too many arguments"
return 1
fi
zle || return 0
local f
for f in precmd "${precmd_functions[@]}"; do
(( ${+functions[$f]} )) && "$f" &>/dev/null
done
if (( ${+functions[p10k]} )); then
p10k display -r
else
zle .reset-prompt
fi