Created
September 20, 2024 08:03
-
-
Save yanyaoer/63b40dc2ca9737286b34e89689fc5fa7 to your computer and use it in GitHub Desktop.
simple app/shortcuts/cli luncher on macos
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# brew install choose-gui | |
# https://github.com/chipsenkbeil/choose?tab=readme-ov-file#open-apps-from-the-applications-directories | |
# bindkey with .skhdrc | |
# ctrl + alt + shift + cmd - r : app-choose.sh | |
shopt -s nullglob globstar | |
candidate() { | |
APPS=( | |
/Applications/ | |
/Applications/Utilities/ | |
/System/Applications/ | |
/System/Applications/Utilities/ | |
) | |
arr=$(ls "${APPS[@]}" | grep '\.app$'); | |
arr+=$(/usr/bin/shortcuts list | xargs -I{} echo short-{}); | |
printf '%s\n' "${arr[@]}" | |
} | |
runner() { | |
echo "$@" | |
if [[ $@ == short-* ]]; then | |
/usr/bin/shortcuts run ${@#short-} | |
elif [[ $@ == *.app ]]; then | |
open -a "$@" | |
else | |
eval "$@" | |
fi | |
} | |
export -f runner | |
candidate | \ | |
choose -m | \ | |
xargs -I {} bash -c 'runner "$@"' _ {} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment