You are not logged in.

#1 2011-01-11 04:23:30

dglmoore
Member
Registered: 2010-10-16
Posts: 11

Use rc in 9term and bash in Xterm

I use xterm on a regular basis and bash is my preferred shell, but I enjoy using Acme from Plan9. In cases when I am using Acme, I prefer rc over bash and would like that to be the default for 9term. How can I do this?

The problem comes down to: "How can make my shell dependent on which terminal I am using?"

I have tried several things, but none have worked yet. Any suggestions?

D.

Last edited by dglmoore (2011-01-11 04:24:42)

Offline

#2 2011-01-11 05:18:51

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: Use rc in 9term and bash in Xterm

How do you start your terminals? 'xterm -e bash' takes care of the first case and a similar command will launch rc in 9term, I suppose.

Offline

#3 2011-01-11 13:12:57

dglmoore
Member
Registered: 2010-10-16
Posts: 11

Re: Use rc in 9term and bash in Xterm

Well, bash is my default shell so issuing 'xterm' gives me bash. I would prefer 9term to default to rc so that issuing '9term' or 'win' (in Acme) would start 9term with rc as the shell.

Within .bashrc if I

export SHELL="/opt/plan9/bin/rc"

it starts every terminal with rc. I also tried

case "$TERM" in
    9term) export SHELL="/opt/plan9/bin/rc";;
        *) export SHELL="/bin/bash";;
esac

But bash starts in every terminal, although

echo $SHELL

in 9term returns rc.

Offline

#4 2011-01-11 13:24:22

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: Use rc in 9term and bash in Xterm

Maybe $TERM is not 9term.
Can't you alias 9term to something like 'xterm -e bash' but for 9term & rc?

I don't know a thing about Acme so I don't know how to solve the 'win' part.

Offline

#5 2011-01-11 13:32:41

dglmoore
Member
Registered: 2010-10-16
Posts: 11

Re: Use rc in 9term and bash in Xterm

Yes, $TERM is 9term. Setting up an alias would work, but I have other settings that are dependent on the terminal. It would be nice if I could set the shell as well as those other settings in the same place. At the moment, all of those other settings work perfectly, and I suppose SHELL does too. I mean, it is setting that environment variable, 9term just isn't using it to determine which shell to use?

Regarding Acme, if I get 9term to start with rc, the win command will start rc.

Offline

#6 2011-01-11 13:55:49

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: Use rc in 9term and bash in Xterm

dglmoore wrote:

But bash starts in every terminal, although

echo $SHELL

in 9term returns rc.

Even if you run 'xterm -e rc'? It should start rc.

Maybe try

export SHELL="/opt/plan9/bin/rc" && 9term

Offline

#7 2011-01-11 14:03:17

dglmoore
Member
Registered: 2010-10-16
Posts: 11

Re: Use rc in 9term and bash in Xterm

That works; it opens 9term with rc as the shell. However, that is no better than '9term rc'.

I need '9term' to start 9term with rc running and 'xterm' to start xterm with bash.

Last edited by dglmoore (2011-01-11 14:03:34)

Offline

#8 2011-01-11 14:06:52

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: Use rc in 9term and bash in Xterm

dglmoore wrote:

I need '9term' to start 9term with rc running and 'xterm' to start xterm with bash.

So exporting shells + specifying which shell to use is not enough?

Offline

#9 2011-01-11 14:14:41

dglmoore
Member
Registered: 2010-10-16
Posts: 11

Re: Use rc in 9term and bash in Xterm

Would you want to type

export SHELL="/opt/plan9/bin/win" && 9term

every time you opened 9term?

I will always want 9term to use rc so typing

9term rc

to run 9term is not the best.

I need a way, preferably not using aliases, to specify from a .profile, .bash_profile, .bashrc, etc to use rc in 9term and bash in any other terminal.

It seems like this should be much more simple than it is.

Offline

#10 2011-01-11 14:40:16

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: Use rc in 9term and bash in Xterm

man xterm wrote:

       XTERM_SHELL
            is set to the pathname of the program which is invoked.  Usually that is a shell program, e.g., /bin/sh.
            Since it is not necessarily a shell program however, it is distinct from "SHELL".

Maybe you need to dig into the manuals?

I have

yeahconsole*term: urxvt

in my .Xdefaults - maybe 9term has a similar option.

Offline

#11 2011-01-11 15:06:19

dglmoore
Member
Registered: 2010-10-16
Posts: 11

Re: Use rc in 9term and bash in Xterm

From the 9term man page:

9term runs the given command in the window, or $SHELL if no command is given.

The 'given command' it is referring to is a command line option.

By that, it should be running rc, but it isn't.

Offline

#12 2011-01-11 15:22:57

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: Use rc in 9term and bash in Xterm

But you said 'export SHELL="/opt/plan9/bin/rc" && 9term' works. If you don't like aliases, maybe bind it to a keyboard shortcut.

case "$TERM" in
    9term) export SHELL="/opt/plan9/bin/rc";;
        *) export SHELL="/bin/bash";;
esac

doesn't work - I think the new term inherits the $SHELL from the one it was called.

Offline

#13 2011-01-11 20:57:47

fsckd
Forum Fellow
Registered: 2009-06-15
Posts: 4,173

Re: Use rc in 9term and bash in Xterm

karol has already given the answer. Figure out how you're calling 9term and change it. e.g., if launching from xmonad, change your xmonad.hs.

and no, changing SHELL when bash has already launched will not magically cause bash to switch to another shell. (see man bash for what SHELL is set to)

(and if it interests anyone, there does exist a form of 9term which reads Xdefaults)


aur S & M :: forum rules :: Community Ethos
Resources for Women, POC, LGBT*, and allies

Offline

#14 2011-01-11 21:28:17

dglmoore
Member
Registered: 2010-10-16
Posts: 11

Re: Use rc in 9term and bash in Xterm

fsckd wrote:

changing SHELL when bash has already launched will not magically cause bash to switch to another shell.

I understand that. However, if I put the following in my .bashrc (note that my default shell is bash):

export SHELL="/opt/plan9/bin/rc"

then every terminal will open running rc. So, at some point this export command is being read and tells the terminals to run rc. Of course, this is at some point being read by bash because it the .bashrc file.

karol wrote:

Can't you alias 9term to something like 'xterm -e bash' but for 9term & rc?

I can't use an alias because I am not actually calling the command from a bash shell, I am running them from within acme. Hence a bash alias is useless.

karol wrote:

If you don't like aliases, maybe bind it to a keyboard shortcut.

Again, because I am running a command from within acme, keyboard shortcuts are a no go.

It seems like a simple problem, but nothing I tried is a viable solution.

Offline

#15 2011-01-11 21:40:42

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: Use rc in 9term and bash in Xterm

Again, 'export SHELL="/opt/plan9/bin/rc" && 9term' works. You first set the $SHELL variable to whatever you want and only then you start the terminal you choose. In 'case "$TERM" in' you first start a terminal, read its $TERM and set the $SHELL. If you run 9term now (i.e. open another terminal from the newly opened one), everything will be as you want it.


What exactly is acme calling - the binary? Can't you configure it so that it executes a macro instead (I'm just guessing here)?
Also, 9term that reads Xdefaults sounds promising.

Offline

#16 2011-01-11 22:34:12

fsckd
Forum Fellow
Registered: 2009-06-15
Posts: 4,173

Re: Use rc in 9term and bash in Xterm

dglmoore wrote:
fsckd wrote:

changing SHELL when bash has already launched will not magically cause bash to switch to another shell.

I understand that. However, if I put the following in my .bashrc (note that my default shell is bash):

export SHELL="/opt/plan9/bin/rc"

then every terminal will open running rc. So, at some point this export command is being read and tells the terminals to run rc. Of course, this is at some point being read by bash because it the .bashrc file.

Yes since the terminals are called from an environment set up by bash (or derived therefrom). I was reacting to the strange case "$TERM" in structure from earlier in this thread.

I assume you're using plan9port. The only thing I can suggest is modifying /opt/plan9/bin/9 to set a new SHELL. That should affect both 9term and win in acme.


aur S & M :: forum rules :: Community Ethos
Resources for Women, POC, LGBT*, and allies

Offline

Board footer

Powered by FluxBB