-
Notifications
You must be signed in to change notification settings - Fork 3
/
deploy
executable file
·114 lines (95 loc) · 3.07 KB
/
deploy
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#!/bin/bash
ALL_OFF="$(tput sgr0)"
BOLD="$(tput bold)"
GREEN="${BOLD}$(tput setaf 2)"
YELLOW="${BOLD}$(tput setaf 3)"
RED="${BOLD}$(tput setaf 1)"
WHITE="${BOLD}$(tput setaf 7)"
err() {
printf "${RED}error: ${ALL_OFF}${1}\n" >&2
}
warn() {
printf "${YELLOW}warning: ${ALL_OFF}${1}\n" >&2
}
msg() {
local mesg=$1; shift
printf "${GREEN}==> ${WHITE}${mesg}${ALL_OFF}\n" "$*" >&2
}
link() {
local target="$2"
[[ -z $2 ]] && target=".${1##*/}" \
if [[ -e "$target" && ! -h "$target" ]]; then
warn "$target exists in filesystem"
return
fi
[[ -d "$target" ]] && rm "$target"
ln -fs "$root/$1" "$target"
}
# Deploy scriptlets {{{1
df_cower() { link cower .config/cower; }
df_dircolors() { link dircolors/dircolors; }
df_fontconfig() { link fontconfig .config/fontconfig; }
df_git() { link git/gitconfig; }
df_gtk2() { link gtk-2.0/gtkrc-2.0; }
df_gtk3() { link gtk-3.0 .config/gtk-3.0; }
df_haskell() { link haskell/haskeline; }
df_htop() { link htop/htoprc; }
df_lxdm() { link lxdm/dmrc; }
df_mutt() { link mutt; }
df_ncmpcpp() { link ncmpcpp; }
df_openbox() { link openbox .config/openbox; }
df_pam() { link pam/pam_environment; }
df_ranger() { link ranger .config/ranger; }
df_makepkg() { link makepkg/makepkg.conf; }
df_mpd() { link mpd/mpd.conf .config/mpd.conf; }
df_systemd() { link systemd .config/systemd; }
df_termite() { link termite .config/termite; }
df_tmux() { link tmux/tmux.conf; }
df_user-dirs() { link user-dirs/user-dirs.dirs .config/user-dirs.dirs; }
df_vimperator() { link vimperator/vimperatorrc; }
df_weechat() { link weechat; }
df_xmonad() { link xmonad; }
df_shell() {
link shell/zshrc
link shell/zprofile
link shell/profile
}
df_vim() {
link vim
link vim/vimrc
link vim/gvimrc
}
df_X() {
link X/Xresources
link X/xinitrc
}
# }}}
root=$PWD
dotfiles=($(compgen -A function df_))
usage() {
cat << HERE
Automated deploy function for dotfile syncronization.
SUPPORTED:
HERE
printf '%s\n' ${dotfiles[@]#df_} | column
exit ${1:-0}
}
deploy() {
while (( $# )); do
local fun=${1#df_}
msg "Deploying $fun..."
if ! declare -f df_$fun >/dev/null; then
err "don't know how to deploy \"$1\""
usage >&2 1
fi
(cd $HOME && df_$fun)
shift
done
}
if (( $# == 0 )); then
deploy ${dotfiles[@]}
elif [[ "$1" =~ -h|--help ]]; then
usage 0
else
deploy $*
fi