Created
August 5, 2011 20:09
-
-
Save borismus/1128396 to your computer and use it in GitHub Desktop.
Pass arguments to any OS X launcher
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 | |
# Example usage: | |
# ./argify '/Applications/Google Chrome Stable.app/Contents/MacOS/Google Chrome' \ | |
# '--user-data-dir=$HOME/.chrome-stable' | |
if [ $# -ne 2 ] | |
then | |
echo "Usage: `basename $0` '/Applications/Google Chrome Stable.app/Contents/MacOS/Google Chrome' '--argument=value'" | |
exit 1 | |
fi | |
bin=$1 | |
args=$2 | |
dir=`dirname "$bin"` | |
newbin=$dir/argify | |
# Go to specified dir | |
cd "$dir" | |
if [ -e "$newbin" ] | |
then | |
echo "Already argified! Can't argify again - quitting." | |
exit 1 | |
fi | |
# Move the binary | |
mv "$bin" "$newbin" | |
# Replace binary with script | |
echo "#!/bin/bash | |
'$newbin' $args | |
" > "$bin" | |
# Make script executable | |
chmod +x "$bin" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment