Skip to content

Commit a18f792

Browse files
author
Robin van der Noord
committed
added menu asking the user what to do
1 parent db5e40b commit a18f792

File tree

1 file changed

+48
-11
lines changed

1 file changed

+48
-11
lines changed

install.sh

100644100755
Lines changed: 48 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ function install_bat {
154154
function setup_bat_alias {
155155
bashrc="/home/$SUDO_USER/.bashrc"
156156

157-
which batcat > /dev/null 2> /dev/null || return
157+
which batcat >/dev/null 2>/dev/null || return
158158

159159
grep 'alias bat' $bashrc >/dev/null && warn "alias bat already exists" || gum confirm "Would you like to setup the alias 'bat' for 'batcat'?" && echo -e "\nalias bat=batcat\n" >>$bashrc
160160
}
@@ -175,7 +175,7 @@ function install_delta {
175175

176176
function show_delta_git_setup {
177177
echo "Write this to your git config if you want to use delta for git:"
178-
cat <<EOF
178+
gum format -t code <<EOF
179179
# ~/.gitconfig
180180
[core]
181181
pager = delta
@@ -211,12 +211,12 @@ function install_broot {
211211
}
212212

213213
function install_fd {
214-
__install_apt "fd-find"
214+
__install_apt "fd-find"
215215
}
216216

217217
function setup_fd_alias {
218-
which fd > /dev/null 2> /dev/null && warn "command fd already exists - not making alias" && return
219-
which fdfind > /dev/null 2> /dev/null && (ln -s $(which fdfind) /usr/bin/fd) || warn "fd not installed - not making alias"
218+
which fd >/dev/null 2>/dev/null && warn "command fd already exists - not making alias" && return
219+
which fdfind >/dev/null 2>/dev/null && (ln -s $(which fdfind) /usr/bin/fd) || warn "fd not installed - not making alias"
220220
}
221221

222222
function install_ripgrep {
@@ -236,13 +236,20 @@ function install {
236236
which $pkg >/dev/null && warn "$name already installed" || _install_tool "$name" "$description" $method
237237
}
238238

239-
function main {
240-
require_sudo
239+
function prepare {
240+
require_sudo $*
241241
require_amd64
242242

243243
# gum can't use install since _install_tool uses gum
244244
install_gum
245+
}
246+
247+
function cleanup {
248+
# todo: cleanup - rm tempdir
249+
echo '-';
250+
}
245251

252+
function install_one_by_one {
246253
install bat "Better cat" install_bat batcat
247254
setup_bat_alias
248255

@@ -269,8 +276,38 @@ function main {
269276
# keep gum?
270277
}
271278

272-
main
279+
function install_all {
280+
install_bat
281+
setup_bat_alias
282+
install_exa
283+
install_lsd
284+
install_delta
285+
show_delta_git_setup
286+
install_dust
287+
install_duf
288+
install_broot
289+
install_fd fdfind
290+
setup_fd_alias
291+
install_ripgrep
292+
install_ag
293+
}
294+
295+
function remove_all {
296+
apt remove -y gum git-delta lsd exa bat du-dust duf fd-find ripgrep silversearcher-ag # ...
297+
# todo: remove aliases?
298+
}
299+
300+
function main {
301+
prepare $*
302+
303+
option=$(gum choose "Install All" "Install Specific" "Remove All" "Remove Specific")
304+
305+
if [[ $option == "Install All" ]]; then install_all; fi;
306+
if [[ $option == "Install Specific" ]]; then install_one_by_one; fi;
307+
if [[ $option == "Remove All" ]]; then remove_all; fi;
308+
if [[ $option == "Remove Specific" ]]; then fail 'currently not supported'; fi;
309+
310+
cleanup;
311+
}
273312

274-
# todo: remove flag
275-
# todo: menu with 1. install all; 2. install some; 3. remove all; 4. remove some
276-
# sudo apt remove -y gum git-delta lsd exa bat du-dust duf fd-find ripgrep silversearcher-ag ...
313+
main $*

0 commit comments

Comments
 (0)