Live data from Hacker News

Zsh Tricks to Blow Your Mind

twilio.com

61–70 of 218 posts

Re: Zsh Tricks to Blow Your Mind

#61
post #11

A lot of these can be easily done in Bash, too! 1. `mkcdir () { mkdir -- "$1" && cd -- "$1"; }` 2a. `bind '"\e[A":history-search-backward'; bind '"\e[B":history-search-forward'` 2b. Default behavior for Bash. 3. `shopt -s autocd` 4. `mmv`, `perl-rename` 5. `qalc` from libqalculate: https://github.com/Qalculate/libqalculate 8. Default behavior for Bash. 9. Default behavior for Bash.

Re 1., if you put a -p on the mkdir it becomes a bit more powerful. I've had equivalents of that command going back to DOS batch files on a 286. I've always called it "ad", for "add directory" (though I'll concede that's mainly a good name because it's short).

Re: Zsh Tricks to Blow Your Mind

#62
post #56
post #11

A lot of these can be easily done in Bash, too! 1. `mkcdir () { mkdir -- "$1" && cd -- "$1"; }` 2a. `bind '"\e[A":history-search-backward'; bind '"\e[B":history-search-forward'` 2b. Default behavior for Bash. 3. `shopt -s autocd` 4. `mmv`, `perl-rename` 5. `qalc` from libqalculate: https://github.com/Qalculate/libqalculate 8. Default behavior for Bash. 9. Default behavior for Bash.

7. in bash, I use the: [Esc], [#] combo, equivalent to: [Alt]-[Shift]-[3] (a.k.a.: "M-#" in the official docs). This is a shortcut which basically prefixes the current line with '#' comment character and then simulates hitting Enter (pushing the commented-out line into history buffer).

And then the inverse operation, uncommenting and running, is "M-3 M-#" (any number will do, but 3 is on the same key as #).

Re: Zsh Tricks to Blow Your Mind

#63
Pretty clickbaity title. Nothing "mind blowing" about what's in that article really. I used to use Zsh but switched back to bash a few years ago because most of the things I liked in Zsh turned out to be doable in Bash and I just didn't look enough.

Re: Zsh Tricks to Blow Your Mind

#64
post #36

Earlier quoted context omitted.

This is always my complaint about posts like this. I read them looking for the killer feature to make me consider switching from bash and it's always stuff bash does natively or with a one line alias.

defaults matter.

Yes, but on the other hand most proponents of zsh have installed ohmyzsh and a dozen plugins. (Just like a lot of long-time users have a long .bashrc.)

Re: Zsh Tricks to Blow Your Mind

#65

I've been using Fish instead and it's much much simpler than configuring ZSH to my liking. It's already good out of the box, without having to carry around any kind of configuration. The only stuff I usually do is to setup `powerline-go` as prompt, and voilà, that's pretty much it.

I rather liked Fish's zero config approach but I found their handling of the PATH very hard to work with day to day. Perhaps it was just my familiarity with having a bunch of statements to alter the PATH in a config file but it felt very opaque, I always had to look up how to add stuff to the PATH and I had great trouble trying to remove stuff from the PATH.

Re: Zsh Tricks to Blow Your Mind

#67
post #57

I've been using Fish instead and it's much much simpler than configuring ZSH to my liking. It's already good out of the box, without having to carry around any kind of configuration. The only stuff I usually do is to setup `powerline-go` as prompt, and voilà, that's pretty much it.

I am a happy Fish user, too. The first downside that comes to my head is that if you want to share a script you wrote that you have to translate it to bash first. Much less of an issue if you're using zsh.

I just write my scripts in bash or python, depending on the use case.

Aliases and macros are fish script though.

Re: Zsh Tricks to Blow Your Mind

#68

I've been using Fish instead and it's much much simpler than configuring ZSH to my liking. It's already good out of the box, without having to carry around any kind of configuration. The only stuff I usually do is to setup `powerline-go` as prompt, and voilà, that's pretty much it.

Same, I use starship[1] as my prompt, it's easy to install and has sane defaults.

[1] https://github.com/starship/starship

Post reply on HN