-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.bash
More file actions
executable file
·92 lines (80 loc) · 1.94 KB
/
setup.bash
File metadata and controls
executable file
·92 lines (80 loc) · 1.94 KB
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
#!/bin/bash -exv
# source .bashrc
ROOT_DIR=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P )
BACKUPDIR="${HOME}/backup_setup_sh"
mkdir -p $BACKUPDIR
declare -a symlink_array=(
".bashrc"
".Xresources"
".aliasrc"
".bash_profile"
".bashrc"
".emacs.d"
".latexmkrc"
".gitignore"
".gitconfig"
".hgrc"
".inputrc"
".tmux.conf"
".Xmodmap"
".xmonad"
".zshrc"
".config/awesome"
".config/fontconfig/conf.d"
".config/systemd/user/emacs.service"
".config/systemd/user/xkeysnail.service"
".config/systemd/user/ssh-agent.service"
".config/dunst/dunstrc"
".config/sway"
".config/alacritty/alacritty.yml"
)
# key = src
# value = dst
declare -A symlink_hash=(
# [""]=".config/"
)
my_symlink(){
src="$1"
dst="$2"
dstdir=$(dirname "$dst")
if [[ ! -d $dstdir ]] ; then
mkdir -p "$dstdir"
fi
if [[ -f $dst ]] ; then
mv --backup=t "$dst" "${BACKUPDIR}/"
elif [[ -h $dst ]] ; then
unlink $dst
fi
ln --backup=numbered -vs "$src" "$dst"
}
deploy_symlink_array(){
for f in "${symlink_array[@]}"
do
my_symlink "${ROOT_DIR}/${f}" "${HOME}/${f}"
done
}
deploy_symlink_hash(){
for k in "${!symlink_hash[@]}"
do
my_symlink "${ROOT_DIR}/${k}" "${HOME}/${symlink_hash[${k}]}"
done
}
setup_go(){
if [[ ! -x "$(which go)" ]]; then
return -1
fi
if [[ ! -x "$(which ghq)" ]]; then
go install github.com/x-motemen/ghq@latest
fi
ghq get https://github.com/clvv/fasd
my_symlink "$(ghq root)"/"$(ghq list clvv/fasd)"/fasd $HOME/bin/fasd
ghq get https://github.com/tmux-plugins/tpm
my_symlink "$(ghq root)"/"$(ghq list tmux-plugins/tpm)" $HOME/.tmux/plugins/tpm
ghq get https://github.com/tmux-plugins/tpm
ghq get github.com/Bash-it/bash-it
my_symlink "$(ghq root)"/"$(ghq list Bash-it/bash-it)" $HOME/.bash_it
}
# main
deploy_symlink_array
deploy_symlink_hash
setup_go