Modern CLI Tools

A presentation at Chemnitzer Linux-Tage in March 2021 in by Alexander Reelsen

Slide 1

Slide 1

Modern CLI tools Alexander Reelsen alex@elastic.co | @spinscale

Slide 2

Slide 2

Today’s goal Learn CLI tools you have not heard about. Increase your productivity

Slide 3

Slide 3

Don’t spew on UIs UIs solve different issues ⏯ UIs help to reduce complexity UIs will help newcomers UIs look nicer GOAT: The web!

Slide 4

Slide 4

Why CLI tools then? Scripting Speed Flexibility Automation

Slide 5

Slide 5

Why CLI tools then? 🛠 Process safety Expert mode Issue: Outdated distribution packages Do one thing and do it well!

Slide 6

Slide 6

Modern CLI tools? Many tools still stem from the early UNIX times Rise of the developer UTF8 Colors 🏎 Faster terminals Debugging (ephemeral containers, no local logs, remote)

Slide 7

Slide 7

New languages Rust Go Crystal JVM: GraalVM, Kotlin Native, Scala Native Zig V

Slide 8

Slide 8

New languages Binary as a result, best startup time No C/memory management learning required Faster development

Slide 9

Slide 9

Shell - zsh in combination with oh-my-zsh scripting syntax similar to bash lots of plugins for easier development

Slide 10

Slide 10

Shell - alternatives bash fish nushell

Slide 11

Slide 11

Slide 12

Slide 12

Shell Prompt - GBT

Slide 13

Slide 13

Shell Prompt - GBT

Slide 14

Slide 14

Shell Prompt - Starship

Slide 15

Slide 15

Shell aliases Make sure you alias what you type often! .. ll

Slide 16

Slide 16

wd

Slide 17

Slide 17

Shell history search Ctrl+R triggers history search Extremely powerful Ensure your history gets written after command execution instead of logout

Slide 18

Slide 18

lsd

Slide 19

Slide 19

lsd a better ls colored output relative/absolute timestamps file type icons (nerdfonts) tree view total directory size view

Slide 20

Slide 20

bat

Slide 21

Slide 21

bat cat with wings Syntax highlighting & themes Line highlighting Range snippets (no more cat | head | tail parties) git integration builtin pagination

Slide 22

Slide 22

fd

Slide 23

Slide 23

fd a better find, very similar syntax colors! takes .gitignore into account case-insensitive by default regexes parallel command execution (when used with -x )

Slide 24

Slide 24

ripgrep

Slide 25

Slide 25

ripgrep It’s fast! match patterns across newlines takes .gitignore into account skips dot files and binary files recursive && regexing by default replacement of matched text ripgrep-all to search in binary files

Slide 26

Slide 26

htop

Slide 27

Slide 27

prettyping

Slide 28

Slide 28

hyperfine

Slide 29

Slide 29

JSON coloring

Slide 30

Slide 30

JSON selection

Slide 31

Slide 31

JSON selection

Slide 32

Slide 32

fzf curl -s ‘localhost:9200/_cat/indices?format=json’ \ | jq -C -r \ ‘[ .[] | select ( .index | startswith(“.”) | not) ] | sort_by(.index) | .[].index’ \ | fzf

Slide 33

Slide 33

curl -s ‘localhost:9200/_cat/indices?format=json’ \ | jq -C -r \ ‘[ .[] | select ( .index | startswith(“.”) | not) ] | sort_by(.index) | .[].index’ \ | fzf

Slide 34

Slide 34

bandwhich

Slide 35

Slide 35

ytop

Slide 36

Slide 36

procs

Slide 37

Slide 37

dust

Slide 38

Slide 38

version managers JVM: sdkman nodejs: nvm ruby: rvm Problem: per project requirements

Slide 39

Slide 39

direnv - unclutter your profile .envrc layout node export NODE_VERSIONS=~/.nvm/versions/node export NODE_VERSION_PREFIX=’v’ use node 15.11.0 dotenv

Slide 40

Slide 40

direnv - unclutter your profile .env DB_USERNAME=”sa” DB_PASSWORD=”” DB_URL=”jdbc:h2:mem:foo_in_memory;MODE=PostgreSQL;DB_CLOSE_DELAY=-1;DATABASE_TO_UPPER=false” Run direnv allow after a change

Slide 41

Slide 41

envchain - store secrets securely envchain —set my_app DB_PASSWORD envchain ./gradlew run

Slide 42

Slide 42

Better diffs

Slide 43

Slide 43

colordiff

Slide 44

Slide 44

icdiff

Slide 45

Slide 45

scc - source code analyzer

Slide 46

Slide 46

Honorable mentions GPU based terminal emulators: alacritty & kitty exiftool, remove exif data exiftool -all= my.png tmux - next session will be all about tmux! sd, a faster sed alternative zoxide, a new cd that remembers your most common paths

Slide 47

Slide 47

Honorable mentions rlwrap, a readline wrapper cli, the github cli tool taskwarrior, the CLI todo management tool

Slide 48

Slide 48

Missing Note taking tool, that automatically syncs in the cloud/via git Time tracking? What are your favourite tools? Feel free to ping (twitter, email, linkedin, whatever)

Slide 49

Slide 49

Write CLI tools Command Line Interface Guidelines

Slide 50

Slide 50

Resources direnv envchain fish shell Starship fd bat hyperfine

Slide 51

Slide 51

Resources ripgrep ripgrep-all Grep tools feature comparison Rewritten in Rust: Modern Alternatives of Command-Line Tools Command Line Interface Guidelines A better zsh history

Slide 52

Slide 52

Thanks for listening Q&A Alexander Reelsen alex@elastic.co | @spinscale