Moderner CLI Stack mit Rust

Linux Infotag | 26.04.2025 | THA

Hubert Högl

https://hhoegl.informatik.hs-augsburg.de/pub/lit25

etc/logos.png

Zusammenfassung

Programm   Zweck        Linux    MacOS   Windows

eza        ls           ✅        ✅       ✅        
fd         find         ✅        ✅       ✅ 
rg         grep         ✅        ✅       ✅ 
starship   prompt       ✅        ✅       ✅ 
atuin      history      ✅        ✅         
zellij     term mux     ✅        ✅         
helix      editor       ✅        ✅       ✅ 

Rust

eza

Ersatz für ls.

Fork von exa (unmaintained).

https://eza.rocks

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.

rg

Starship

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

Zellij

$ 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

Nützliche Kommandos

  • Alt-[ und Alt-] Verschiedene Ansichten
  • Alt + n New Pane
  • Alt + ←↓↑→ Change Focus
  • Alt + <+-> Resize
  • Alt + f Floating

Pane History

  • Enter search with C-s, then j, k
  • C-s e Edit Scrollbuffer

Tutorial

Mehr

Helix

hx --tutor

oder

:tutor

Sonstige

  • Alacritty Terminal Emulator

  • WezTerm Terminal Emulator

  • Rio Terminal Emulator

    A hardware-accelerated GPU terminal emulator powered by WebGPU, focusing to run in desktops and browsers.

  • Btm (bottom)

  • tealdeer (tldr in Rust)

  • rusmux

    Alternative in Rust zu tmuxinator (Ruby) und tmuxp. Damit kann man Layouts für tmux Windows und Panes in YAML Dateien schreiben.

    https://github.com/MeirKriheli/rusmux

  • 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 
    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

    Lit.: https://lwn.net/Articles/1007907

  • Viele weitere Rust Programme

    https://www.tha.de/homes/hhoegl/home/RustTools.html