Skip to content

Instantly share code, notes, and snippets.

@ernesto-jimenez
Created October 5, 2009 19:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ernesto-jimenez/202353 to your computer and use it in GitHub Desktop.
Save ernesto-jimenez/202353 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
# By: Ernesto Jiménez <erjica@gmail.com>
#
# This script will generate aliases for all your applications
# in your /Applications folder in OS X allowing you to easily
# open applications from your command line.
# Examples:
# safari http://ernesto-jimenez.com
# finder ~
# quicktime-player /path/to/video.mov
#
# I've added these lines to my $HOME/.bashrc:
# if [ -f $HOME/.bashrc_aliases ]; then
# source $HOME/.bashrc_aliases
# fi
echo "alias finder=\"open -a finder\"" > $HOME/.bashrc_aliases
for i in $(
ls /Applications | awk -F / '{
if ($NF ~ /\.app$/) {
app_name = tolower($NF);
sub(/\.app/, "", app_name);
gsub(/[^a-z0-9]+/, "-", app_name);
print app_name
}
}'); do
COMMAND="open -a \\\"$(echo $i | sed -e 's/-/ /g')\\\""
echo "alias $i=\"$COMMAND\"" >> $HOME/.bashrc_aliases
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment