Skip to content

Instantly share code, notes, and snippets.

@hongymagic
Created March 12, 2012 23:57
Show Gist options
  • Star 9 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save hongymagic/2025540 to your computer and use it in GitHub Desktop.
Save hongymagic/2025540 to your computer and use it in GitHub Desktop.
Simple zsh wrapper to launch iA Writer from the terminal

This is a simple script to launch iA Writer from the terminal. It is extremely useful for interacting with Github's own wiki system as it provides git access.

INSTALL

One-liner

curl -L https://raw.github.com/gist/2025540/4f3f094286468db2588f40345e6faaf07bd5af2a/ia > /usr/local/bin/ia && chmod u+x /usr/local/bin/ia

Manual, safer way

  1. Copy the script below to /usr/local/bin (or anywhere else where you store your custom executables)
  2. Make it executable: chmod u+x /usr/local/bin/ia

Usage

Simple launch

$ ia

Launch and open a file

$ ia Home.md

Launch multiple files

$ ia Home.md About.md FAQ.md
#!/bin/zsh
for FILE in "$@"
do
open -a "iA Writer" "$FILE"
done;
@gustavnikolaj
Copy link

I've ported this to bash - just changing the header and the appending to the args variable.

I did find a little bug in your snippet though. If you have the iA Writer app open already, and try to open something from the shell, you will end up with a new empty file and not the files you asked for.

I tinkered around with it a bit, and found that if I removed the --args flag it worked.

@hongymagic
Copy link
Author

Cool! Thanks for letting me know. I'll play around with it as well and see what's going on there!

@hongymagic
Copy link
Author

In the spirit of Mountain Lion, I've updated this gist with the latest script:

July 2012 fixes

  • Previous instance of iA Writer is reused if ia command is invoked while instance of iA Writer is already active;
  • Fixed an issue with escaping arguments

Enhancements

  • One-liner install command

@aaronmoodie
Copy link

I've just created a fork and added in a if/else to check if file params exist, and create if not.
https://gist.github.com/3605724

@lwu
Copy link

lwu commented Sep 14, 2012

alias ia="open -a 'iA Writer'"

works for me... (put in .zshrc if you like)

@buk
Copy link

buk commented Mar 22, 2013

Thank you @lwu

@yarko
Copy link

yarko commented May 5, 2013

bash / OS/X folks might appreciate this version:

ia() {
   for FILE in "$@"; do
      if [ ! -e "$FILE" ]; then
        touch "$FILE"
      fi
   done
   open -a "iA Writer" "$@"
}

Then just put this function definition in your $HOME/.bash_login file (for example).

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