This contains random assortment of things I've found useful. If you've wanted a better way to do something, chances are someone else has already implemented it.
Bash
Utilities
Finding files
There are a number of tools that try to improve on grep. ripgrep is the
best one I've come across.
For searching files a fuzzy finder is pretty nice.
Either way it's worth learning the basics of find and grep, at least enough
to know when to use it (you can always Google for finds weird syntax).
File watching
If you subscribe to the Unix way of doing things, you probably want a simple
tool that takes a list of files to watch, and runs an arbitrary command when
any of them change. entr does exactly that.
Example usage:
# Run rust project when any non-gitignored files change.
# Clear screen before each run.
rg -l "" | entr -c cargo run
# If any matching files change, run `node changed_file`
ls test/parallel/test-os* | entr node /_
Git tricks
Referring to commits
There are lots of useful shortcuts for referring to commits, see the git docs and this great StackOverflow answer answer for an in-depth review.
| Commit-ish/Tree-ish | Examples |
|---|---|
<sha1> | dae86e1950b1277e545cee180551750029cfe735 |
<describeOutput> | v1.7.4.2-679-g3bee7fb |
<refname> | master, heads/master, refs/heads/master |
<refname>@{<date>} | master@{yesterday}, HEAD@{5 minutes ago} |
<refname>@{<n>} | master@{1} |
@{<n>} | @{1} |
@{-<n>} | @{-1} |
<refname>@{upstream} | master@{upstream}, @{u} |
<rev>^ | HEAD^, v1.5.1^0 |
<rev>~<n> | master~3 |
<rev>^{<type>} | v0.99.8^{commit} |
<rev>^{} | v0.99.8^{} |
<rev>^{/<text>} | HEAD^{/fix nasty bug} |
:/<text> | :/fix nasty bug |
Above table cribbed from the StackOverflow answer.
Some of the most convenient ones are:
| Short | Equivalent |
|---|---|
@, @~ | HEAD, HEAD~ |
:/some msg | First parent that contains some msg |
branch, tag | Head of branch or tag |
branch^{/some msg} | Search branch for some msg |