Shell Tricks That Make Life Easier (and Save Your Sanity)
blog.hofstede.it
Shell Tricks That Make Life Easier (and Save Your Sanity)
1–10 of 287 posts
Re: Shell Tricks That Make Life Easier (and Save Your Sanity)
#2One 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).
Re: Shell Tricks That Make Life Easier (and Save Your Sanity)
#3 $ 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 ..
Re: Shell Tricks That Make Life Easier (and Save Your Sanity)
#4Quite a few useful ones
Re: Shell Tricks That Make Life Easier (and Save Your Sanity)
#5My 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 ..
I could kiss you.. this alone is amazing!
Re: Shell Tricks That Make Life Easier (and Save Your Sanity)
#6The 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."
The article is relying on some Emacs mode, which is not POSIX.
$_ is not POSIX if I remember correctly.
History in vi mode is easier, just escape, then forward slash (or question mark) and the search term (regex?), then either "n" or "N" to search the direction or its reverse.
I've seen a lot of people who don't like vi mode, but its presence is the most deeply standardized.
Re: Shell Tricks That Make Life Easier (and Save Your Sanity)
#7My 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)
#8Be 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)
#9> 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.