1

I created a custom prompt generated from http://bashrcgenerator.com/

export PS1="\[$(tput bold)\]\[\033[38;5;14m\]\u\[$(tput sgr0)\]\[\033[38;5;13m\]@\[$(tput sgr0)\]\[\033[38;5;14m\]\h\[$(tput sgr0)\]\[$(t put sgr0)\]\[\033[38;5;15m\] \[$(tput bold)\]\[$(tput sgr0)\]\[\033[38;5;13m\]\w\[$(tput sgr0)\]\[$(tput sgr0)\]\[\033[38;5;15m\] \[$(tpu t sgr0)\]"

and pasted that line to the bottom of my ~/.bashrc which did work. However, now my window only shows xterm as the title instead of the directory like it showed before.

Here is a picture to better illustrate what I mean.

custom prompt showing xterm

normal prompt showing directory

How can I still show the directory for the window title while retaining the custom prompt?

1
  • 1
    It's only showing "xterm" because nothing in your prompt sets the title. You will have to combine your custom prompt with the original script (which uses a bash prompt command). Commented Oct 10, 2016 at 8:30

1 Answer 1

1

In my ~/.bashrc, I have:

# from the "xttitle(1)" man page - put info in window title
update_title()
{
    [[ $TERM = xterm ]] || [[ $TERM = xterm-color ]]  && xttitle "[$$] ${USER}@${HOSTNAME}:$PWD"
}

cd()
{
    [[ -z "$*" ]] && builtin cd $HOME
    [[ -n "$*" ]] && builtin cd "$*"
    update_title
}

which works for me. I need to change it only when I cd, not at each and every command prompt.

2
  • Adding that to the end of my ~/.bashrc didn't resolve the title issue. Is there anything else I would need to do?
    – kalenpw
    Commented Oct 11, 2016 at 18:38
  • Nevermind, I didn't have xttitle installed. It works now just a little more verbose than I prefer the title to be so I'll have to tweak it. Thanks!
    – kalenpw
    Commented Oct 11, 2016 at 18:41

You must log in to answer this question.

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