Re: xtset or xtermset tricks?

2004-08-18 Thread Greg 'groggy' Lehey
On Tuesday, 17 August 2004 at 11:38:33 -0400, Duane Winner wrote:
> Hello,
>
> Hey, does anybody know of any useful tricks for automating xtset or
> xtermset?
>
> I use xtset to set the title and icon labels to [EMAIL PROTECTED]:path so I can
> keep track of my xterms littered all over my desktop (pretty frequent! :)
>
> But it sure would be nice to have them updated whenever I 'cd' to
> another directory or 'su' to another user or 'ssh' to another host!
>
> I'm sure there's got to be someway to make this a little more seamless
> then running # xtset [EMAIL PROTECTED]:`pwd` everytime, but I'm just not good enough
> with shell programming to know how to do this.
>
> The closest I came was writing a small bash script that does:
>
>for filename in /dev/ttyp*; do
>   /usr/local/bin/xtset [EMAIL PROTECTED]:`pwd` > "$filename"
>done

Here's what I do (in .bashrc):

ssh ()
{
  xtset -t $*
  xtset -i "[EMAIL PROTECTED]:%D"
  command ssh $*
  xtset -t "%u (%T) %h:%D"
  xtset -i "[EMAIL PROTECTED]:%D"
}
cd ()
{
  command cd $*
  if [ $? = 0 ]; then
xtset -t "%u (%T) %h:%D"
xtset -i "[EMAIL PROTECTED]:%D"
true
  else
false
  fi
}

  xtset -t "%u (%T) %h:%D"
  xtset -i "[EMAIL PROTECTED]:%D"

The last two lines set the initial heading.

Note also that you can set headings from another window: xtset writes
to its stdout, so this will do what you expect:

  xtset "Foo bah baz" >/dev/ttyp5

Greg
--
When replying to this message, please copy the original recipients.
If you don't, I may ignore the reply or reply to the original recipients.
For more information, see http://www.lemis.com/questions.html
Note: I discard all HTML mail unseen.
Finger [EMAIL PROTECTED] for PGP public key.
See complete headers for address and phone numbers.


pgpni255cb8jx.pgp
Description: PGP signature


Re: xtset or xtermset tricks?

2004-08-18 Thread Nikos Vassiliadis
Since you use bash, you can use the variable
PROMPT_COMMAND to execute something,
just before the shell prints out PS1. And then
you can set the xterm's title using something
like this:

echo -ne "\033]0;my xterm\007"

Cheers, NikV

On Tuesday 17 August 2004 20:10, Duane Winner wrote:
> This is a little better:
>
> cd ()
> {
>  # do the actual cd
>  builtin cd "$@"
>
>  # if in homedir, then make path '~', not full path
>  if [ $PWD == $HOME ]; then
>  XTDIR="~"
>  else
>  XTDIR="$PWD"
>  fi
>
>  # set xtset title and icon to [EMAIL PROTECTED]:path
>  /usr/local/bin/xtset [EMAIL PROTECTED]:`echo $XTDIR`
> }
>
> # force an xtset title at shell login:
> cd
>
>
> -Duane
>
> Duane Winner wrote:
> > Found a solution!
> >
> > In ~/.bashrc, put this:
> >
> > cd ()
> > {
> >builtin cd "$@"
> >/usr/local/bin/xtset [EMAIL PROTECTED]:`pwd`
> > }
> >
> >
> >
> > -Duane
> >
> > Duane Winner wrote:
> >> Hello,
> >>
> >> Hey, does anybody know of any useful tricks for automating xtset or
> >> xtermset?
> >>
> >> I use xtset to set the title and icon labels to [EMAIL PROTECTED]:path so I
> >> can keep track of my xterms littered all over my desktop (pretty
> >> frequent! :)
> >>
> >> But it sure would be nice to have them updated whenever I 'cd' to
> >> another directory or 'su' to another user or 'ssh' to another host!
> >>
> >> I'm sure there's got to be someway to make this a little more seamless
> >> then running # xtset [EMAIL PROTECTED]:`pwd` everytime, but I'm just not good
> >> enough with shell programming to know how to do this.
> >>
> >> The closest I came was writing a small bash script that does:
> >>
> >>for filename in /dev/ttyp*; do
> >>   /usr/local/bin/xtset [EMAIL PROTECTED]:`pwd` > "$filename"
> >>done
> >>
> >> And thought about cron'ing it (every minute), but the problem is that
> >> when I tested this, all my xterms get the same title/icon based on who
> >> is running the script and where at the time. No good :(
> >> (And of course this would be useless to update the titles/icons for
> >> xterms that are remote shells (ssh).
> >>
> >>
> >> Any thoughts?
> >>
> >> Thanks!
> >> Duane
> >> ___
> >> [EMAIL PROTECTED] mailing list
> >> http://lists.freebsd.org/mailman/listinfo/freebsd-questions
> >> To unsubscribe, send any mail to
> >> "[EMAIL PROTECTED]"
>
> ___
> [EMAIL PROTECTED] mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-questions
> To unsubscribe, send any mail to
> "[EMAIL PROTECTED]"

___
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


Re: xtset or xtermset tricks?

2004-08-18 Thread Giorgos Keramidas
On 2004-08-17 21:51, Duane Winner wrote:
Gary Kline wrote:
On Tue, Aug 17, 2004 at 12:41:02PM -0400, Duane Winner wrote:
Found a solution!
In ~/.bashrc, put this:
cd ()
{
  builtin cd "$@"
  /usr/local/bin/xtset [EMAIL PROTECTED]:`pwd`
}

I've got a slight problem with having the host/directory/etc on the
title bar. It will help clear my zsh right-prompt, of course.

But now, since I hammered out that little cd() function for .bashrc, I
found another little problem:
If I su to another user (for instance, "su - root"), the title changes
as long as the other account has my the function in .bashrc, but when
I exit, the title still has the old credentials (example:
[EMAIL PROTECTED]:~) until I cd somewhere again. Sigh.
Don't use cd aliases for showing the current path in your xterm
titlebar.  There's a more elegant way involving PROMPT_COMMAND:
bash-2.05b$ export PS1='\$ '
$ export PROMPT_COMMAND='echo ::`pwd`::'
::/home/keramida::
$ cd /etc
::/etc::
$ cd /usr/src
::/usr/src::
$ exit
exit
You can set PROMPT_COMMAND to any command you want, no matter how
complicated.  A nice wrapper script around your "usual stuff" for
PROMPT_COMMAND can be called too with:
$ export PROMPT_COMMAND='/home/keramida/bin/promptcmd.sh'
Regarding the current username, host name and directory, you might be
interested in this output too:
$ echo $USER
keramida
$ hostname -s
orion
$ echo $PWD
/home/keramida
$
- Giorgos
___
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


Re: xtset or xtermset tricks?

2004-08-17 Thread Gary Kline
On Tue, Aug 17, 2004 at 09:51:23PM -0400, Duane Winner wrote:
> 
> 
> Gary Kline wrote:
> > Is there a way of using xtset/xtermset to retrieve the
> > -n "Name"??
> 
> Hm, not sure. I just started with xtset myself this morning when I 
> decided I was getting sick of having 10 xterm windows all over my lawn 
> with the name 'xterm'. I never gave descriptive labels since I'm most 
> often ssh'd into other boxes and am more interested in where I am.
> 
> Maybe, depending on how you start each xterm (icon/shortcut), you could 
> set a variable name (XTNAME="Mail") for each one, then run:
> # xtset `echo $XTNAME`

Yeah, sure there is some kludgey way of resetting 
the xterms.  Looking at the issue from a hacker's perspective
I can't see many options for resetting.  Unless you wantedthe
names always reset at 04:30 or whatever.  Oh-well. 
> 
> But now, since I hammered out that little cd() function for .bashrc, I 
> found another little problem:
> 
> If I su to another user (for instance, "su - root"), the title changes 
> as long as the other account has my the function in .bashrc, but when I 
> exit, the title still has the old credentials (example: [EMAIL PROTECTED]:~) 
> until I cd somewhere again. Sigh.
> 

What happns if you omit the " - " when you su?  

gary



-- 
   Gary Kline [EMAIL PROTECTED]   www.thought.org Public service Unix

___
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


Re: xtset or xtermset tricks?

2004-08-17 Thread Duane Winner

Gary Kline wrote:
On Tue, Aug 17, 2004 at 12:41:02PM -0400, Duane Winner wrote:
Found a solution!
In ~/.bashrc, put this:
cd ()
{
  builtin cd "$@"
  /usr/local/bin/xtset [EMAIL PROTECTED]:`pwd`
}

-Duane
Duane Winner wrote:
Hello,
Hey, does anybody know of any useful tricks for automating xtset or 
xtermset?

I use xtset to set the title and icon labels to [EMAIL PROTECTED]:path so I can 
keep track of my xterms littered all over my desktop (pretty frequent! :)

But it sure would be nice to have them updated whenever I 'cd' to 
another directory or 'su' to another user or 'ssh' to another host!


[ ... ]
I've got a slight problem with having the host/directory/etc on the
title bar. It will help clear my zsh right-prompt, of course.
But how do you set the title bar *back* to the name of the xterm?
(My xterms are titled "Mail", "Net", "Hacking", "Scratch", and so
forth.)  Is there a way of using xtset/xtermset to retrieve the
-n "Name"??
Hm, not sure. I just started with xtset myself this morning when I 
decided I was getting sick of having 10 xterm windows all over my lawn 
with the name 'xterm'. I never gave descriptive labels since I'm most 
often ssh'd into other boxes and am more interested in where I am.

Maybe, depending on how you start each xterm (icon/shortcut), you could 
set a variable name (XTNAME="Mail") for each one, then run:
# xtset `echo $XTNAME`

But now, since I hammered out that little cd() function for .bashrc, I 
found another little problem:

If I su to another user (for instance, "su - root"), the title changes 
as long as the other account has my the function in .bashrc, but when I 
exit, the title still has the old credentials (example: [EMAIL PROTECTED]:~) 
until I cd somewhere again. Sigh.

Cheers,
Duane

thanks,
gary

___
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


Re: xtset or xtermset tricks?

2004-08-17 Thread Duane Winner
This is a little better:
cd ()
{
# do the actual cd
builtin cd "$@"
# if in homedir, then make path '~', not full path
if [ $PWD == $HOME ]; then
XTDIR="~"
else
XTDIR="$PWD"
fi
# set xtset title and icon to [EMAIL PROTECTED]:path
/usr/local/bin/xtset [EMAIL PROTECTED]:`echo $XTDIR`
}
# force an xtset title at shell login:
cd
-Duane

Duane Winner wrote:
Found a solution!
In ~/.bashrc, put this:
cd ()
{
   builtin cd "$@"
   /usr/local/bin/xtset [EMAIL PROTECTED]:`pwd`
}

-Duane
Duane Winner wrote:
Hello,
Hey, does anybody know of any useful tricks for automating xtset or 
xtermset?

I use xtset to set the title and icon labels to [EMAIL PROTECTED]:path so I 
can keep track of my xterms littered all over my desktop (pretty 
frequent! :)

But it sure would be nice to have them updated whenever I 'cd' to 
another directory or 'su' to another user or 'ssh' to another host!

I'm sure there's got to be someway to make this a little more seamless 
then running # xtset [EMAIL PROTECTED]:`pwd` everytime, but I'm just not good 
enough with shell programming to know how to do this.

The closest I came was writing a small bash script that does:
   for filename in /dev/ttyp*; do
  /usr/local/bin/xtset [EMAIL PROTECTED]:`pwd` > "$filename"
   done
And thought about cron'ing it (every minute), but the problem is that 
when I tested this, all my xterms get the same title/icon based on who 
is running the script and where at the time. No good :(
(And of course this would be useless to update the titles/icons for 
xterms that are remote shells (ssh).

Any thoughts?
Thanks!
Duane
___
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to 
"[EMAIL PROTECTED]"


___
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


Re: xtset or xtermset tricks?

2004-08-17 Thread Gary Kline
On Tue, Aug 17, 2004 at 12:41:02PM -0400, Duane Winner wrote:
> Found a solution!
> 
> In ~/.bashrc, put this:
> 
> cd ()
> {
>builtin cd "$@"
>/usr/local/bin/xtset [EMAIL PROTECTED]:`pwd`
> }
> 
> 
> 
> -Duane
> 
> 
> Duane Winner wrote:
> >Hello,
> >
> >Hey, does anybody know of any useful tricks for automating xtset or 
> >xtermset?
> >
> >I use xtset to set the title and icon labels to [EMAIL PROTECTED]:path so I can 
> >keep track of my xterms littered all over my desktop (pretty frequent! :)
> >
> >But it sure would be nice to have them updated whenever I 'cd' to 
> >another directory or 'su' to another user or 'ssh' to another host!
> >

[ ... ]


I've got a slight problem with having the host/directory/etc on the
title bar. It will help clear my zsh right-prompt, of course.
But how do you set the title bar *back* to the name of the xterm?
(My xterms are titled "Mail", "Net", "Hacking", "Scratch", and so
forth.)  Is there a way of using xtset/xtermset to retrieve the
-n "Name"??

thanks,

gary


-- 
   Gary Kline [EMAIL PROTECTED]   www.thought.org Public service Unix

___
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


Re: xtset or xtermset tricks?

2004-08-17 Thread Duane Winner
Found a solution!
In ~/.bashrc, put this:
cd ()
{
   builtin cd "$@"
   /usr/local/bin/xtset [EMAIL PROTECTED]:`pwd`
}

-Duane
Duane Winner wrote:
Hello,
Hey, does anybody know of any useful tricks for automating xtset or 
xtermset?

I use xtset to set the title and icon labels to [EMAIL PROTECTED]:path so I can 
keep track of my xterms littered all over my desktop (pretty frequent! :)

But it sure would be nice to have them updated whenever I 'cd' to 
another directory or 'su' to another user or 'ssh' to another host!

I'm sure there's got to be someway to make this a little more seamless 
then running # xtset [EMAIL PROTECTED]:`pwd` everytime, but I'm just not good enough 
with shell programming to know how to do this.

The closest I came was writing a small bash script that does:
   for filename in /dev/ttyp*; do
  /usr/local/bin/xtset [EMAIL PROTECTED]:`pwd` > "$filename"
   done
And thought about cron'ing it (every minute), but the problem is that 
when I tested this, all my xterms get the same title/icon based on who 
is running the script and where at the time. No good :(
(And of course this would be useless to update the titles/icons for 
xterms that are remote shells (ssh).

Any thoughts?
Thanks!
Duane
___
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to 
"[EMAIL PROTECTED]"

___
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


xtset or xtermset tricks?

2004-08-17 Thread Duane Winner
Hello,
Hey, does anybody know of any useful tricks for automating xtset or 
xtermset?

I use xtset to set the title and icon labels to [EMAIL PROTECTED]:path so I can 
keep track of my xterms littered all over my desktop (pretty frequent! :)

But it sure would be nice to have them updated whenever I 'cd' to 
another directory or 'su' to another user or 'ssh' to another host!

I'm sure there's got to be someway to make this a little more seamless 
then running # xtset [EMAIL PROTECTED]:`pwd` everytime, but I'm just not good enough 
with shell programming to know how to do this.

The closest I came was writing a small bash script that does:
   for filename in /dev/ttyp*; do
  /usr/local/bin/xtset [EMAIL PROTECTED]:`pwd` > "$filename"
   done
And thought about cron'ing it (every minute), but the problem is that 
when I tested this, all my xterms get the same title/icon based on who 
is running the script and where at the time. No good :(
(And of course this would be useless to update the titles/icons for 
xterms that are remote shells (ssh).

Any thoughts?
Thanks!
Duane
___
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[EMAIL PROTECTED]"