What is your favorite shell?

justinnoor

Member

Thanks: 23
Messages: 61

#1
What shell do you use with FreeBSD? Why do you use it? What do you like about it?

I’m currently using FreeBSD sh(1) because it’s lightweight, simple, and for the most part, compatible with Bash (the opposite is not true), which is the lingua franca in Linuxville.
 

Vull

Active Member

Thanks: 45
Messages: 117

#2
At the command prompt, I generally use whatever shell the OS has as a default. For scripts I use the shebang line #!/bin/sh because it's cross-platform compatible and POSIX-compliant. Sometimes as the FreeBSD super-user I'll use /bin/sh in a secondary shell, by entering the commands /bin/sh followed by SHELL=/bin/sh. My only (good) reason for doing this is to allow me to copy and paste environment variable assignment statements from text files without editing in the set command required by the native root /bin/csh shell. I can then return to the /bin/csh shell at any time by entering the exit command. I don't think it's a good idea to change the default shell, so I've broken the habit of doing it, particularly for the root account, where I've never done it.

In the past I've written scripts that required bash, and some that required sudo, but now I'm in the proceses of rewriting them all to use sh and su instead. I would have saved myself some trouble if I had only done it that way in the first place, but as it turns out it's really not that much trouble to fix them. IMO and for my purposes, it's well worth whatever trouble it takes to improve cross-platform compatibility.
 

forquare

Active Member

Thanks: 91
Messages: 228

#6
For my day-to-day interactive use, I use shells/zsh (with vi mode enabled). I was introduced to UNIX via shells/bash and shells/ksh on Solaris. When I passed over to Linux for a time, bash was already there so I used it.

I have a number of friends that use ZSH, so I decided to give it a go and found that (certainly at the time) it was more featureful and flexible in configuration than bash. Also it is MIT licensed, and at the time I was trying to reduce the amount of GPL applications I was using.
I tried oh-my-zsh at the start, but it was too much additional 'stuff' to comprehend, and didn't seem to offer me additional, useful, features to trade off learning them. Also, since I work with many shells in a given day which I can't choose and customise, I try to keep my personal shell customisations fairly simple to avoid additional friction on other systems.

For scripting I always use sh(1). For root's interactive shell I've always used tcsh(1), aside from when I want to do longish "one liners" or looping, then I revert to sh(1) interactively much like Vull described, because I use tcsh(1) so rarely I easily forget how to do things like looping in it, and reverting to sh(1) is quicker than checking a man page.
 

olli@

Active Member
Developer

Thanks: 128
Messages: 145

#7
Another zsh user here.

In my early UNIX days (that was mostly SunOS) I used csh and tcsh, because it was the default for new users at the place where I worked. But soon I noticed that it sucked for scripting, so I switched to bourne shell (to be more exact: ksh) for scripting. And then I noticed that it sucks to use different shells for scripting and interactive use. Then I started looking for a better interactive shell.

First I looked at bash, because many people used it. But I never was the guy who used something just because many other people did … So I looked further and tried several other bourne-compatible shells. And finally I settled for zsh, because it was the most flexible regarding its configuration. For example, it is way ahead regarding the possibilities configuring your shell prompt, the editor shortcuts, tab completion and various other things. I can work with zsh much faster and more efficient than with any other shell.

I still use the “normal” /bin/sh for scripting (unless I decide that Python is better for the job at hand). The nice thing is that zsh has an sh-compatibility mode (it can also emulate ksh), so you can easily copy&paste fragments from scripts to the command line, try them out, improve them, and copy them back to your script.

By the way, I have an alias su="su -m", so when I switch to root, I get the same shell that I have as normal user, i.e. zsh, without having to modify root's login shell. Note that – for various reasons – it is usually not a good idea to change root's login shell.
 

Vull

Active Member

Thanks: 45
Messages: 117

#8
Thanks for the tip olli@ - Using su -m to retain the non-root user's shell is quicker than the way I've been doing it.
 
Top