Created
March 3, 2011 16:15
-
-
Save mmattozzi/853024 to your computer and use it in GitHub Desktop.
OSX: Changing iterm tab with each cd
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I created a perl script: | |
#!/usr/bin/perl -w | |
my $dir = `pwd`; | |
chomp $dir; | |
$dir =~ s/\/trunk$//; | |
$dir = substr($dir, rindex($dir, "/") + 1); | |
print "\033]0;$dir\007"; | |
Then set the PROMPT_COMMAND variable in my ~/.bash_profile: | |
export PROMPT_COMMAND="$HOME/scripts/dir.pl" | |
Now whenever I change directories, the tab title is set in iterm. Also, if I am in a trunk directory | |
(as is often the case) the terminal tab will be set to the name of the directory above it. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Also works in regular Mac Terminal.
And yes, this means every time you run any command, perl will run. Is that bad? I think today's machines should be able to handle it. Although it'd be nice to find a way to do this sort of string manipulation in just bash. Not sure if that's possible anyway without invoking sed or something.