Mastodon

Setting default screen window name

Here is a small scrip snippet which once put into your .bashrc file, it will set the screen name to the one of hostname.

# for screen session
case $TERM in
  xterm*)
    PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME}: ${PWD}\007"'
    ;;
  screen)
    PROMPT_COMMAND='echo -ne "\033k$HOSTNAME\033\\"'
    ;;
  *)
    PS1="\[\033[0;31m\]\u\[\033[1;34m\]@\[\033[0;25m\]\h\[\033[1;35m\]:\[\033[1;33m\]\w\[\033[0m\]\[\033[1;34m\]$\[\033[0m\] "
    ;;
esac

Advantage is, while in a screen session, you dont have to set the screen name manually every time you connect to that server.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.