Discussion
tetris11: Never heard of instant truncate, nor `fc`, nor `Esc .`Quite a few useful ones
aa-jv: My favourite shell trick is to comment my code: $ some_long_command -with -args -easily -forgotten # thatspecialthing ... Some weeks later .. $ CTRL-R<specialthing> .. finds: $ some_long_command -with -args -easily -forgotten # thatspecialthing Need to see all the special things you've done this week/whenever? $ history | grep "\#" ...Makes for a definite return of sanity ..
zahlman: Not a fan of the LLM-flavoured headings, and the tips seem like a real mixed bag (and it'd be nice to give credit specifically to the readline library where appropriate as opposed to the shell), but there are definitely a few things in here I'll have to play around with.One thing I dislike about brace expansions is that they don't play nicely with tab completion. I'd rather have easy ways to e.g. duplicate the last token (including escaped/quoted spaces), and delete a filename suffix. And, while I'm on that topic, expand variables and `~` immediately (instead of after pressing enter).
senectus1: omg >$ CTRL-R<specialthing>I could kiss you.. this alone is amazing!
fellerts: CTRL + W usually deletes everything until the previous whitespace, so it would delete the whole '/var/log/nginx/' string in OP's example. Alt + backspace usually deletes until it encounters a non-alphanumeric character.Be careful working CTRL + W into muscle memory though, I've lost count of how many browser tabs I've closed by accident...
aa-jv: Yes indeed, it is very fun to discover this if you don't know it already, it expands your understanding of your shell life immensely, doesn't it?
chasil: A much larger base for ksh (as a pdksh descendent) is Android. OpenBSD is a tiny community in comparison, although Android has acquired code directly from OpenBSD, notably the C library.The vi editing mode is always present in ksh, but is optional in dash. If present, the POSIX standard requires that "set -o vi" enable this mode, although other methods to enable it are not prohibited (such as inputrc for bash/readline), and as such is a "universal trick."
gryfft: Ctrl-Shift-T usually brings that tab right back at least
tkocmathla: I love this, from a comment on the article: He had in his path a script called `\#` that he used to comment out pipe elements like `mycmd1 | \# mycmd2 | mycmd3`. This was how the script was written: ``` #!/bin/sh cat ```
voidUpdate: With ctrl+r, if you press it twice, it will autofill the search with whatever you last searched for. pressing it more will go back through the history. Been using that a lot recently when doing docker stuff. ctrl+r, type the container name, keep going until I get the compose build command. ctrl+r, ctrl+r, repeat until the log command. Then I can just mash ctrl+r to get the build and log commands. Ctrl+r is your friend. ctrl+r
Joker_vD: > The “Works (Almost) Everywhere” Club> The Backspace ReplacementsAlso known as "emacs editing mode". Funnily enough, what POSIX mandates is the support for "vi editing mode" which, to my knowledge, almost nobody ever uses. But it's there in most shells, and you can enable it with "set -o vi" in e.g. bash.
talkin: > cd -: The classic channel-flipper. Perfect for toggling back and forth.And not only cd. Gotta love 'git checkout -'
fragmede: http://atuin.sh adds a database to store history in and a custom app to use for lookup with added modes to help with searching.
hejira: In my terminal it's the exact opposite – Alt-Backspace deletes to the previous space, whereas Ctrl-W deletes to the last non-alphanumeric (such as /). I'm using fish shell in an Alacritty terminal.Yeah, pressing Ctrl-W accidentially is a pain sometimes ... but Ctrl-Shift-T in Firefox is a godsend.