Here’s how I got my tmux windows to be named ‘short hostname:working directory’.

Create a bash function in your $HOME/.bashrc.

settitle ()
{
    # only run this in tmux
    case "$TERM" in
        screen*)
            # get hostname without FQDN
            H=`hostname -s`
            # get current directory without the full path
            D=`basename $PWD`
            # set title of tmux/screen window
            printf "33k$H:$D33\\"
            ;;
    esac
}

Then call settitle from your PS1 prompt variable:

PS1="...(settitle)\$ "

Here is my current prompt:

PS1="[\u@\h \W\$(git branch 2> /dev/null | grep -e '\* ' | sed 's/^..\(.*\)/{\1}/')]\$(settitle)\$ " 

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s