Moderner CLI Stack mit Rust
Linux Infotag | 26.04.2025 | THA
Hubert Högl
https://hhoegl.informatik.hs-augsburg.de/pub/lit25
Zusammenfassung
Programm Zweck Linux MacOS Windows
eza ls ✅ ✅ ✅
fd find ✅ ✅ ✅
rg grep ✅ ✅ ✅
starship prompt ✅ ✅ ✅
atuin history ✅ ✅
zellij term mux ✅ ✅
helix editor ✅ ✅ ✅
Rust
Kompilierte Sprache
Systemnahe Programme, Embedded Systems
Schnell
Sicher
Angenehmes Tooling:
rustup
,cargo
$ cargo new rs-demo $ eza -T rs-demo rs-demo/ ├── Cargo.toml └── src/ └── main.rs
Lernen: https://doc.rust-lang.org/book
eza
Ersatz für ls
.
Fork von exa
(unmaintained).
https://github.com/eza-community/eza
# display type indicator by file names
$ alias ls = "eza -F=auto"
$ ls --hyperlink
# Tree
$ ls -T
# Git
$ ls -l --git
alias ll='eza --long --no-permissions --no-user --time-style=long-iso --total-size'
Themes (theme.yml
) in $HOME/.config/eza/
.
# file type code or glob = ANSI;ANSI;ANSI;...
export EZA_COLORS='test.txt=1;4;93'
Man Pages
fd
fd is a modern, git-aware, syntax-enabled alternative to find that handles unicode, respects .gitignore, and ignores hidden directories by default.
-u
wie beirg
rg
“ripgrep” von Andrew Gallant (“BurntSushi”)
-u
: unrestricted-u = --no-ignore -uu = --no-ignore -./--hidden -uuu = --no-ignore -./--hidden --binary
Starship
- Cross-shell prompt
- https://starship.rs
- “Universal: works on any shell, on any operating system.”
- Schnell
- Konfigurierbar über TOML, einzelne “Module”: https://starship.rs/config
- Presets: https://starship.rs/presets
Nerd fonts (https://github.com/ryanoasis/nerd-fonts) müssen installiert sein (Kurzanleitung: Von https://www.nerdfonts.com/font-downloads die Datei 0xProto.zip
herunterladen und in ~/.local/share/fonts/
entpacken, danach sudo fc-cache -f
# ~/.bashrc
eval "$(starship init bash)"
$ starship -V
starship 1.22.1
$ starship -h
...
$ starship completions bash > .bash_completion.d/starship.bash
$ starship explain
Here's a breakdown of your prompt:
"(🅒 :base) " (<1ms) - The current conda environment, if $CONDA_DEFAULT_ENV is set
"…/lit25 " (<1ms) - The current working directory
"[📝++(1)🤷✓] " (3ms) - Symbol representing the state of the repo
"t420:" (<1ms) - The system hostname
"hhoegl" (<1ms) - The active user's username
$ starship timings
Here are the timings of modules in your prompt (>=1ms or output):
git_status - 3ms - "[📝++(1)🤷✓] "
conda - <1ms - "(🅒 :base) "
directory - <1ms - "…/lit25 "
hostname - <1ms - "t420:"
username - <1ms - "hhoegl"
Mein erster Konfigurations-Versuch: etc/starship.toml:
(🅒 :base) hhoegl@t420:…/lit25 [📝++(2)🤷✓] $
Ausgabe von Modul username
anzeigen
$ starship module username
Früher habe ich https://github.com/magicmonty/bash-git-prompt als Git Prompt verwendet.
Atuin
Sync, search and backup shell history
von Ellie Huxtable, https://ellie.wtf/projects/atuin
Default Pfade:
~/.config/atuin/
~/.local/share/atuin/
~/.local/share/atuin/key
(setzen ueber key_path)~/.local/share/atuin/history.db
(setzen ueber db_path)
Unterstützte Shells: Bash, ZSH, Fish und NuShell
Installiere preexec (https://github.com/rcaloras/bash-preexec)
# Installation
$ curl --proto '=https' --tlsv1.2 -LsSf https://setup.atuin.sh | sh
$ which atuin
/home/hhoegl/.atuin/bin/atuin
$ atuin -V
atuin 18.5.0
~/.bashrc
. "$HOME/.atuin/bin/env"
[[ -f ~/.bash-preexec.sh ]] && source ~/.bash-preexec.sh
eval "$(atuin init bash)"
Synchronisation
Atuin Cloud Sync
$ atuin register $ atuin login
Eigener Sync Server
FOSDEM23 Vortrag von Ellie Huxtable: https://www.youtube.com/watch?v=uyRmV19qJ2o
Alternative: McFly - https://github.com/cantino/mcfly
Zellij
“A terminal workspace with batteries included”
https://zellij.dev, von Aram Drevekenin,
aram@poor.dev
Zum Namen: https://de.wikipedia.org/wiki/Zellij
Nerdfonts angenehm, aber nicht unbedingt nötig.
Terminologie
- Theme (https://zellij.dev/documentation/theme-list.html)
- Session
- Tab (= Tmux Window)
- Sync Tab
- Pane
- Stacked Panes
- Layout
- Layout Templates
- Modes: normal, locked, resize, pane, move, tab, scroll, search, session, tmux, shared (+ some others)
Builtin Layouts
classic (built-in)
compact (built-in)
Ohne Hilfezeile:
zellij --layout compact
disable-status-bar (built-in)
strider (built-in)
Filesystem explorer
$ zellij -V
zellij 0.42.2
Mein Alias zj
:
alias zj="zellij options --simplified-ui true --no-pane-frames --theme dracula \
--show-startup-tips false"
Konfiguration über KDL: https://kdl.dev (“A Cuddly Document Language”)
$ eza -T ~/.config/zellij/
~/.config/zellij
├── config.kdl
└── layouts
├── layout1.kdl
└── layout2.kdl
# bash completion
zellij setup --generate-completion bash
# initial config
$ zellij setup --dump-config > ~/.config/zellij/config.kdl
# check setup
$ zellij setup --check
# bash completion
$ zellij setup --generate-completion bash > ~/.bash_completion.d/zellij.bash
# without nerdfonts
$ zellij options --simplified-ui true --no-pane-frames \
--show-startup-tips false --theme dracula
# layout files
$ zellij --layout ~/.config/zellij/layout1.kdl
# Welcome screen
$ zellij -l welcome
# list sessions (ls)
$ zellij ls
# list plugin aliases (list-aliases, la)
$ zellij la
about
compact-bar
configuration
filepicker
plugin-manager
session-manager
status-bar
strider
tab-bar
welcome-screen
$ zellij action dump-screen [-f] <file>
$ zellij action dump-layout # dump to stdout
Egal ob man zellij mit Quit (C-g C-q) oder Detach (C-g o d) beendet, die Sessions werden aufgehoben. Siehe zellij ls
.
Locked Mode (C-g), damit man z.B. GNU Readline Tastaturkürzel eingeben kann:
C-p C-n C-b C-f C-a C-e ...
Mit Maus-Doppelklick werden Worte markiert, mit Dreifachklick Zeilen.
Plugins
- WASM (https://wasmtime.dev)
- Plugins angeben durch File, URL, zellij: (internal plugin URL)
- https://zellij.dev/documentation/plugin-examples: harpoon, jbz, monocle, multitask, room, zellij-forgot, zjstatus
Nützliche Kommandos
Alt-[
undAlt-]
Verschiedene AnsichtenAlt + n
New PaneAlt + ←↓↑→
Change FocusAlt + <+->
ResizeAlt + f
Floating
Pane History
- Enter search with
C-s
, then j, k C-s e
Edit Scrollbuffer
Tutorial
Mehr
Helix
“A post-modern modal text editor.”
vi → vim → neovim → helix (modern) (post modern)
Home: https://helix-editor.com (Alternativ: https://helixeditor.com)
selection → action
Vorbild: Kakoune Editor, https://kakoune.org
https://github.com/helix-editor/helix/wiki/Migrating-from-Vim
NOR (normal) | INS (insert)
Sieben Minor Modes
+---+ +---+ | v | select mode | z | view mode, Z: sticky view +---+ +---+ +---+ +---+ | g | goto mode |C-w| window mode +---+ +---+ +---+ +-----+ | m | match mode |Space| pickers and other mappings +---+ +-----+ +---+ | : | command mode +---+
Aktuelle Version
$ hx --version helix 25.01.1 (e7ac2fcd)
Konfiguration in
~/.config/helix
Language Server
- Python:
pip install -U python-lsp-server
- C:
apt install clangd clang-format
- Rust: https://rust-analyzer.github.io
- Markdown:
marksman
(https://github.com/artempyanykh/marksman)dprint
(https://dprint.dev)
- Über 250 Sprachen und Formate
$ hx --health Language Language servers Debug adapter Formatter Highlight Textobject Indent ... c ✓ clangd ✘ codelldb ✓ clang-format ✓ ✓ ✓ ... markdown ✓ marksman None ✓ dprint ✓ ✘ ✘ ... python ✓ pylsp None ✓ ruff ✓ ✓ ✓ ...
- Python:
Eingebautes Tutorial
hx --tutor
oder
:tutor
Sonstige
Alacritty Terminal Emulator
- https://alacritty.org
.config/alacritty/alacritty.toml
- Announcing Alacritty (2017), https://jwilm.io/blog/announcing-alacritty
- Geschwindigkeit: ~ 500 fps, teste mit
find /usr
WezTerm Terminal Emulator
Rio Terminal Emulator
A hardware-accelerated GPU terminal emulator powered by WebGPU, focusing to run in desktops and browsers.
Btm (bottom)
- aehnlich top
- Ctrl + ↑ ↓ ← →
- expand (e)
- https://linuxblog.io/bottom-btm
tealdeer (tldr in Rust)
- https://github.com/tealdeer-rs/tealdeer
~/local/tldr/<local-pages>
~/.config/tealdeer/config.toml
rusmux
Alternative in Rust zu tmuxinator (Ruby) und tmuxp. Damit kann man Layouts für
tmux
Windows und Panes in YAML Dateien schreiben.uutils
“The uutils project reimplements ubiquitous command line utilities in Rust. Our goal is to modernize the utils, while retaining full compatibility with the existing utilities.”
“We are planning to replace all essential Linux tools.”
Aktuell umfasst
uutils
coreutils
findutils
diffutils
$ ./coreutils coreutils 0.0.30 (multi-call binary) Usage: coreutils [function [arguments...]] coreutils --list Options: --list lists all defined functions, one per row Currently defined functions: [, arch, b2sum, b3sum, base32, base64, basename, basenc, cat, chgrp, chmod, chown, chroot, cksum, comm, cp, csplit, cut, date, dd, df, dir, dircolors, dirname, du, echo, env, expand, expr, factor, false, fmt, fold, groups, hashsum, head, hostid, hostname, id, install, join, kill, link, ln, logname, ls, md5sum, mkdir, mkfifo, mknod, mktemp, more, mv, nice, nl, nohup, nproc, numfmt, od, paste, pathchk, pr, printenv, printf, ptx, pwd, readlink, realpath, rm, rmdir, seq, sha1sum, sha224sum, sha256sum, sha3-224sum, sha3-256sum, sha3- 384sum, sha3-512sum, sha384sum, sha3sum, sha512sum, shake128sum, shake256sum, shred, shuf, sleep, sort, split, stat, stty, sum, sync, tac, tail, tee, test, timeout, touch, tr, true, truncate, tsort, tty, uname, unexpand, uniq, unlink, vdir, wc, whoami, yes
Viele weitere Rust Programme