Live data from Hacker News

My favourite Zsh features

code.joejag.com

21–30 of 44 posts

Re: My favourite Zsh features

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

You can do it in bash too. I have this in my bashrc:

    bind '"^[[1;5A": history-search-backward'
    bind '"^[[1;5B": history-search-forward'
where ^[ is the escape character. This way, crtl-up goes to previous partial match (and up goes to last command as usual). I use it all the time.

Re: My favourite Zsh features

#22
post #21
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.

You can do it in bash too. I have this in my bashrc: bind '"^[[1;5A": history-search-backward' bind '"^[[1;5B": history-search-forward' where ^[ is the escape character. This way, crtl-up goes to previous partial match (and up goes to last command as usual). I use it all the time.

I didn't think that was possibile. Thank you.

Re: My favourite Zsh features

#24
post #21
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.

You can do it in bash too. I have this in my bashrc: bind '"^[[1;5A": history-search-backward' bind '"^[[1;5B": history-search-forward' where ^[ is the escape character. This way, crtl-up goes to previous partial match (and up goes to last command as usual). I use it all the time.

I have this to use the arrow keys without any modifier:

    # Use up/down arrows to search on partially typed command
    bind '"\e[A"':history-search-backward
    bind '"\e[B"':history-search-forward
Just type the first letter(s) and use the up/down arrows to scroll through the filtered command history. Incredibly convenient.

Re: My favourite Zsh features

#25
While we're on the topic of non-bash shells, I recommend taking a look at Fish: http://fishshell.com/

I wrote a tutorial on how to install it on Mac OS X and Ubuntu: http://hackercodex.com/guide/install-fish-shell-mac-ubuntu/ For me, the chief advantage to Fish is that you get more functionality out-of-the-box than with most other shells, including zsh.

I also published two related projects for easily sharing Fish shell enhancements — Tacklebox https://github.com/justinmayer/tacklebox and Tackle https://github.com/justinmayer/tackle) — because I wanted a way for folks to be able to have access to multiple plugin repositories and easily share their favorite shell snippets.

Re: My favourite Zsh features

#26
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"?

I put L in 'single quotes' or I \escape it

  touch 'L'
  ls 'L'
  ls \L

Re: My favourite Zsh features

#27
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"?

./L

Re: My favourite Zsh features

#28

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…

Agreed. I really like bash-it to get some of those 'missing' features: https://github.com/revans/bash-it

Re: My favourite Zsh features

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

You should check out https://github.com/tymm/directory-history then. It makes your history matching sensitive to the directory you are in. That means that commands will show up first which were typed in the directory you are in.

I don't want to miss this plugin and can't really understand why not everyone wants it. I guess I am a little biased though since I wrote that plugin ;)

Re: My favourite Zsh features

#30

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…

Indeed. Bash has, or can be configured, to have almost all the features listed in this article. The article is really a testament to the power of defaults. The bash maintainership is extremely conservative about enabling new features by default even when these features are unalloyed good.

For example, I contributed bracketed paste support to bash and readline. Yay! No more inadvertent command execution! No security problems pasting shell commands from web pages! You'd think we'd want that feature enabled by default, right?

Well, no. The feature will be off by default. For reasons.

http://lists.gnu.org/archive/html/bug-bash/2014-10/msg00211....

Post reply on HN