Naposledy aktivní 6 months ago

Revize f8992d74bd43abab4611173a4f7a84498f887363

slides.md Raw
 __  __           _                   _ _                  
|  \/  | ___   __| | ___ _ __ _ __   | (_)_ __  _   ___  __
| |\/| |/ _ \ / _` |/ _ \ '__| '_ \  | | | '_ \| | | \ \/ /
| |  | | (_) | (_| |  __/ |  | | | | | | | | | | |_| |>  < 
|_|  |_|\___/ \__,_|\___|_|  |_| |_| |_|_|_| |_|\__,_/_/\_\
                                                           
      _ _   _              _     
  ___| (_) | |_ ___   ___ | |___ 
 / __| | | | __/ _ \ / _ \| / __|
| (__| | | | || (_) | (_) | \__ \
 \___|_|_|  \__\___/ \___/|_|___/
                                 

Target audience

  • linux desktop CLI users
  • linux admins
  __________________________________________
 / This is the year of linux on the desktop \
|                                            |
|          ...Windows10 has WSL ;-)          |
 \                                          /
  ------------------------------------------
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||

Linux tooling philosophy

  • do one thing (and only one thing!) well

  • chaining

  • sound familiar? (hint: functional programming...)


Why? Improvements to...

  • productivity

  • optics

    • "unix porn" (PS1, ls, ...)

Learn the basics

  • emacs and vim

    • learn navigation, copy & paste, (and how to exit 👍)
    • pick one and become fluent
  • cd, ls, cat, less, find, grep, sed, tail, awk, dd, rsync, ...

  • Combine using pipes ( | ) and redirection ( > )


terminals and shells

What is the difference between terminal and shell?

+--------------------+
|     "terminal"     |
+--------------------+
|                    |
| +--------------+   |
| |              |   |
| |    "shell"   |   |
| |              |   |
| +--------------+   |
|                    |
+--------------------+

terminals and shells

terminal

  • colors (16 or more), fonts (utf8, ligatures, ...)
  • interactions
    • keyboard shortcuts
    • mouse interaction (copy & paste, scrolling, selection, ...)

shell

  • everything else (f.ex. PS1, scripting language)

terminal

What is the best terminal?

  • use your default

Unicode, Emojis, Fonts, Image support (!)

  • but think about enriching your output!

  • Emojis: 👍 ☑️ 💥 ✌️ 💩 💬 ⚡ € ★ ⭐


shell

  • bash
  • zsh
  • fish
  • dash (embedded)

shell / zsh


shell / fish: The new kid on the block


shell / bash


shell / PS1

PS1: alias for "prompt"

  • default: username:/some/location$
  • $PWD present working directory

Extra, nice-to-have information

  • only show relevant parts (hide user/machine name on local machine)
  • compact location ( $PWD )
  • git status
  • environment infos (node / .NET / Java / Python / etc version)

shell / PS1: liquidprompt

simple prompt


shell / PS1: Powerline

started as fancy statusline for vim …


shell / PS1: Starship

the new kid on the block


tldr

  • 41k stars https://tldr.sh/

  • man pages can be difficult

  • tldr: implemented in many languages (js, ruby, python, perl, haskell, etc)

  • Demo: ln, tar, scp


McFly

McFly replaces your default Ctrl R shell history search with an intelligent search engine that takes into account your working directory and the context of recently executed commands. McFly’s suggestions are prioritized in real time with a small neural network


thefuck

fix common typos / mistakes


The GNU Midnight Commander

mc is a visual shell much like a file manager, only with many more features

  • text mode application, but it also includes mouse support
  • best features are its ability to FTP, view tar and zip files, and to poke into tar, ar, deb, zip, cpio, lha and rar for specific files

bat

cat & less with syntax highlighting

bat 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.

  • category: read / file display

ripgrep

very fast grep replacement

  • 33.7k stars https://github.com/BurntSushi/ripgrep

  • ripgrep recursively searches directories for a regex pattern

  • sensible defaults: respect .gitignore, ignores hidden files & folders

  • command: rg

  • use rg hidden g '!.git' "your search" to search all hidden folder except .git

  • category: search


ripgrep-all

ripgrep, but also search in PDFs, E-Books, Office documents, zip, tar.gz, sqlite (!), etc


fzf

interactive fuzzy search

  • 47.5k stars https://github.com/junegunn/fzf
  • 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>
  • category: search
  • Demos:
    • find files and select them
    • search a text file

fd

simple alternative to find

  • "The command name is 50% shorter than find"
  • Convenient syntax fd PATTERN (instead of find -iname '*PATTERN*')
  • Sensible defaults: .gitignore, ignore hidden files/folders
  • fast
  • category: search

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

progress

monitor any kind of "copy"

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.
  • Demo:
    • ~/tmp/demo/origin/ contains very large file
    • tmux split screen ~/tmp/demo/
    • copy from ~/tmp/demo/origin/* to ~/tmp/demo/destination/ using cp.
    • watch progress

Ultimate Plumber (up)

interactive REPL (read–eval–print loop) for shell piping

  • 7.8k stars https://github.com/akavel/up

  • interactive piping

  • instant live preview

  • category: search, file manipulation, interactive

  • Demo: images/up-demo.gif


lolcat

Rainbows and unicorns


ttyd

            _ ._  _ , _ ._
          (_ ' ( `  )_  .__)
        ( (  (    )   `)  ) _)
       (__ (_   (_ . _) _) ,__)
           `~~`\ ' . /`~~`
           ,::: ;   ; :::,
          ':::::::::::::::'
 ______________/_ __ \_____________
|                                  |
|               ttyd               |
| share your terminal over the web |
|__________________________________|
  • category: network, dangerous

sl

typo sl (instead of ls) -> show steam locomotive


patat

  • 1.9k 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";
  • next slide: experimental image support in some terminals (same as for ranger)

    • iterm2, urxvt, kitty
  • category: presentation, slides, unix porn


ls on steroids

ls problem: sort by name and time at the same time...

Use colors!

Required: font providing all symbols


ncdu


Making Connections

the serial way


terminal

$ picocom -b 115200 /dev/ttyUSB0
$ screen /dev/ttyUSB0 115200
$ minicom -s -D /dev/ttyUSB0

grafical

  • cutecom
  • moserial
  • PuTTY

Windows


monitoring

  • htop
  • apachetop
  • ngxtop
  • mtp
  • pg_top
  • powertop
  • iotop
  • iftop
  • nethogs

Some more tools


Bonus: CLI murder mystery