[clug] Terminal Control Sequences

Kevin Pulo kev at pulo.com.au
Mon Jul 5 00:06:01 MDT 2010

On Mon, Jul 05, 2010 at 03:21:54PM +1000, Owen wrote:

> > 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

If the non-printing stuff isn't surrounded by \[\], then on long lines
readline will get confused and mess up.

I use an old utility called xtermset which nicely abstracts away the
details of the control characters.  For $TERM == xterm || screen I

    PS1="\[$(xtermset title "\u@\h:\w")\]\u@\h:\w\$ "

I prefer this to using PROMPT_COMMAND, since the xtermset program is
only run once at the start, not at every prompt (which is unnecessary
for a simple stuff like this).

For the function above, you'd want

    function settitle {
        PS1="\[\e]2;penguin\a\]\u@\h:\$ "
        echo "Done."

Though why it warrants a function and shouldn't just be entered
directly is beyond me.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://lists.samba.org/pipermail/linux/attachments/20100705/e953b176/attachment.pgp>

More information about the linux mailing list