In Lion, the new version of Terminal remembers your Windows and Tabs, including your scroll history, and with bash, also your path. If you use tcsh (as I have for 20 years or so), then it does not remember your path - here is how to fix it.
A little digging finds that bash sets this up in /etc/bashrc, specifically with update_terminal_cwd which it adds to PROMPT_COMMAND. It is careful to only do this for Apple_Terminal and while not inside Emacs. Since I don't use any other terminals (except TouchTerm on my iPhone) and I don't use Emacs, I've ignored that, but keep in mind there may be cases you need to disable this.
The trick is done by outputting a URL in an escape sequence.
In tcsh, you can set an alias to a command that is run immediately before printing your path, so you can set it to print the magic escape sequence using something like this:
alias precmd ~/perl/update_terminal_cwd.pl
update_terminal_cwd.pl duplicates the behaviour of update_terminal_cwd in /etc/bashrc:
#!/usr/bin/perl my $pwd = $ENV{PWD}; $pwd =~ s! !%20!g; $pwd = "file://$ENV{HOSTNAME}$pwd"; printf( "\e]7;%s\a", $pwd );
Add the alias to you .login and Terminal will remember your paths in tcsh too.
Posted Sunday, August 7, 2011. Permalink. Post a Comment.
None yet.
Comments