Beta
×

Welcome to the Slashdot Beta site -- learn more here. Use the link in the footer or click here to return to the Classic version of Slashdot.

Thank you!

Before you choose to head back to the Classic look of the site, we'd appreciate it if you share your thoughts on the Beta; your feedback is what drives our ongoing development.

Beta is different and we value you taking the time to try it out. Please take a look at the changes we've made in Beta and  learn more about it. Thanks for reading, and for making the site better!

From Bash To Z Shell

timothy posted more than 9 years ago | from the what-about-ash dept.

Unix 214

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.

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.

Sorry! There are no comments related to the filter you selected.

MacSlash is .... (-1, Flamebait)

Anonymous Coward | more than 9 years ago | (#12227450)


--fffff------f-----f-----f-
-f-----f----f-f---- -f---f--
-f---------f---f-----f-f---
-f--ffff--f -----f-----f----
-f-----f--fffffff-----f----
-f- ----f--f-----f-----f----
--ffffff--f-----f-----f- ---

for deleting posts....GAWD!!

Re:MacSlash is .... (0, Offtopic)

GET THE FACTS! (850779) | more than 9 years ago | (#12227480)

ATTN SLASHDOT EDITORS: PLEASE DELETE THE PARENT POST. THX!

Lameness filter encountered. Post aborted!
Reason: Don't use so many caps. It's like YELLING.

Lameness filter encountered. Post aborted!
Reason: Don't use so many caps. It's like YELLING.

Lameness filter encountered. Post aborted!
Reason: Don't use so many caps. It's like YELLING.

Re:MacSlash is .... (-1, Offtopic)

Anonymous Coward | more than 9 years ago | (#12227511)

ATTN SLASHDOT EDITORS: PLEASE DELETE THE PARENT POST. THX! Lameness filter encountered. Post aborted! Reason: Don't use so many caps. It's like YELLING. Lameness filter encountered. Post aborted! Reason: Don't use so many caps. It's like YELLING. Lameness filter encountered. Post aborted! Reason: Don't use so many caps. It's like YELLING.

Re:MacSlash is .... (-1, Redundant)

GET THE FACTS! (850779) | more than 9 years ago | (#12227552)

ATTN SLASHDOT EDITORS: PLEASE DELETE THE PARENT POST. THX! Lameness filter encountered. Post aborted! Reason: Don't use so many caps. It's like YELLING. Lameness filter encountered. Post aborted! Reason: Don't use so many caps. It's like YELLING. Lameness filter encountered. Post aborted! Reason: Don't use so many caps. It's like YELLING.

wow....yuo are teh asstard (0)

Anonymous Coward | more than 9 years ago | (#12227993)

Which one? (4, Funny)

Anonymous Coward | more than 9 years ago | (#12227457)

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

Re:Which one? (3, Funny)

SIGALRM (784769) | more than 9 years ago | (#12227491)

#!/bin/bash

source tfa
[ "$?" -eq 0 ] && return 1

Re:Which one? (4, Funny)

Anonymous Coward | more than 9 years ago | (#12227564)

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

Wouldn't it have been better... (4, Insightful)

jgerry (14280) | more than 9 years ago | (#12227458)

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.

Re:Wouldn't it have been better... (3, Funny)

AKAImBatman (238306) | more than 9 years ago | (#12227486)

"From Ash to Z Shell"?

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

Re:Wouldn't it have been better... (0)

Anonymous Coward | more than 9 years ago | (#12227601)

Actually, it should have been:

"From Almquist to Z Shell"

Re:Wouldn't it have been better... (0)

AKAImBatman (238306) | more than 9 years ago | (#12227652)

"From Almquist to Z Shell"

If that were true, then the original title would have been "From Bourne Again to Z Shell".

Re:Wouldn't it have been better... (2, Informative)

Len (89493) | more than 9 years ago | (#12227664)

or "From A to Z Shell".

Technically that's not right either because ash is the Adventure Shell! [ifarchive.org]

Re:Wouldn't it have been better... (2, Informative)

AKAImBatman (238306) | more than 9 years ago | (#12227702)

Ummm... no. That would be a different thing. Ash is the Almquist Shell [wikipedia.org] , an open source replacement for /bin/sh (the bourne shell).

Re:Wouldn't it have been better... (4, Insightful)

exley (221867) | more than 9 years ago | (#12227645)

Well, considering that the focus appears to be just on bash and zsh, I'd say no. With that in mind, however, perhaps they could have spent more time choosing a more concise title.

Re:Wouldn't it have been better... (3, Informative)

jondt (870495) | more than 9 years ago | (#12228085)

except, if you'd read the article, you would have noticed that the author only covers bash and zsh. Ash is given but a cursory glance.

Oooo, religious wars!! (5, Funny)

smcdow (114828) | more than 9 years ago | (#12227462)

It's like the good old days!!!

zshell sux!! bash rules!!

Re:Oooo, religious wars!! (1, Funny)

Anonymous Coward | more than 9 years ago | (#12227506)

zshell sux!! bash rules!!

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

Re:Oooo, religious wars!! (2, Funny)

smitty_one_each (243267) | more than 9 years ago | (#12227566)

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

Re:Oooo, religious wars!! (2, Funny)

LurkerXXX (667952) | more than 9 years ago | (#12227612)

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

Re:Oooo, religious wars!! (2, Interesting)

AKAImBatman (238306) | more than 9 years ago | (#12227543)

Did anyone ever actually argue over ZShell? I thought the primary arguments were always the BASH vs. KSH arguments (i.e. general users vs. hardcore unix admins) and the TCSH vs. BASH arguments (there is *some* validity to TCSH being a bit more professional, but BASH is just more useful).

Re:Oooo, religious wars!! (0)

Anonymous Coward | more than 9 years ago | (#12227585)

Isn't Tcsh based on Csh with just a few extra goodies? Read all you want: CSH Considered Harmful [google.com] .

Re:Oooo, religious wars!! (3, Informative)

AKAImBatman (238306) | more than 9 years ago | (#12227633)

Short answer: Yes [wikipedia.org]

Long answer: I don't think most tcsh users use it for its programming ability. Instead, it tends to be useful as a solid interactive shell. Its general "feel" tends to be more solid than bash, owing partly to the fact that bash has a lot of built in key-shortcuts that tcsh doesn't. Of course, once you're used to being able to double tab for a directory listing, it's kind of hard to give up.

Re:Oooo, religious wars!! (2, Informative)

sp0rk173 (609022) | more than 9 years ago | (#12227726)

that kind of tab completion exists in tcsh too - just toss set autolist in your .cshrc file. I had it enabled on my last freebsd install - basically makes tcsh work exactly like bash while still feeling more solid. Silly linux kids, when will they learn?!

Re:Oooo, religious wars!! (1)

AKAImBatman (238306) | more than 9 years ago | (#12227749)

Dude, you rock! I just cured my Mac of one of it's longest standing failings! (Yes, I'm too lazy to switch the default shell to BASH.)

autolist (0)

Anonymous Coward | more than 9 years ago | (#12228717)

Even better is:

set autolist=ambiguous

Re:Oooo, religious wars!! (1, Troll)

smcdow (114828) | more than 9 years ago | (#12227607)

(there is *some* validity to TCSH being a bit more professional, but BASH is just more useful).

My God. Surely you're joking.

How, exactly, is tcsh more professional ? And more professional than what? Csh? Using Emacs hexl-mode as a shell is more professional than csh.

Re:Oooo, religious wars!! (5, Funny)

Anonymous Coward | more than 9 years ago | (#12227707)

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.

Re:Oooo, religious wars!! (0)

Anonymous Coward | more than 9 years ago | (#12228655)

If mine is +5 funny how is this a troll? Sigh.

Re:Oooo, religious wars!! (1)

superpulpsicle (533373) | more than 9 years ago | (#12227586)

It's simple, the premiere shell would have...

-tab completions
-color code
-long ass history list

Re:Oooo, religious wars!! (1)

AKAImBatman (238306) | more than 9 years ago | (#12227683)

-color code

Has anyone actually found this to be useful? I've always found it to be more annoying than anything. The alternative standard (for those of us with purdy graphical terminals on our UltraSparcs) of using Bold and Italics is much easier on the eyes and conveys just as much information.

Re:Oooo, religious wars!! (1)

sp0rk173 (609022) | more than 9 years ago | (#12227791)

Now that you mention it, bold and italics would look better. Seems kind of like once linux+bash started color coding everything, it became defacto. Any idea how one would go about bolding directories and italicizing executables in tcsh?

Re:Oooo, religious wars!! (3, Informative)

AKAImBatman (238306) | more than 9 years ago | (#12227840)

IIRC, the standard is:

Directories are bold
Links are italic

I think there were also underlines for something, but hell if I can remember what.

Here's some links to help you on your way:

http://www.webservertalk.com/archive109-2004-3-1 44 589.html
http://sunsite.nus.sg/pub/LDP/HOWTO/mini /Colour-ls

Re:Oooo, religious wars!! (2, Interesting)

sp0rk173 (609022) | more than 9 years ago | (#12227925)

Thank you, kind sir. We have both helped each other out today. Italics on links does make more sense.

Re:Oooo, religious wars!! (2, Funny)

fimbulvetr (598306) | more than 9 years ago | (#12228704)

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.

Re:Oooo, religious wars!! (1)

value_added (719364) | more than 9 years ago | (#12227637)

set -o vi

Discuss among yourselves.

Re:Oooo, religious wars!! (0)

bosewicht (805330) | more than 9 years ago | (#12227669)

nano rox!!!!! :)

Re:Oooo, religious wars!! (0)

Reducer2001 (197985) | more than 9 years ago | (#12227705)

vi

Oh wait, what?

Re:Oooo, religious wars!! (0)

Anonymous Coward | more than 9 years ago | (#12227809)

Wow Slashdotters are in a bad mood today, seems like everything is getting modded down. I mean come on he was joking!

Re:Oooo, religious wars!! (2, Interesting)

pilgrim23 (716938) | more than 9 years ago | (#12227833)

Well actually, the True Believer will go waaaaay back before this Unix upstart and enter the command CATALOG from a Apple Basic 3.3 prompt, or if "modern school", CAT on a ProDOS line.

Everytime I try to understand a *nix shell parm I have to switch to Emacs and ask the Doctor....

Re:Oooo, religious wars!! (-1, Flamebait)

KH (28388) | more than 9 years ago | (#12228051)

No way. bash is so gay, and it's so '90s.

The only true shell got to be sh. It was a shame when Panther came around, Apple decided to replace /bin/sh with bash binary. Up until Jaguar, Mac OS X had BSD sh. It just felt so cool. Too bad Apple succumbed to Linux crowd who wanted bash for everything.

Actually, I really don't care which shell I use. Most shells have enough customize options. Using other shells feels so cool (oh, but not csh or tcsh).

Seriously though, It's kinda sad that this nice flamebait which is the parent I'm replying is not producing so many responses. /. readers these days don't use shell much, I suppose.

Which shell is best for you? (5, Informative)

Greg Wright (104533) | more than 9 years ago | (#12227465)

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.

Eh? (0)

Anonymous Coward | more than 9 years ago | (#12227856)

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:

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?

tcsh (-1, Redundant)

Anonymous Coward | more than 9 years ago | (#12227469)

tcsh. Use it or die.

Frist post.

insensitive clods! (1)

tubbtubb (781286) | more than 9 years ago | (#12227478)

What?
No A shell [ticalc.org] ??

Re:insensitive clods! (0)

Raelus (859126) | more than 9 years ago | (#12227710)

Rank the parent up, geez. TIs forever, baby!

What a crappy title... (1, Funny)

ikewillis (586793) | more than 9 years ago | (#12227541)

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

Re:What a crappy title... (1)

fishbowl (7759) | more than 9 years ago | (#12227662)

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

I had the exact same thought, and couldn't believe someone missed the boat on this. Also holding possibilities is the alphabetical "ash, bash, csh, ..., zsh"

What? No "Making vi Sane?" (2, Funny)

suitepotato (863945) | more than 9 years ago | (#12227562)

Other than that omission, I will add it to my "must waste time at Borders sipping coffee and avoiding my insane family" reading list.

Re:What? No "Making vi Sane?" (2, Funny)

soupdevil (587476) | more than 9 years ago | (#12227608)

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

Don't believe it. (2, Funny)

Anonymous Coward | more than 9 years ago | (#12227567)

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.

Zsh gaining momentum?? :) (1, Interesting)

Anonymous Coward | more than 9 years ago | (#12227581)

More recent zsh praise [blog.sejo.be] from Jochen Maes (Gentoo developer).

Re:Zsh gaining momentum?? :) (1)

Anonymous Coward | more than 9 years ago | (#12228514)

yeah, some random gentoo weenie mentioning it on his blog is surely signs of gaining momentum.

W00t! Finally! (4, Interesting)

lpangelrob2 (721920) | more than 9 years ago | (#12227593)

A book I might just buy after reading about it on Slashdot.

I like the Advanced Bash Scripting Guide [tldp.org] 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!").

Re:W00t! Finally! (0)

Anonymous Coward | more than 9 years ago | (#12227786)

I would think that Bash Advanced Scripting Handguide would be appropriate, but...

Re:W00t! Finally! (1)

Big Mark (575945) | more than 9 years ago | (#12227853)

BASH? What does the B stand for?

Re:W00t! Finally! (0)

Anonymous Coward | more than 9 years ago | (#12227902)

Um, it probably stands for BASH. Unless you were talking about the shell, then Borne.

What about COMMAND.COM? (5, Funny)

Ann Elk (668880) | more than 9 years ago | (#12227596)

Quickly runs out of the room and hides.

Re:What about COMMAND.COM? (0, Redundant)

Urusai (865560) | more than 9 years ago | (#12227844)

Fewel, CMD.EXE pwnz j00.

Monad (1)

grennis (344262) | more than 9 years ago | (#12227983)

I guess you never heard of Monad. Look it up sometime.

Re:What about COMMAND.COM? (1)

EnronHaliburton2004 (815366) | more than 9 years ago | (#12228729)

Quickly runs out of the room and hides.

Sorry, command.com is so lame I don't think it can even handle a simple command like that.

Oh my god!!! (1)

armando_wall (714879) | more than 9 years ago | (#12227610)

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!

shell war game..... (2, Funny)

ocularDeathRay (760450) | more than 9 years ago | (#12227866)

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

Re:shell war game..... (0)

Anonymous Coward | more than 9 years ago | (#12228052)

bash: Shall: command not found

also a good book (3, Informative)

carnivore302 (708545) | more than 9 years ago | (#12227615)

Unix shells by example [amazon.com] . 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.

SASH? (2, Informative)

techfury90 (806273) | more than 9 years ago | (#12227616)

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.

Re:SASH? (1)

AKAImBatman (238306) | more than 9 years ago | (#12227799)

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.

Huh. You'd think SGI would just improve the OpenPROM code instead. Maybe they felt that would be "too much like Sun". No wonder they fell by the wayside.

Re:SASH? (1)

techfury90 (806273) | more than 9 years ago | (#12227872)

Its nothing like Sun's.... its really odd.. on my Indy it can refer to disks in two notations, one's very NT style, its something like scsi(0)disk(1)rdisk(1)partition(0) for my XFS root partition, whereas the SGI style notation as I call it is just dksc(0,1,0). Apparently they used to use the SGI notation exclusively until the Indigo2/Indy. Thank god my Indy accepts both. The firmware is called ARCS, which may be similar to the ARC firmware for NT. But I dunno...

Re:SASH? (1)

AKAImBatman (238306) | more than 9 years ago | (#12228021)

Its nothing like Sun's.... its really odd.. on my Indy it can refer to disks in two notations, one's very NT style

Aren't the Indy's the machines that ran Windows NT MIPS Edition? That would explain why it accepts both formats. You could get the machine equipped with either OS.

Am I misremembering, or did SGI used to use OpenPROM?

Re:SASH? (1)

techfury90 (806273) | more than 9 years ago | (#12228121)

Nope, Indy's IRIX only. IIRC SGI never used OpenPROM.

ARCS (1)

green pizza (159161) | more than 9 years ago | (#12227927)

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.

Re:ARCS (1)

techfury90 (806273) | more than 9 years ago | (#12228002)

Correct, it indeed is slick, but I wish it was a little more like unix... just for the coolness factor. Its very useful though.

bash rules! (1)

creimer (824291) | more than 9 years ago | (#12227668)

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.

Re:bash rules! (2, Informative)

pilkul (667659) | more than 9 years ago | (#12228155)

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.

If I'm thrown into a shell I don't like, I just type "bash"<enter> and that's that. If the students can't figure that one out, they really are screwed.

Re:bash rules! (1)

robbieduncan (87240) | more than 9 years ago | (#12228519)

And what if bash isn't installed?

Re:bash rules! (1)

vga_init (589198) | more than 9 years ago | (#12228781)

If your college is teaching classes on shell scripting, I can understand the availability of bash courses because of its popularity in the ever growing linux world, but you make it sound like what is mainly being taught here is how to interact with the shell (ie "use it").

Because of scripting, even the slightest difference between shells becomes very important, but for interactive use the differences often become trivial. Anyone who is familiar with any sort of unix shell can "handle" bash, even if they aren't aware of all of its nifty features.

I started learning the unix shell with bash, and later I made the decision to switch over to tcsh, which is now the stock shell I choose for login. The basics I learned in bash carried right over, and what difference I had encountered only took a few minutes to learn and adjust to. I imagine it would have worked the same way if the migration went the other direction.

Different shells have a lot to offer, but basic intercompatibility allows us not to be totally stumped by one shell or another.

I personally would like to know the details of that study you mentioned. Is it possible that rather than not being able to handle bash at the universities, the students simply choose not to use it because they prefer something else? After all, we tend to stick with what we know, and students who don't learn bash first probably continue with their original shell at the university.

All your Bash are belong to Ksh (1)

WillAffleckUW (858324) | more than 9 years ago | (#12227672)

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.

Why I love zsh (5, Interesting)

winkydink (650484) | more than 9 years ago | (#12227688)

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.

Re:Why I love zsh (1)

OrangeTide (124937) | more than 9 years ago | (#12227723)

bindkey -v

put that in your ~/.zshrc if you always want vi keys enabled. Or you could have bought the book that was reviewed.

Re:Why I love zsh (1)

winkydink (650484) | more than 9 years ago | (#12227773)

I'm sorry, that wasn't my question. I know of bindkey -v. I've been using the shell for 14 years.

My question is, how do I make the command esc-esc put the last command in the history file into a full vi session?

Or, in simpler terms, how do I make esc-esc execute the 'fc' command? I've tried lots of clever ways over the years, none of them have worked.

Re:Why I love zsh (0)

Anonymous Coward | more than 9 years ago | (#12228007)

Esc-K? Or I just not understanding you fully...

Re:Why I love zsh (0)

Anonymous Coward | more than 9 years ago | (#12228471)

Something like:
bindkey -s '^[^[' 'fc\n'

Re:Why I love zsh (1)

EnronHaliburton2004 (815366) | more than 9 years ago | (#12228693)

I think I remember what you are talking about...

Are you thinking of 'ESC-k' (or 'ESC-up-arrow') which opens the commandline history? That's like the 'fc' command, without opening a vi session.

In the ksh93, the vi command-line editing actually consisted of some vi-style commands, some ksh-only style commands, and some emacs-style.

I think the ESC-ESC was a ksh-only command, or it was some common binding on some OSs... but it wasn't universal. ksh93 was annoyingly different on Solaris 8 vs HPUX or AIX. Drove me crazy...

Re:Why I love zsh (4, Interesting)

Anonymous Coward | more than 9 years ago | (#12228550)

Whilst I am no expert on ZSH, the following seems to do what you ask for

bindkey -s '\e\e' 'fc\n'

This is with a freshly updated debian 'unstable' system,

zsh --version
zsh 4.3.0-dev-1 (i686-pc-linux-gnu)

Re:Why I love zsh (2, Informative)

Alakaboo (171129) | more than 9 years ago | (#12228636)

In bash (and ksh) I hit ESC to enter command mode, then v to bring up (v)isual mode. Perhaps zsh is similar? HTH.

Best shell (4, Funny)

Kaa (21510) | more than 9 years ago | (#12227704)

My shell is
perl -d -e 42

Re:Best shell (0)

Anonymous Coward | more than 9 years ago | (#12227776)

My shell is
$ emacs -nw --eval (eshell)

Re:Best shell (0)

Anonymous Coward | more than 9 years ago | (#12227938)

Finally, a legimate use for perl!

From Justin to Kelly (-1, Offtopic)

Anonymous Coward | more than 9 years ago | (#12227765)

That sucked and so will this ...

zsh (1)

lakerdonald (825553) | more than 9 years ago | (#12227806)

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.

New ideas (2, Informative)

/ASCII (86998) | more than 9 years ago | (#12227940)

<shameless plug>

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 [no-ip.org] . It has lots of new features [no-ip.org] . Check it out.

</shameless plug>

Suggestion (4, Funny)

metamatic (202216) | more than 9 years ago | (#12228149)

I cordially propose that the default prompt of your new shell be changed to

}><(([@>

for reasons which should be obvious.

Re:Suggestion (0)

/ASCII (86998) | more than 9 years ago | (#12228595)

Awesome! =D

Re:New ideas (1)

Macrobat (318224) | more than 9 years ago | (#12228508)

'$foo' is not the same thing as `$foo` or "$foo"?

echo $foo
will give you the value of $foo (say, "bar").

echo "$foo"
will return the string "$foo"

`$foo`
will give you the output of the command, if the value of foo is set to a recognized command. Useful for combo commands.

These are convenient, and not too hard to remember. Just out of curiosity, how are these things done in fish?

Re:New ideas (2, Informative)

/ASCII (86998) | more than 9 years ago | (#12228634)

No, you are wrong.

In bash:

$foo gives you the contents of variables foo as a list of space-separated strings. "foo bar" becomes "foo" and "bar".

"$foo" gives you the contents of variable foo as a single variable. "foo bar" remains "foo bar".

'$foo' gives you the string "$foo".

`$foo` executes the command pointed to by the variable foo in a subshell. If foo has the value "ls" executes the "ls" command.

In fish:

$foo gives you the contents of variable foo as a single string, "foo bar" remains "foo bar".

"$foo" and '$foo' both give you the string "$foo".

And those are all the quoting styles allowed in fish.

Unicode (5, Insightful)

olafc (183227) | more than 9 years ago | (#12228093)

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... :(

Wicked! (4, Informative)

veg_all (22581) | more than 9 years ago | (#12228412)

. 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.

What a timesaver! I start so many commands with
$ March 2004
In all seriousness, though, I'd like to stick my suggestion in here: Wicked Cool Shell Scripts [intuitive.com] is a charming little read and the scripts are all on line!

TI-85 (1)

Gadgetfreak (97865) | more than 9 years ago | (#12228572)

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?

Mr Old fashioned (3, Insightful)

mrbooze (49713) | more than 9 years ago | (#12228597)

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!

Fir5T post! (-1, Offtopic)

Anonymous Coward | more than 9 years ago | (#12228739)

Load More Comments
Slashdot Login

Need an Account?

Forgot your password?