git diff
…in a huge number of languages. See the impressive list with:
bat -L
cat /home/marie/parvus/prog/slides/static/files/tools/julia.jl
…in a huge number of languages. See the impressive list with:
bat -L
bat /home/marie/parvus/prog/slides/static/files/tools/julia.jl
Uses less
by default with options -RFX
Very convenient: quits the pager automatically if the entire content fits on one script
bat -d
Even colourizes your man pages if you set the MANPAGER
environment variable (e.g. in your .bashrc
):
export MANPAGER="sh -c 'col -bx | bat -l man -p'"
bat -n # Remove frame
bat -p # Remove frame & line numbers
I personally have an alias for this: alias rat='bat -p'
bat -pp # Remove frame & line numbers & don't use pager
bat -f # Keep colour highlighting after piping
I made this the default behaviour for bat
with the alias: alias bat='bat -f'
The defaults are great, but if they don’t suit you, you can change tab width, language, wrapping method…
bat --config-file # Location of config file (if it exists)
bat --generate-config-file # Create config file template
bat --list-themes # List themes with examples
rg
: The syntax is similar to that of grep
Because, by default, rg
is recursive (grep
isn’t) & ignores some files, rg -uuu
is equivalent to grep -r
I will compare grep
and rg
to recursively search the word “Unix” in my directory “~/parvus/prog/tcl”
grep -r Unix ~/parvus/prog/tcl
rg Unix ~/parvus/prog/tcl
I will do a cold test (clearing my computer cache before each run) using hyperfine
hyperfine -i --prepare 'sync; echo 3 | sudo tee /proc/sys/vm/drop_caches' \
'grep -r Unix ~/parvus/prog/tcl' \
'rg Unix ~/parvus/prog/tcl'
Benchmark 1: grep -r Unix ~/parvus/prog/tcl
Time (mean ± σ): 1.027 s ± 0.016 s [User: 0.269 s, System: 0.222 s]
Range (min … max): 1.007 s … 1.052 s 10 runs
Benchmark 2: rg Unix ~/parvus/prog/tcl
Time (mean ± σ): 76.0 ms ± 5.6 ms [User: 21.5 ms, System: 29.6 ms]
Range (min … max): 63.0 ms … 82.4 ms 10 runs
Summary
'rg Unix ~/parvus/prog/tcl' ran
13.51 ± 1.02 times faster than 'grep -r Unix ~/parvus/prog/tcl'
Uses parallelism
Uses Rust regex engine with finite automata, SIMD, & aggressive literal optimizations (regular expressions follow the syntax of grep -E
; see this
& this
for details)
By default, ignores files in .gitignore & similar, hidden files/directories, & binary files (this behaviour can be changed with flags)
pass init your-gpg-id # Initialize password store
pass insert somesite.ca/your@email # Enter password for a site
pass somesite.ca/your@email # Print password
pass -c somesite.ca/your@email # Copy password to clipboard
pass edit somesite.ca/your@email # Edit password
pass generate othersite.com/userid 12 # Generate password of size 12
pass generate -c othersite.com/userid 12 # Same, but copy to clipboard
pass generate -n othersite.com/userid 12 # Same, without special characters
pass rm othersite.com/userid # Delete password
pass # Print content of password store
ssh
ed into it or to using sudo emacs
to edit root filesC-x C-f /ssh:user@server:/home/user/path/to/file RET
C-x C-f /sudo::/path/to/file RET
emacs /ssh:user@server:/home/user/path/to/file
emacs /sudo::/path/to/file