Live data from Hacker News

Zsh is your friend.

mikegrouchy.com

51–60 of 117 posts

Re: Zsh is your friend.

#51

Earlier quoted context omitted.

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 bot…

wow - would you know the settings for the whole shared history thing you wrote about. I have mine set up in a less than ideal way and have never been able to google for these settings.

These are the history setopt's I have, but I don't know if they all make sense with each other though. I set it up once and haven't touched it in years.

HIST_IGNORE_DUPS # don't add multiple 'cd ..', etc in a row?

HIST_EXPIRE_DUPS_FIRST # save unique hist entries longer

HIST_VERIFY # edit recalled history before running

INC_APPEND_HISTORY # add commands to .history immediately

EXTENDED_HISTORY # save timestamp on history entries

# set a huge history... doesn't seem to affect performance at all

HISTFILE=~/.zsh_history

HISTSIZE=10000

SAVEHIST=$((HISTSIZE/2))

For the completion I setopt AUTO_REMOVE_SLASH GLOB_COMPLETE MENU_COMPLETE NO_AUTO_LIST NO_BAD_PATTERN NO_BEEP NO_LIST_AMBIGUOUS NO_LIST_BEEP NO_NOMATCH, but I'm not sure what they all do ;-P

Re: Zsh is your friend.

#52

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…

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…

Same here, the syntax highlighting rocks (I couldn't go back now), and I do like the shared history.

For simple non-interactive scripts I still use bash because of its ubiquity, python for complex needs.

Re: Zsh is your friend.

#54

The supremacy of bash over zsh &c. seems to be an excellent case study in the "Worse is Better" hypothesis. http://www.jwz.org/doc/worse-is-better.html

Not really, you're not seeing bash have many more features because its simpler on the inside at the cost of sometimes breaking. Rather, it seems an example of " the most dangerous enemy of a better solution is an existing codebase that is just good enough"

Not sure that is the real reason. Zsh was not free software in the Linux formative years. It lost its chance, and mindshare, like so much commercial Unix

Re: Zsh is your friend.

#55
post #7

Earlier quoted context omitted.

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!

This is indeed a lovely feature I couldn't live without. In bash, you can get it by adding the following to your .inputrc (at least on mac terminal) "\e[B": history-search-forward "\e[A": history-search-backward

I add these lines so the left- and right-arrows still work correctly:

    "\e[C": forward-char
    "\e[D": backward-char

Re: Zsh is your friend.

#57
post #50
post #42

Earlier quoted context omitted.

How is that better than bash or zsh: for i in `seq 1 100`; do echo $i; done zsh: for i in `seq 1 100`; echo $i

It's sort of ok when its `do... done`. But what about `if`..`fi` or `case`..`esac`. +1 for rc.

Honestly, I find that stuff pretty easy to remember. And is it that ugly, in the grand scheme of ugly shell syntax? :)

I mean, what about [[ ]] vs. (( )) vs. [ ]? Or the beginning of a case statement? Those always get me since I don't use them often enough for them to stick.

Re: Zsh is your friend.

#58
post #42
post #38

Earlier quoted context omitted.

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.

How is that better than bash or zsh: for i in `seq 1 100`; do echo $i; done zsh: for i in `seq 1 100`; echo $i

Even better: for i in {1..100}; echo $i

Re: Zsh is your friend.

#59

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…

Same here, the syntax highlighting rocks (I couldn't go back now), and I do like the shared history. For simple non-interactive scripts I still use bash because of its ubiquity, python for complex needs.

  >  I do like the shared history.
Maybe the implementation is different, but ZShell has shared history. (Just noting that this is not a 'fish rocks other shells because of X' feature)

Re: Zsh is your friend.

#60
post #50

Earlier quoted context omitted.

It's sort of ok when its `do... done`. But what about `if`..`fi` or `case`..`esac`. +1 for rc.

Honestly, I find that stuff pretty easy to remember. And is it that ugly, in the grand scheme of ugly shell syntax? :) I mean, what about [[ ]] vs. (( )) vs. [ ]? Or the beginning of a case statement? Those always get me since I don't use them often enough for them to stick.

[ ] is easy. It's just the 'test' command.[1]

  % which \[
  /usr/bin/[
All of the other syntax is shell-specific (run via built-ins), so that can vary, and be a little more obtuse.

[1] Albiet with some minor differences:

  % if [ -d /tmp ]; then echo "TRUE"; fi
  TRUE
  
  % if test -d /tmp ]; then echo "TRUE"; fi
  test: too many arguments
  
  % if test -d /tmp; then echo "TRUE"; fi 
  TRUE

  % diff /usr/bin/{test,\[}
  Binary files /usr/bin/test and /usr/bin/[ differ

  % man \[
  No manual entry for [
Post reply on HN