Skip to content

Instantly share code, notes, and snippets.

@Velrok
Created July 25, 2022 08:20
Show Gist options
  • Save Velrok/70c56bbd479cb3822770af6f72e83feb to your computer and use it in GitHub Desktop.
Save Velrok/70c56bbd479cb3822770af6f72e83feb to your computer and use it in GitHub Desktop.
presentation on text UIs

The power of command line tools

Topics

  1. modern fast replacements for established use cases
  2. new more powerful tools
  3. interactive command line tools aka text UI or TUI

Modern fast replacements for established use cases

Out with the old in with the new

These are faster better stronger replacements for established use cases.


grep ripgrep (rg)

mortgage-engine$ time grep user # does not finish
# does not finish

mortgage-engine$ time rg user # skipps anything in git ignore by default
# rg user  0.08s user 0.30s system 211% cpu 0.179 total

mortgage-engine$ time rg -vvv user # search it all!
# rg -vvv user  0.27s user 0.51s system 37% cpu 2.072 total

find fd

mortgage-engine$ time find . -name user.rb
# ./app/models/brokers/user.rb
# ./app/models/user.rb
# find . -name user.rb  0.19s user 2.73s system 99% cpu 2.932 total

mortgage-engine$ time fd user.rb
# app/models/admin_user.rb
# app/models/brokers/application_user.rb
# app/models/brokers/user.rb
# app/models/user.rb
# db/migrate/20201022095750_remove_provider_from_user.rb
# db/migrate/20210111150109_add_role_to_admin_user.rb
# db/migrate/20210203090756_add_intercom_id_to_user.rb
# db/migrate/20210617153246_add_names_to_admin_user.rb
# db/migrate/20210622124717_add_oauth_fields_to_admin_user.rb
# db/migrate/20210728081905_add_phone_number_to_broker_user.rb
# fd user.rb  0.04s user 0.06s system 426% cpu 0.023 total

ls exa

cat bat

Demo in shell.

Remember to

unalias ls
unalias cat

New more powerful tools

Do more on the command line

These are tools that allow easier scripting and new workflows without leaving the terminal.


fzf

fzf is a general-purpose command-line fuzzy finder.

gh pr view --web $(gh pr list | fzf | cut -f 1)

# gh is githubs cli
# cut allows to cut a string into parts (split)
# and only take certain fields (here the first split by <space>)

sttr (newly discovered)

# With input prompt
sttr

# Direct input
sttr md5 "Hello World"

# File input
sttr md5 file.text
sttr base64-encode image.jpg

# Reading from different processor like cat, curl, printf etc..
echo "Hello World" | sttr md5
cat file.txt | sttr md5

# Writing output to a file
sttr yaml-json file.yaml > file-output.json

Interactive command line tools aka text UI or TUI

Now you are living in the terminal

It's nice why would you ever lave to use a mouse :D.

There are interactive tools, that often replace GUI functions. But unlike GUI apps, they are designed to be used keyboard first.


Demo time


slides

Write slides in markdown. You have been seeing this in action for a while now.


LazyGit

mortgage-engine$ lazygit

VisiData

Downloads$ vd entries.csv

Vim (NeoVim)

One of the oldest TUI available :D. But it plays really nice with all its new friends. Specially NeoVim with terminal and floating window support.

mortgage-engine$ vim

But wait there is more ...

  • glow will render markdown on the command line for you.
  • termdbms seams to be a SQL client TUI
  • Kubelive kubernetes cluster management
  • share-cli quick temporary file sharing
  • emma-cli node package browser

Questions / Comments ?

I love this stuff, talk to me anytime ;) .

slides

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment