What's the equivalent to .bashrc for sh?

Miscellaneous tools
Post Reply
Message
Author
User avatar
Rattlehead
Posts: 368
Joined: Thu 11 Sep 2008, 11:40

What's the equivalent to .bashrc for sh?

#1 Post by Rattlehead »

I am trying to use the Quake-style terminal Stjerm, but it doesn't recognize all the customizations I've been adding to my .bashrc (used in Sakura).

Stjerm's prompt starts with 'sh', so I guess sh uses a different configuration file. I've searched the computer for a .shrc file, equivalent to .bashrc, but nothing shows. Also, I have read the sh man page, and searched the Internet, but haven't found anything (it doesn't help that the .sh termination is commonly used in script names :roll: ).

So, what's the way to customize sh? Is there such a configuration file, or is it a whole different deal? Thank you

User avatar
trapster
Posts: 2117
Joined: Mon 28 Nov 2005, 23:14
Location: Maine, USA
Contact:

#2 Post by trapster »

Have a look in ~/.Xdefaults

Then see Here
trapster
Maine, USA

Asus eeepc 1005HA PU1X-BK
Frugal install: Slacko
Currently using full install: DebianDog

User avatar
Rattlehead
Posts: 368
Joined: Thu 11 Sep 2008, 11:40

#3 Post by Rattlehead »

Thank you for the links, Trapster, they are a great resource, but, from what I've seen, they refer to stjerm-specific configuration (say, colors, autohide on-off, key to press to make the terminal pop in...), rather than to sh itself.

I have never had to tweak .Xdefaults, because the stjerm pet I installed also included a small script called stjerm-bin, that takes care of all that kind of stuff.

You made me realize I should have defined better what I meant by 'configuration'. The kind of configuration I was referring to is rather the list of alias and functions I go creating along the way and adding to .bashrc. For example, that typing s enter takes you to seamonkey, typing c instead of clear... That kind of customization that makes your life more comfortable...

If I could have that customization plus the emerging terminal it would be the best of both worlds... I was thinking maybe of separating such configuration instructions as a different text file, and sourcing it in both bash and sh so I can use it in any terminal...

I find strange that such aspect of sh is not explained out there, but, again, sh is a very short word, and usable in several contexts, which makes finding possible information harder.

WillM
Posts: 173
Joined: Wed 30 Dec 2009, 04:42
Location: Oakland, California

#4 Post by WillM »

HI Rattlehead,
In the /etc/passwd file you could change your user log in shell from /bin/sh to /bin/bash. Then restart the computer.

User avatar
don570
Posts: 5528
Joined: Wed 10 Mar 2010, 19:58
Location: Ontario

#5 Post by don570 »

I believe that only bash 3.0 is installed in Puppy linux.

There is a link so that a script that runs sh shell is actually
running bash shell.

I would have to run pfind to find that link.

_____________________________________

User avatar
Rattlehead
Posts: 368
Joined: Thu 11 Sep 2008, 11:40

#6 Post by Rattlehead »

There is a link so that a script that runs sh shell is actually
running bash shell.
Yes, you're right. I did the search and /bin/sh is a link to /bin/bash.

But then, I wonder, shouldn't all the bash alias work just fine in this pseudo sh? :?

Funny, if in sakura (bash) I execute

Code: Select all

sh
From them on the terminal does not recognize my alias.
But if, then, I open a new Sakura terminal, here come the alias again...

:? :? :?

WillM
Posts: 173
Joined: Wed 30 Dec 2009, 04:42
Location: Oakland, California

#7 Post by WillM »

If /bin/sh is a link to bash, bash will not behave the same when called as /bin/bash.
When sh is linked to bash I get this:

Code: Select all

#  echo $SHELL
/bin/sh
# 
~/.bash_profile which will source .bashrc, if it is present, and is read by bash only.
sh does not read .bash_profile. That is why aliases in .bashrc don't work.
sh will read ~/.profile so you could move .bash_profile to .profile, and have that source a file
with aliases, and other stuff.

On a side note, when invoked as sh, Bash enters POSIX mode.

User avatar
drongo
Posts: 374
Joined: Sat 10 Dec 2005, 23:35
Location: UK

Cut down shell

#8 Post by drongo »

I thought Puppy didn't have a full shell as that would be too big for a small distro.

Isn't it mostly Busybox with some additional full commands from Bash (or is it Ash?)

But I could well be very wrong about this!

User avatar
Rattlehead
Posts: 368
Joined: Thu 11 Sep 2008, 11:40

#9 Post by Rattlehead »

sh does not read .bash_profile. That is why aliases in .bashrc don't work.
sh will read ~/.profile so you could move .bash_profile to .profile, and have that source a file
with aliases, and other stuff.
Thank you, I tried that, but no luck. Here's what I did.

There was no .bash_profile file. There wasn't a ~/.profile, either, so what I did was copying .bashrc as ~/.profile, and then restarting X (stjerm didn't want to die with ctrl+c). It still did not recognize the alias. However, after I source .profile from sjterm,

Code: Select all

source ~/.profile
, stjerm does start to recognize the alias, so it seems a logic conclusion that stjerm does not read neither .bashrc nor .profile at startup. Maybe the program is in development and it still can't be configurated? Another limitation that I have just noticed, and which makes it hard to make it a full time substitute for Sakura, is that it does not have tab autocompletion.

So anyways, thank you for the suggestions, I'm glad I've learned a bit more about how terminals work.

Post Reply