So, I like to use TextWrangler for editing code in OSX, and I tend to use a terminal to control my workflow. Generally, I use a bash alias:
alias text='open -a /Applications/TextWrangler.app'
However, this method doesn’t allow me to open new files on the fly from the prompt. For example, if I typed emacs newfile.py it would temporarily create a new file, but not touch it until I actually saved the file. With my alias, though, if newfile.py doesn’t exist, then I get an error, and have to manually touch the file then open it.
Any suggestions on hidden ways to use open that solve this? Or third-party alternatives to the open command? Or is this just a fundamental limitation of GUI-based editors?
I think you want a full-fledged shell script rather than just an alias. Make a file with these contents:
Save it as
textsomewhere in your PATH and chmod it to be executable and you’re golden.If you really want to make it so that the file doesn’t exist if you don’t save it, that’s trickier. I think you’ll have to do something like this:
This will actually create the file and then delete it one second later. The app will still have the file open, though, so that when you save it will be recreated.