[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Bag o' Questions



On Sat 06 May, 2000 at 02:49:06AM -0500, Eric Gillespie, Jr. wrote:
> On Sat, May 06, 2000 at 12:19:25AM -0400,
> Patrick Dahiroc <patd@dahiroc.net> wrote:
> 
> > 1) I'm running gnome-terminal as my xterm. The title on the
> > window simply says 'Terminal'. Is possible to have the window
> > title dynamically change to the current working directory. Kinda
> > like the way emacs changes the window title to the name of the
> > current file.
> 
> I have this in ~/.zshrc. Not sure how to do it in bash (why would
> you use bash, anyway?).
> 
> settitle() {
>     case $TERM in
>     *xterm* | *rxvt* | (dt|k|E)term)
> 	print -Pn "\e]2;$*\a"
> 	;;
>     esac
> }
> 
> seticontitle() {
>     case $TERM in
>     *xterm* | *rxvt* | (dt|k|E)term)
> 	print -Pn "\e]1;$*\a"
> 	;;
>     esac
> }
> 
> precmd() {
> 	[[ -t 1 ]] || return	# return if not on a terminal
> 
> 	settitle "%n@%m: %~"
> 	seticontitle "%n@%m: %~"
> }
> 
> P.S. Please wrap lines at 65 columns.
> 
> -- 
> Eric Gillespie, Jr. <*> epg@pobox.com
> 
> "Let us be thankful we have commerce. Buy more. Buy more now.
>  Buy. And be happy."
> --OMM (THX 1138)

I have the following script in my .bashrc file - modify it for your own use:

# Changes titlebar text in xterm, eterm, etc. depending in the directory youare working in; e.g hostname@~ or hostname@/var/lib

prompt ()
{
MYPWD=`echo $PWD | sed "s/\/home\/traxus/\~/"`  #echoes the current directory 
						#at startup... 
echo -ne '\033]0;ashurbanipal@'$MYPWD' \007'    #shows hostname@current directory
unset MYPWD
}

if [ "x$DISPLAY" != "x" ]; then			
export PROMPT_COMMAND=prompt
fi

--> I hope this is what you're looking for...

-- 
Emil Soleyman-Zomalan


Reply to: