View previous topic :: View next topic |
Author |
Message |
phong Bodhisattva
Joined: 16 Jul 2002 Posts: 778 Location: Michigan - 15 & Ryan
|
Posted: Thu Oct 10, 2002 9:04 pm Post subject: Set your xterm/konsole/other terminal title |
|
|
I put this in my /etc/profile:
Code: | if [ "$SHELL" = '/bin/bash' ] || [ "$SHELL" = '/bin/sh' ]
then
if [ "$TERM" = 'xterm' ]
then
PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME}: ${PWD}\007"'
fi
fi |
Works quite nicely so I know where all my terminals are at from the taskbar. _________________ "An empty head is not really empty; it is stuffed with rubbish. Hence the difficulty of forcing anything into an empty head."
-- Eric Hoffer |
|
Back to top |
|
|
kaffee n00b
Joined: 23 Nov 2002 Posts: 1
|
Posted: Sat Nov 23, 2002 12:19 pm Post subject: |
|
|
Zsh users can utilize precmd() to achieve the same. For example:
Code: |
if [ $TERM = xterm ]; then
precmd () {
print -Pn "\e]0;[ %/ ]\a"
}
fi
|
|
|
Back to top |
|
|
buckminst n00b
Joined: 18 Jul 2002 Posts: 22 Location: Idaho
|
Posted: Thu Jan 16, 2003 1:06 pm Post subject: title changing with non-xterm terms |
|
|
It should be noted that some terminal emulators don't identify themselves as 'xterm'... case in point being aterm... you would need to modify the code thusly:
Code: |
if [ "$TERM" = 'xterm' ] || [ "$TERM" = 'rxvt' ]
|
Everything else would be the same. _________________ Curtis Hogg [ buckminst at inconnu dot islug dot org ]
Sattinger's Law: "It works better if you plug it in!"
This post sponsored by: Frungy, the sport of kings!
Registered Linux User #202758 Sept/1997 |
|
Back to top |
|
|
itsr0y Tux's lil' helper
Joined: 22 Dec 2002 Posts: 81
|
Posted: Fri Jan 17, 2003 7:02 am Post subject: |
|
|
kaffee wrote: | Zsh users can utilize precmd() to achieve the same. |
In fact, with zsh, you can set the term title to be the path when you are at a prompt, and to the current command when a program is running:
Code: | case $TERM in
*xterm*|rxvt|(dt|k|E)term)
precmd () { print -Pn "\e]0;$TERM - %~\a" }
preexec () { print -Pn "\e]0;$TERM - $1\a" }
;;
esac
|
You can modify the $TERM - %~ and $TERM - $1 as needed. See http://www.acm.uiuc.edu/workshops/zsh/prompt/escapes.html for a full list of stuff to put in the prompt (or title). |
|
Back to top |
|
|
barmaley n00b
Joined: 26 Nov 2002 Posts: 36
|
Posted: Mon Feb 03, 2003 2:50 am Post subject: |
|
|
This version will substitute user's home directory with a tilde:
Code: | PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME}: ${PWD/$HOME/~}\007"' |
|
|
Back to top |
|
|
vbenares Apprentice
Joined: 13 Aug 2003 Posts: 205
|
Posted: Fri Sep 12, 2003 7:00 pm Post subject: |
|
|
I recognize this thread is dead, but . . .
Is there any way to identify in the title bar whether one has su'ed or not? |
|
Back to top |
|
|
barmaley n00b
Joined: 26 Nov 2002 Posts: 36
|
Posted: Fri Sep 12, 2003 8:39 pm Post subject: |
|
|
Of course! If you do 'su -', the version above will display root@host. However, if you do su without '-', it won't, because bash profile is not sourced and $USER contains the old value.
If it's not enought, you have at least the following two possibilities:
- insert `whoami` instead of ${USER}
- place a condition in your .bashrc and set custom PROMPT_COMMAND depending on the value of `whoami`, like this:
Code: |
case `whoami` in
root)
PROMPT_COMMAND='echo -ne "\033]0;---root---\007"'
;;
*)
PROMPT_COMMAND='echo -ne "\033]0;---non-root---\007"'
;;
esac
|
This is the code from my real bash config:
Code: |
case `whoami` in
root)
USER_AT_HOST="# ${USER}@${HOSTNAME%%.*}"
;;
*)
USER_AT_HOST="${USER}@${HOSTNAME%%.*}"
;;
esac
case $TERM in
xterm*|rxvt|eterm)
PROMPT_COMMAND='echo -ne "\033]0;${USER_AT_HOST}: ${PWD/$HOME/~}\007"'
;;
screen)
PROMPT_COMMAND='echo -ne "\033_${USER_AT_HOST}: ${PWD/$HOME/~}\033\\"'
;;
esac
|
|
|
Back to top |
|
|
vbenares Apprentice
Joined: 13 Aug 2003 Posts: 205
|
Posted: Sat Sep 13, 2003 1:29 am Post subject: |
|
|
This is totally cool. |
|
Back to top |
|
|
ed0n l33t
Joined: 23 Apr 2003 Posts: 638 Location: Prishtine/Kosove
|
Posted: Sat Sep 13, 2003 7:51 am Post subject: |
|
|
in gnome-terminal which I use is to easy and simple to change it , you can change it by change-ing the profile .
But sometimes I also use xterm and this looks cool
thank you phong |
|
Back to top |
|
|
shm Advocate
Joined: 09 Dec 2002 Posts: 2380 Location: Atlanta, Universe
|
Posted: Thu Oct 02, 2003 4:09 am Post subject: |
|
|
with konsole, you can even set the name of the tab using dcop:
I use this:
Quote: | A="$PWD"
PROMPT_COMMAND='echo -ne $A; dcop $KONSOLE_DCOP_SESSION renameSession $A' |
I also put this in .vimrc to set the tab to vim's current file
Code: |
autocmd BufReadPost * :silent !dcop $KONSOLE_DCOP_SESSION renameSession %
|
_________________ what up |
|
Back to top |
|
|
varnyu n00b
Joined: 23 Aug 2002 Posts: 16
|
Posted: Sat Dec 13, 2003 11:57 am Post subject: displaying current process |
|
|
hi,
is there any solution for displaying the current running process in the titlebar using bash? (like emerge does)
thanks |
|
Back to top |
|
|
kernelcowboy Guru
Joined: 14 Feb 2004 Posts: 391 Location: New Plymouth, New Zealand
|
Posted: Thu Sep 21, 2006 10:35 pm Post subject: |
|
|
Yeah, would like to hear the answer to this !BUMP! This is one old thread. |
|
Back to top |
|
|
Zentoo Apprentice
Joined: 18 Nov 2002 Posts: 195 Location: /dev/console
|
Posted: Wed Oct 04, 2006 3:28 pm Post subject: |
|
|
!bump 2!
I'm looking the way to do the same too ! I whish my script could update title for chroot environment to make the difference between chrooted environment and normal one. _________________ Kernel 5.14.15-zen | Gcc 11.2 | Glibc 2.34
Core i7 6700K @ 4.6GHz | 32Gb
ACCEPT_KEYWORDS="~amd64"
CFLAGS="-march=native -O2 -pipe" |
|
Back to top |
|
|
shadeheim n00b
Joined: 03 Mar 2007 Posts: 56
|
Posted: Sun Mar 11, 2007 4:13 pm Post subject: |
|
|
bump |
|
Back to top |
|
|
|