Dynamic Konsole Session Tabs/Names Updated

I've previously wrote about setting konsole's tab names dynamically, but there have been some problems with my solution.

  1. The prompt gets kinda messed up for non-xterms (like when logging in locally
  2. You have to modify each user's .bashrc file

So I wanted to make sure these changes only got set on xterms and to streamline the creation of the string to build the colors and usernames dynamically.

Luckily I found a solution with Fedora's /etc/bashrc file - it executes /etc/sysconfig/bash-prompt-xterm only for xterms and stores the result in PROMPT_COMMAND. Using this I've crafted a bash-silfreed-prompt-command package for FC6 and EL4. Here's the contents of the bash-prompt-xterm file I created:

DEFAULT_COLOR=160SYSTEM_COLOR=10485760COLOR=KONSOLE_USER=# set color to DEFAULT_COLOR for non-system users# only when the username is the same as the group name# (it's usually only different after a 'su')if [ "`id -gn`" = "`id -un`" -a `id -u` -gt 99 ]; then        COLOR=$DEFAULT_COLOR        # prefix the username only if the username is different        # from the initial login name (and we're not a system user)        if [ "`stat -c %U \`tty\``" != "`id -un`" ]; then                KONSOLE_USER="${USER}@"        fi# set color to SYSTEM_COLOR for system userselse        COLOR=$SYSTEM_COLORfiBASH_DEFAULT="\033]0;${USER}@${HOSTNAME%%.*}:${PWD/#$HOME/~}\007"BASH_KONSOLE="\e]30;${KONSOLE_USER}${HOSTNAME%%.*}:${PWD/#$HOME/~}\a\e[28;${COLOR}t"echo -ne ${BASH_DEFAULT}${BASH_KONSOLE}# vim: set syntax=sh tabstop=4 :