Skip to content

Instantly share code, notes, and snippets.

@borismus
Created August 5, 2011 20:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save borismus/1128396 to your computer and use it in GitHub Desktop.
Save borismus/1128396 to your computer and use it in GitHub Desktop.
Pass arguments to any OS X launcher
#!/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