2

I set up a very nice custom bash prompt in .bash_profile, but I noticed that I've now lost the ability for new tabs to open in the same directory, and the ability to see the current working directory's icon in the titlebar.

How can I get that back?

I've made some progress in the direction by adding "\e]2;\w\a" to $PS1, but that displays the full path in the titlebar, not just the name of the working directory. Any suggestions would be greatly appreciated.

1 Answer 1

1

Did you change PROMPT_COMMAND? The default PROMPT_COMMAND is defined in /etc/bashrc:

# Tell the terminal about the working directory at each prompt.
if [ "$TERM_PROGRAM" == "Apple_Terminal" ] && [ -z "$INSIDE_EMACS" ]; then
    update_terminal_cwd() {
        # Identify the directory using a "file:" scheme URL,
        # including the host name to disambiguate local vs.
        # remote connections. Percent-escape spaces.
        local SEARCH=' '
        local REPLACE='%20'
        local PWD_URL="file://$HOSTNAME${PWD//$SEARCH/$REPLACE}"
        printf '\e]7;%s\a' "$PWD_URL"
    }
    PROMPT_COMMAND="update_terminal_cwd; $PROMPT_COMMAND"
fi
2
  • Yeah... I overrode PROMPT_COMMAND to track the time it took the last command to execute. This function did the trick. Thanks!
    – Soumya
    Sep 6, 2013 at 17:43
  • 1
    Note: Don't just copy this code into your startup script. This code is installed in the system and you should continue using whatever's installed, because it gets updated over time. In particular, this code was significantly overhauled in OS X 10.11 El Capitan to work with all pathnames (the above version doesn't handle non-ASCII characters). When customizing PROMPT_COMMAND append your commands to it like this: PROMPT_COMMAND="${PROMPT_COMMAND:+$PROMPT_COMMAND; }your_code_here"
    – Chris Page
    Dec 10, 2015 at 21:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .