Live data from Hacker News

My favourite Zsh features

code.joejag.com

11–20 of 44 posts

Re: My favourite Zsh features

#11

Something I've noticed is that osx users believe bash to be less capable than it is because of the poor out of the box configuration of bash on that platform (in addition to the ancient version installed). Particularly the tab completion stuff. It doesn't pop up menus and all that, but the ubuntu install of bash has a ton of context-sensitive tab completion stuff in it, and the git package properly installs __git_ps1…

I guess "bad PR" like this is actually one downside for projects switching to GPL3.

Re: My favourite Zsh features

#13
I love that if you have vi key bindings active you can update the prompt when you change modes. I never used vi bindings in bash because I would become confused when I entered normal mode without realizing it. In zsh it was easy to configure my prompt to change colors and symbols when outside insert mode.

https://github.com/everett1992/dotfiles/blob/master/home/.zs...

I have noticed that zsh's globbing is greedy.

    `grep ^foo *` tries to expand ^foo when bash would pass it as a string to grep.

Re: My favourite Zsh features

#14
A killer feature not listed here is global aliases. These are aliases that can be anywhere in a line. The most use I get out of this is from having

   alias -g L=' | less '
which allows me to simply append "L" to a line to pipe the output to less.

    ls L
The pattern of short all-caps global aliases for ' | command 's make building/editing pipelines really easy/fast.

    alias -g C=' | wc -l '
    alias -g A=' | ack-grep '
    alias -g S=' | sort '
    alias -g JQL=' | jq -C  | less'

    ls **/*png L
    ls **/*png A -v regex C
    curl $site JQL
putting

bindkey '^g' _expand_alias

in your zshrc allows you to expand aliases with

You can find more global aliases and tips at: http://grml.org/zsh/zsh-lovers.html

Re: My favourite Zsh features

#16
post #8

bash only needs better history manipulation. absolutely nothing else. all those z shell features the only useful one (i.e. the only one that's impossible on bash) is the recursion (i typed star star, but hn hides it) hack. and it's awful. because now you just learned something that you can't use anywhere else! and to search that same way in a shell script? though luck. also it has less parameter then find. and find i…

bash support recursion. also supports going up/down in researched history, just not with arrows by default.

Re: My favourite Zsh features

#18
post #8

bash only needs better history manipulation. absolutely nothing else. all those z shell features the only useful one (i.e. the only one that's impossible on bash) is the recursion (i typed star star, but hn hides it) hack. and it's awful. because now you just learned something that you can't use anywhere else! and to search that same way in a shell script? though luck. also it has less parameter then find. and find i…

This works fine in bash:

    $ echo **/*.txt
Of course if you're using an ancient version of bash, you're out of luck.

    $ bash --version
    GNU bash, version 4.3.11(1)-release (x86_64-pc-linux-gnu)
    GNU bash, version 4.1.13(7)-release (x86_64-unknown-cygwin)

Re: My favourite Zsh features

#19
post #12

The up arrow to go back in history matching the partial command I typed is has become essential to me. I feel lost without it, more than the tab completion.

I use C-r and C-s in bash, for incremental searching backwards and forwards. Takes less time to type these than reach across to the up and down arrow keys. Mind to stty stop undef to stop C-s from freezing your terminal, of course.

Zsh would probably be worth using, except for the fact that bash is almost everywhere, and I already know it very well. It's a tough one to call.

Re: My favourite Zsh features

#20
post #14

A killer feature not listed here is global aliases. These are aliases that can be anywhere in a line. The most use I get out of this is from having alias -g L=' | less ' which allows me to simply append "L" to a line to pipe the output to less. ls L The pattern of short all-caps global aliases for ' | command 's make building/editing pipelines really easy/fast. alias -g C=' | wc -l ' alias -g A=' | ack-grep ' alias -…

So what do you do when you want to ls a file called "L"?
Post reply on HN