title | author | patat | ||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
░▒▓ modern linux command line tools ▓▒░ |
patrick @drechsler Hackerkegeln 2020-01 https://github.com/draptik/2020-01-modern-linux-command-line-tools |
|
███╗ ███╗ ██████╗ ██████╗ ███████╗██████╗ ███╗ ██╗
████╗ ████║██╔═══██╗██╔══██╗██╔════╝██╔══██╗████╗ ██║
██╔████╔██║██║ ██║██║ ██║█████╗ ██████╔╝██╔██╗ ██║
██║╚██╔╝██║██║ ██║██║ ██║██╔══╝ ██╔══██╗██║╚██╗██║
██║ ╚═╝ ██║╚██████╔╝██████╔╝███████╗██║ ██║██║ ╚████║
╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚══════╝╚═╝ ╚═╝╚═╝ ╚═══╝
██╗ ██╗███╗ ██╗██╗ ██╗██╗ ██╗
██║ ██║████╗ ██║██║ ██║╚██╗██╔╝
██║ ██║██╔██╗ ██║██║ ██║ ╚███╔╝
██║ ██║██║╚██╗██║██║ ██║ ██╔██╗
███████╗██║██║ ╚████║╚██████╔╝██╔╝ ██╗
╚══════╝╚═╝╚═╝ ╚═══╝ ╚═════╝ ╚═╝ ╚═╝
██████╗██╗ ██╗ ████████╗ ██████╗ ██████╗ ██╗ ███████╗
██╔════╝██║ ██║ ╚══██╔══╝██╔═══██╗██╔═══██╗██║ ██╔════╝
██║ ██║ ██║ ██║ ██║ ██║██║ ██║██║ ███████╗
██║ ██║ ██║ ██║ ██║ ██║██║ ██║██║ ╚════██║
╚██████╗███████╗██║ ██║ ╚██████╔╝╚██████╔╝███████╗███████║
╚═════╝╚══════╝╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚══════╝╚══════╝
Douglas Adams
I've come up with a set of rules that describe our reactions to technologies:
Anything that is in the world when you're born is normal and ordinary and is just a natural part of the way the world works.
Anything that's invented between when you're fifteen and thirty-five is new and exciting and revolutionary and you can probably get a career in it.
Anything invented after you're thirty-five is against the natural order of things.
- linux desktop CLI users
- linux admins
__________________________________________
/ This is the year of linux on the desktop \
| |
| ...Windows10 has WSL ;-) |
\ /
------------------------------------------
\ ^__^
\ (oo)\_______
(__)\ )\/\
||----w |
|| ||
-
do one thing (and only one thing!) well
-
chaining
-
sound familiar? (hint: functional programming...)
-
productivity
-
optics
- "unix porn" (
PS1
,ls
, ...)
- "unix porn" (
-
emacs
andvim
- learn navigation, copy & paste, (and how to exit 👍)
- pick one and become fluent
-
cd
,ls
,cat
,less
,find
,grep
,sed
,tail
,awk
,dd
,rsync
, ...
+--------------------+
| "terminal" |
+--------------------+
| |
| +--------------+ |
| | | |
| | "shell" | |
| | | |
| +--------------+ |
| |
+--------------------+
- colors (16 or more), fonts (utf8, ligatures, ...)
- interactions
- keyboard shortcuts
- mouse interaction (copy & paste, scrolling, selection, ...)
- everything else (f.ex.
PS1
, scripting language)
- use your default
-
but think about enriching your output!
-
Emojis: 👍 ☑️ 💥 ✌️ 💩 💬 ⚡ € ★ ⭐
_______________________________________
/\ \
\_| You've got to know when to hold 'em |
| Know when to fold 'em |
| Know when to walk away |
| And know when to run |
| __________________________________|_
\_/____________________________________/
(...this presentation is running in a terminal (kitty
), not a browser...)
- bash
- zsh
- fish
- dash (embedded)
-
package manager
- oh-my-zsh (99k stars) https://ohmyz.sh
-
category: shell
-
package manager
- fisher (4k stars) https://github.com/jorgebucaran/fisher
- oh-my-fish (5.5k stars) https://github.com/oh-my-fish/oh-my-fish
-
category: shell
-
package manager
- bash-it (10k stars) https://github.com/Bash-it/bash-it
- oh-my-bash (0.5k stars) https://ohmybash.github.io
-
category: shell
-
PS1: alias for "prompt"
-
default:
username:/some/location $
-
$PWD
present working directory
-
3.9k stars https://github.com/nojhan/liquidprompt
-
shortens
$PWD
-
adds git status
-
available for
zsh
,bash
, etc -
category: unix-porn
-
11k stars https://github.com/powerline/powerline
-
started as fancy statusline for
vim
... -
shortens
$PWD
-
adds git status
-
available for
zsh
,bash
, etc -
category: unix-porn
-
(mirrored repo: ~500 stars) http://byobu.co/
-
tmux
-wrapper for non-vim userstmux
(16k stars) https://github.com/tmux/tmux/wiki
-
Keybindings
F1
-F12
-
Sensible defaults (layout, info line)
-
category: productivity
_________________________________
/ \
| ...a personal favorite... |
\______________________________ '\
() \\
O \\ .
o |\\/|
/ " '\
. . .
/ ) |
' _.' |
'-'/ \
-
6.9k stars https://ranger.github.io
-
file explorer
-
2 layout options
- miller columns ("mac" style)
- multipane (similar to Midnight commander)
-
powerful preview mode and program launcher (word, music, ...)
- with image support for certain terminals (
iterms2
,urxvt
,kitty
) notgnome-terminal
(!)
- with image support for certain terminals (
-
key bindings: see
~/.config/ranger/rc.conf
starting at line ~300... -
category: navigation, file system
-
Demos:
- kitty with image preview
- copy
yy
& pastepp
-
25k stars https://tldr.sh/
-
man pages can be difficult
-
tldr: implemented in many languages (js, ruby, python, perl, haskell, etc)
-
Demo:
ln
,tar
,scp
-
17k stars https://github.com/sharkdp/bat
-
cat
&less
with syntax highlightingbat looks good on a dark background by default. However, if your terminal uses a light background, some themes like GitHub or OneHalfLight will work better for you.
-
hint: not the same preview used by
ranger
... -
category: read / file display
_________________________________
/ \
| daily usage |
\______________________________ '\
() \\
O \\ .
o |\\/|
/ " '\
. . .
/ ) |
' _.' |
'-'/ \
-
17k stars https://github.com/BurntSushi/ripgrep
-
ripgrep
recursively searches directories for a regex pattern -
very fast
grep
replacement (benchmarks on website) -
sensible defaults: respect
.gitignore
, ignores hidden files & folders -
command:
rg
-
category: search
\\\///
/ _ _ \
(| (.)(.) |)
.-.OOOo--()--oOOO.-.
| |
| Power-Tool! | -> Demo: search in exercism folder
| |
'-.oooO------------'
( ) Oooo.
\ ( ( )
\_) ) /
(_/
-
1.4k stars https://github.com/phiresky/ripgrep-all
-
ripgrep, but also search in PDFs, E-Books, Office documents, zip, tar.gz, sqlite (!), etc
-
command:
rga
-
faster than
pdfgrep
(see website for a benchmark) -
category: search
-
Demo: search in Manning books folder
-
26k stars https://github.com/junegunn/fzf
-
interactive fuzzy search
-
pipe any line based input to fzf: Example
find * -type f | fzf
-
good integration with other tools
-
nice helper methods for
- files & directories
cd **<TAB>
- kill
kill -9 <TAB>
- host names
ssh **<TAB>
- environment variables & aliases
unset **<TAB>
,export **<TAB>
,unalias **<TAB>
- files & directories
-
category: search
-
Demos:
- find files and select them
- search a text file
-
11k stars https://github.com/sharkdp/fd
-
simple alternative to
find
-
"The command name is 50% shorter than
find
" -
Convenient syntax
fd PATTERN
(instead offind -iname '*PATTERN*'
) -
Sensible defaults:
.gitignore
, ignore hidden files/folders -
fast
-
category: search
-
4k stars https://github.com/sharkdp/hyperfine
-
benchmarking tool
# comparing `fd` with `find`
# ubuntu uses `fdfind` by default
hyperfine --warmup 3 'fdfind -HI '.*[0-9]\.jpg$'' 'find ~ -iregex '.*[0-9]\.jpg''
# arch
hyperfine --warmup 3 'fd -HI '.*[0-9]\.jpg$' Documents/talks' 'find Documents/talks -iregex '.*[0-9]\.jpg$''
# unfair comparison: `fd` ignores hidden files and `.git` be default
hyperfine --warmup 3 'fd '.*[0-9]\.jpg$' Documents/talks' 'find Documents/talks -iregex '.*[0-9]\.jpg$''
- category: benchmarking
-
4k stars https://github.com/Xfennec/progress
-
attach to any kind of copy
-
category: monitoring
-
Demo:
~/tmp/demo/origin/
contains very large file- tmux split screen
~/tmp/demo/
- copy from
~/tmp/demo/origin/*
to~/tmp/demo/destination/
usingcp
. watch progress
No command currently running: cp, mv, dd, tar, cat, rsync, grep, fgrep, egrep, cut, sort, md5sum,
sha1sum, sha224sum, sha256sum, sha384sum, sha512sum, adb, gzip, gunzip, bzip2, bunzip2, xz,
unxz, lzma, unlzma, 7z, 7za, zcat, bzcat, lzcat, split, gpg, or wrong permissions.
-
4k stars https://github.com/akavel/up
-
interactive piping
-
instant live preview
-
interactive REPL for bash piping
-
category: search, file manipulation, interactive
-
Demo: images/up-demo.gif
-
3k stars https://github.com/busyloop/lolcat
-
Rainbows and unicorns
-
category: fun, unix porn
_ ._ _ , _ ._
(_ ' ( ` )_ .__)
( ( ( ) `) ) _)
(__ (_ (_ . _) _) ,__)
`~~`\ ' . /`~~`
,::: ; ; :::,
':::::::::::::::'
______________/_ __ \_____________
| |
| ttyd |
| share your terminal over the web |
|__________________________________|
- category: network, dangerous
-
when the tv team comes in your office
-
category: fun, unix porn
-
1k stars https://github.com/mtoyoda/sl
-
typo
sl
(instead ofls
) -> show steam locomotive -
category: fun, unix porn
-
51k stars https://github.com/nvbn/thefuck
-
fix common typos / mistakes
-
category: productivity
-
1k stars https://github.com/jaspervdj/patat
-
nerdy slides in your shell
-
runs in a terminal (similar to
revealJs
for the browser) -
Pandoc syntax (f. ex. markdown)
-
syntax highlighting
let foo = "bar";
-
emojis: 👍, ✅, ☑️, 💥
-
next slide: experimental image support in some terminals (same as for
ranger
)iterm2
,urxvt
,kitty
-
category: presentation, slides, unix porn
ls
problem: sort by name and time at the same time...
Use colors!
colorls
("the original" in ruby: https://github.com/athityakumar/colorls)lsd
(in rust: https://github.com/Peltoche/lsd)exa
(in rust: https://github.com/ogham/exa)
Required: font providing all symbols
- Example: NerdFonts https://github.com/ryanoasis/nerd-fonts
- 2k stars https://github.com/athityakumar/colorls
- category: unix porn
_________________________________
/ \
| daily usage |
\______________________________ '\
() \\
O \\ .
o |\\/|
/ " '\
. . .
/ ) |
' _.' |
'-'/ \
- 3k stars https://github.com/Peltoche/lsd
- alternative to
colorls
-
24 stars https://github.com/k4rtik/pydf-pypi
-
colorized
df
alternative
-
interactive
df
alternative
-
ascii art boxes
-
show all templates:
boxes -l
-
category: unix porn
- htop
- apachetop
- ngxtop
- mtp
- pg_top
- powertop
- iotop
- iftop
- nethogs
.-"""-.
/ .===. \
/ / a a \ \
/ ( \___/ ) \
______ooo\__\_____/__/________
/ \
| did I miss your favorite tool? |
\_____________________ooo______/
/ \
/:.:.:.:.:.:.:\
| | |
\==|==/
/-'Y'-\
(__/ \__)
- mosh (robust replacement for ssh) https://mosh.org/
- neofetch (fancy system info in the shell) 7.7k stars https://github.com/dylanaraps/neofetch
- expect https://likegeeks.com/expect-command/
- jq (sed for json) https://stedolan.github.io/jq/
- httpie (cli http client) 45k stars https://httpie.org/
- http-prompt (cli http client) 7.6k stars http://http-prompt.com/
- pywal (color schemes for terminal) 3.4k stars https://github.com/dylanaraps/pywal
- fish_config (web-based configuration tool for fish shell) https://fishshell.com/docs/current/commands.html#fish_config
- xclip (cli to X clipboard) 403 stars https://github.com/astrand/xclip
- apt-iselect (interactive ncurses package search for debian) https://www.rot13.org/~dpavlin/apt-iselect.html
- gcalcli (google calender in the shell) 2k stars https://github.com/insanum/gcalcli
- pastebinit (cli tool to send data to pastebin) 17 stars https://github.com/skorokithakis/pastebinit
- MapSCII (ascii google maps in the terminal) https://github.com/rastapasta/mapscii
- alwaysontop (always move prompt to top of screen) 160 stars https://github.com/swirepe/alwaysontop
-
3.8k stars https://github.com/veltman/clmystery
-
CLI murder mystery