-
Notifications
You must be signed in to change notification settings - Fork 0
/
create_links.sh
executable file
·225 lines (164 loc) · 6.53 KB
/
create_links.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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
#!/usr/bin/env bash
#
# Purpose of this file is to create symlinks to configuration files I have in my repo.
# Because directory links have to be created with root privileges,
# this file has to be run with root or sudo
target="$1"
HOME=$target
src="$target/src"
dotfiles="$src/dotfiles"
config="$target/.config"
clear
echo "setting up links from $dotfiles"
echo "targeting into $target"
read -p "Are you sure? " -n 1 -r
echo # (optional) move to a new line
if [[ ! $REPLY =~ ^[Yy]$ ]]
then
exit 1
fi
# 0. links creation functions
echo "#!/usr/bin/env bash" > remove_links.sh
echo "#" >> remove_links.sh
echo "###################################################################">>remove_links.sh
echo "# Autogenerated remove links file">>remove_links.sh
echo "###################################################################">>remove_links.sh
function log_warning(){
# coloring output message in yellow
echo -n "$(tput setaf 3)"
echo "$1"
# reset to terminal defaults
echo -n "$(tput sgr0)"
}
function log_info(){
# coloring output message in green
echo -n "$(tput setaf 2)"
echo -n "$1"
# reset to terminal defaults
echo "$(tput sgr0)"
}
function ln_file() {
echo "linking file from $1 to $2"
(ls $2 >> /dev/null 2>&1 && log_warning "File $2 exists") || (ln -s $1 $2 && log_info "File $2 created!")
echo "# Removing file -------------------------------------- $2">>remove_links.sh
echo "delete_link \"$2\"">>remove_links.sh
}
function ln_directory(){
echo "linking directory from $1 to $2"
(ls $2 >> /dev/null 2>&1 && log_warning "$2 exists") || (ln -ds $1 $2 && log_info "Directory $2 created!")
echo "# Removing directory ********************************* $2">>remove_links.sh
echo "delete_link \"$2\"">>remove_links.sh
}
function delete_link(){
[-h $1] && rm -i $1
}
# Create user home .config
mkdir -p $config
# Git configuration
echo "creating git config at $target/git"
ln_directory "$dotfiles/git/git" $target/git
ln_file "$dotfiles/git/system.gitconfig" "$target/.gitconfig"
ln_file "$dotfiles/git/global.gitignore" "$target/.gitignore"
#
# Onedrive syncer
# URL: https://github.com/abraunegg/onedrive
#
mkdir -p $config/onedrive
ln_file $dotfiles/onedrive.config $config/onedrive/config
ln_file $dotfiles/sync_list.config $config/onedrive/sync_list
# Zsh settings
ln_directory "$dotfiles/zsh/scripts" "$target/.zsh"
(ls $target/.zsh/private.zshrc >> /dev/null 2>&1 && echo "private zshrc exists") || touch $target/.zsh/private.zshrc
ln_file "$dotfiles/zsh/.shellrc" "$target/.shellrc"
ln_file "$dotfiles/zsh/.zshrc" "$target/.zshrc"
ln_file "$dotfiles/zsh/.zprofile" "$target/.zprofile"
ln_file "$dotfiles/zsh/.p10k.zsh" "$target/.p10k.zsh"
#
# Tmux
#
ln_file $dotfiles/.tmux.conf $target/.tmux.conf
#
# Espanso text expander
# URL: https://espanso.org
#
ln_directory "$dotfiles/espanso" "$config/espanso"
ln_directory "$dotfiles/doomemacs" "$target/.doom.d"
mkdir -p $config/kitty
ln_file $dotfiles/kitty/kitty.conf $config/kitty/kitty.conf
function alacritty(){
#mkdir -p $config/alacritty
ln_directory $dotfiles/alacritty $config/alacritty
}
alacritty
function vim() {
ln_file $dotfiles/vim/.vsvimrc $target/.vsvimrc
ln_file $dotfiles/vim/.ideavimrc $target/.ideavimrc
ln_file $dotfiles/vim/.vimrc $target/.vimrc
ln_file $dotfiles/vim/.gvimrc $target/.gvimrc
mkdir -p $config/nvim
ln_file $dotfiles/vim/init.vim $config/nvim/init.vim
mkdir $target/.vim
mkdir $target/.vim/backup_files
mkdir $target/.vim/swap_files
mkdir $target/.vim/undo_files
ln_file $dotfiles/vim/autocmd.vimrc $target/.vim/autocmd.vimrc
ln_file $dotfiles/vim/plugin-settings.vimrc $target/.vim/plugin-settings.vimrc
ln_file $dotfiles/vim/ide.vimrc $target/.vim/ide.vimrc
ln_file $dotfiles/vim/simple-mapping.vimrc $target/.vim/simple-mapping.vimrc
ln_file $dotfiles/vim/mapping.vimrc $target/.vim/mapping.vimrc
ln -ds $dotfiles/vim/plugins $target/.vim/plugins
}
function autocomplete(){
# generating shell completions for tools
kubectl completion zsh > $target/.zsh/completions/_kubectl
helm completion zsh > $target/.zsh/completions/_helm
k3d completion zsh > $target/.zsh/completions/_k3d
minikube completion zsh > $target/.zsh/completions/_minikube
}
#
#(ls ~/.autoenv >> /dev/null 2>&1 && echo "autoenv already installed") || git clone git@github.com:hyperupcall/autoenv.git ~/.autoenv
ln_file $dotfiles/user-dirs.dirs $config/user-dirs.dirs
ln_directory $dotfiles/paru $config/paru
#
# Sway config
#
mkdir -p $config/sway
ln_file $dotfiles/sway/config $config/sway/config
ln_directory $dotfiles/sway/config.d $config/sway/config.d
ln_directory $dotfiles/sway/scripts $config/sway/scripts
ln_directory $dotfiles/sway/profiles $config/sway/profiles
ln_file $dotfiles/swaylock/config $config/swaylock/config
ln_file $dotfiles/waybar/config $config/waybar/config
ln_file $dotfiles/waybar/style.css $config/waybar/style.css
ln_directory $dotfiles/rofi $config/rofi
ln_directory $dotfiles/kanshi $config/kanshi
ln_directory $dotfiles/swaync $config/swaync
ln_directory $dotfiles/swappy $config/swappy
ln_directory $dotfiles/workstyle $config/workstyle
ln_directory $dotfiles/sworkstyle $config/sworkstyle
ln_file $dotfiles/sway/desktops/sway_nvidia.sh /usr/bin/sway_nvidia
sudo chmod +x /usr/bin/sway_nvidia
sudo cp $dotfiles/sway/desktops/sway_nvidia.desktop /usr/share/wayland-sessions
ln_file $dotfiles/sway/desktops/sway_amd.sh /usr/bin/sway_amd
sudo chmod +x /usr/bin/sway_amd
sudo cp $dotfiles/sway/desktops/sway_amd.desktop /usr/share/wayland-sessions
ln_file $dotfiles/sway/desktops/sway_intel.sh /usr/bin/sway_intel
sudo chmod +x /usr/bin/sway_intel
sudo cp $dotfiles/sway/desktops/sway_intel.desktop /usr/share/wayland-sessions
# link desktop files
# To override default desktop files you can create a .desktop file with the same name in ~/.local/share/applications
# Arch by default uses /usr/share/applications
for file in $dotfiles/desktop/*; do
ln_file $file $target/.local/share/applications/$(basename $file)
done
# Thunderbird and Firefox are bastards. There's no way to customize their look without hacking the css files
# To make things worse, it's not really possible to get profile path from the command line easily
# grep "Path=" ~/.thunderbird/profiles.ini | sed 's/^Path=//'
#
# I will try linking the whole thunderbird dir to this path from search command above, let's see if it works on all machines
thunderbird_profile=$(grep "Path=" ~/.thunderbird/profiles.ini | sed 's/^Path=//')
if [ -z "$thunderbird_profile" ]; then
log_warning "Thunderbird profile not found"
else
ln_directory $dotfiles/thunderbird $target/.thunderbird/$thunderbird_profile/chrome
fi