Set the title for bash Terminal on mac OS X to current working directory [closed]

Posted on


I know they have been asking a lot of this question and I got it worked perfectly, but one thing I don’t understand is why this is different.

 #This will show the full path (/usr/bin)
 PROMPT_COMMAND='echo -ne "33]0;${PWD}07"'

 #This will set to the directory name only (bin)
 PROMPT_COMMAND='echo -ne "33]0;${PWD##*/}07"'

The problem I have here is that I want to use the second one, but when I open a new tap it will go back to the default working directory, whereas the first one will keep the same working directory if I open another tap which I want that.


Strange. Maybe it has to do with when the pattern-expansion takes place in bash’s order of processing.

Something like `PROMPT_COMMAND=’BASED=${PWD##*/} echo -ne “33]0;$BASED07″‘ might do the trick.

EDIT: That didn’t work? Maybe this will

set_prompt () {
    echo -ne "33]0;$BASE_PATH07"


Leave a Reply

Your email address will not be published. Required fields are marked *