-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathlist-apps
executable file
·44 lines (31 loc) · 992 Bytes
/
list-apps
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
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 "$@"