Earlier quoted context omitted.
As many others here have noted, terse syntax for things like `repeat` loops or normal `for`/`while` loops or shell var expansion can all be addictive, but some specific things I miss in Bash that are easy in Zsh are: 1) auto cd to any evar just from its name e.g. lb=/usr/local/bin; lb ($lb works in bash, but I always forget the $. I know I could do aliases...Yuck.) 2) auto cd does not seem to use $CDPATH this is a re…
What's Yuck about using aliases? I use those extensively. Is that a bad practice?
Zsh Tricks to Blow Your Mind
201–210 of 218 posts
Re: Zsh Tricks to Blow Your Mind
#202Earlier quoted context omitted.
Last time I checked it was slower than https://github.com/romkatv/powerlevel10k , because it doesn't decouple the rendering of the prompt from the background processes collecting status information. Ergo no instant prompt. Also, some other cool tricks w.r.t. prompt vs. backscroll. Has that changed?
It seems fast enough but once you enter an actual directory of code where it needs to get the version of node, kotlin, package, etc it slows down noticeably. I've ended up disabling most packages because it is absurd to (I assume) be running node --version every time a prompt is generated. It's a shame they can't do these things asyncronously or cache them.
Re: Zsh Tricks to Blow Your Mind
#203Knew most of those, not much interested in "shell plugins". One thing that many people miss are parameter expansions. Those are in Posix, so pretty much any bare shell should be able to use that, too. So dash/bash/zsh/ksh… echo Hello ${PLANET:-World} to have a default if you're not sure a variable is set. Replace "-" with "=" to actually set it, not just use it for this statement. Or removing suffixes: filename=/tmp/…
echo $filename:r is the shorter, Zsh way to strip a file extension. What am I missing from Ksh93?
Compound and active variables are quite convenient in longer scripts. As are namerefs, but I think zsh might have something similar enough.
Re: Zsh Tricks to Blow Your Mind
#204A 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.
https://www.gnu.org/savannah-checkouts/gnu/bash/manual/bash....
Re: Zsh Tricks to Blow Your Mind
#205Earlier quoted context omitted.
As many others here have noted, terse syntax for things like `repeat` loops or normal `for`/`while` loops or shell var expansion can all be addictive, but some specific things I miss in Bash that are easy in Zsh are: 1) auto cd to any evar just from its name e.g. lb=/usr/local/bin; lb ($lb works in bash, but I always forget the $. I know I could do aliases...Yuck.) 2) auto cd does not seem to use $CDPATH this is a re…
For your #8 a function might be helpful to remove the $[] characters. $ function c;{echo $[$*]} $ c 1234./56 22.035714285714285 $ a=33;c a / 3 11
Re: Zsh Tricks to Blow Your Mind
#206Earlier quoted context omitted.
>Despite remaining in zsh while in a terminal, I still find myself writing only bash scripts when a script it needed. I do this too. I think it's good practice; zsh is amazing as an interactive shell, but bash is everywhere.
Bash is not everywhere, but /bin/sh is..! If portability is important, I'd recommend Bourne shell instead. Sometimes there's a justification for writing shell scripts in bash. E.g. if you only care about Linux forever. Frequently though, a simple script will unexpectedly grow, and start to require non-trivial data structures, etc. If there's no time for a rewrite in a more appropriate language (Python/Ruby/Perl), the…
You caught me, and you're right: sh (not bash) is the portable option.
Re: Zsh Tricks to Blow Your Mind
#207None 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.
Plus any project from sharkdp and burntsushi and any tools recommended by Brendan Gregg.
ht editor is a personal favorite too (press F6 and go to image to get started).
Re: Zsh Tricks to Blow Your Mind
#208Having done this sort of thing for years, I've come to realize that the biggest barrier to getting more efficient on the command line isn't "sets of features," i.e. the space of the things the shell can do -- it's figuring out how to retrain myself?
A common thing: I see a new (to me) thing like fzf or fd and can immediately conceive of how adding it to my workflow would be phenomenal, but it takes so much more to make it a part of the day. I'm curious if anyone has come up with ways to teach/train themselves better? The best I've come up with so far is to just add something stupid to my .bashrc like
echo "hey, try out that fzf trick"
Re: Zsh Tricks to Blow Your Mind
#209Earlier quoted context omitted.
Salty/sweet contrast is the core of Hawaiian pizza appeal, and flavour/texture contrasts are the foundation of some of the most interesting foods, for instance salted caramel, pork and apples, etc.
Pineapple, banana pepper, and jalapeño may be my favorite pizza.
Re: Zsh Tricks to Blow Your Mind
#210zsh4humans is the most recent zsh “trick” I’ve discovered. zsh is a bit like emacs when first installed: it can do a lot of things but it’s not nearly as useful without a lot of manual configuration. I’m honestly surprised it doesn’t have more stars on GitHub. https://github.com/romkatv/zsh4humans
Is this similar to Oh My Zsh [1]? I personally have been using Oh My Zsh for years and I've always been a fan of it. I can quickly add themes and plugins and have my shell ready to go how I like it quite quickly on new systems. [1]: https://ohmyz.sh/