Reputation: 11669
I want to get the hostname of the remote system i connect to as the title of my terminal. I have a simple setting done in my bash_profile , which is populated in all the systems where i login.
I am using this script as of now
PS1='[\u@\h:\w]\$ '
export TITLEBAR='\[\033]0;\u@\h:\w \007\]'
# Terminal sets TERM_PROGRAM so we can tell it apart from regular VT100
case "$TERM_PROGRAM" in
"Apple_Terminal")PS1="$TITLEBAR$PS1"
esac
case "$TERM" in
"xterm")PS1="$TITLEBAR$PS1"
esac
# end insert
The problem is when i logout from a remote system , i am not able to get my current system(hostname details) in the terminal title.
Upvotes: 0
Views: 2793
Reputation: 371
I am using this one:
export PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME%%.*}:${PWD/$HOME/~}\007"'
add it in $HOME/.bash_profile on both local machine and remote machines.
Upvotes: 3
Reputation: 29266
Make all of that a little bash function and then call that bash function manually when you logout of a remote system?
Upvotes: -1