Skip to content

Instantly share code, notes, and snippets.

@heywoodlh
Last active February 15, 2024 01:40
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save heywoodlh/2f3f3bd83bb32719cb89ec3ee137fb5b to your computer and use it in GitHub Desktop.
Save heywoodlh/2f3f3bd83bb32719cb89ec3ee137fb5b to your computer and use it in GitHub Desktop.
choose-launcher.sh
#!/usr/bin/env bash
if ! command -v choose > /dev/null
then
echo 'Please install choose.'
fi
if ! command -v buku > /dev/null
then
echo 'Please install buku.'
fi
if ! command -v jq > /dev/null
then
echo 'Please install jq.'
fi
selection=$(buku -p -j | jq -r '.[] | "\(.title) || (\(.index))"' | choose | cut -d'|' -f3 | tr -d '( )')
if [[ ${selection} == "" ]]
then
exit
fi
buku -o ${selection}
#!/usr/bin/env bash
### brew install choose-gui
if ! command -v choose > /dev/null
then
echo 'Please install choose. Exiting.'
fi
target="$(printf "$HOME\n$(ls /Volumes)" | choose)"
if [[ $target == "" ]]
then
exit
fi
## Loop through directories until file is selected
while true
do
if [[ -d $target ]]
then
files=$(ls $target)
target_name="$(printf "..\n$(ls ${target})\n$(ls -a ${target} | grep -E '^\.' | grep -v -E '^\.\.|^.$')" | choose)"
target="${target}/${target_name}"
if [[ $target_name == "" ]]
then
exit
fi
elif [[ -f $target ]]
then
selection=$target
break
fi
done
if [ -n $selection ]
then
open "${selection}"
fi
#! /usr/bin/env bash
application_dirs="/Applications/ /System/Applications/ /System/Library/CoreServices/ /System/Applications/Utilities/"
if [ -e $HOME/Applications ]
then
application_dirs="${application_dirs} $HOME/Applications $HOME/.nix-profile/Applications"
fi
### Simple MacOS application launcher that relies on choose: https://github.com/chipsenkbeil/choose
### brew install choose-gui
if ! command -v choose > /dev/null
then
echo 'Please install choose. Exiting.'
fi
selection=$(ls ${application_dirs} | /usr/bin/grep -v -E 'Applications/:|Applications:' | /usr/bin/grep '.app' | /usr/bin/sort -u | choose)
open -a "${selection}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment