Two Dimensional World RSS

Lou Kosak's day dreams about web development, clouds, curmudgeonly letters to companies, talking pictures.

@hoverkraft on Twitter.

See also: yugster.tumblr.com.

Archive

Aug
3rd
Wed
permalink

Fixing the OS X Lion Terminal zshell pwd bug

(I wonder what percentage of mac users this represents, and whether or not I’d need to use scientific notation to represent that number.)

So, IF you’re running OS X Lion, and IF you use the terminal frequently, and IF you use zshell (which you probably should, but nobody does) THEN this might interest you.

Basically there’s a bug with the terminal’s “New tabs open with ‘Same Working Directory’” problem, that also affects restoring a terminal window, where the correct PWD (..present working directory..) isn’t received from zshell and the terminal ends up opening in /private/var (…for some reason.)

Here’s the fixeroo, snatched from this superuser answer. Drop the following into your ~/.zshrc:

# Set Apple Terminal.app resume directory
if [[ $TERM_PROGRAM == "Apple_Terminal" ]] && [[ -z "$INSIDE_EMACS" ]] {
  function chpwd {
    local SEARCH=' '
    local REPLACE='%20'
    local PWD_URL="file://$HOSTNAME${PWD//$SEARCH/$REPLACE}"
    printf '\e]7;%s\a' $PWD_URL
  }

  chpwd
}

And be merry forevermore.