How to open a Terminal.app window in the current directory
Sometimes it’s useful to have another OS X Terminal window in the directory you are currently in. For example, let’s say I am working on my Rails app and I have a Terminal window open in the app’s directory, but I want to run the console or server. I could give up my existing window or I could push Cmd + n for a new window and then navigate to that directory, but neither of those are optimal.
I Googled around and came up with a few solutions, but I wanted just a simple one-liner. So here’s what I made (the “\” escape the line breaks):
echo `pwd` | pbcopy; \\
osascript -e "tell application \\"Terminal\\" \\
to do script \\"cd \\\\\\"`pbpaste`\\\\\\"\\""
Yes, it has a lot of escape slashes, but it works! I made an alias of my new one-liner so I can open a new window by just typing windowhere. Add this to your ~/.profile file to use it as an alias.
It’s just a simple script, but it saved me from the repetitiveness of typing “cd Sites/path[tab]/to[tab]/my[tab]/app[tab]” and I wanted to share. Maybe you too will find it useful.
