-
Notifications
You must be signed in to change notification settings - Fork 0
/
dotfiles.zsh
executable file
·75 lines (63 loc) · 1.31 KB
/
dotfiles.zsh
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
#!/usr/bin/env zsh
__list(){
pushd ${HOME}/.dotfiles-zsh
ls -d * | xargs -L1 -I{} echo " ==> {}"
popd
}
__help(){
echo "
Usage: dotfiles <command> [candidate]
commands:
install or i <candidate>
uninstall or rm <candidate>
list or ls [candidate]
use or u <candidate>
current or c [candidate]
upgrade or ug [candidate]
help or h
"
}
__use(){
pushd ${HOME}/.dotfiles-zsh/${1}
./install
popd
echo $1 > ${HOME}/.dotfiles-zsh/current
}
__install(){
# echo "git clone https://github.com/${1}.git ${HOME}/.dotfiles-zsh/`echo $1 | tr '/' '_'`"
git clone https://github.com/${1}.git ${HOME}/.dotfiles-zsh/`echo $1 | tr "/" "_"`
}
__uninstall(){
pushd ${HOME}/.dotfiles-zsh/
rm -rf ${1}
popd
}
__current(){
pushd ${HOME}/.dotfiles-zsh/
cat current
popd
}
__upgrade(){
pushd ${HOME}/.dotfiles-zsh/${1}
git pull origin master
popd
}
__evaluate(){
eval "__${1} $2"
}
dotfiles(){
COMMAND="$1"
QUALIFIER="$2"
case "$COMMAND" in
(l) COMMAND="list" ;;
(ls) COMMAND="list" ;;
(h) COMMAND="help" ;;
(u) COMMAND="use" ;;
(i) COMMAND="install" ;;
(rm) COMMAND="uninstall" ;;
(c) COMMAND="current" ;;
(ug) COMMAND="upgrade" ;;
esac
mkdir -p "${HOME}/.dotfiles-zsh"
__evaluate $COMMAND $QUALIFIER
}