-
Notifications
You must be signed in to change notification settings - Fork 1
/
setup.sh
executable file
·150 lines (125 loc) · 3.91 KB
/
setup.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
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
#!/bin/bash
cd "$(dirname "$0")" || exit 1
LN_OPTS="-sT"
FORCE=false
if [[ "$1" = "-f" ]] || [[ "$1" = "--force" ]]; then
FORCE=true
echo "(Force-installing)"
LN_OPTS+="f"
shift
else
LN_OPTS+="i"
fi
DOTFILES_DIR="${1:-$HOME}"
echo "Current path: $PWD"
echo "Installing to: $DOTFILES_DIR"
echo "--- Linking directories & files ---"
safe-link() {
echo "> Linking '$1'"
SOURCE="$PWD/$1"
DEST="$DOTFILES_DIR/${2:-$1}"
mkdir -p "$(dirname "$DEST")"
if [[ -d "$SOURCE" ]] && [[ -d "$DEST" ]] && [[ ! -L "$DEST" ]]; then
echo "! Made a backup of pre-existing '$1'"
mv "$DEST" "$DEST.bak.$(date '+%D-%T' | tr ':/' '-')"
fi
ln "$LN_OPTS" "$SOURCE" "$DEST"
}
safe-link .bin
safe-link .zshrc
safe-link .zpreztorc
safe-link .gitignore
safe-link .gitconfig
safe-link .tmux.conf
if [[ "$(uname)" == Linux ]]; then
safe-link .xprofile
safe-link .xprofile .xsession
safe-link .xprofile .xsessionrc
safe-link .Xresources
XTHEMES_DIR="$DOTFILES_DIR/.config/rice/Xthemes"
if [[ -d "$XTHEMES_DIR" ]] && [[ ! -L "$XTHEMES_DIR/_selected" ]]; then
echo "Setting google.xresources as the default rice theme"
ln "$LN_OPTS" "$XTHEMES_DIR/google.xresources" "$XTHEMES_DIR/_selected"
fi
xrdb -merge "$DOTFILES_DIR/.Xresources"
CONKY_DIR="$DOTFILES_DIR/.config/conky"
if [[ -d "$CONKY_DIR/now-clocking" ]]; then
ln "$LN_OPTS" "$CONKY_DIR/config.now-clocking.env" "$CONKY_DIR/now-clocking/config.env"
fi
fi
# safe-link .config/coc
safe-link .config/conky
safe-link .config/dotfiles
safe-link .config/git
safe-link .config/gtk-3.0
# safe-link .config/hangups
safe-link .config/nvim/lua/user/init.lua
safe-link .config/nvim-vscode
safe-link .config/picom.conf
safe-link .config/rice
safe-link .config/starship.toml
safe-link .config/tint2
safe-link .config/xbindkeysrc
safe-link .config/zsh
for file in "$PWD/.templates/"*; do
safe-link ".templates/$(basename "$file")"
done
echo "--- Dependency setup ---"
PREZTO_DIR="${ZDOTDIR:-$HOME}/.zprezto"
if [[ ! -d "$PREZTO_DIR" ]] && command -v zsh /dev/null; then
echo "Setting up Prezto"
zsh -c '
git clone --recursive https://github.com/sorin-ionescu/prezto.git "${ZDOTDIR:-$HOME}/.zprezto"
setopt EXTENDED_GLOB
for rcfile in "${ZDOTDIR:-$HOME}"/.zprezto/runcoms/^README.md(.N); do
ln -s "$rcfile" "${ZDOTDIR:-$HOME}/.${rcfile:t}"
done
'
fi
if ! command -v starship >/dev/null; then
if command -v brew >/dev/null; then
brew install starship
else
curl -sS https://starship.rs/install.sh | sh
fi
fi
# if [ "$CONFIGURE_NEOVIM" ]; then
# echo -n "Installing or updating vim-plug... "
# curl -sfLo ~/.local/share/nvim/site/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
# echo "done"
#
# echo -n "Updating coc.nvim extensions... "
# if ! command -v npm >/dev/null; then
# echo "fail, npm not found"
# else
# npm --prefix "$DOTFILES_DIR/.config/coc/extensions" install --silent --no-package-lock &>/dev/null
#
# if [[ $? = 0 ]]; then
# echo "done"
# else
# echo "fail, unknown error"
# fi
# fi
# fi
if command -v budgie-desktop >/dev/null; then
echo -n "Loading Budgie settings... "
./scripts/load-budgie-settings.sh
echo done
fi
if command -v fc-list >/dev/null && ! fc-list | grep -q "Iosevka Nerd Font"; then
echo -n "Downloading fonts... "
(
cd "$(mktemp -d)"
curl -sSLO "https://github.com/ryanoasis/nerd-fonts/releases/download/v2.1.0/Iosevka.zip"
unzip -q Iosevka.zip
# we don't really need these
rm -rf *'Windows Compatible.ttf'
mkdir -p ~/.local/share/fonts
cp *.ttf ~/.local/share/fonts
echo -n "refreshing font cache... "
fc-cache -f
echo -n "removing temp dir... "
rm -rf "$(pwd)"
)
echo done
fi