-
Notifications
You must be signed in to change notification settings - Fork 0
/
restore_dotfiles.sh
executable file
·71 lines (56 loc) · 1.96 KB
/
restore_dotfiles.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
#!/bin/bash
DARWIN_PKGS=('emacs' 'vim' 'zsh' 'tmux' 'starship' 'wget' 'radare2')
! command -v stow 1>/dev/null && echo '[!] Please install stow!' && exit 1
! command -v curl 1>/dev/null && echo '[!] Please install curl!' && exit 1
! command -v git 1>/dev/null && echo '[!] Please install git!' && exit 2
echo "[-] Start stowing"
if [[ `uname -a | cut -d' ' -f 1` == 'Darwin' ]]; then
for PKG in ${DARWIN_PKGS[@]}; do
stow -v 1 -R -t ~ $PKG 2>&1 | grep 'WARNING! unstowing' -A1
done
else
find * -maxdepth 0 -type d | grep -v '^common$' | \
xargs -I@ stow -v 1 -R -t ~ @ 2>&1 | grep 'WARNING! unstowing' -A1
fi
echo "[+] Done stowing"
echo "[-] Setting XDG dirs"
if [[ -z "$XDG_DATA_HOME" ]]; then
echo '[!] XDG_DATA_HOME is not set. Please enter XDG_DATA_HOME (newline for default): '
read -r XDG_DATA_HOME
if [[ -z "$XDG_DATA_HOME" ]]; then
XDG_DATA_HOME=${HOME}/.local/share
fi
if [[ ! -d "$XDG_DATA_HOME" ]]; then
mkdir -p "$XDG_DATA_HOME"
fi
fi
if [[ -z "$XDG_CACHE_HOME" ]]; then
echo '[!] XDG_CACHE_HOME is not set. Please enter XDG_CACHE_HOME (newline for default): '
read -r XDG_CACHE_HOME
if [[ -z "$XDG_CACHE_HOME" ]]; then
XDG_CACHE_HOME=${HOME}/.cache/
fi
if [[ ! -d "$XDG_CACHE_HOME" ]]; then
mkdir -p "$XDG_CACHE_HOME"
fi
fi
mkdir -p "$XDG_CACHE_HOME"/vim \
"$XDG_DATA_HOME"/vim \
"$XDG_DATA_HOME"/vim/spell \
"$XDG_DATA_HOME"/vim/pack \
"$XDG_DATA_HOME"/zsh
echo "[+] Done setting XDG dirs"
echo "[-] Setting up vim"
# Install spell
if [[ ! -f "$XDG_DATA_HOME/vim/spell/it.utf-8.spl" ]]; then
curl -L 'http://ftp.vim.org/pub/vim/runtime/spell/it.utf-8.spl' -o "$XDG_DATA_HOME/vim/spell/it.utf-8.spl"
fi
echo '[+] Done setting up vim'
echo '[-] Setting up tmux'
if [[ ! -d "${XDG_CONFIG_HOME}/tmux/plugins/tpm" ]]; then
git clone https://github.com/tmux-plugins/tpm "${XDG_CONFIG_HOME}/tmux/plugins/tpm"
fi
echo '[+] Done setting up tmux'
echo '[-] Do common things'
find ./common -type f -exec {} \;
echo '[+] All done!'