Skip to content

Instantly share code, notes, and snippets.

@hemanth
Created June 25, 2012 02:06
Show Gist options
  • Save hemanth/2986017 to your computer and use it in GitHub Desktop.
Save hemanth/2986017 to your computer and use it in GitHub Desktop.
Poor Man's Application Launcher

Why?

I'm in terminal a lot. Like, all the time. I thought it'd be cool to make my Terminal work like an application launcher.

What?

This just aliases every Application to a terminal command. Stripping out spaces and downcasing. For instance, running safari will do open -a Safari. Running activitymonitor will do open -a "Activity Monitor".

How?

Just stick this in your ~/.(zsh|bash)rc (note, it will slightly impact shell startup time. But not too badly, as it only traverses two directories deep, not into the applications themselves).

for app in $(find /Applications -maxdepth 2 -iname "*.app" | tr ' ' '^')
do
app="$(echo "$app" | egrep -o '([^/]+)\.app')"
app="${app%.app}"
app_name="$(echo "$app" | tr '^' ' ')"
app_command="$(echo "$app" | tr -d '^' | tr '[A-Z]' '[a-z]')"
alias "$app_command"="open -a \"$app_name"\"
done
app=""
for app in $(find $HOME/Applications -maxdepth 2 -iname "*.app" | tr ' ' '^')
do
app="$(echo "$app" | egrep -o '([^/]+)\.app')"
app="${app%.app}"
app_name="$(echo "$app" | tr '^' ' ')"
app_command="$(echo "$app" | tr -d '^' | tr '[A-Z]' '[a-z]')"
alias "$app_command"="open -a \"$app_name\""
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment