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 :
- in Finder, right-click on OpenTerminalHere.app and select Show Package Contents
- drill down to OpenTerminalHere.app/Contents/Resources/Scripts and click on main.scpt – this opens the AppleScript editor
- 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
- 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 :
- Leave the OpenTerminalHere unchanged
- 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.
Great Post