8 ms·
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":histo
by j-james 6y ago
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 https://github.com/Qalculate/libqalculate
8. Default behavior for Bash.
9. Default behavior for Bash.
- rootlocus 6y ago> 5. `qalc` from libqalculate: https://github.com/Qalculate/libqalculate https://github.com/Qalculate/libqalculate Or, you know, any REPL available.
- alpaca128 6y agoOr a simple `=() { bc -l <<< "scale=10;$1" }` in the usual bash file and you can use bc to do calculations by starting with a =. Just a little shortcut but REPLs like Python's take a while to spin up, so it's pretty convenient.
- xorcist 6y agoThat'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.
- JNRowe 6y agoI'd guess that xorcist added a space at the end of the function name because zsh uses =( to specify one type of process substitution. Without the space or an escape for = zsh will error on alpaca128's definition believing you wanted something else entirely. To that point zsh has some excellent additions for process substitution beyond bash's <(list), but it also makes for yet more weird incompatibilities for when that matters. I only looked at this to start with because I assumed the space was because =() would have been treated as the full path modifier for a command called (), because it would mean that with any other character including other bracket types. TIL.
- deadbunny 6y ago> Just a little shortcut but REPLs like Python's take a while to spin up, so it's pretty convenient. Really? Loading python takes basically 0 seconds for me... the slowest I could get running `time python3` and hitting ctrl-d (to exit) is like 0m0.104s.
- stjohnswarts 6y agopython comes up in way less than a second on my old mac air?
- enriquto 6y agomy favourite is pari/gp, that can be used as a simple calculator, but also has quite fancy math at your fingertips. For example, it is the easiest way to compute entire series: you type "exp(sin(x))" and you get "1+x+1/2*x^2-1/8*x^4-1/15*x^5 ..."
- JNRowe 6y agoIt isn't shown in TFA, but the zcalc keymap is bindable in the line editor so not only can you use it like qalc/irb/luap/whatever you can also take advantage of any other functionality of zsh within it. Admittedly, you could do some of that with some magic $if/$endif guards in your ~/.inputrc if your REPL uses readline, but the integration is nice functionality if you're a heavy zsh user. I think of it more like the expression register in vim or eval-print-expression in emacs.
- marvingardens 6y agoBash supports at least a subset of emacs motion keys. 7. C-a C-k <enter other command> C-y # to park a command
- m463 6y agoWell, 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)
- cle 6y agoThese are provided by Readline. Many command line programs support Readline, and for those that don’t, rlwrap is like magic (even automatically adds history!).
- deadbunny 6y agoThis 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.
- petepete 6y agoI'm happy in zsh or bash but the one thing I love in zsh is that completion options for program arguments. Having a list with a snippet of documentation to tab through is a huge benefit.
- caymanjim 6y agoBash supports completions as well.
- p_l 6y agoIIRC, bash doesn't support extended completion editor features of ZSH, which GP alluded to - like generating a table of options with help strings that can be selected by arrow keys and the like.
- Symbiote 6y agoA (slightly contrived) example: > rsync --e«TAB» Completing file some-file-with-extra-hyphens Completing host a-n-example.local Completing option --cvs-exclude -- auto-ignore files the same way CVS does --delete-excluded -- also delete excluded files on the receiving side --exclude -- exclude files matching pattern --exclude-from -- read exclude patterns from specified file --executability -- preserve executability --ignore-existing -- ignore files that already exist on receiving side --ignore-non-existing --existing -- ignore files that do not exist on receiving side There are various ways to present the completion; I have the simple "keep typing letters" way, but Zsh can also present a table with an entry to highlight.
- 6y ago
- grtehy 6y agoWhile 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.
- akavel 6y ago7. 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).
- mkl 6y agoAnd then the inverse operation, uncommenting and running, is "M-3 M-#" (any number will do, but 3 is on the same key as #).
- mkl 6y agoRe 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).
- thomasahle 6y ago> 4. `mmv`, `perl-rename` I didn't have this on my system. I like the article because this was a command I've needed many times without realizing it.
- j-james 6y agoYou may also like the renameutils programs that let you freely manipulate file names in your text editor. https://www.nongnu.org/renameutils/ https://www.nongnu.org/renameutils/
- aklemm 6y agoThank goodness, I can close this tab with no fomo.
- Spivak 6y agoThe one thing I really don’t want to live without is “intellisense” that changes the default input to a prefix-search that ghosts the top result ahead of your typing. The feature was stolen from fish it’s 100% worth it to me.
- nicwolff 6y ago7. alt-# to comment and accept the current line, alt-1 alt-# to uncomment and execute it https://www.gnu.org/savannah-checkouts/gnu/bash/manual/bash.html#index-insert_002dcomment-_0028M_002d_0023_0029 https://www.gnu.org/savannah-checkouts/gnu/bash/manual/bash....