James Montgomerie’s World Wide Web Log

PWD in the Title Bar (or, “A Regex Adventure in BASH”)


In which a five-minute hack to put the current working directory in the title bar of the Terminal descends into hours learning the surprising arcanities of BASH.

Like most developers, I spend a lot of time at my computer living in Terminal (and the rest Xcode)*. I have what might be a strange tendency to open a new Terminal window for each new task, I think so that I don’t have to lose the context in my current window. This means that after I’ve finished doing something (or in the middle, when I look at the screen and my obsessive-compulsive…