Text editors like TextMate and Atom provide command line helpers to open application windows in a specific context from the terminal. With a simple shell alias, this can be achieved for Safari, too.
I like to run development tools like git and build tools from the terminal. When I want to open the project I'm currently in in my favorite editor, I use TextMate's command line helper.
mate .
mate
is the name of the command, .
is the working directory. This works with Atom as well.
To open an HTML file or URI in Safari, you can use Apple's open command. The following command opens a file called index.html
from the working directory in Safari.
open -a safari index.html
To simplify its usage, I created an alias and put it into my ~/.bash_profile
.
alias safari='open -a safari'
Type source ~/.bash_profile
after modifying ~/.bash_profile
to publish the modification to your current shell session (not required in future shell sessions). Now you can simply type safari index.hml
.
Write a comment
via