Skip to content

Instantly share code, notes, and snippets.

@xgqfrms
Forked from mathiasbynens/appify
Last active April 9, 2024 06:39
Show Gist options
  • Save xgqfrms/d8797e253e8df0c5748ffbe9209bd07d to your computer and use it in GitHub Desktop.
Save xgqfrms/d8797e253e8df0c5748ffbe9209bd07d to your computer and use it in GitHub Desktop.
appify — create the simplest possible Mac app from a shell script

appify

#!/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"
@xgqfrms
Copy link
Author

xgqfrms commented Apr 9, 2024

#!/usr/bin/env bash

#!/usr/bin/env bash

echo "Python & Django & shell bin env ✅"
echo 'Python & Django & shell bin env 🚀'

# $ chmod +x ./dev.sh
# $ chmod +x ./test.py

<<EOF

#!/usr/bin/env python
# ❌ env: python: No such file or directory

#!/usr/bin/python3
# ❌ ModuleNotFoundError: No module named 'django'

#!/usr/local/bin/python3
# ✅ django version = 5.0.4

EOF


<<EOF

$ which python 
python: aliased to /usr/local/bin/python3
$ which python3
/usr/bin/python3
$ which py3    
py3: aliased to python

EOF


<<EOF
$ ls -al //usr/bin | grep env
-rwxr-xr-x    1 root   wheel    135104 Dec 15 22:43 env
-rwxr-xr-x    1 root   wheel    133856 Dec 15 22:43 printenv
EOF

The echo utility writes any specified operands, separated by single blank (‘ ’) characters and followed by a newline (‘\n’) character, to the standard output.

@xgqfrms
Copy link
Author

xgqfrms commented Apr 9, 2024

#!/usr/bin/env bash

echo "Python & Django & shell bin env ✅"
echo 'Python & Django & shell bin env 🚀'

# $ chmod +x ./dev.sh
# $ chmod +x ./test.py

<<EOF

#!/usr/bin/env python
❌ env: python: No such file or directory

#!/usr/bin/python3
❌ ModuleNotFoundError: No module named 'django'

#!/usr/local/bin/python3
✅ django version = 5.0.4

EOF


<<EOF

$ which python 
python: aliased to /usr/local/bin/python3
$ which python3
/usr/bin/python3
$ which py3    
py3: aliased to python

EOF


<<EOF
$ ls -al //usr/bin | grep env
-rwxr-xr-x    1 root   wheel    135104 Dec 15 22:43 env
-rwxr-xr-x    1 root   wheel    133856 Dec 15 22:43 printenv
EOF

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment