Live data from Hacker News

My favourite Zsh features

code.joejag.com

1–10 of 44 posts

Re: My favourite Zsh features

#3
The tab completion isn't limited to the beginning of file names either. Useful when many of your file names start with the same pattern but then diverge.

  ls something
will complete to

  ls prefixSomething.sh
if it's unique enough. This is probably my single favorite zsh feature.

Re: My favourite Zsh features

#4

The tab completion isn't limited to the beginning of file names either. Useful when many of your file names start with the same pattern but then diverge. ls something will complete to ls prefixSomething.sh if it's unique enough. This is probably my single favorite zsh feature.

Having gotten used to ido in emacs, I must say that I am now disappointed in most all autocompletes. Shame it doesn't work in the shell. (Quick, someone prove me wrong! Please! :) )

Re: My favourite Zsh features

#5
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 and very good tab completion (which even the homebrew git recipe on osx doesn't manage to do).

This is not to say that zsh doesn't have a lot more features, just that the comparison from the perspective of an osx user tends to be a lot more stark.

Re: My favourite Zsh features

#6
One of my favorites instead of aliasing ".."'s is this function:

  rationalise-dot() {
    if [[ $LBUFFER = *.. ]]; then
      LBUFFER+=/..
    else
      LBUFFER+=.
    fi
  }
  zle -N rationalise-dot
  bindkey . rationalise-dot
When you hit ... it will produce a slash and a ../ for each . you type after that.

Re: My favourite Zsh features

#7
post #4

The tab completion isn't limited to the beginning of file names either. Useful when many of your file names start with the same pattern but then diverge. ls something will complete to ls prefixSomething.sh if it's unique enough. This is probably my single favorite zsh feature.

Having gotten used to ido in emacs, I must say that I am now disappointed in most all autocompletes. Shame it doesn't work in the shell. (Quick, someone prove me wrong! Please! :) )

I also love ido and I was made curious by your comment. Just found this. The top answer, unfortunately, is not really of ido quality and doesn't provide the same near-magical feeling: it only seems to do contiguous-substring matching. http://stackoverflow.com/questions/1112805/emacs-ido-style-s... http://pgas.freeshell.org/shell/bash-ido It also does not work in my zsh.

Just trying to save others some time here.

Re: My favourite Zsh features

#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 is available everywhere so you can use it in scripts.

Re: My favourite Zsh features

#9
post #4

The tab completion isn't limited to the beginning of file names either. Useful when many of your file names start with the same pattern but then diverge. ls something will complete to ls prefixSomething.sh if it's unique enough. This is probably my single favorite zsh feature.

Having gotten used to ido in emacs, I must say that I am now disappointed in most all autocompletes. Shame it doesn't work in the shell. (Quick, someone prove me wrong! Please! :) )

How does ido work? Is there any demo or a quick tutorial? (I don't use Emacs.)

Re: My favourite Zsh features

#10
post #9
post #4

Earlier quoted context omitted.

Having gotten used to ido in emacs, I must say that I am now disappointed in most all autocompletes. Shame it doesn't work in the shell. (Quick, someone prove me wrong! Please! :) )

How does ido work? Is there any demo or a quick tutorial? (I don't use Emacs.)

https://www.youtube.com/watch?v=AfZX39jd6cw#t=80s Ignore the first 1:20 or so, in which he configures things the slow way.

The real magic of ido is the completion engine. It's not made super explicit in that video, but it's actually possible to complete on arbitrary subsequences of strings you want.

With my configuration (using the popular "flx-ido" matching engine), if you wanted to match "README.md", you could achieve this by just typing ED. Even though E and D aren't consecutive, E appears before D. (But "GOOD_EDITING_SOFTWARE" would be matched before "README.md", because it prioritizes consecutive matches and characters at the beginnings of logical groups of characters.)

Post reply on HN