-
Notifications
You must be signed in to change notification settings - Fork 7
/
install.sh
executable file
·47 lines (40 loc) · 1.53 KB
/
install.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
#!/usr/bin/env bash
set -Eeuo pipefail
thisDir="$(dirname "$(readlink -f "$BASH_SOURCE")")"
if [ -e "$HOME/.bashrc" ]; then
sed -ri 's!^(HIST[A-Z]*SIZE=)!#\1!' "$HOME/.bashrc"
fi
declare -A files=(
["$HOME/.bashrc"]="source '$thisDir/bashrc'"
["$HOME/.gitconfig"]=$'[include]\n\t'"path = $thisDir/git-config"
["$HOME/.inputrc"]="\$include $thisDir/inputrc"
["$HOME/.ssh/config"]="Include $thisDir/ssh-config.d/*" # TODO this should only be done if the permissions on "ssh-config.d" are such that it will actually work (SSH is very picky and if permissions are bad this will make "ssh" literally fail to do *anything* which is not ideal)
["$HOME/.tmux.conf"]="source-file '$thisDir/tmux.conf'"
)
# Debian includes a default ~/.profile that loads bashrc, but Alpine doesn't, so if ~/.profile doesn't exist or doesn't mention bashrc, let's adjust it too
if [ ! -e "$HOME/.profile" ] || ! grep -q bashrc "$HOME/.profile"; then
files["$HOME/.profile"]='[ -z "$BASH_VERSION" ] || . "$HOME/.bashrc"'
fi
if [ ! -d "$HOME/.ssh" ]; then
mkdir "$HOME/.ssh"
chmod 700 "$HOME/.ssh"
fi
if [ ! -d "$HOME/.ssh/sockets" ]; then
mkdir "$HOME/.ssh/sockets"
fi
for f in "${!files[@]}"; do
if [ ! -e "$f" ] || ! grep -q "$thisDir" "$f"; then
line="${files[$f]}"
printf "updating %q -- %s\n" "$f" "${line//$'\n'/\\n}"
if [ -s "$f" ]; then
echo >> "$f"
fi
echo "${files[$f]}" >> "$f"
fi
done
for d in "$HOME/.vim/pack" "$HOME/.config/nvim/pack"; do
if [ ! -d "$d/tianon" ]; then
mkdir -pv "$d"
ln -svfT "$thisDir/vim-pack-tianon" "$d/tianon"
fi
done