-
Notifications
You must be signed in to change notification settings - Fork 0
/
export-preferences.fish
executable file
·217 lines (162 loc) · 5.4 KB
/
export-preferences.fish
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
#!/usr/bin/env fish
# Spoiler, I don't have more experience in fish scripting than in regular bash
# Found it !
set -g dryrun false
if [ "$argv[1]" = "--dryrun" ]
set -g dryrun true
end
function get_greet_time
set -f hour $(date "+%H")
if [ $hour -ge 19 ] || [ $hour -lt 5 ]
set -f greet_time evening
else if [ $hour -ge 5 ] && [ $hour -lt 12 ]
set -f greet_time morning
else
set -f greet_time afternoon
end
echo $greet_time
end
# It is important to greet people before working with them...
function greet_me
if [ $dryrun = true ]
set -f formula "we will perform a debugging dry run."
else
set -f formula "we will proceed to the exportation of your preferences in the current environment."
end
echo "Good $(get_greet_time) $USER, $formula"
end
# ...and saying goodbye as well
function goodbye_me
echo "All seem to have completed successfully. Have a nice day."
end
# Real shit starts here...
function check_font
echo "Remember to install recommended font at https://github.com/romkatv/powerlevel10k-media/ (MesloLGS NF)"
if [ $dryrun = false ]
# TODO: Find a way to automate font installation
echo "TODO: Find a way to automate font installation"
end
end
# ...Well, more like here
function check_fisher
echo -n "Checking Fisher... "
if ! type fisher &> /dev/null
echo -n "Fisher seems to be missing. Installing now... "
if [ $dryrun = false ]
curl -sL https://git.io/fisher | source && fisher install jorgebucaran/fisher
end
end
echo "Fisher is installed !"
end
function check_fish_plugins
echo -n "Checking Tide and other plugins... "
if [ ! (fisher list | grep ilancosman/tide) ]
echo -n "Tide is not installed. Installing now... "
if [ $dryrun = false ]
fisher install IlanCosman/tide@v6
end
end
if [ ! (fisher list | grep decors/fish-source-highlight) ]
echo -n "fish-source-highlight is not installed. Installing now... "
if [ $dryrun = false ]
fisher install decors/fish-source-highlight
end
end
echo "Everything is installed !"
end
function export_fishrc
echo -n "Exporting fish configuration... "
if [ $dryrun = false ]
cp {./dot-files,$HOME/.config/fish}/config.fish
end
echo "Exported."
echo "Note that some configurations may be platform specific. Please check in ~/.config/fish/config.fish."
end
# Did you mean: emacs
function check_vim
echo -n "Checking VIM... "
if ! type vim &> /dev/null
echo "Vim is not installed, you may want to run install.sh first. Aborting."
exit 1
end
set -f vim_major $(vim --version | head -n1 | sed -e 's/^[^0-9]*//' -e 's/\..*//')
if [ $vim_major -lt 9 ]
echo "VIM is not up to date: must be >9.0 ! Aborting."
exit 1
end
echo "VIM is installed and up to date !"
end
function check_vim_features
echo -n "Checking VIM features... "
# For Yggdroot/indentLine
if [ ! (vim --version | grep +conceal) ]
echo "VIM is missing a feature: conceal! Aborting."
exit 1
end
if [ ! (vim --version | grep +python3) ]
echo "VIM needs to be compiled with python3 support! Aborting."
exit 1
end
# TODO Check other features
echo "VIM has all required features !"
end
function check_vim_plugins
echo -n "Checking VIM plugins... "
if [ ! -d ~/.vim/bundle/Vundle.vim ]
echo -n "Vundle was not detected. Installing now... "
if [ $dryrun = false ]
mkdir -p $HOME/.vim/bundle
git clone https://github.com/VundleVim/Vundle.vim.git $HOME/.vim/bundle/Vundle.vim
end
end
if [ ! -d ~/.vim/pack/plugins/start/vim-cpp-modern ]
echo -n "vim-cpp-modern was not detected. Installing now... "
if [ $dryrun = false ]
mkdir -p $HOME/.vim/pack/plugins/start
git clone --depth=1 https://github.com/bfrg/vim-cpp-modern.git $HOME/.vim/pack/plugins/start/vim-cpp-modern
end
end
echo "VIM plugins are installed and ready to go !"
end
function export_vimrc
echo -n "Exporting VIM dot files... "
if [ $dryrun = false ]
cp {./dot-files,$HOME}/.vimrc
cp {./dot-files,$HOME/.vim}/init.vim
end
echo "Exported."
echo "Note that some configurations may be platform specific. Please check in ~/.vimrc"
end
function configure_vim
echo -n "Now configuring VIM... "
# TODO: Maybe delete any previous plugins, in case of update
if [ $dryrun = false ]
vim -u $HOME/.vimrc +PluginInstall +qall
end
# TODO: build YCM
echo "VIM configured"
echo "/!\ Remember to build YCM with 'cd ~/.vim/bundle/YouCompleteMe && python3 install.py --all'"
end
function export_terminal
echo -n "Exporting alacritty and tmux dot files... "
if [ $dryrun = false ]
mkdir -p $HOME/.config/alacritty/themes
cp {./dot-files,$HOME/.config/alacritty}/alacritty.toml
cp {./dot-files,$HOME/.config/alacritty/themes}/gruvbox_dark.toml
cp {./dot-files,$HOME}/.tmux.conf
end
echo "Exported."
echo "TODO: Automate installation of Tmux Plugin Manager (https://github.com/tmux-plugins/tpm)"
end
greet_me
check_font
check_fisher
check_fish_plugins
export_fishrc
check_vim
check_vim_features
check_vim_plugins
export_vimrc
configure_vim
export_terminal
goodbye_me