Linux Advent Calendar: "24 Outstanding ZSH Gems" 46
First time submitter Manko10 writes "After the Advent series last year, there is again a Linux Advent calender. The topic of this year's Advent series is '24 Outstanding ZSH Gems'. Every day from December 1st until December 24th an article will be published each covering a special feature of the Z Shell you might not have known yet."
Only 24 features? (Score:4, Interesting)
Well, that'll get you through... what, the first page of the manual?
The damn thing has a built-in tcp command system (ok, I think it's technically a "module"). The main man page is just a redirect page. Hell, it might even rival emacs for complexity. I know, I didn't think it was possible either...
Re: (Score:3)
Here is a fixed version:
exec 5<>/dev/tcp/www.google.com/80
echo -e "GET / HTTP/1.1\n\n" >&5
cat <&5
Preview is your friend!
Re: (Score:3)
Hell, it might even rival emacs for complexity. I know, I didn't think it was possible either...
It's not so strange if you think about it. Both are operating systems cleverly disguised as applications, complete with their own programming languages.
The major difference is that zsh is disguised as a shell, and Emacs is disguised as a text editor.
I, for one, look forward to the arrival of our minor-mode-wielding zsh overlords.
<3 zsh (Score:4, Informative)
I wasn't familiar with zsh until I used grml [grml.org] (a fairly handy debian-based live distro, I use for fixing things on occasion). It comes with a pretty spiffy zshrc and zsh by default, which opened me to some of the features of it... pretty nifty... Now I use zsh on everything.
Some info about grml's use of zsh, here [grml.org].
Re:3 zsh (Score:1)
I started using zsh the instant I read about ** globs.
Bash has them now, but I see little reason to switch back.
Re:3 zsh (Score:2)
Not a ZSH gem, but... (Score:5, Funny)
Not a ZSH gem, but this is probably the last word in BASH prompts.
PS1='C:$(echo ${PWD//\//\\\} | tr "[:lower:]" "[:upper:]" |
sed -e"s/\\([^\\]\\{6\\}\\)[^\\]\\{2,\\}/\\1~1/g" ) >'
you'd be wise not to trust random code, but if you look carefully it uses only echo, tr and sed, none of which have programmable IO and only piping, so it is safe.
Re:Not a ZSH gem, but... (Score:5, Funny)
You are evil.
Re: (Score:1)
+1 Nostalgia
Brings me back to 1996 when Windows was cool.
Re: (Score:1)
I feel ... unclean ...
Re: (Score:3)
I like how you even used sed to switch up the slashes and break down long names. Now to sneak this into someones bashrc and catch their face when they login...
Re: (Score:2)
I don't get it:
PS1='C:$(echo ${PWD//\//\\\} | tr "[:lower:]" "[:upper:]" | sed -e"s/\\([^\\]\\{6\\}\\)[^\\]\\{2,\\}/\\1~1/g" ) >' xterm
I got a regular xterm with my regular PS1 prompt. Whoosh?!?
Aside, I liked both zsh and grml when I used them, but decided neither were necessary and not for me. Besides, unless you're a shell programmer wizard, you're not going to see a lot of differences between bash, ksh, and zsh. They all pretty much function the same at a user level. Well, except for the resources
Re:Not a ZSH gem, but... (Score:4, Informative)
You should have got a Windows style C:prompt, including truncated directroy names if they were over 8 characters.
Try an "export" before the command, and see if that helps
Re: (Score:2)
Funny enough, I sorta figured out what it did by careful inspection of the line.
So PS1 gets set to "C:", then the current working directory. Hrm... then TR is used to change all lowercase to upper case, followed by a very peculiar sed. All the while it seems the / are being replaced with \ (\\ for the escaping).
Since the word "evil" was attached t
Re: (Score:2)
Re: (Score:2)
Z Shell (Score:2)
Here's a gem:
In my country Shell petrol stations have recently re-branded as: Z
Co-incidence? I think not.
Re: (Score:1)
Re: (Score:2)
The great thing about ZSH, is that it greatly expands what you can actually do, without crossing the line into "major shell programming". These are one or two liners here, if you were using Bash you might rightly choose Perl for this stuff, but not if you use ZSH.
Why zsh instead of bash? (Score:2)
Maybe I'm ill informed since I've only run "Redhatty" distros (SCEfoos wacky Kondara-ized RH6 on the PS2, YDL, and now Fedora) but isn't bash the standard shell for Linux? So wouldn't bash tricks be more useful?
Re: (Score:2)
I think the trick here is that people who think zsh is a better shell than bash are using this campaign to raise awareness of zsh.
By the way, I do think zsh is the better shell. Just to name one of the things I love about it: writing custom command completion for it is pretty easy (certainly compared to bash). I and other people have used this to provide tab completion for mostly anything you can think of, including things like command options and filenames on remote machines. Go check it out if you haven't
I'm being completely serious here... (Score:1)
Re:I'm being completely serious here... (Score:5, Informative)
You are looking for something like this? [perladvent.org]
Re: (Score:1)
Re: (Score:2)
Well, the reason the dates are all mixed up is that it in the real world, it adds to a six year-olds excitement when he's searching for todays door, which has *candy* behind it.