OpenTerminalHere with wd in title

How to open a Mac Terminal application from Finder, in its current directory?

Get the app OpenTerminalHere by Marc Liyanage and add its icon in the Finder toolbar. Click on the icon to open a Terminal.

How  to make that Terminal display the working directory in its window title?

Modify the OpenTerminalHere like this :

  1. in Finder, right-click on and select Show Package Contents
  2. drill down to and click on main.scpt – this opens the AppleScript editor
  3. just before the line “end process_item” at the end of script insert this line: tell application “Terminal” to set custom title of window 1 to the_path
  4. Compile and Run – it should open a Terminal that displays the path in its title

Bonus: when you right-click on the Terminal’s Dashboard icon, each terminal listed displays the working directory, end of guessing which is which.

How  to make that Terminal display the working directory in its window title? — take two —

As Marc Liyanage, the author of OpenTerminalHere pointed out to me, my change to his script sets the window title at the time of opening the Terminal, but it does not react to subsequent changes of working directory. He suggested putting a suitable ecape sequence into ~/.bashrc. After some man reading and experimenting I settled to the following solution :

  1. Leave the OpenTerminalHere unchanged
  2. Add to ~/.profile

export PROMPT_COMMAND='echo -ne "\033]0; ${PWD}\007"'

This gets executed on every command, and keeps the window title in sync with any change of the working directory.


One thought on “OpenTerminalHere with wd in title

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s