[clug] Terminal Control Sequences

Duncan Roe duncan_roe at acslink.net.au
Mon Jul 5 16:25:43 MDT 2010


bash also has PROMPT_COMMAND, rather more powerful than PS1. I like to have
login name, host name and cwd in my xterm title bar. Then I just have the time
in my command prompt. From my .bashrc:

  [ "$TERM" = xterm ] &&
  {
        PROMPT_COMMAND='echo -ne "\033]0;${LOGNAME}@${HOSTNAME}:${PWD/#$HOME/~}\007"'
        PS1='\t\$ '
  }

Cheers ... Duncan.

On Mon, Jul 05, 2010 at 03:21:54PM +1000, Owen wrote:
>
> > On 05/07/2010, at 00:53 , moncojhr wrote:
> >
> >> Thanks for the input, so for instance with this:
> >>
> >> echo -e '\033]2;Hello\007'
> >>
> >> which is ESC ] 2 ; Hello BEL
> >>
> >> Am I able to actually type this in?
> >
> > I have this function defined in my collection of ZSH scripts:
> >
> > function settitle
> > {
> >         print -Pn "\e]0;$1\a"
> >         return 0
> > }
>
> >
> > Sadly I haven't had the time/motivation to make the same thing work
> > for Bash or other shells.
>
>
> From the Great God Google try this for bash
>
> function settitle
> {
> PS1="\e]2;penguin\a\u@\h:\$ "
> echo "Done."
> }
>
> and restart your console and type settitle


More information about the linux mailing list