From Bash To Z Shell
A *nix-style shell is available on a number of platforms, so the authors chose not to limit themselves to just one, such as Linux. The techniques they discuss can be used in Unix, as well as under Windows using cygwin.
In case you're not overly well-versed in shell handling, the first part of the book does a pretty good job covering all of the things a typical user might want to do. Basic command editing, I/O redirection, jobs, processes, and some simple scripting are all covered. For many users, this is also as far as they would like to go. However, reading a little further yields treasure.
The next part delves into bash version 3.0 and zsh version 4.2, both freely available on the Internet. In addition to more sophisticated command line editing techniques, the authors also delve into the misty realms of re-binding keys. A great many users find themselves typing the same sequences over and over again. While sometimes a script makes sense to encapsulate these sequences, sometimes you want to simply enter some text and that's where a key binding makes sense. One example given in the book for zsh is bindkey -s '\C-xt' 'March 2004\eb' . After the binding, typing CTRL-x t puts the string 'March 2004' onto the command line, and moves the cursor under the '2' so you can insert the day of the month. That's a very simple example for a very powerful facility. A good chunk of chapter 4 is spent on showing how to make the most of bindkey (or its bash cousin 'bind').
The next few chapters cover common topics of prompt strings, file/directory globbing, and shell history. Then, significant press is given to the subject of pattern matching. Many people understand basic pattern matching and regular expressions, but From Bash to Z Shell goes into careful detail, with many examples from both bash and zsh, to contrast the (minor) differences between these two powerful shells. The next chapter discusses command line and file/directory name completion, a topic usually glossed over in other texts. Finally, job processing wraps up Part 2.
The third and final part of the book deals with extending the shell using variables, scripts, and functions. Here's where we get into the nitty-gritty. The first two chapters go over familiar territory: shell variables and shell programming. The chapter on programming is easy to follow, and I suggest you try the examples as you go to get the most out of it. The last two chapters focus on topics frequently overlooked: editor functions, and completion functions. Editor functions allow you (with bind[key]) to define new capabilities to use while editing the command line. This is where a true power user can shine, creating a suite of new functions to speed his/her use of zsh or bash. Completion functions work in defining new ways for the shell to complete a command, file name, or directory, based on a user-written function. Honestly, it's not something I would tend to use, but the capability is intriguing.
All in all, From Bash to Z Shell provides a frequent shell user with a plethora of new insights into customizing the bash and zsh shell programs to fit his/her tastes. The authors have filled a void in tackling the subject of customizing the shell rather than just simply using it. I would have liked to see more coverage of some of the more standard uses of the shells, just so the book could be a more complete reference, rather than the specialized one it is. Specialized or not, there is a lot offered here, and you couldn't go wrong getting this book.
You can purchase From Bash to Z Shell: Conquering the Command Line from bn.com. Slashdot welcomes readers' book reviews -- to see your own review here, read the book review guidelines, then visit the submission page.
Which shell has a better wallpaper? More options when I right-click?
Uh, wouldn't it have been cooler to actually go the extra mile with the whole A to Z metaphor and call the book "From Ash to Z Shell"? There is a shell called ash.
It's like the good old days!!!
zshell sux!! bash rules!!
In the course of every project, it will become necessary to shoot the scientists and begin production.
I think either shell mentioned in the book is great, I personally use
bash, mostly just because of historical reasons.
Speaking of different shells in general. Here is a very handy list
that can help you pick which shell is best for you. This is not meant
to start a war over which shell is better but is just meant to help
pick the shell that is best for you:
http://www.unix.com/showthread.php?t=12274
Just thought it would be helpful.
--greg Vulcan quiescent... Q: What machine shutdown with this message?
What?
No A shell ??
I would've personally prefered "From ash to zsh"
Other than that omission, I will add it to my "must waste time at Borders sipping coffee and avoiding my insane family" reading list.
If my grammar and spelling are off, I am [distracted/tired/careless] (take your pick)
but this one goes into some litte-seen side streets and alleyways to show you the shortcuts
Oh sure, those dark alleys might seem to be the shortest route to your destination, but really their just a quick path to a mugging.
More recent zsh praise from Jochen Maes (Gentoo developer).
I like the Advanced Bash Scripting Guide quite a bit, but I'd also like to learn about other shells, without reading through a mountain of manpages, nor reading through webpages, and just for general interest while riding the El (not because "I need to do x!").
-Rob
Marriage doesn't have to suck!
Quickly runs out of the room and hides.
Shell is so powerful! I still remember when I made a war game with it 4-5 years ago! I would kill myself if I had to redo it from scratch nowadays!
Unix shells by example. Just enough in-depth for my taste. Full of tricks you actually will remember, and if you don't remember the exact syntax it can be quickly found in the book again (which I occasionally/often have to do... Kudos to those that can write commands with multiple single and double quotes in one go :-) ).
The book is mostly on bash, and c-shell.
Please login to access my lawn
I still can't figure out why the Irix bootloader is called SASH, which means the standalone shell... it would make you think it lets you do unix like things without Irix booted, but nooooo it uses the same syntax and commands even as the PROM monitor uses, except sash can read XFS volumes unlike the boot PROM and list the contents of directories.
I'm friends with the youngest daughter of the former head of the PowerPC division of IBM you insensitive clod!
At the local community college, bash is taught in all the linux classes. They did an informal study about which shell to use, and they found out if the instructor doesn't use bash while teaching how to use the shell, the students can't handle bash when they get to the university.
The flip-side is that students who don't know how to use the different shells are probably screwed anyway once they get into the real world. Go figure.
last time I used Z shell was when I dialed in via z-term, and that's so long ago I can't remember which century it was ... or if my modem went faster than 300 baud.
-- Tigger warning: This post may contain tiggers! --
Back in '91 or so, I lost legitamate source-code access to ksh. bash was around but, at the time, it only had emacs-like command-line editing. I then discovered that a bunch of folks in the CS dept at Princeton were developing a new (to me anyway) metashell called zsh that was, for the most part a ksh workalike with vi-like command-line editing.
One thing I have never been able to do successfully is to emulate the old ksh's ability to hit Esc-Esc on the command line and get popped into vi with the last command in the history file ready to be edited. It was such a boon to rapid development of shell scripts. Then again, I don't do as much shell scripting these days, so its probably no great loss.
If anybody knows how to do this, esc-esc thing in zsh and can tell me, I'd be really grateful.
"I'd rather be a lightning rod than a seismometer." -Ken Kesey
Kaa
Kaa's Law: In any sufficiently large group of people most are idiots.
Having only used zsh once or twice, I can't exactly be cited as an "expert", but I do seem to like it a lot. It's very powerful, especially when it comes to command line globbing. Hopefully this book goes into those customization options in depth, as that is the true power of zsh in my opinion.
And you think this statement will calm the huddled masses yearning to let loose with a litany of zealotry comments about their favoutite shell, the likes of which you have never had the pleasure of hearing?
bash$ Shall we play a game? bash$ How about Global Thermonuclear War
Obama is a twitter sock puppet
SGI's MIPS-based machines (and their first NT PC too) used an ARCS PROM and SASH bootloader. These come from the Advanced RISC Computing Specification, back in the pre-Pentium days when people thought Intel was about to drop into obscurity.
SASH is pretty slick, actually.
I think both zsh and bash could use a redesign. The syntax is crufty, with stupid variable assignment syntax ('foo = bar' is not the same thing as 'foo=bar'? '$foo' is not the same thing as `$foo` or "$foo"?), insufficient tab-completion support and very few features enabled by default.
I have written a shell called fish. It has lots of new features. Check it out.
</shameless plug>
Try out fish, the friendly interactive shell.
I like zsh and use it a lot, but there is just one big feature still missing: proper unicode support.
:(
I know they started working on it in february, at least more actively then before. So it will come eventually. Once the internals are done they will move on to the line editor.
Untill then, it still "eats" my prompt when backslashing over multibyte characters...
I cordially propose that the default prompt of your new shell be changed to
}><(([@>
for reasons which should be obvious.
GCHQ Quantum Insert installed. If only our tongues were made of glass, how much more careful we would be when we speak
What a timesaver! I start so many commands withIn all seriousness, though, I'd like to stick my suggestion in here: Wicked Cool Shell Scripts is a charming little read and the scripts are all on line!
grammar-lesson free since 1999. (rescinded - 2005)
I may be one of the few here who don't do much in the way of coding (I'm a MechE) but I can't be the only person reminded of the TI-85 application called ZShell. Anyone else have fond memories of this?
"No fair, you changed the outcome by measuring it!" - Professor Hubert J. Farnsworth
Every shell script I write can run in a non-dynamic bourne shell. With all my years of supporting dozens of different flavors of unix, I grew accustomed to never assuming what shells may or may not be available on a given system.
#!/bin/sh 4 LIFE!
Even better is:
set autolist=ambiguous
I used to find myself using find a lot -- mostly for handling files in subdirectories, and/or for selecting files based on metadata of various kinds. But zsh makes find almost totally unnecessary: it has a simple but very powerful syntax which extends the simple '*' and '?' file completion to allow selection by size/date/type/&c, exclusion lists, user-specified ordering, and most usefully it can select files in subdirectories too. And because it's right there in the shell, the results are easy to use without that awkward -exec syntax. I don't think I've used find once since switching to zsh!
I really don't understand why it hasn't become more popular. It's free and open source; it can mimic other shells (notably, ksh), and it ships with systems such as Mac OS X.
Ceterum censeo subscriptionem esse delendam.
sniff..
tcsh is a marked improvement over csh. csh is actually harmful. However my favourite is still bash. I might switch over to zsh though...
Vivin Suresh Paliath
http://vivin.net
I like
Oh darn. No SCSH
Perhaps I'm evil, not supporting bn.com but, it's a massive difference in price - cheap enough to pick up casually.
Someday we'll all be negroes
http://www.command.com/
He's in housewares....follow the sounds of shotgun fire :)
Those shopping for a shell, and with a taste for Python, would do well to check out ipython.
In the 'pysh' mode, it acts as a fully functional system shell, even on Windows. Bash and friends suck on windows, but IPython truly shines there. It really makes the command prompt use of Windows feasible, with bash like filename completion etc. Being able to extend it with python functions (as opposed to separate scripts) is a killer feature as well.
I've actually replaced the command prompt launchers on my KDE desktop with 'ipython -p pysh' launchers.
Save your wrists today - switch to Dvorak
Unix, Books, Linux, okay... But any idea why they added the Windows icon to this story?? Because those shells run under Cygwin? Wouldn't then at least make as much sense to put BSD and even Apple icons as well?
The filesystem is the package manager
MSH, MSH, MSH!
;-)
OK, seriously, it'll be interesting to see what comes out from Redmond there.
I'm surprised that them working on a new shell hasn't spawned a ton of bad jokes about it already.
Beware: In C++, your friends can see your privates!
I just tried to tab complete 'echo ?li' in a directory containing files like 'alias.c' and 'alias.h'. zsh did not find any completions.
I tried using this both with the default completion and using the new 'compinit' completions. Nothing.
Is there yet _another_ command you have to give to zsh in order to make it work the way it should by default?
Try out fish, the friendly interactive shell.
I went back to bash after being totally unable to get zsh to remember the history between sessions. Bash is handy as I can log out, log back in, and up-arrow takes me back to my history from the previous session(s). I can't get zsh to do this. If someone can explain how, I'll go straight back to zsh again!
Sparks:Gadget:Beer Maker
I think this is a good illustration of one of the major problems with zsh. To get a decent history file with all the cool features, you have to add 9 different commands to you configuration file.
To get a goob tab completion, with a good pager, etc, you need another boatload of commands. You will also want to redefine some keyboard shortcuts to more powerful versions of the same commands and install a few nifty add-ons.
So suddenly you have spent a few hours creating a 100+ lines long configuration file just to enable some of the common zsh options. If dedicating your life to tweaking your shell sounds like fun, then go ahead. But most people have better things to do with their time.
Try out fish, the friendly interactive shell.
> So suddenly you have spent a few hours creating
> a 100+ lines long configuration file just to
> enable some of the common zsh options.
Most modern distributions ship a decently configured zsh. In my case, an apt-get install zsh gives me a shell with a lot of tab completions (plenty more than bash), a pager as good as bash's (if not better), and so on...
And for your information, bash also has a lot of configuration commands in the initialization scripts. AFAIK it doesnt do any magic "on its own".
Who needs Unix?
-Clio
Karma: Bad (mostly from not giving a fuck)
Blog: http://clintjcl.wordpress.com