-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbootstrap.sh
executable file
·136 lines (121 loc) · 2.97 KB
/
bootstrap.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
#!/bin/bash
# Variables
backup=false
tmux=false
fisherman=false
for ARGS in "$@"; do
shift
case "$ARGS" in
"-backup") backup=true ;;
"-tmux") tmux=true ;;
"-fisherman") fisherman=true ;;
*) set -- "$@" "$ARGS" ;;
esac
done
dir=$HOME/.dotfiles # dotfiles directory
olddir=$HOME/.dotfiles_old # old dotfiles backup directory
# Files list
files="
zshrc
gitconfig
tmux.conf
atom
Xresources
gitignore_global
zpreztorc
xmonad
p10k.zsh
ideavimrc
"
# Config dirs list
config_files="
fish
nvim
i3
picom.conf
rofi
termite
wal
zellij
ghostty
hypr
waybar
dunst
wlogout
"
if [ $backup == true ]; then
# create dotfiles_old in homedir
echo "Creating $olddir for backup of any existing dotfiles in ~"
mkdir -p $olddir
echo "...done"
# change to the dotfiles directory
echo "Changing to the $dir directory"
cd $dir
echo "...done"
# move any existing dotfiles in homedir to dotfiles_old directory
echo "Moving any existing dotfiles from ~ to $olddir"
for file in $files; do
if [ ! -L ~/.$file ]; then
mv ~/.$file $olddir
fi
done
# check if .dotfiles_old is empty
if [ ! "$(ls -A $olddir)" ]; then
echo "Delete $olddir because it is empty"
rm -r $olddir
fi
fi
# Create config dir symlinks
echo "Creating config dir symlinks"
for config_file in $config_files; do
echo "Manage $config_file configuration"
if [ -d "$HOME/.config/$config_file" -a ! -L "$HOME/.config/$config_file" ]; then
echo "Moving current $config_file config to ~/.config/$config_file""_old"
mv ~/.config/$config_file ~/.config/$config_file_old
fi
if [ ! -L "$HOME/.config/$config_file" ]; then
echo "Create the config or file directory symlink"
ln -sf $dir/$config_file ~/.config/$config_file
fi
done
if [ $fisherman == true ]; then
echo "Install fisherman if needed"
if [ ! -d "$HOME/.config/fisherman" ]; then
git clone https://github.com/fisherman/fisherman $HOME/.config/fisherman
cd $HOME/.config/fisherman
make
else
echo "Fisherman is already installed"
fi
fi
echo "Install Prezto if needed"
if [ ! -d "$HOME/.zprezto" ]; then
echo "Installing Prezto"
git clone --recursive https://github.com/sorin-ionescu/prezto.git "${ZDOTDIR:-$HOME}/.zprezto"
else
echo "Prezto is already installed"
fi
# Create symlinks
echo "Creating symlinks"
for file in $files; do
if [ ! -L ~/.$file ]; then
echo "Creating symlink to $file in home directory."
ln -sf $dir/$file ~/.$file
fi
done
echo "Source .zshrc file"
zsh $HOME/.zshrc
if [ $tmux == true ]; then
echo "Configuring TMUX"
if [ ! -d "$HOME/.tmux/plugins" ]; then
mkdir -p ~/.tmux/plugins
fi
if [ ! -d "$HOME/.tmux/plugins/tpm" ]; then
echo "Cloning tmux plugin manager"
git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm
fi
echo "Install tmux plugings"
tmux start-server
tmux new-session -d
~/.tmux/plugins/tpm/scripts/install_plugins.sh
fi