Skip to content

Commit

Permalink
Add list-apps
Browse files Browse the repository at this point in the history
  • Loading branch information
0xmachos committed Apr 23, 2024
1 parent 57b97d5 commit 14a1025
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions list-apps
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/usr/bin/env zsh
# macos-scripts/list-apps

# list-apps
# List installed applications
# Explitict goal of not using system_profiler

set -euo pipefail
# -e exit if any command returns non-zero status code
# -u prevent using undefined variables
# -o pipefail force pipelines to fail on first non-zero status code

IFS=$'\n\t'
# Set Internal Field Separator to newlines and tabs
# This makes bash consider newlines and tabs as separating words
# See: http://redsymbol.net/articles/unofficial-bash-strict-mode/

### UTILITY FUNCTIONS ###
# ctrl_c
# usage

function ctrl_c {
echo -e "\\n[❌] ${USER} has chosen to quit!"
exit 1
}

### END UTILITY FUNCTIONS ###


function main {

trap ctrl_c SIGINT
# Detect and react to the user hitting CTRL + C

declare -a DIRECTORIES=("/Applications" "$HOME/Applications")
readonly DIRECTORIES

for directory in "${DIRECTORIES[@]}"; do
find "${directory}" -type d -name "*.app" -depth 1 -exec basename {} .app \;
done

}

main "$@"

0 comments on commit 14a1025

Please sign in to comment.