-
-
Save cicorias/7ded843121295e0c820b to your computer and use it in GitHub Desktop.
#!/bin/bash | |
if [ "$1" = "-h" -o "$1" = "--help" -o -z "$1" ]; then cat <<EOF | |
appify v3.0.1 for Mac OS X - http://mths.be/appify | |
Creates the simplest possible Mac app from a shell script. | |
Appify takes a shell script as its first argument: | |
`basename "$0"` my-script.sh | |
Note that you cannot rename appified apps. If you want to give your app | |
a custom name, use the second argument: | |
`basename "$0"` my-script.sh "My App" | |
Copyright (c) Thomas Aylott <http://subtlegradient.com/> | |
Modified by Mathias Bynens <http://mathiasbynens.be/> | |
EOF | |
exit; fi | |
APPNAME=${2:-$(basename "$1" ".sh")} | |
DIR="$APPNAME.app/Contents/MacOS" | |
if [ -a "$APPNAME.app" ]; then | |
echo "$PWD/$APPNAME.app already exists :(" | |
exit 1 | |
fi | |
mkdir -p "$DIR" | |
cp "$1" "$DIR/$APPNAME" | |
chmod +x "$DIR/$APPNAME" | |
echo "$PWD/$APPNAME.app" |
Launch a local web server from a directory
Say you’re working on a project and you want to debug it from a web server. The following shell script will use Python to launch a local web server from a specific directory and open the index page in your default browser of choice. After appifying it, you won’t even need to open the terminal for it anymore.
!/usr/bin/env bash
cd ~/Projects/Foo/
python -m SimpleHTTPServer 8080 &> /dev/null &
open http://localhost:8080/
Chrome/Chromium bootstrappers
I like to run Chrome/Chromium with some command-line switches or flags enabled. On Windows, you can create a shortcut and set the parameters you want in its properties; on a Mac, you’ll need to launch it from the command line every time. Well, not anymore :)
!/usr/bin/env bash
/Applications/Chromium.app/Contents/MacOS/Chromium --enable-benchmarking --enable-extension-timeline-api&
The & at the end is not a typo; it is there to make sure Chromium is launched in a separate thread. Without the &, Chromium would exit as soon as you quit Terminal.app.
Adding a custom app icon
Create an .icns file or a 512×512 PNG image with the icon you want, and copy it to the clipboard (⌘ + C). (Alternatively, copy it from an existing app as described in steps 2 and 3.)
Right-click the .app file of which you want to change the icon and select “Get Info” (or select the file and press ⌘ + I).
Select the app icon in the top left corner by clicking it once. It will get a subtle blue outline if you did it right.
Now hit ⌘ + V (paste) to overwrite the default icon with the new one.
Note that this will work for any file or folder, not just .app files.