Last active
February 5, 2024 22:49
-
-
Save matthewhenderson/48c04997c21be36529cd to your computer and use it in GitHub Desktop.
iA Writer new README.md file in selected directory
This file contains hidden or 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
| This script is designed to make opening a file | |
| in iA Writer on the Mac from the Terminal | |
| command line easy. | |
| EXAMPLE USE: | |
| Running "ia README" will open the file if it exists, | |
| exactly as the name is specified with no extension. | |
| Otherwise, it will create a new file called README.md | |
| with the md file extension, if it doesn't already exist, | |
| and open it. If a file called README.md does already | |
| exist, it will be safely opened without being overwritten. | |
| Add either of the two options below to your .bash_profile file | |
| in your user directory (~/). | |
| OPTION 1: | |
| ia() { | |
| if [ -z "$1" ]; then | |
| echo "No file specified." | |
| else | |
| if [ -f "$1" ]; then | |
| ## OPEN EXISTING SPECIFIED FILE | |
| open -a "iA Writer" "$1" | |
| else | |
| ## OPEN NEW OR EXISTING FILE WITH MD EXTENSION | |
| touch "$1.md" | |
| open -a "iA Writer" "$1.md" | |
| fi | |
| fi | |
| } | |
| OPTION 2: SINGLE LINE EXAMPLE | |
| ia2() { if [ -z "$1" ]; then echo "No file specified."; else if [ -f "$1" ]; then open -a "iA Writer" "$1"; else touch "$1.md"; open -a "iA Writer" "$1.md"; fi fi } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment