@@ -76,6 +76,10 @@ On_IWhite='\033[0;107m' # White
7676
7777tempdir=$( mktemp -d)
7878
79+ function untar {
80+ tar -xf $*
81+ }
82+
7983function require_sudo {
8084 if [[ $UID != 0 ]]; then
8185 echo " Please run this script with sudo:"
@@ -156,7 +160,15 @@ function setup_bat_alias {
156160
157161 which batcat > /dev/null 2> /dev/null || return
158162
159- 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
163+ 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 )
164+ }
165+
166+ function setup_bottom_alias {
167+ bashrc=" /home/$SUDO_USER /.bashrc"
168+
169+ which btm > /dev/null 2> /dev/null || return
170+
171+ grep ' alias bottom' $bashrc > /dev/null && warn " alias bottom already exists" || (gum confirm " Would you like to setup the alias 'bottom' for 'btm'?" && echo -e " \nalias bottom=btm\n" >> $bashrc )
160172}
161173
162174function install_exa {
@@ -207,7 +219,12 @@ function install_duf {
207219}
208220
209221function install_broot {
210- fail " broot is currently not supported"
222+ url=" https://github.com/Canop/broot/releases/download/v1.14.2/broot_1.14.2.zip"
223+ gum spin --spinner dot --title " wget broot" -- wget " $url " -O " $tempdir /broot.zip"
224+ unzip " $tempdir /broot.zip" -d " $tempdir /broot" > /dev/null 2> /dev/null
225+ mv " $tempdir /broot/x86_64-linux/broot" /usr/local/bin/broot
226+ chmod +x /usr/local/bin/broot
227+
211228}
212229
213230function install_fd {
@@ -216,7 +233,7 @@ function install_fd {
216233
217234function setup_fd_alias {
218235 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"
236+ which fdfind > /dev/null 2> /dev/null && (ln -s " $( which fdfind) " /usr/bin/fd) || warn " fd not installed - not making alias"
220237}
221238
222239function install_ripgrep {
@@ -227,6 +244,72 @@ function install_ag {
227244 __install_apt silversearcher-ag
228245}
229246
247+ function install_fzf {
248+ __install_apt fzf
249+ }
250+
251+ function install_mcfly {
252+ url=" https://github.com/cantino/mcfly/releases/download/v0.6.1/mcfly-v0.6.1-x86_64-unknown-linux-musl.tar.gz"
253+ gum spin --spinner dot --title " wget mcfly" -- wget " $url " -O " $tempdir /mcfly.tar.gz"
254+
255+ untar " $tempdir /mcfly.tar.gz"
256+ mv mcfly /usr/local/bin/mcfly
257+ }
258+
259+ function install_choose {
260+ url=" https://github.com/theryangeary/choose/releases/download/v1.3.4/choose-x86_64-unknown-linux-gnu"
261+ gum spin --spinner dot --title " wget choose" -- wget " $url " -O " $tempdir /choose"
262+ mv " $tempdir /choose" /usr/local/bin/choose
263+ chmod +x /usr/local/bin/choose
264+ }
265+
266+ function install_jq {
267+ url=" https://github.com/stedolan/jq/releases/download/jq-1.6/jq-linux64"
268+ gum spin --spinner dot --title " wget jq" -- wget " $url " -O " $tempdir /jq"
269+ mv " $tempdir /jq" /usr/local/bin/jq
270+ chmod +x /usr/local/bin/jq
271+ }
272+
273+ function install_sd {
274+ url=" https://github.com/chmln/sd/releases/download/v0.7.6/sd-v0.7.6-x86_64-unknown-linux-gnu"
275+ gum spin --spinner dot --title " wget sd" -- wget " $url " -O " $tempdir /sd"
276+ mv " $tempdir /sd" /usr/local/bin/sd
277+ chmod +x /usr/local/bin/sd
278+ }
279+
280+ function install_cheat {
281+ url=" https://github.com/cheat/cheat/releases/download/4.3.1/cheat-linux-amd64.gz"
282+ gum spin --spinner dot --title " wget cheat" -- wget " $url " -O " $tempdir /cheat.gz"
283+ gunzip " $tempdir /cheat.gz"
284+ mv " $tempdir /cheat" /usr/local/bin/cheat
285+ chmod +x /usr/local/bin/cheat
286+ }
287+
288+ function install_tldr {
289+ if [[ $( which npm) ]]; then
290+ # install with npm
291+ npm install -g tldr
292+ else
293+ if [[ $( which pip3) ]]; then
294+ # install with pip3
295+ pip3 install tldr
296+ else
297+ if [[ $( which pip) ]]; then
298+ # install with regular pip
299+ pip install tldr
300+ else
301+ fail " npm or pip must be installed in order to install tldr!"
302+ fi
303+ fi
304+ fi
305+ }
306+
307+ function install_bottom {
308+ url=" https://github.com/ClementTsang/bottom/releases/download/0.6.8/bottom_0.6.8_amd64.deb"
309+ __install_dpkg $url " bottom"
310+ success " bottom can be used with the command 'btm'"
311+ }
312+
230313function install {
231314 name=$1
232315 description=$2
@@ -245,8 +328,8 @@ function prepare {
245328}
246329
247330function cleanup {
248- # todo: cleanup - rm tempdir
249- echo ' -' ;
331+ # todo: cleanup - rm tempdir
332+ echo ' -'
250333}
251334
252335function install_one_by_one {
@@ -272,6 +355,23 @@ function install_one_by_one {
272355
273356 install ag " A code searching tool similar to ack, but faster." install_ag
274357
358+ install fzf " A general purpose command-line fuzzy finder." install_fzf
359+
360+ install mcfly " Fly through your shell history. Great Scott!" install_mcfly
361+
362+ install choose " A human-friendly and fast alternative to cut and (sometimes) awk" install_choose
363+
364+ install jq " sed for JSON data." install_jq
365+
366+ install sd " An intuitive find & replace CLI (sed alternative)." install_sd
367+
368+ install cheat " Create and view interactive cheatsheets on the command-line." install_cheat
369+
370+ install tldr " A community effort to simplify man pages with practical examples." install_tldr
371+
372+ install bottom " Yet another cross-platform graphical process/system monitor." install_bottom
373+ setup_bottom_alias
374+
275375 # ...
276376 # keep gum?
277377}
@@ -290,24 +390,67 @@ function install_all {
290390 setup_fd_alias
291391 install_ripgrep
292392 install_ag
393+ install_fzf
394+ install_mcfly
395+ install_choose
396+ install_jq
397+ install_sd
398+ install_cheat
399+ install_tldr
400+ install_bottom
401+ setup_bottom_alias
293402}
294403
295404function remove_all {
296- apt remove -y gum git-delta lsd exa bat du-dust duf fd-find ripgrep silversearcher-ag # ...
405+ apt remove -y git-delta lsd exa bat du-dust duf fd-find ripgrep silversearcher-ag fzf # ...
297406 # todo: remove aliases?
407+ rm " $( which mcfly) " || echo " mcfly not installed"
408+ rm " $( which choose) " || echo " choose not installed"
409+ rm " $( which jq) " || echo " jq not installed"
410+ rm " $( which sd) " || echo " sd not installed"
411+ rm " $( which cheat) " || echo " cheat not installed"
412+ rm " $( which broot) " || echo " broot not installed"
413+
414+ # tldr:
415+ if [[ $( which npm) ]]; then
416+ # install with npm
417+ npm uninstall -g tldr
418+ else
419+ if [[ $( which pip3) ]]; then
420+ # install with pip3
421+ pip3 uninstall tldr
422+ else
423+ if [[ $( which pip) ]]; then
424+ # install with regular pip
425+ pip uninstall tldr
426+ else
427+ warn " npm or pip must be installed in order to (un)install tldr!"
428+ fi
429+ fi
430+ fi
431+
432+ # apt remove -y gum
433+
298434}
299435
300436function main {
301437 prepare $*
302438
439+ if [[ $1 ]]; then
440+ method=" install_$1 "
441+ $method # execute
442+ exit
443+ fi
444+ # else:
445+
303446 option=$( gum choose " Install All" " Install Specific" " Remove All" " Remove Specific" )
304447
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 ;
448+ if [[ $option == " Install All" ]]; then install_all; fi
449+ if [[ $option == " Install Specific" ]]; then install_one_by_one; fi
450+ if [[ $option == " Remove All" ]]; then remove_all; fi
451+ if [[ $option == " Remove Specific" ]]; then fail ' currently not supported' ; fi
309452
310- cleanup;
453+ cleanup
311454}
312455
313- main $*
456+ main $*
0 commit comments