Live data from Hacker News

Zsh Tricks to Blow Your Mind

twilio.com

21–30 of 218 posts

Re: Zsh Tricks to Blow Your Mind

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

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.

Re: Zsh Tricks to Blow Your Mind

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

Bash supports at least a subset of emacs motion keys. 7. C-a C-k C-y # to park a command

Well, actually... Using C-x C-e you can use EVERY key emacs offers.

(since it invokes your editor, and you can configure it to be emacs)

Re: Zsh Tricks to Blow Your Mind

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

While I agree that these are not killer features, I'd suggest reading more about zsh. It's not meant to "replace" bash. It's meant to be easily extensible (addons, etc.) The target is folks that stay from bash scripting.

Re: Zsh Tricks to Blow Your Mind

#24

Earlier quoted context omitted.

> 5. `qalc` from libqalculate: https://github.com/Qalculate/libqalculate Or, you know, any REPL available.

Or a simple `=() { bc -l Just a little shortcut but REPLs like Python's take a while to spin up, so it's pretty convenient.

That's a nifty idea!

Maybe without lower scale and with the semicolon:

  = () { bc -l 
"Stealing" the equals sign for this purpose feels a bit risky, but maybe it isn't.

Re: Zsh Tricks to Blow Your Mind

#25
post #8
post #5

did twilio suddenly become medium? why are they posting zsh tricks blogspam

They always had "developer tips" even on their YouTube

This is called Inbound Marketing, which consists of creating actual useful content slightly tangential to your own product/service so to attract audience which will, potentially, convert to customers.

Sometimes it’s well executed (see Realm’s) sometimes it’s not.

Re: Zsh Tricks to Blow Your Mind

#26
post #16
post #3

https://github.com/natethinks/jog/ I'm not sure why this isn't a part of zsh already, but if you want to see the last few commands you ran in the current directory, that little utility will do that for you. Great for reminding yourself what you did last time you were in a directory.

Wow jog is tiny: grep -a "${PWD} " ~/.zsh_history_ext | cat | cut -f1 -d"|" | tail

Why does it pipe to cat?

Re: Zsh Tricks to Blow Your Mind

#27
My favorite alias, which is not really a zsh exclusive thing, is combining cd && ls :

    cl() { cd "$@" && ls; }
It's wonderfully simple and saves me so much time by giving me an instant refresher of what's in the directory I just changed to.

Re: Zsh Tricks to Blow Your Mind

#28
post #3

https://github.com/natethinks/jog/ I'm not sure why this isn't a part of zsh already, but if you want to see the last few commands you ran in the current directory, that little utility will do that for you. Great for reminding yourself what you did last time you were in a directory.

mcfly is a nice alternative https://github.com/cantino/mcfly

Re: Zsh Tricks to Blow Your Mind

#30

None of these blew my mind. If you like terminal productivity I recommend: fzf, Facebook path picker (aka fpp), fd, ripgrep, lf, tig. Some honorable mentions: tokei, hyperfine, lazydocker, ctop, ncspot.

Solid selection. I'd also add nnn as the fastest tool to navigate directories I've ever seen.

nnn is certainly very fast.

lf is also fast but has ranger's look and feel.

Post reply on HN