Created
October 5, 2009 19:12
-
-
Save ernesto-jimenez/202353 to your computer and use it in GitHub Desktop.
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 | |
# By: Ernesto Jiménez <[email protected]> | |
# | |
# 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