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

Re: Prompt in Bash



Rob, thanks a lot for your script. I think there is a small glitch,
though:

 > if [ ${PS1:-UNSET} = UNSET ]
 > then
 > 	INTERACTIVE_SHELL=F
 > else
 > 	INTERACTIVE_SHELL=T
 > 
 >   if [ "$TERM" = xterm -o "$TERM" = rxvt ]
 >   then
 >     set_titlebar () { echo -n "]2;$*"; }
 >     export -f set_titlebar
 > 
 >     my_dirname () { 
 >       if [ "${PWD#$HOME}" != "$PWD" ]
 >       then
 >     	  echo '~'${PWD#$HOME}
 >       else
 >     	  echo $PWD
 >       fi
 >     }
 >     export -f my_dirname

This effectively returns the current working directory, taking care to
replace the $HOME prefix with a single `~`.

 >     export PS1='\n\!\$ '
 >     export PROMPT_COMMAND='eval set_titlebar `whoami`@`hostname`:`my_dirname`'

When I did this, the title bar showed the full path, without replacing
$HOME with a '~' character. I got rid of the "eval", and things were
fine.

 >   else
 >     export PS1='\n\u@\h:\w\n\!\$ '
 >   fi 
 > fi
 > 
 > if [ "${BASH_INITIALIZED}" != "Yes" ]
 > then
 > 	export BASH_INITIALIZED=Yes
 > 
 >   # Do other stuff here that should only happen once, and be
 >   # inherited by sub-shells.
 > 
 > fi

 > Rob

-- 
Gonzalo A. Diethelm G.
gonzo@ing.puc.cl


--
TO UNSUBSCRIBE FROM THIS MAILING LIST: e-mail the word "unsubscribe" to
debian-user-request@lists.debian.org . 
Trouble?  e-mail to templin@bucknell.edu .


Reply to: