Right justification in putty title bar

Right justification in putty title bar

am 16.04.2008 16:15:07 von jaredsubman

I'd like to do is have the short hostname, of the title bar of my
putty window in the far upper left-hand corner, followed by the date
in the far upper right-hand corner.

Currently, this is what I have in my .bashrc:

export HOST=$(echo $HOSTNAME |cut -d"." -f1)
export DATE=$(date +%a" "%b" "%d)
export TERM=xterm

printf "\033]0;$HOST%160s$DATE\007"

(Also, why would this be 160 and not
80???)

It works reasonably well except for when the hostname is too long at
which time the date scrolls off the title bar :

What I would really like to do for the date piece is something like
this:

printf "%80s" "$DATE"

which keeps the DATE right-justified at the command prompt but not in
my .bashrc.

What am I doing wrong?

Any help would be much appreciated. Thanks in advance.

Re: Right justification in putty title bar

am 16.04.2008 16:30:09 von Glenn Jackman

At 2008-04-16 10:15AM, "jaredsubman@yahoo.com" wrote:
> I'd like to do is have the short hostname, of the title bar of my
> putty window in the far upper left-hand corner, followed by the date
> in the far upper right-hand corner.
>
> Currently, this is what I have in my .bashrc:
>
> export HOST=$(echo $HOSTNAME |cut -d"." -f1)
> export DATE=$(date +%a" "%b" "%d)
> export TERM=xterm
>
> printf "\033]0;$HOST%160s$DATE\007"
>
> (Also, why would this be 160 and not
> 80???)

That's up to you. The difficulty is the title bar does not use a
monospace font (by default).

Try: printf "\033]0;%-80s%s\007" "$HOST" "$DATE"

and play with the first field width to taste


--
Glenn Jackman
"If there is anything the nonconformist hates worse than a conformist,
it's another nonconformist who doesn't conform to the prevailing
standard of nonconformity." -- Bill Vaughan