Live data from Hacker News

Ask HN: Can I see your cheatsheet?

news.ycombinator.com

81–90 of 173 posts

Re: Ask HN: Can I see your cheatsheet?

#81

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 ` +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 it…

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

Re: Ask HN: Can I see your cheatsheet?

#82

This surprised me that people do this. I don't have any, since if I have to look up one, it's not really useful :) But my cheat sheet is google, I usually find what I want in no time.

"my cheat sheet is google"

Useful information disappears from the internet all the time.

If I find something useful I record it myself so I can easily find it again instead of wasting my time searching for something that may no longer exist.

Re: Ask HN: Can I see your cheatsheet?

#84

  * Some zsh tips
  ** Zero-pad (preserve zeroes) a variable
  Either
  *** typeset -Z2 FOO
  *** printf %02 $FOO
  ** Do arithmetic
  *** examples
  **** addition
  (( count = $count + 1 ))
  ** Loop through a directory of long filenames with spaces
  while read -r line
  do
    echo "'$line'"
  done 

Re: Ask HN: Can I see your cheatsheet?

#85

I write down all my commands, ever issued in the terminal, in temporal ordered markdown files per task/project. This means I can go back, compare, see how I did it in the past and improve, if possible. Or investigate, why something isn't working (based on my noted commands, which is eaier in hindsight).

How do you format them? Mine look very verbose, I don't like markdown at all, but since Gitlab/Github renders them, you can't use anything else...

Re: Ask HN: Can I see your cheatsheet?

#86

Set a huuuuuuuge shell history https://github.com/craigjperry2/dotfiles/blob/aa77ddcbde63bf... then fzf ctrl+r bindings mean you can recall anything right where you need it. If you’re going to do this then have an escape hatch for commands you don’t want memorised https://github.com/craigjperry2/dotfiles/blob/aa77ddcbde63bf...

Your file just reminded me I have "broot" installed..

Its sad how I install all those things, forget about them the next day and cd/ls/vi like a caveman.

The problem is much deeper than you think, OP...

Re: Ask HN: Can I see your cheatsheet?

#87
post #43

- Find all files modified in the last 90 minutes find . -type f -mmin -90 - Find all files and do something to each one find . -type f -mmin -90 | xargs ls -l - Find all files modified before 2 days ago find . -type f -mtime +2 - Removing files older than 7 days find . -type f -mtime +7 -name '*.gz' -exec rm {} \; - Find all files modified after last 2 days find . -type f -mtime -2 - Find all files modified at the la…

With zsh you don't need to use find, fd, or any other external tool. zsh's built-in globbing features can be used instead. - Find all files modified in the last 90 minutes print -l **/*(mm-90) - Find all files and do something to each one print -l **/*(mm-90) | xargs ls -l - Find all files modified before 2 days ago print -l **/*(m+2) - Removing files older than 7 days zargs -- **/*(m+7) -- rm - Find all files modifi…

The zsh rm command doesn't with too many (say, 100 000) files, execve() fails with: Argument list too long. This works and it is relatively fast (runs rm in big batches): find ... | xargs -d '\n' rm --

Re: Ask HN: Can I see your cheatsheet?

#89
post #87

Earlier quoted context omitted.

With zsh you don't need to use find, fd, or any other external tool. zsh's built-in globbing features can be used instead. - Find all files modified in the last 90 minutes print -l **/*(mm-90) - Find all files and do something to each one print -l **/*(mm-90) | xargs ls -l - Find all files modified before 2 days ago print -l **/*(m+2) - Removing files older than 7 days zargs -- **/*(m+7) -- rm - Find all files modifi…

The zsh rm command doesn't with too many (say, 100 000) files, execve() fails with: Argument list too long. This works and it is relatively fast (runs rm in big batches): find ... | xargs -d '\n' rm --

You can do the same with:

  zargs -- **/*(m+7) -- rm
I updated my answer above accordingly.

Re: Ask HN: Can I see your cheatsheet?

#90
post #12
post #4

https://tldr.sh/

tldr is one of the best things to happen to the command line

I'm probably missing something here, but it seems to me that it's just a summary of the command plus a few examples?

I usually just man the command and / my way either to the Examples section, or search for whatever other question I may have.

But I'm on OpenBSD, where man pages are worth the time you spend reading them.

Other than that, although I always intend to add useful stuff to my ~/txt/scratch, in the end it's either Ctrl-R or history | grep.

Post reply on HN