-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·162 lines (138 loc) · 5.46 KB
/
setup.sh
File metadata and controls
executable file
·162 lines (138 loc) · 5.46 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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
#!/bin/bash
set -e # exit on failure
echo -ne 'DANGER! This script will overwrite "${HOME}"/.bashrc and other config files.\n\nType "yes" to continue: '
read -r DISCLAIMER
if [[ "${DISCLAIMER}" == "yes" || "${DISCLAIMER}" == "\"yes\"" ]]; then
DIR="${PWD}"
# === bash ===
[[ -f "${HOME}"/.bashrc || -L "${HOME}"/.bashrc ]] && \
rm "${HOME}"/.bashrc
ln -s "${DIR}"/bash/bashrc "${HOME}"/.bashrc
[[ -f "${HOME}"/.profile || -L "${HOME}"/.profile ]] && \
rm "${HOME}"/.profile
ln -s "${DIR}"/bash/profile.sh "${HOME}"/.profile
# === rc files ===
for f in rc/*rc; do
RC="${HOME}"/.$(basename "${f}")
[[ -f "${RC}" || -L "${RC}" ]] && \
rm "${RC}"
ln -s "${PWD}/${f}" "${RC}"
done
## === binaries ===
[[ -d "${HOME}"/bin ]] || mkdir "${HOME}"/bin
for f in bin/*; do
link="${HOME}/${f/.sh/}"
[[ -f "${link}" || -L "${link}" ]] && \
rm "${link}"
ln -s "$(pwd)/${f}" "${link}"
done
# === emacs ===
if [[ -d "${HOME}"/.emacs.d ]]; then
rm -rf "${HOME}"/.emacs.d
elif [[ -f "${HOME}"/.emacs.d || -L "${HOME}"/.emacs.d ]]; then
rm "${HOME}"/.emacs.d
fi
ln -s "${DIR}"/emacs "${HOME}"/.emacs.d
# === gdb ===
[[ -f "${HOME}"/.gdbinit || -L "${HOME}"/.gdbinit ]] && \
rm "${HOME}"/.gdbinit
ln -s "${DIR}"/gdb/gdbinit "${HOME}"/.gdbinit
# === git ===
[[ -f "${HOME}"/.gitconfig || -L "${HOME}"/.gitconfig ]] && \
rm "${HOME}"/.gitconfig
if [[ ! -d "${HOME}"/.config/git/template ]]; then
mkdir -p "${HOME}"/.config/git/template
echo "ref: refs/heads/main" > "${HOME}"/.config/git/template/HEAD
fi
ln -s "${DIR}"/git/gitconfig "${HOME}"/.gitconfig
# === i3wm ===
if [[ -d "${HOME}"/.config/i3 ]]; then
rm -rf "${HOME}"/.config/i3
elif [[ -f "${HOME}"/.config/i3 || -L "${HOME}"/.config/i3 ]]; then
rm "${HOME}"/.config/i3
fi
ln -s "${DIR}"/i3wm "${HOME}"/.config/i3
# === julia ===
if [[ -d "${DIR}"/julia ]]; then
if [[ -d "${HOME}"/.julia/config ]]; then
rm -r "${HOME}"/.julia/config
elif [[ -f "${HOME}"/.julia/config || -L "${HOME}"/.julia/config ]]; then
rm "${HOME}"/.julia/config
fi
mkdir -p "${HOME}"/.julia
ln -s "${DIR}"/julia "${HOME}"/.julia/config
fi
# === nano ===
if [[ ! -d "${HOME}/.nano" ]]; then
NANO_TMP="/tmp/nanorc.zip"
NANO_DIR="${HOME}/.nano"
git clone --recursive github:scopatz/nanorc "${NANO_DIR}"
fi
# === tmux ===
[[ ! -d "${HOME}"/.config/tmux ]] && \
mkdir -p "${HOME}"/.tmux
ln -sf "${DIR}"/tmux/tmux.conf "${HOME}"/.tmux.conf
ln -sf "${DIR}"/tmux/tmux.conf.local "${HOME}"/.tmux.conf.local
# === urxvt ===
if [[ -d "${HOME}"/.urxvt ]]; then
rm -rf "${HOME}"/.urxvt
elif [[ -f "${HOME}"/.urxvt || -L "${HOME}"/.urxvt ]]; then
rm "${HOME}"/.urxvt
fi
ln -s "${DIR}"/urxvt "${HOME}"/.urxvt
## === X session ===
[[ -f "${HOME}"/.Xresources || -L "${HOME}"/.Xresources ]] && \
rm "${HOME}"/.Xresources
ln -s "${DIR}"/x11/Xresources "${HOME}"/.Xresources
[[ -f "${HOME}"/.Xdefaults || -L "${HOME}"/.Xdefaults ]] && \
rm "${HOME}"/.Xdefaults
ln -s "${DIR}"/x11/Xresources "${HOME}"/.Xdefaults
[[ -f "${HOME}"/.xsessionrc || -L "${HOME}"/.xsessionrc ]] && \
rm "${HOME}"/.xsessionrc
ln -s "${DIR}"/x11/xsessionrc "${HOME}"/.xsessionrc
# === volantes cursor theme ===
mkdir -p "${HOME}"/.local/share/icons
rsync -a --quiet "${DIR}"/x11/volantes "${HOME}"/.local/share/icons/
[[ "$(which xrdb)" != "" ]] && \
xrdb -merge "${HOME}"/.Xresources
# === check dependencies ===
DEBPKG="byobu diff-so-fancy direnv emacs-nox exa fzf i3 keychain \
konsole lnav mdp plocate pyflakes3 pygmentize python3-flake8 \
rxvt-unicode tig tmux visidata xsel yamllint zathura"
for PKG in ${DEBPKG}; do
PKG_PRESENT=$(dpkg -l "${PKG}" 2>/dev/null | grep '^ii')
[[ "${PKG_PRESENT}" == "" ]] && \
echo "Warning: ${PKG} not found!"
done
# === rust utilities ===
[[ -f "${HOME}/.cargo/env" ]] && \
. "${HOME}/.cargo/env"
if [[ ! -d "${HOME}/.cargo" ]]; then
curl --proto '=https' --tlsv1.2 -sSf https://static.rust-lang.org/rustup/rustup-init.sh | sh
else
rustup update
fi
# h/t Julia Evans <https://jvns.ca/blog/2022/04/12/a-list-of-new-ish--command-line-tools/>
source "${HOME}/.cargo/env"
cargo install ag choose difftastic du-dust exa git-delta lsd ripgrep sd xsv
# === node utilities ===
if [[ ! -d "${HOME}/.nvm" ]]; then
curl -o- https:/raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
[ -s "${HOME}/.nvm/nvm.sh" ] && \
. "${HOME}/.nvm/nvm.sh" # This loads nvm
[ -s "${HOME}/.nvm/bash_completion" ] && \
. "${HOME}/.nvm/bash_completion" # This loads nvm bash_completion
nvm install --lts
nvm use --lts
nvm alias default node
fi
[ -s "${HOME}/.nvm/nvm.sh" ] && \
. "${HOME}/.nvm/nvm.sh" # This loads nvm
[ -s "${HOME}/.nvm/bash_completion" ] && \
. "${HOME}/.nvm/bash_completion" # This loads nvm bash_completion
if [[ -d "${HOME}/.npm" ]]; then
npm install --global markdownlint-cli2 tldr yarn 2&>/dev/null # don't tell me about audit errors
fi
else
echo "No changes were made."
fi