-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbootstrap.sh
102 lines (76 loc) · 2.87 KB
/
bootstrap.sh
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
function apply {
local target="$1"
$(which stow) -t ${HOME} ${target} --dotfiles --adopt --verbose -d ${DOTFILES}
}
function bootstrap {
targets=(zsh brew bat broot eza tig tmux zoxide vim thefuck nvim direnv kitty emacs maven gradle hammerspoon shallow-backup)
for target in "${targets[@]}"; do
if [ -d ${DOTFILES}/${target} ]; then
echo "apply ${target} success"
apply ${target}
fi
done
}
function dot {
if [ $# -eq 0 ]; then
echo "
Usage: dot <command> [target]
Commands:
pull Fetch the latest changes from the remote repository and merge them into the target branch (default: develop).
Usage: dot pull [target]
push Push your local changes to the remote repository on the target branch (default: develop).
Usage: dot push [target]
commit Stage all changes and commit them with a default message.
Usage: dot commit
diff Show the differences between your local changes and the latest commit.
Usage: dot diff
cd Change directory to the dotfiles repository.
Usage: dot cd
status Show the current status of your dotfiles repository.
Usage: dot status
apply Apply a patch or configuration.
Usage: dot apply [target]
bootstrap Initialize or set up the dotfiles (e.g., by installing dependencies).
Usage: dot bootstrap
benchmark Run benchmark tests on the dotfiles setup.
Usage: dot benchmark
edit use fzf to edit file.
Usage: dot benchmark
"
return 1
fi
local command="$1"
local target="$2"
case "$command" in
"pull")
$(which git) -C "${DOTFILES}" pull origin ${target:-develop} --autostash
;;
"push")
$(which git) -C "${DOTFILES}" push origin ${target:-develop}
;;
"commit")
$(which git) -C "${DOTFILES}" add . && $(which git) -C "${DOTFILES}" commit
;;
"diff")
$(which git) -C "${DOTFILES}" diff
;;
"cd")
cd "${DOTFILES}"
;;
"status")
$(which git) -C "${DOTFILES}" status
;;
"apply")
apply ${target}
;;
"bootstrap")
bootstrap
;;
"benchmark")
zsh ${ZDOTDIR}/plugins/zsh-bench/zsh-bench
;;
"edit")
find ${DOTFILES} -type f | fzf | xargs -0 -o nvim
;;
esac
}