I used !<index> Together with history by giving an index displayed in the history list, but did not know that you can use it like that! Also didn’t know about ^
You say this, but then you discover $HISTTIMEFORMAT which helps records when you last ran a command as a comment in the history file and Ctrl+R won’t tell you that information.
The hard part with adopting that, though, is editing in plausible looking dates for commands that were issued before it was set up (or choosing not to and dealing with the confusion until those commands disappear off the top of the history).
Another awesome tip I’ve learned today, thanks! Yeah often I remember the actual day I typed a specific command but must manually scroll through. This is another useful tip. I don’t think I’ll completely let go of history since it’s also super convenient to just look up index and type !345 for example.
The default ones are the same as in emacs, so if you know emacs, you probably know them too, but Control-U kills (roughly equivalent to “cut” for non-emacs people) from the cursor to the beginning of the line, which emacs doesn’t do; that defaults to something like M-- M-1 C-k in emacs.
If you’re a vi person, you can do set -o vi and use vi functionality. Hit Esc to go into vi-style command mode.
I feel like I forget those that I just don’t use often enough, and when I would need them I default to what I know (which is always a slower way than knowing a shortcut) in a “hurry”.
Guess I should just print them and tape the paper next to my monitor.
This is why I follow linux memes, I don’t know if I have ever bumped into CTRL+R but I finally can let go of
history
If you haven’t used them before, there’s also
!
and^
.!
invokes the last command starting with the following string.^
searches for the last command containing the first string, replaces that string with the second, and invokes that.I used
!<index>
Together withhistory
by giving an index displayed in the history list, but did not know that you can use it like that! Also didn’t know about^
Thanks for the tips!
You say this, but then you discover
$HISTTIMEFORMAT
which helps records when you last ran a command as a comment in the history file and Ctrl+R won’t tell you that information.The hard part with adopting that, though, is editing in plausible looking dates for commands that were issued before it was set up (or choosing not to and dealing with the confusion until those commands disappear off the top of the history).
Another awesome tip I’ve learned today, thanks! Yeah often I remember the actual day I typed a specific command but must manually scroll through. This is another useful tip. I don’t think I’ll completely let go of history since it’s also super convenient to just look up index and type !345 for example.
While you are at it, look up readline shortcuts.
The default ones are the same as in
emacs
, so if you knowemacs
, you probably know them too, but Control-U kills (roughly equivalent to “cut” for non-emacs
people) from the cursor to the beginning of the line, whichemacs
doesn’t do; that defaults to something likeM-- M-1 C-k
in emacs.If you’re a
vi
person, you can doset -o vi
and usevi
functionality. Hit Esc to go intovi
-style command mode.In emacs it would be
C-u - C-k
I think.That’d be equivalent. Emacs has a number of way to input arguments to functions.
True, I forgot that it’s possible to pass argument with
M-#
. 😺I feel like I forget those that I just don’t use often enough, and when I would need them I default to what I know (which is always a slower way than knowing a shortcut) in a “hurry”.
Guess I should just print them and tape the paper next to my monitor.