Comment by scrapheap

4 years ago

No maintained cheat sheet here either. I do use `history | grep` quite a lot though.

One thing I try to do is to keep my keyboard shortcuts consistent between programs/systems. That way the chance of my instinct of pressing `<CTRL>+a` to move the cursor to the start of the line will be correct more often.

Another thing I try to do when a project has a set of complex commands that are needed, is to add them as a rule in its Makefile, that way they're available for my colleagues as well.

I use zsh-histdb[1], which records my entire shell history for all time in a database, which also stores:

  • The start and stop times of the command
  • The working directory where the command was run
  • The hostname of the machine
  • A unique per-host session ID, so history from several sessions is not confused
  • The exit status of the command

This the working directory of the command has been especially useful for me to get the context of what I did, not only the command itself.

[1] - https://github.com/larkery/zsh-histdb

same here - my cheatsheet is `history | grep`

  • I'm curious why history | grep and not ctrl-R?

    • Probably because ctrl-R doesn't present you a list in most shells. Maybe you want to scan the list visually and look at neighboring commands. ctrl-R doesn't really take advantage of human vision by showing all results next to each other.

      3 replies →

    • Regular expressions. Sometimes you remember two non-adjacent parts. Ctrl-R doesn't let you find "when I used find with awk" unless you type in everything in between.