Date: Thu, 19 Sep 2002 09:04:25 +0300 From: Giorgos Keramidas <keramida@ceid.upatras.gr> To: Peter Leftwich <Hostmaster@Video2Video.Com> Cc: FreeBSD-Questions@FreeBSD.ORG Subject: Re: ~/.terminalrc challenge Message-ID: <20020919060425.GD39149@hades.hell.gr> In-Reply-To: <20020919013316.C83658-100000@earl-grey.cloud9.net> References: <20020919013316.C83658-100000@earl-grey.cloud9.net>
next in thread | previous in thread | raw e-mail | index | archive | help
On 2002-09-19 01:35, Peter Leftwich <Hostmaster@Video2Video.Com> wrote: > I would like a file similar to my ~/.login (which sets some leave reminders > and prompt customizations) but only to run when a new gnome-terminal is > launched, for example some kind of ~/.terminalrc file? > > This may be possible via my ~/.cshrc but I am not very crafty at using > "test" in the first few lines to run `ps -auxww | grep XFree86` and if that > returns true to run a few lines of code. That's almost certainly the wrong way of doing something like this. You can't be sure that the new login session is within a gnome-terminal, just because some process happens to be called XFree86. Think of the following series of events: - You fire up X11. - You switch to console ttyv0 with CTRL+ALT+F1. - You log into console ttyv0. - Your ttyv0 console login runs .terminalrc !!! I'm sure that gnome-terminal has some other way of firing up a shell with customised settings. Or you could check for DISPLAY in the environment *and* make sure that this is a gnome-terminal by making sure that the process-ID of $$ matches a running gnome-terminal instance. That can get tricky though. An example of a way to determine the name of the program that spawned the currently running shell (bash in my case) is shown below: $ ps -o pid,ppid,command | awk -v pid=$$ '$1 == pid && $3 ~ bash {print $2}' 219 $ ps -ax -o pid,ppid,command | awk '$1 == 219 {print $0}' 219 1 screen -a -O Using this in a shell script could be a bit tricky: pid=`ps -o pid,ppid,command |\ awk -v pid=$$ '$1 == pid && $3 ~ bash {print $2}'` if ps -ax -o pid,ppid,command | awk '$1 == '"$pid"' {print $0}' |\ grep screen >/dev/null 2>&1 ;then # echo "We are running bash under screen." else # echo "What is this? Where am I?" fi I hope this helps. -- Giorgos Keramidas <keramida@{ceid.upatras.gr,freebsd.org}> FreeBSD 4.6-RELEASE #0: Wed Sep 18 23:08:01 EEST 2002 To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020919060425.GD39149>