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
```Shell Tricks That Make Life Easier (and Save Your Sanity)
11–20 of 287 posts
Re: Shell Tricks That Make Life Easier (and Save Your Sanity)
#12CTRL + 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...
Re: Shell Tricks That Make Life Easier (and Save Your Sanity)
#13CTRL + 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...
Yeah, pressing Ctrl-W accidentially is a pain sometimes ... but Ctrl-Shift-T in Firefox is a godsend.
Re: Shell Tricks That Make Life Easier (and Save Your Sanity)
#14My favourite shell trick is to comment my code: $ some_long_command -with -args -easily -forgotten # thatspecialthing ... Some weeks later .. $ CTRL-R .. 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 ..
omg >$ CTRL-R I could kiss you.. this alone is amazing!
Re: Shell Tricks That Make Life Easier (and Save Your Sanity)
#15And not only cd. Gotta love 'git checkout -'
Re: Shell Tricks That Make Life Easier (and Save Your Sanity)
#16> The “Works (Almost) Everywhere” Club > The Backspace Replacements Also 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.
Once you get used to it, it is painful to go back.
Re: Shell Tricks That Make Life Easier (and Save Your Sanity)
#17Simple, no need to learn any commandline these days.
I used to use arch and all, and managed many big projects. I find little value in learning new tools anymore, just feed it docs and it generated working plan most of the time
Now I've moved to coding in Haskell, which i find suits me better than wasting my time with cli and exploring what options all these cli tools have.
Re: Shell Tricks That Make Life Easier (and Save Your Sanity)
#18A mistake 3 words earlier? No problem: 3bcw and I'm good to go.
Want to delete the whole thing? Even easier: cc
I can even use v to open the command inside a fully-fledged (neo)vim instance for more complex rework.
If you use (neo)vim already, this is the best way to go as there are no new shortcuts to learn and memorize.
Re: Shell Tricks That Make Life Easier (and Save Your Sanity)
#19With 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 frien…
Re: Shell Tricks That Make Life Easier (and Save Your Sanity)
#20Not 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…
As someone who works mostly in WSL and has to use PS occasionally, it really reduces the overhead of the context switch.