Slashdot Mirror


From Bash To Z Shell

r3lody (Raymond Lodato) writes "Novice users and power users of *nix will enjoy reading From Bash to Z Shell: Conquering the Command line by Oliver Kiddle, Jerry Peek, and Peter Stephenson. In this moderate-sized book from Apress, the authors delve into both bash (the Bourne Again Shell) and zsh (Z Shell) to enable you to use them to their fullest advantage. Topics range from the simple editing of the command line to redefining key sequences, down into creating functions for editing and command-line completion. Some areas are covered in other books, but this one goes into some little-seen side streets and alleyways to show you the shortcuts to more efficient use of the shell." Read on for the rest of Lodato's review. From Bash to Z Shell: Conquering the Command Line author Oliver Kiddle, Jerry Peek, and Peter Stephenson pages 472 publisher Apress rating 9 reviewer Raymond Lodato (rlodato AT yahoo DOT com) ISBN 1590593766 summary An in-depth look at the functionality of bash and zsh.

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.

21 of 214 comments (clear)

  1. Which one? by Anonymous Coward · · Score: 4, Funny

    Which shell has a better wallpaper? More options when I right-click?

    1. Re:Which one? by SIGALRM · · Score: 3, Funny
      #!/bin/bash

      source tfa
      [ "$?" -eq 0 ] && return 1
      --
      Sigs cause cancer.
    2. Re:Which one? by Anonymous Coward · · Score: 4, Funny

      My Bash console shell has a screenshot from Doom III as the wallpaper. At least it looks that way...

  2. Oooo, religious wars!! by smcdow · · Score: 5, Funny

    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.
    1. Re:Oooo, religious wars!! by Anonymous Coward · · Score: 1, Funny

      zshell sux!! bash rules!!

      Did you write that with stuoopid old VI or the great and wonderful Emacs?

    2. Re:Oooo, religious wars!! by smittyoneeach · · Score: 2, Funny

      Likely the former, or he'd have touted eshell.el.

      --
      Get thee glass eyes, and, like a scurvy politician, seem to see things thou dost not.--King Lear
    3. Re:Oooo, religious wars!! by LurkerXXX · · Score: 2, Funny

      What are you talking about? Everyone knows pico is the only editor worth using!

    4. Re:Oooo, religious wars!! by Anonymous Coward · · Score: 5, Funny

      How, exactly, is tcsh more professional

      I once caught bash selling my personal files on ebay. Also, tcsh cured my grandmother of rheumatoid arthritis.

      In related news, emacs is more articulate than vi, three-button mice are sweeter than one-button mice and perl grepped your sister.

      Actually, that last one is true ;-> Sorry.

    5. Re:Oooo, religious wars!! by fimbulvetr · · Score: 2, Funny

      I rarely find it useful, especially dir and executable colors, but I will tell you what has saved my ass once or twice:

      The big bold red color that tells me a symlink is broken.

      Outside of that one use, I cannot name a another time when I have thanked the color granting shell overlords.

  3. Re:Wouldn't it have been better... by AKAImBatman · · Score: 3, Funny

    "From Ash to Z Shell"?

    Technically, that should be either "From ash to zsh" or "From A to Z Shell".

  4. What a crappy title... by ikewillis · · Score: 1, Funny

    I would've personally prefered "From ash to zsh"

  5. What? No "Making vi Sane?" by suitepotato · · Score: 2, Funny

    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)
    1. Re:What? No "Making vi Sane?" by soupdevil · · Score: 2, Funny

      Some of us avoid our insane families by moving out of the basement and into our own apartments.

    2. Re:What? No "Making vi Sane?" by Anonymous Coward · · Score: 1, Funny

      What are you talking about? vi is perfectly intuitive.:wq

  6. Don't believe it. by Anonymous Coward · · Score: 2, Funny

    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.

  7. What about COMMAND.COM? by Ann+Elk · · Score: 5, Funny

    Quickly runs out of the room and hides.

  8. Best shell by Kaa · · Score: 4, Funny
    My shell is
    perl -d -e 42
    --

    Kaa
    Kaa's Law: In any sufficiently large group of people most are idiots.
  9. shell war game..... by ocularDeathRay · · Score: 2, Funny

    bash$ Shall we play a game? bash$ How about Global Thermonuclear War

    --
    Obama is a twitter sock puppet
  10. Suggestion by metamatic · · Score: 4, Funny

    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
  11. Re:New ideas by lawpoop · · Score: 4, Funny

    A shell called fish? Can you call it shellfish for short? Did you make it GPL? If so, thanks for not being selfish with shellfish!

    --
    Computers are useless. They can only give you answers.
    -- Pablo Picasso
  12. Try it yourself ;-) by codergeek42 · · Score: 2, Funny