Live data from Hacker News

Zsh is your friend.

mikegrouchy.com

31–40 of 117 posts

Re: Zsh is your friend.

#31

Earlier quoted context omitted.

I have been using fish for several years now. It's community is a fraction of zsh, bash, and others, and I've tried to go back to them, mostly out of misplaced "everyone else is doing it" mindset Fish is a great shell. It's a modern shell, that uses colors, UTF, and processing power that didn't exist when the others were designed. I feel the best thing about it is the sane defaults and large number of prebuilt comple…

Do you have to do anything weird to Lua to make it work as a system scripting language? Do you just use the built in OS interfaces?

Yes, I just use the builtin's. Basically os.execute, and io.popen.

Popen is not the greatest because you can't get exit statuses from it. But for a quick script that is too messy in shell, it suffices. I believe that there is an extension to lua that has a popen that returns exit statuses. That can be used too.

For pattern matching, I either pipe to perl and capture the output, or use the inbuilt pattern matching system. It's surprisingly powerful.

Re: Zsh is your friend.

#33

- I'm using bash on Ubuntu. When I type "kill " I get a list of process numbers, not the list of files in my current directory as you imply. - shared history sounds like a bug, not a feature. I have long lived terminals open, each dedicated to a specific purpose. Shared history would intermingle them. - typing `gut` in bash gives me: No command 'gut' found, did you mean: Command 'cut' from package 'coreutils' (main)…

about the 3'rd thing, that's not a bash thing - that's a ubuntu thing, which nicely integrates with bash by default. You could get the same thing by putting

function command_not_found_handler() { /usr/bin/python /usr/lib/command-not-found -- $1 }

in your .zshrc

P.S.

Re: Zsh is your friend.

#34

- I'm using bash on Ubuntu. When I type "kill " I get a list of process numbers, not the list of files in my current directory as you imply. - shared history sounds like a bug, not a feature. I have long lived terminals open, each dedicated to a specific purpose. Shared history would intermingle them. - typing `gut` in bash gives me: No command 'gut' found, did you mean: Command 'cut' from package 'coreutils' (main)…

Your third example is not the same. Does Bash correct it for you, or just lists similar commands?

Re: Zsh is your friend.

#35
post #26

Earlier quoted context omitted.

He also doesn't hit the mark on editing modes. Emacs and Vi keybindings for shells are usually provided by libreadline. I was really looking for a different shell before. But if those are zsh killler features, it certainly wont be my choice.

Zsh use's zle(Z-Shell Line Editor), which is different then libreadline as its part of the shell not a separate library. Zle's behavior is editable through your .zshrc. Maybe I dumbed the post down too much, was just listing a few features that I use every day that IMO work better then the comparable Bash features.

I read and enjoyed the article and I am surprised it has recieved this level of criticism here.

Perhaps you should update it and add a number of the other features that you like about it (with a brief description..)?

(edit: spelling)

Re: Zsh is your friend.

#36

- I'm using bash on Ubuntu. When I type "kill " I get a list of process numbers, not the list of files in my current directory as you imply. - shared history sounds like a bug, not a feature. I have long lived terminals open, each dedicated to a specific purpose. Shared history would intermingle them. - typing `gut` in bash gives me: No command 'gut' found, did you mean: Command 'cut' from package 'coreutils' (main)…

Shared history in zsh is essential to my workflow. I also keep many terminals open, and while I do separate them by task, I often just pick one which happens to be in the right directory and start typing away. I always search through history using Ctrl-R, and almost never use up-arrow cycling. Shared history makes this work seamlessly.

This is obviously configurable, so if you prefer a different workflow, zsh will accomodate it.

Re: Zsh is your friend.

#37
post #18

Earlier quoted context omitted.

I reccommend ksh over bash. That's all I use these days. It was sh done right, although it does have a bit of history to it for compatibility. To use associative arrays in ksh: typeset -A table column="name" table[$column]="value" echo ${table[$column]} ksh is much more decent than bash, although I reccommend using in an emacs M-x shell buffer for better command line editing. Edit: forgot to dereference column when s…

For reference, to use associative arrays in Bash: declare -A table column="name" table[$column]="value" Included in recent versions of bash :)

I say typeset, you say declare, let's call the whole thing off! :)

Re: Zsh is your friend.

#38

While from what I have read about it zsh is a nice shell, it doesn't deal with what I find to be the biggest problem with bash, sh, and just about every shell that isn't fish: the horribly ugly and inconsistent syntax. And I think it's rather sad that on what is supposedly the most advanced shell of our generation, you still have to deal with a thousand ridiculous redirections and quoting styles, different delimiter…

Try Plan 9's "rc". It has a more C-like syntax, so you write things like "for (i in `{seq 1 100}) { echo $i }"; I really enjoy writing in rc.

Re: Zsh is your friend.

#39
post #7

While from what I have read about it zsh is a nice shell, it doesn't deal with what I find to be the biggest problem with bash, sh, and just about every shell that isn't fish: the horribly ugly and inconsistent syntax. And I think it's rather sad that on what is supposedly the most advanced shell of our generation, you still have to deal with a thousand ridiculous redirections and quoting styles, different delimiter…

The thing I like about fish is the easy history nav. I type "git" and press Up, and I get to go through my history of anything that started with "git" very quickly. I'll often remember I typed an svn command three weeks ago, but forget the parameters, and I'll have it back within 15 seconds. It's like magic!

Works the same in zsh.

Re: Zsh is your friend.

#40

- I'm using bash on Ubuntu. When I type "kill " I get a list of process numbers, not the list of files in my current directory as you imply. - shared history sounds like a bug, not a feature. I have long lived terminals open, each dedicated to a specific purpose. Shared history would intermingle them. - typing `gut` in bash gives me: No command 'gut' found, did you mean: Command 'cut' from package 'coreutils' (main)…

Shared history can be either a burden or a godsend, I like it but I usually just end up using whatever basic bash shell I'm on without a custom config as most of the things I do are remote. The zsh autocorrect works much differently than what you have given. You have shown a feature of ubuntu (and probably debian) that looks for packages matching/close to your given command but what zsh does is give you, depending on…

Zsh has knobs for shared history. You can configure all terminals to have the same history at the same time, but I have it set to add history to the .zsh_history file immediately, but each shell gets it's own history. So ctrl-r in a shell lists commands entered into that shell (or preexisting when it started), and opening a new terminal starts with the shared history from all terminals. This is really the best of both worlds. Also there's a knob to only add a command if it isn't in the history, so no scrolling back over a dozen "cd .." or whatever.

Zsh has floating point math, for instance $((1.0/2)) is 0.5 instead of an error. This comes in handy sometimes in simple scripts.

Zsh is significantly faster.

Zsh autocomplete is much more advanced. Bash may have copied the pid completion and some other easy ones, but zsh has all sorts of completion hooks, for instance "svn help ch" expands to "changelist". It also runs --help and parses out GNU style help text for completing options.

Zsh completion also has optional Windows-style cycle mode, so you can do "prefix"... and cycle through the matches instead of prefixab-" like in bash. I think you can actually make bash do this but it's some obscure key binding.

...basically zsh is just a bit better at everything.

{edit: oops meant to reply to grandparent}

Post reply on HN