Slashdot Mirror


Linux Advent Calendar: "24 Outstanding ZSH Gems"

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

46 comments

  1. Zomg... by Anonymous Coward · · Score: 0

    brilliant!

  2. Only 24 features? by Baloroth · · Score: 3, 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...

    --
    "None can love freedom heartily, but good men; the rest love not freedom, but license." --John Milton
    1. Re:Only 24 features? by Anonymous Coward · · Score: 0

      so does bash.

      exec 5/dev/tcp/www.google.com/80
      echo -e "GET / HTTP/1.1\n\n" >&5
      cat &5

    2. Re:Only 24 features? by inglorion_on_the_net · · Score: 2

      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.

      --
      Please correct me if I got my facts wrong.
    3. Re:Only 24 features? by ArsenneLupin · · Score: 2
      Slashdot eats < signs for breakfast.

      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!

  3. <3 zsh by mirix · · Score: 3, Informative

    I wasn't familiar with zsh until I used grml (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.

    --
    Sent from my PDP-11
  4. Re:3 zsh by EvanED · · Score: 1

    I started using zsh the instant I read about ** globs.

    Bash has them now, but I see little reason to switch back.

  5. Re:3 zsh by Baloroth · · Score: 1

    Yep, I too strongly recommend zsh. The command line completion especially is far, far better than bash. Although you pretty much have to create (or download: there are quite a few good ones online) an extensive zshrc file to use it properly. Thanks for pointing out grml, I might have to look into using that in the future.

    --
    "None can love freedom heartily, but good men; the rest love not freedom, but license." --John Milton
  6. Not a ZSH gem, but... by serviscope_minor · · 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.

    --
    SJW n. One who posts facts.
    1. Re:Not a ZSH gem, but... by Anonymous Coward · · Score: 5, Funny

      You are evil.

    2. Re:Not a ZSH gem, but... by Anonymous Coward · · Score: 1

      +1 Nostalgia

      Brings me back to 1996 when Windows was cool.

    3. Re:Not a ZSH gem, but... by Anonymous Coward · · Score: 1

      I feel ... unclean ...

    4. Re:Not a ZSH gem, but... by Kagetsuki · · Score: 2

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

    5. Re:Not a ZSH gem, but... by Anonymous Coward · · Score: 0

      I chuckled a bit, not gonna lie.

    6. Re:Not a ZSH gem, but... by Anonymous Coward · · Score: 0

      That is absolutely hilarious.
      It may very well be worthwhile "incorporating" this into someone's account just for the shocked expression that will occur

    7. Re:Not a ZSH gem, but... by Anonymous Coward · · Score: 0

      root will be doing this to everyone's .bashrc via cron on April 1 from now on.

    8. Re:Not a ZSH gem, but... by tqk · · Score: 1

      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 that zsh sucks up, that is.

      --
      "Tongue tied and twisted, just an Earth bound misfit ..." -- Pink Floyd.
    9. Re:Not a ZSH gem, but... by CronoCloud · · Score: 3, 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

    10. Re:Not a ZSH gem, but... by Anonymous Coward · · Score: 0

      It basically makes the prompt look like a dos prompt. Your .whateverrc is probably resetting PS1. Run it without the xterm.

    11. Re:Not a ZSH gem, but... by Anonymous Coward · · Score: 0

      When you do it that way, you get your regular prompt because the new shell will execute .bashrc which is going to override the PS1 you just set. Just try setting PS1 in a shell *without* running a command in the same line, and you will see it take effect immediately.

    12. Re:Not a ZSH gem, but... by tlhIngan · · Score: 1

      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.

      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 to it, well, there could only really be one trick evil enough to do on a UN*X user... especially one involving the command prompt line.

      It might be nice to get rid of the space between the directory and the > though. It is C:\>, not C:\ >.

    13. Re:Not a ZSH gem, but... by Anonymous Coward · · Score: 0

      Reminds of an old (like '98) book about Linux that's still somewhere in my University's library - the blurb on the back was "Friends don't let friends use DOS"

    14. Re:Not a ZSH gem, but... by Anonymous Coward · · Score: 0

      I'd love to get a version of this that works in ksh :)

  7. Correction by Anonymous Coward · · Score: 0

    It's spelled "calendar."

    1. Re:Correction by larry+bagina · · Score: 2

      No, it's a Linux Advent Colander. For straining your linux advents.

      --
      Do you even lift?

      These aren't the 'roids you're looking for.

    2. Re:Correction by Just+Some+Guy · · Score: 1

      Not if it's holy.

      --
      Dewey, what part of this looks like authorities should be involved?
  8. Z Shell by Trogre · · Score: 1

    Here's a gem:

    In my country Shell petrol stations have recently re-branded as: Z

    Co-incidence? I think not.

    --
    "Nine times out of ten, starting a fire is not the best way to solve the problem." - my wife
  9. perl by Anonymous Coward · · Score: 0

    Who does major shell programming, when they can use perl instead?

    1. Re:perl by Anonymous Coward · · Score: 0

      Who uses perl programing when they can use python instead?

    2. Re:perl by leaen · · Score: 1

      Who uses python programming if they can use ruby instead?

    3. Re:perl by Anonymous Coward · · Score: 0

      Who uses ruby programming if they can use unicon instead?

    4. Re:perl by Anonymous Coward · · Score: 0

      Who uses ruby programming when they can use zsh?

    5. Re:perl by Hatta · · Score: 1

      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.

      --
      Give me Classic Slashdot or give me death!
    6. Re:perl by Anonymous Coward · · Score: 0

      Who uses lisp programming if they can use lisp instead?

      (Get it?)

  10. Why zsh instead of bash? by CronoCloud · · Score: 1

    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?

    1. Re:Why zsh instead of bash? by Anonymous Coward · · Score: 0

      I thaught bash was only installed by default as an excercise to get a real shell.

    2. Re:Why zsh instead of bash? by inglorion_on_the_net · · Score: 1

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

      --
      Please correct me if I got my facts wrong.
  11. I'm being completely serious here... by fotoguzzi · · Score: 1

    ...I'm seeing a blog. Is there an Advent calendar somewhere that I'm missing?

    --
    Their they're doing there hair.
    1. Re:I'm being completely serious here... by bLanark · · Score: 4, Informative

      You are looking for something like this?

      --
      Note to ACs: I won't mod you up, even if you are being funny or insightful. So take a chance! It's not real life!
    2. Re:I'm being completely serious here... by fotoguzzi · · Score: 1

      Yeah! Thanks. I had never even heard of an Advent calendar until a year ago. I have not found when/why some of them have the dates out of sequence, but that's a separate question.

      --
      Their they're doing there hair.
    3. Re:I'm being completely serious here... by bLanark · · Score: 1

      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.

      --
      Note to ACs: I won't mod you up, even if you are being funny or insightful. So take a chance! It's not real life!
  12. Re:3 zsh by Anonymous Coward · · Score: 0

    For some reason which I don't really understand, my .zshrc is the top hit on Google UK for "zshrc".

    It doesn't have anything amazing, but some of it is useful to know about (from zstyle onwards, mostly).

  13. Re:3 zsh by Anonymous Coward · · Score: 0

    There's also https://github.com/robbyrussell/oh-my-zsh that adds some nice features, and has a really active community.