diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 74ce4df..c3ba481 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,3 +18,10 @@ jobs: for t in windows/arm64 windows/386 windows/amd64 darwin/arm64 darwin/amd64 linux/amd64; do CGO_ENABLED=0 GOOS=${t%/*} GOARCH=${t#*/} go build -o /dev/null ./cmd/sshtermy done + + packaging: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - run: sudo apt-get install -y -qq apt-utils python3-yaml >/dev/null + - run: packaging/check.sh diff --git a/.github/workflows/pages.yml b/.github/workflows/pages.yml new file mode 100644 index 0000000..0fae371 --- /dev/null +++ b/.github/workflows/pages.yml @@ -0,0 +1,64 @@ +# Webseite (site/, Englisch + Deutsch) und apt-Paketquelle auf GitHub Pages: +# https://db9979.github.io/sshtermy/ Anleitung +# https://db9979.github.io/sshtermy/apt/ apt-Quelle (.deb aus dem neuesten Release) +# Läuft nach jedem Release und bei Änderungen an der Webseite. +# Einmalig nötig: Settings → Pages → Source „GitHub Actions“. +name: pages + +on: + push: + branches: [main] + paths: ["site/**", "docs/bilder/**", "packaging/apt-repo.sh", ".github/workflows/pages.yml"] + workflow_run: + workflows: [release] + types: [completed] + workflow_dispatch: + +permissions: + contents: read + pages: write + id-token: write + +concurrency: + group: pages + cancel-in-progress: false + +jobs: + build: + if: github.event_name != 'workflow_run' || github.event.workflow_run.conclusion == 'success' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + ref: main + + - name: Webseite zusammenstellen + run: | + mkdir -p _site + cp -r site/. _site/ + mkdir -p _site/bilder && cp docs/bilder/*.png _site/bilder/ + + - name: apt-Quelle aus dem neuesten Release + env: + GH_TOKEN: ${{ github.token }} + APT_GPG_PRIVATE_KEY: ${{ secrets.APT_GPG_PRIVATE_KEY }} + run: | + mkdir -p _site/apt + gh release download --repo "$GITHUB_REPOSITORY" --pattern '*.deb' --dir _site/apt || echo "noch kein Release mit .deb" + sudo apt-get install -y -qq apt-utils >/dev/null + packaging/apt-repo.sh _site/apt + ls -la _site/apt + + - uses: actions/upload-pages-artifact@v3 + with: + path: _site + + deploy: + needs: build + runs-on: ubuntu-latest + environment: + name: github-pages + url: ${{ steps.d.outputs.page_url }} + steps: + - id: d + uses: actions/deploy-pages@v4 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 970d6e8..52b85a6 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,12 +1,14 @@ # Bei jedem Push auf main: testen, Version hochzählen (MAJOR.MINOR aus VERSION, # PATCH = Anzahl Commits), für alle Plattformen bauen, signieren und als # GitHub Release veröffentlichen. Die App findet das Release per Auto-Update. +# Dazu: .deb-Pakete (apt-Quelle baut pages.yml) und die Homebrew-Formel +# (Formula/sshtermy.rb, dieses Repo ist der Tap). winget: winget.yml. name: release on: push: branches: [main] - paths-ignore: ["docs/**", "**.md"] + paths-ignore: ["docs/**", "site/**", "Formula/**", "**.md"] workflow_dispatch: permissions: @@ -59,6 +61,13 @@ jobs: done cd dist && sha256sum sshtermy_* > checksums.txt && cat checksums.txt + - name: Debian-Pakete (amd64, arm64) + run: | + for a in amd64 arm64; do + packaging/deb.sh ${{ steps.v.outputs.version }} $a dist/sshtermy_linux_$a dist + done + cd dist && sha256sum sshtermy_* > checksums.txt && cat checksums.txt + - name: Signieren (Ed25519) env: UPDATE_SIGNING_KEY: ${{ secrets.UPDATE_SIGNING_KEY }} @@ -70,7 +79,7 @@ jobs: GH_TOKEN: ${{ github.token }} run: | V=${{ steps.v.outputs.version }} - gh release create "v$V" dist/* --title "sshTermy v$V" --notes-file notes.md --latest + gh release create "v$V" dist/sshtermy_* dist/checksums.txt* --title "sshTermy v$V" --notes-file notes.md --latest - name: Alte Releases aufräumen (die letzten 10 bleiben) env: @@ -79,3 +88,20 @@ jobs: gh release list --limit 100 --json tagName --jq '.[10:][].tagName' | while read -r tag; do gh release delete "$tag" --yes --cleanup-tag || true done + + - name: Homebrew-Formel aktualisieren (Formula/sshtermy.rb in main) + continue-on-error: true # z. B. Branch-Schutz: Release ist trotzdem draußen + run: | + V=${{ steps.v.outputs.version }} + git config user.name "github-actions[bot]" + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" + for i in 1 2 3 4; do + git fetch -q origin main && git checkout -q -f -B formula origin/main + mkdir -p Formula && packaging/formula.sh "$V" dist/checksums.txt > Formula/sshtermy.rb + git add Formula/sshtermy.rb + git diff --cached --quiet && exit 0 + git commit -q -m "Homebrew-Formel für v$V" + git push -q origin HEAD:main && exit 0 + sleep $((i * 3)) + done + exit 1 diff --git a/.github/workflows/winget.yml b/.github/workflows/winget.yml new file mode 100644 index 0000000..098b595 --- /dev/null +++ b/.github/workflows/winget.yml @@ -0,0 +1,36 @@ +# Neueste Version bei winget einreichen (Pull Request an microsoft/winget-pkgs). +# Von Hand starten (Actions → winget → Run workflow), nicht bei jedem Release: +# jede Einreichung prüfen dort Menschen, tägliche PRs wären zu viel. +# Einmalig nötig: Secret WINGET_TOKEN = klassischer GitHub-Token mit „public_repo“ +# (wingetcreate legt damit einen Fork von winget-pkgs im eigenen Konto an). +name: winget + +on: + workflow_dispatch: + +permissions: + contents: read + +jobs: + submit: + runs-on: windows-latest + steps: + - uses: actions/checkout@v4 + + - name: Manifeste für das neueste Release schreiben + shell: bash + env: + GH_TOKEN: ${{ github.token }} + run: | + tag=$(gh release view --repo "$GITHUB_REPOSITORY" --json tagName --jq .tagName) + gh release download "$tag" --repo "$GITHUB_REPOSITORY" --pattern checksums.txt --dir rel + packaging/winget.sh "${tag#v}" rel/checksums.txt out + echo "DIR=$(cygpath -w "$(ls -d out/manifests/d/db9979/sshTermy/*)")" >> "$GITHUB_ENV" + + - name: Einreichen + env: + WINGET_TOKEN: ${{ secrets.WINGET_TOKEN }} + run: | + if (-not $env:WINGET_TOKEN) { throw "Secret WINGET_TOKEN fehlt (siehe Kommentar oben in winget.yml)" } + Invoke-WebRequest https://aka.ms/wingetcreate/latest -OutFile wingetcreate.exe + .\wingetcreate.exe submit --token $env:WINGET_TOKEN $env:DIR diff --git a/.gitignore b/.gitignore index f58df65..b2e373f 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ *.old *.new .DS_Store +tools/dev/gifs/out/ diff --git a/README.de.md b/README.de.md index ee6d571..7c4078a 100644 --- a/README.de.md +++ b/README.de.md @@ -62,7 +62,21 @@ Das Bedienkonzept der KI (Vorschläge, Ziel-Modus, feste Gefahrenregeln) stammt ## Installation -Lade die passende Datei aus den [Releases](https://github.com/db9979/sshtermy/releases/latest): +📖 Anleitung mit Animationen: **https://db9979.github.io/sshtermy/de/** + +**Paketquellen** (die kümmern sich auch um Updates): + +``` +winget install db9979.sshTermy # Windows (sobald im winget-Katalog freigegeben) +brew tap db9979/sshtermy https://github.com/db9979/sshtermy # macOS und Linux +brew install sshtermy +echo "deb [trusted=yes] https://db9979.github.io/sshtermy/apt ./" | sudo tee /etc/apt/sources.list.d/sshtermy.list +sudo apt update && sudo apt install sshtermy # Debian, Ubuntu (amd64, arm64) +``` + +Über Homebrew oder apt installiert, tauscht sshTermy sich nicht selbst aus, sondern zeigt den Update-Befehl. + +Oder lade die passende Datei aus den [Releases](https://github.com/db9979/sshtermy/releases/latest): | System | Datei | |---|---| diff --git a/README.md b/README.md index ba95915..e42ef9a 100644 --- a/README.md +++ b/README.md @@ -62,7 +62,21 @@ The AI interaction concept (suggestions, goal mode, fixed danger rules) comes fr ## Installation -Download the matching file from the [Releases](https://github.com/db9979/sshtermy/releases/latest): +📖 Guide with animations: **https://db9979.github.io/sshtermy/** + +**Package managers** (they also take care of updates): + +``` +winget install db9979.sshTermy # Windows (once approved in the winget catalog) +brew tap db9979/sshtermy https://github.com/db9979/sshtermy # macOS and Linux +brew install sshtermy +echo "deb [trusted=yes] https://db9979.github.io/sshtermy/apt ./" | sudo tee /etc/apt/sources.list.d/sshtermy.list +sudo apt update && sudo apt install sshtermy # Debian, Ubuntu (amd64, arm64) +``` + +Installed via Homebrew or apt, sshTermy does not replace itself but shows the update command instead. + +Or download the matching file from the [Releases](https://github.com/db9979/sshtermy/releases/latest): | System | File | |---|---| diff --git a/internal/i18n/en.go b/internal/i18n/en.go index b7b27c4..ad3aba9 100644 --- a/internal/i18n/en.go +++ b/internal/i18n/en.go @@ -3,11 +3,11 @@ package i18n // en: deutscher Text → englische Fassung. Schlüssel sind die deutschen // Texte aus dem Code (i18n.T); fehlt ein Eintrag, bleibt der deutsche Text. var en = map[string]string{ - "\n\nj = ja · n = nein": "\n\ny = yes · n = no", - "\n\nu = jetzt aktualisieren · ": "\n\nu = update now · ", - "\nDer Inhalt (%s) rückt in %s. Es wird keine Verbindung gelöscht.": "\nIts content (%s) moves to %s. No connection is deleted.", - "\nFingerprint: ": "\nFingerprint: ", - "\nLiegt in: ": "\nLocated in: ", + "\n\nj = ja · n = nein": "\n\ny = yes · n = no", + "u = jetzt aktualisieren · ": "u = update now · ", + "\nDer Inhalt (%s) rückt in %s. Es wird keine Verbindung gelöscht.": "\nIts content (%s) moves to %s. No connection is deleted.", + "\nFingerprint: ": "\nFingerprint: ", + "\nLiegt in: ": "\nLocated in: ", " Leertaste wählen · g Ordner · a alle": " Space selects · g folder · a all", " ⏎ oder Doppelklick belegt neu · werden mit dem Sync übernommen": " ⏎ or double-click rebinds · synced to other computers", " %d Datei(en) nicht lesbar": " %d file(s) not readable", @@ -15,12 +15,12 @@ var en = map[string]string{ " %d gewählt · Ordner „%s“ · Benutzer %s": " %d selected · folder „%s“ · user %s", " %d–%d von %d": " %d–%d of %d", " (laufende Befehle, Tunnel und Dateiübertragungen brechen ab).\n\n": " (running commands, tunnels and file transfers are aborted).\n\n", - " (von Hand)": " (manual)", - " Esc schließen": " Esc closes", - " KI-Agent": " AI agent", - " Keine SSH-Geräte gefunden. Subnetz oder Port prüfen (r).": " No SSH devices found. Check subnet or port (r).", - " Keine Treffer.": " No matches.", - " Nichts gefunden.\n Esc = Filter aufheben": " Nothing found.\n Esc = clear filter", + " (von Hand)": " (manual)", + " Esc schließen": " Esc closes", + " KI-Agent": " AI agent", + " Keine SSH-Geräte gefunden. Subnetz oder Port prüfen (r).": " No SSH devices found. Check subnet or port (r).", + " Keine Treffer.": " No matches.", + " Nichts gefunden.\n Esc = Filter aufheben": " Nothing found.\n Esc = clear filter", " Noch keine Protokolle.\n Jede SSH-Sitzung wird ab dem\n ersten Befehl mitgeschrieben.": " No logs yet.\n Every SSH session is recorded\n from its first command.", " Noch keine Verbindung.\n n = neue Verbindung anlegen\n o = Ordner anlegen": " No connections yet.\n n = add a new connection\n o = add a folder", " Port %d": " port %d", @@ -1137,33 +1137,35 @@ var en = map[string]string{ "ungültiger Name": "invalid name", "unter dieser Adresse antwortet kein WebDAV (HTTP %d)": "no WebDAV answers at this address (HTTP %d)", "update: HTTP %d": "update: HTTP %d", - "update: Prüfsumme stimmt nicht, Download verworfen": "update: checksum does not match, download discarded", - "update: Release enthält %s oder checksums.txt nicht": "update: release does not contain %s or checksums.txt", - "update: Signatur fehlt": "update: signature missing", - "update: Signatur ungültig, Update abgelehnt": "update: signature invalid, update rejected", - "update: URL nicht erlaubt: %s": "update: URL not allowed: %s", - "update: Weiterleitung nach %s abgelehnt": "update: redirect to %s rejected", - "update: eingebauter Schlüssel ungültig": "update: built-in key invalid", - "update: keine Prüfsumme für ": "update: no checksum for ", - "update: keine Schreibrechte im Programmordner: %w": "update: no write permission in the program folder: %w", - "vault: DPAPI auf diesem System nicht verfügbar": "vault: DPAPI not available on this system", - "vault: DPAPI-Entsperren fehlgeschlagen: %v": "vault: DPAPI unlock failed: %v", - "vault: DPAPI: %w": "vault: DPAPI: %w", - "vault: Datei unlesbar: %w": "vault: file unreadable: %w", - "vault: Master-Passwort braucht mindestens 8 Zeichen": "vault: master password needs at least 8 characters", - "vault: Master-Passwort falsch oder Datei verändert": "vault: wrong master password or file modified", - "vault: gesperrt": "vault: locked", - "vault: kein Entsperr-Weg verfügbar (Passwort nötig)": "vault: no way to unlock (password needed)", - "vault: unbekanntes Format %q v%d": "vault: unknown format %q v%d", - "vault: ungültige KDF-Parameter": "vault: invalid KDF parameters", - "verbinde …": "connecting …", - "verbinden": "connect", - "verbindet": "connects", - "verbindet neu": "reconnects", - "verbindet neu (⏎ / Esc)": "reconnects (⏎ / Esc)", - "verboten (HTTP 403)": "forbidden (HTTP 403)", - "verschieben": "move", - "verschlüsselt gespeichert; leer für lokale Server": "stored encrypted; empty for local servers", + "update: Prüfsumme stimmt nicht, Download verworfen": "update: checksum does not match, download discarded", + "update: Release enthält %s oder checksums.txt nicht": "update: release does not contain %s or checksums.txt", + "update: Signatur fehlt": "update: signature missing", + "über eine Paketquelle installiert, aktualisieren mit: ": "installed from a package manager, update with: ", + "Aktualisieren mit: ": "Update with: ", + "update: Signatur ungültig, Update abgelehnt": "update: signature invalid, update rejected", + "update: URL nicht erlaubt: %s": "update: URL not allowed: %s", + "update: Weiterleitung nach %s abgelehnt": "update: redirect to %s rejected", + "update: eingebauter Schlüssel ungültig": "update: built-in key invalid", + "update: keine Prüfsumme für ": "update: no checksum for ", + "update: keine Schreibrechte im Programmordner: %w": "update: no write permission in the program folder: %w", + "vault: DPAPI auf diesem System nicht verfügbar": "vault: DPAPI not available on this system", + "vault: DPAPI-Entsperren fehlgeschlagen: %v": "vault: DPAPI unlock failed: %v", + "vault: DPAPI: %w": "vault: DPAPI: %w", + "vault: Datei unlesbar: %w": "vault: file unreadable: %w", + "vault: Master-Passwort braucht mindestens 8 Zeichen": "vault: master password needs at least 8 characters", + "vault: Master-Passwort falsch oder Datei verändert": "vault: wrong master password or file modified", + "vault: gesperrt": "vault: locked", + "vault: kein Entsperr-Weg verfügbar (Passwort nötig)": "vault: no way to unlock (password needed)", + "vault: unbekanntes Format %q v%d": "vault: unknown format %q v%d", + "vault: ungültige KDF-Parameter": "vault: invalid KDF parameters", + "verbinde …": "connecting …", + "verbinden": "connect", + "verbindet": "connects", + "verbindet neu": "reconnects", + "verbindet neu (⏎ / Esc)": "reconnects (⏎ / Esc)", + "verboten (HTTP 403)": "forbidden (HTTP 403)", + "verschieben": "move", + "verschlüsselt gespeichert; leer für lokale Server": "stored encrypted; empty for local servers", "versteckte": "hidden", "versteckte Dateien": "hidden files", "vertrauen": "trust", diff --git a/internal/ui/modal.go b/internal/ui/modal.go index 87ff552..e189a06 100644 --- a/internal/ui/modal.go +++ b/internal/ui/modal.go @@ -81,7 +81,12 @@ func (a *App) aboutModal() *modal { i18n.T("KI ohne Werkzeuge: jeder Befehl braucht deine Bestätigung.\n\n") + i18n.T("☕ Gefällt dir sshTermy? Spendier einen Kaffee: ") + version.Coffee + "\n\n" if a.rel != nil { - b += i18n.T("⬆ Neue Version v") + a.rel.Version + i18n.T(" verfügbar.\n") + firstLines(a.rel.Notes, 6) + i18n.T("\n\nu = jetzt aktualisieren · ") + b += i18n.T("⬆ Neue Version v") + a.rel.Version + i18n.T(" verfügbar.\n") + firstLines(a.rel.Notes, 6) + "\n\n" + if cmd := update.Managed(); cmd != "" { + b += i18n.T("Aktualisieren mit: ") + cmd + "\n\n" + } else { + b += i18n.T("u = jetzt aktualisieren · ") + } } else if a.restartPending != "" { b += "v" + a.restartPending + i18n.T(" ist installiert.\n\nr = jetzt neu starten · ") } else { @@ -173,7 +178,7 @@ func (a *App) modalKey(k tea.KeyPressMsg) tea.Cmd { case mAbout: switch key { case "u": - if a.rel != nil { + if a.rel != nil && update.Managed() == "" { rel := a.rel a.modal = &modal{kind: mBusy, title: "Update", body: i18n.T("Lade v") + rel.Version + i18n.T(", prüfe Signatur und Prüfsumme …")} return func() tea.Msg { return applyDoneMsg{update.Apply(context.Background(), rel)} } diff --git a/internal/update/managed.go b/internal/update/managed.go new file mode 100644 index 0000000..cf83c40 --- /dev/null +++ b/internal/update/managed.go @@ -0,0 +1,42 @@ +package update + +import ( + "os" + "runtime" + "strings" + + "github.com/db9979/sshtermy/internal/i18n" +) + +// Managed: Befehl zum Aktualisieren, wenn sshTermy über eine Paketquelle +// installiert wurde (Homebrew, apt). Dann tauscht sshTermy sich nicht selbst +// aus: apt hält /usr/bin schreibgeschützt, und Homebrew würde eine fremd +// ausgetauschte Datei im Cellar nicht kennen. Leer = selbst aktualisieren. +// winget (portable) bleibt beim Selbst-Update, der Ordner gehört dem Nutzer. +func Managed() string { + exe, err := Executable() + if err != nil { + return "" + } + return managedBy(exe, runtime.GOOS, fileExists) +} + +func managedBy(exe, goos string, exists func(string) bool) string { + p := strings.ReplaceAll(exe, "\\", "/") + if goos != "windows" && (strings.Contains(p, "/Cellar/") || strings.HasPrefix(p, "/opt/homebrew/") || strings.HasPrefix(p, "/home/linuxbrew/")) { + return "brew upgrade sshtermy" + } + if goos == "linux" && p == "/usr/bin/sshtermy" && exists("/var/lib/dpkg/info/sshtermy.list") { + return "sudo apt update && sudo apt install --only-upgrade sshtermy" + } + return "" +} + +func fileExists(p string) bool { _, err := os.Stat(p); return err == nil } + +// ManagedError: Fehlermeldung für Apply bei Paketquellen-Installation. +type ManagedError struct{ Cmd string } + +func (e ManagedError) Error() string { + return i18n.T("über eine Paketquelle installiert, aktualisieren mit: ") + e.Cmd +} diff --git a/internal/update/managed_test.go b/internal/update/managed_test.go new file mode 100644 index 0000000..900bb45 --- /dev/null +++ b/internal/update/managed_test.go @@ -0,0 +1,26 @@ +package update + +import "testing" + +func TestManagedBy(t *testing.T) { + yes := func(string) bool { return true } + no := func(string) bool { return false } + cases := []struct { + exe, goos string + exists func(string) bool + want string + }{ + {"/opt/homebrew/Cellar/sshtermy/1.0.40/bin/sshtermy", "darwin", no, "brew upgrade sshtermy"}, + {"/usr/local/Cellar/sshtermy/1.0.40/bin/sshtermy", "darwin", no, "brew upgrade sshtermy"}, + {"/home/linuxbrew/.linuxbrew/Cellar/sshtermy/1.0.40/bin/sshtermy", "linux", no, "brew upgrade sshtermy"}, + {"/usr/bin/sshtermy", "linux", yes, "sudo apt update && sudo apt install --only-upgrade sshtermy"}, + {"/usr/bin/sshtermy", "linux", no, ""}, + {"/Users/d/Applications/sshTermy.app/Contents/Resources/sshtermy", "darwin", yes, ""}, + {`C:\Users\d\AppData\Local\Microsoft\WinGet\Packages\db9979.sshTermy_x\sshtermy.exe`, "windows", yes, ""}, + } + for _, c := range cases { + if got := managedBy(c.exe, c.goos, c.exists); got != c.want { + t.Errorf("%s: %q, want %q", c.exe, got, c.want) + } + } +} diff --git a/internal/update/update.go b/internal/update/update.go index 6c5abcd..8f6aab7 100644 --- a/internal/update/update.go +++ b/internal/update/update.go @@ -166,6 +166,9 @@ func parse(v string) ([3]int, bool) { // Apply lädt, prüft und tauscht die laufende Datei aus. func Apply(ctx context.Context, rel *Release) error { + if cmd := Managed(); cmd != "" { + return ManagedError{cmd} + } name := AssetName() binURL, ok1 := rel.assets[name] sumURL, ok2 := rel.assets["checksums.txt"] diff --git a/packaging/apt-repo.sh b/packaging/apt-repo.sh new file mode 100755 index 0000000..b3ce8eb --- /dev/null +++ b/packaging/apt-repo.sh @@ -0,0 +1,30 @@ +#!/bin/sh +# Baut ein flaches apt-Repository aus .deb-Dateien (für GitHub Pages): +# packaging/apt-repo.sh _site/apt (die .deb liegen schon dort) +# Mit APT_GPG_PRIVATE_KEY (ASCII-armored, ohne Passphrase) wird signiert: +# InRelease, Release.gpg und der öffentliche Schlüssel sshtermy.gpg. +# Ohne Schlüssel bleibt das Repo unsigniert (Einbinden mit [trusted=yes]). +set -eu +dir="$1" +cd "$dir" +rm -f Release InRelease Release.gpg +apt-ftparchive packages . >Packages +gzip -9kf Packages +apt-ftparchive \ + -o APT::FTPArchive::Release::Origin=sshTermy \ + -o APT::FTPArchive::Release::Label=sshTermy \ + -o APT::FTPArchive::Release::Suite=stable \ + -o APT::FTPArchive::Release::Codename=stable \ + -o APT::FTPArchive::Release::Description="sshTermy – SSH terminal with an AI copilot" \ + release . >Release +if [ -n "${APT_GPG_PRIVATE_KEY:-}" ]; then + export GNUPGHOME="$(mktemp -d)" + printf '%s\n' "$APT_GPG_PRIVATE_KEY" | gpg --batch --import 2>/dev/null + gpg --batch --yes --pinentry-mode loopback --clearsign -o InRelease Release + gpg --batch --yes --pinentry-mode loopback -abs -o Release.gpg Release + gpg --batch --export >sshtermy.gpg + rm -rf "$GNUPGHOME" + echo "apt: signiert" +else + echo "apt: ohne Signatur (Secret APT_GPG_PRIVATE_KEY fehlt)" +fi diff --git a/packaging/check.sh b/packaging/check.sh new file mode 100755 index 0000000..08b910e --- /dev/null +++ b/packaging/check.sh @@ -0,0 +1,56 @@ +#!/bin/sh +# CI-Prüfung der Paket-Skripte mit Dummy-Dateien und der Webseite (Links, +# Bilder). Lokal: packaging/check.sh +set -eu +t="$(mktemp -d)" +trap 'rm -rf "$t"' EXIT INT TERM +mkdir -p "$t/dist" +for n in windows_arm64.exe windows_386.exe windows_amd64.exe darwin_arm64 darwin_amd64 linux_amd64 linux_arm64; do + printf '#!/bin/sh\necho "sshTermy v1.0.0"\n' >"$t/dist/sshtermy_$n" +done +(cd "$t/dist" && sha256sum sshtermy_* >checksums.txt) + +packaging/deb.sh 1.0.0 amd64 "$t/dist/sshtermy_linux_amd64" "$t/apt" >/dev/null +dpkg-deb -f "$t/apt/sshtermy_1.0.0_amd64.deb" Package Version Architecture +packaging/apt-repo.sh "$t/apt" +grep -q "^Filename: ./sshtermy_1.0.0_amd64.deb" "$t/apt/Packages" + +packaging/formula.sh 1.0.0 "$t/dist/checksums.txt" >"$t/sshtermy.rb" +ruby -c "$t/sshtermy.rb" +[ "$(grep -c 'sha256 "[0-9a-f]\{64\}"' "$t/sshtermy.rb")" = 4 ] + +d="$(packaging/winget.sh 1.0.0 "$t/dist/checksums.txt" "$t/w")" +python3 - "$d" <<'PY' +import sys, glob, yaml +files = glob.glob(sys.argv[1] + "/*.yaml") +assert len(files) == 4, files +for f in files: + m = yaml.safe_load(open(f, encoding="utf-8")) + assert m["PackageIdentifier"] == "db9979.sshTermy" and m["PackageVersion"] == "1.0.0", f + for i in m.get("Installers", []): + assert len(i["InstallerSha256"]) == 64, i +print("winget ok:", len(files), "Manifeste") +PY + +# Webseite: jede lokale href/src muss existieren (bilder/ kommt aus docs/bilder). +python3 - <<'PY' +import re, os, sys +bad = 0 +for root, _, files in os.walk("site"): + for f in files: + if not f.endswith(".html"): + continue + p = os.path.join(root, f) + for ref in re.findall(r'(?:href|src)="([^"#:?]+)"', open(p, encoding="utf-8").read()): + if ref.startswith("//"): + continue + q = os.path.normpath(os.path.join(root, ref)) + if q.startswith("site/bilder/"): + q = "docs/bilder/" + q[len("site/bilder/"):] + if ref.endswith("/"): + q = os.path.join(q, "index.html") + if not os.path.exists(q): + print("fehlt:", p, "->", ref); bad += 1 +sys.exit(1 if bad else 0) +PY +echo "packaging ok" diff --git a/packaging/deb.sh b/packaging/deb.sh new file mode 100755 index 0000000..77de2f1 --- /dev/null +++ b/packaging/deb.sh @@ -0,0 +1,35 @@ +#!/bin/sh +# Baut ein .deb aus einer fertigen Programmdatei (kein Kompilieren hier). +# packaging/deb.sh 1.0.42 amd64 dist/sshtermy_linux_amd64 dist +# Ergebnis: dist/sshtermy_1.0.42_amd64.deb (Programm unter /usr/bin/sshtermy). +set -eu +ver="$1"; arch="$2"; bin="$3"; out="$4" + +root="$(mktemp -d)" +trap 'rm -rf "$root"' EXIT INT TERM +chmod 755 "$root" +install -Dm755 "$bin" "$root/usr/bin/sshtermy" +install -d "$root/usr/share/doc/sshtermy" "$root/DEBIAN" +cat >"$root/usr/share/doc/sshtermy/copyright" <<'TXT' +sshTermy – SSH terminal with an AI copilot +Idea: Dominik Bornhäußer +Source: https://github.com/db9979/sshtermy +TXT +size="$(du -sk "$root/usr" | cut -f1)" +cat >"$root/DEBIAN/control" < +Installed-Size: $size +Section: net +Priority: optional +Homepage: https://db9979.github.io/sshtermy/ +Description: SSH terminal with an AI copilot + sshTermy is a terminal application (TUI) with a connection manager, + encrypted store, SFTP, tunnels, broadcast and an AI copilot for any + OpenAI-compatible endpoint. Updates come through apt. +TXT +mkdir -p "$out" +dpkg-deb --root-owner-group --build "$root" "$out/sshtermy_${ver}_${arch}.deb" >/dev/null +echo "$out/sshtermy_${ver}_${arch}.deb" diff --git a/packaging/formula.sh b/packaging/formula.sh new file mode 100755 index 0000000..cb20ec4 --- /dev/null +++ b/packaging/formula.sh @@ -0,0 +1,51 @@ +#!/bin/sh +# Schreibt die Homebrew-Formel für ein Release (Tap = dieses Repo): +# packaging/formula.sh 1.0.42 dist/checksums.txt > Formula/sshtermy.rb +# Installation: brew tap db9979/sshtermy https://github.com/db9979/sshtermy +# brew install sshtermy +set -eu +ver="$1"; sums="$2" +sha() { + s="$(awk -v n="$1" '{f=$2; sub(/^\*/, "", f); if (f == n) print tolower($1)}' "$sums")" + [ -n "$s" ] || { echo "formula.sh: keine Prüfsumme für $1" >&2; exit 1; } + echo "$s" +} +u="https://github.com/db9979/sshtermy/releases/download/v$ver" +cat < "sshtermy" + end + + test do + assert_match version.to_s, shell_output("#{bin}/sshtermy --version") + end +end +RB diff --git a/packaging/winget.sh b/packaging/winget.sh new file mode 100755 index 0000000..a24fa99 --- /dev/null +++ b/packaging/winget.sh @@ -0,0 +1,88 @@ +#!/bin/sh +# Schreibt die winget-Manifeste (portable .exe) für ein Release: +# packaging/winget.sh 1.0.42 dist/checksums.txt out/ +# Ergebnis: out/manifests/d/db9979/sshTermy/1.0.42/*.yaml, so wie im Repo +# microsoft/winget-pkgs. Eingereicht wird mit .github/workflows/winget.yml. +set -eu +ver="$1"; sums="$2"; out="$3" +id="db9979.sshTermy" +sha() { + s="$(awk -v n="$1" '{f=$2; sub(/^\*/, "", f); if (f == n) print toupper($1)}' "$sums")" + [ -n "$s" ] || { echo "winget.sh: keine Prüfsumme für $1" >&2; exit 1; } + echo "$s" +} +u="https://github.com/db9979/sshtermy/releases/download/v$ver" +d="$out/manifests/d/db9979/sshTermy/$ver" +mkdir -p "$d" +mv_="1.6.0" +hdr="# yaml-language-server: \$schema=https://aka.ms/winget-manifest" + +cat >"$d/$id.yaml" <"$d/$id.installer.yaml" <"$d/$id.locale.en-US.yaml" <"$d/$id.locale.de-DE.yaml" < + + + + +sshTermy – SSH-Terminal mit KI-Copilot + + + + + + +
+ +
+ +
+
+

SSH-Terminal mit KI-Copilot

+

Eine kleine Datei für Windows, macOS und Linux. Verbindungsmanager, echtes Terminal, SFTP und Tunnel, dazu eine KI, die Befehle vorschlägt, ein Ziel Schritt für Schritt umsetzt und Fehler erklärt. Jeder Befehl braucht deine Bestätigung.

+

Idee: Dominik Bornhäußer

+ +
+ Ziel-Modus: die KI richtet Nginx Schritt für Schritt ein, jeder Befehl wird mit Enter bestätigt +
Ziel-Modus (F2): Ziel beschreiben, die KI schlägt immer genau einen Befehl vor, du bestätigst.
+
+
+ +
+

Installieren

+

Wähle dein System. Jeder Weg installiert dasselbe Release von GitHub.

+
+
+

Windows ARM64 · x64 · x86

+

Mit winget (Windows 11 und 10):

+
winget install db9979.sshTermy
+

Verfügbar, sobald das Paket im winget-Katalog freigegeben ist.

+

Oder die .exe für deinen Prozessor aus den Releases laden und im Windows Terminal starten.

+
+
+

macOS Apple Silicon · Intel

+

Mit Homebrew:

+
brew tap db9979/sshtermy https://github.com/db9979/sshtermy
+brew install sshtermy
+

Oder mit einer Zeile, die zusätzlich ~/Applications/sshTermy.app anlegt:

+
curl -fsSL https://raw.githubusercontent.com/db9979/sshtermy/main/install.sh | sh
+
+
+

Linux amd64 · arm64

+

Debian, Ubuntu, Raspberry Pi OS 64 Bit (apt):

+
echo "deb [trusted=yes] https://db9979.github.io/sshtermy/apt ./" | sudo tee /etc/apt/sources.list.d/sshtermy.list
+sudo apt update && sudo apt install sshtermy
+

Homebrew und der Einzeiler von oben gehen auch unter Linux.

+
+
+

Danach sshtermy eingeben. Beim ersten Start legst du ein Master-Passwort für deinen verschlüsselten Speicher fest.

+
+ +
+

Rundgang

+
+
+

Entsperren, Host wählen, los

+

Verbindungen, Passwörter und Schlüssel liegen in einem verschlüsselten Speicher (AES-256-GCM, Argon2id, unter Windows zusätzlich DPAPI). Der Manager zeigt Ordner, Tags und Details, Enter verbindet. Die Statuszeile zeigt sofort Last, RAM und Platte des Servers.

+
+
Startanimation, Entsperren mit dem Master-Passwort, Verbinden mit web-01
+
+
+
+

Ghost-Text und Fehler erklärt

+

Beim Tippen ergänzt die KI die Zeile in Grau, Tab übernimmt. Nach jedem Befehl gibt es Folgebefehle (Alt+1…4). Schlägt ein Befehl fehl, fragt Alt+0 die KI nach dem Grund, mit der Ausgabe als Kontext, und 1…9 fügt einen vorgeschlagenen Fix ein.

+
+
Ghost-Text ergänzt systemctl status nginx, der Befehl schlägt fehl, Alt+0 erklärt den Grund und fügt den Fix ein
+
+
+
+

Eine Palette für alles

+

Strg+Leertaste öffnet die Befehlspalette: Aktionen, Tunnel, Verbindungen und Runbooks. Freier Text wird ein Ziel (Enter) oder eine Frage an die KI (Tab).

+
+
Die Befehlspalette filtert Aktionen, dann geht eine Frage mit Terminal-Kontext an die KI
+
+
+ +
+

Funktionen

+
+

Verbindungsmanager

Ordner, Tags, Jump-Hosts, Import aus ~/.ssh/config, PuTTY und MobaXterm.

+

Echtes Terminal

xterm-256color, Truecolor, vim, htop und tmux, Scrollback, Tabs, geteilte Ansicht, Suche.

+

Auto-Reconnect

Reißt WLAN oder VPN ab, kommt die Sitzung von selbst zurück, mit Tunneln und tmux/screen.

+

Dateien (F5)

SFTP über dieselbe Verbindung: links lokal, rechts der Server.

+

Host-Übersicht (F6)

CPU, Last, RAM, Platte und Updates bei Servern; Firmware, Ports und VLANs bei Aruba- und Cisco-Switches, mit Konfig-Sicherung und Diff.

+

Tunnel

-L, -R, -D (SOCKS5) und Webdienste mit einem Klick.

+

Broadcast

Ein Befehl oder Runbook parallel auf einer ganzen Gruppe, Ergebnisse nebeneinander.

+

Netzwerk-Scan

SSH-Geräte in einem Subnetz finden und als Verbindungen anlegen.

+

Gefahr-Regeln

Feste Regeln markieren riskante Befehle rot; sie brauchen zweimal Enter, auch beim Einfügen.

+

Sitzungsprotokoll

Verschlüsselt, durchsuchbar, mit KI-Zusammenfassung und Markdown-Export.

+

Sync

Ende-zu-Ende-verschlüsselt über OneDrive, Dropbox, iCloud, Syncthing oder WebDAV (Synology, Nextcloud).

+

Systemprofil

Kennt Linux-Distributionen, macOS, Windows und Netzwerk-Dialekte, damit die KI passende Befehle vorschlägt.

+
+
+
Verbindungsmanager
Verbindungsmanager
+
Host-Übersicht eines Switches
Host-Übersicht eines Switches (F6)
+
Dateien per SFTP
Dateien per SFTP (F5)
+
Gefährlicher Befehl braucht Bestätigung
Gefahr-Regeln
+
+
+ +
+

KI einrichten

+

sshTermy spricht mit jedem OpenAI-kompatiblen Endpunkt (/v1/chat/completions): Ollama, vLLM, SGLang, LiteLLM, LocalAI oder OpenAI selbst. Mit einem lokalen Modell bleibt dein Terminal-Inhalt auf deiner eigenen Hardware.

+
    +
  1. Im Manager s drücken (KI-Einstellungen).
  2. +
  3. URL eintragen, z. B. http://localhost:11434/v1 für Ollama, und einen API-Schlüssel, falls der Endpunkt einen braucht (wird verschlüsselt gespeichert).
  4. +
  5. Strg+T testet den Endpunkt, Strg+L listet die Modelle zur Auswahl.
  6. +
+

Der Punkt oben rechts zeigt, ob die KI erreichbar ist (grün, gelb bei langsamer Antwort, rot bei Fehler). Die KI hat keine eigenen Werkzeuge: sie schlägt nur vor, du entscheidest, was läuft. Passwörter und Geheimnisse werden vor dem Senden aus dem Kontext entfernt.

+
+ +
+

Tasten

+ + + + + + + + + + + + +
TasteWirkung
Strg+LeertasteBefehlspalette
Tab / →Ghost-Text übernehmen
Alt+1…4Folgebefehl einfügen
Alt+0Nach einem Fehler: Ursache und Fix
F2Ziel-Modus (Agent)
F3KI fragen, mit Terminal-Kontext
F4 / F5 / F6Tunnel / Dateien (SFTP) / Host-Übersicht
F9, ⇧+F1…F8Schnellbefehle
F10Zurück zum Manager (Sitzungen laufen weiter)
F1 / F12 / Strg+QHilfe / Über und Update / Beenden
+

Alle Tasten lassen sich ändern: b im Manager. Die ganze Liste steht in der README und in der App (F1).

+
+ +
+

Updates

+

Ein direkter Download oder der Einzeiler aktualisiert sich selbst: sshTermy fragt einmal am Tag bei GitHub nach, prüft die Prüfsumme und tauscht die Datei aus (F12 → u oder sshtermy --update).

+

Über eine Paketquelle installiert, aktualisiert die Paketquelle:

+ + + + +
Homebrewbrew upgrade sshtermy
aptsudo apt update && sudo apt upgrade
wingetwinget upgrade db9979.sshTermy (das eingebaute Update geht auch)
+
+ +
+

Fragen

+
Windows meldet „Der Computer wurde durch Windows geschützt“

Die .exe ist noch nicht codesigniert, deshalb warnt SmartScreen beim ersten Start. „Weitere Informationen“ → „Trotzdem ausführen“. Mit winget installiert, kommt die Warnung meist nicht.

+
macOS meldet, die App „kann nicht geöffnet werden“

Mit dem Browser geladene Dateien bekommen eine Quarantäne-Markierung. Nimm Homebrew oder den Einzeiler, oder entferne die Markierung: xattr -d com.apple.quarantine sshtermy_darwin_arm64.

+
Wo liegen meine Daten?

Windows: %APPDATA%\sshtermy, macOS: ~/Library/Application Support/sshtermy, Linux: ~/.config/sshtermy. Die Umgebungsvariable SSHTERMY_HOME verlegt sie, z. B. auf einen USB-Stick.

+
Welches Terminal soll ich nehmen?

Unter Windows das Windows Terminal, unter macOS Terminal oder iTerm2, unter Linux jedes moderne Terminal. Funktionstasten und Truecolor sollten gehen.

+
Geht das auch auf Englisch?

Ja: F12 → l oder Palette → „Sprache“. Beim ersten Start folgt sshTermy der Systemsprache.

+
+
+ + + + + diff --git a/site/gifs/ghost-de.gif b/site/gifs/ghost-de.gif new file mode 100644 index 0000000..bb5d79d Binary files /dev/null and b/site/gifs/ghost-de.gif differ diff --git a/site/gifs/ghost-en.gif b/site/gifs/ghost-en.gif new file mode 100644 index 0000000..7e89805 Binary files /dev/null and b/site/gifs/ghost-en.gif differ diff --git a/site/gifs/goal-de.gif b/site/gifs/goal-de.gif new file mode 100644 index 0000000..6d3ad38 Binary files /dev/null and b/site/gifs/goal-de.gif differ diff --git a/site/gifs/goal-en.gif b/site/gifs/goal-en.gif new file mode 100644 index 0000000..afc9a73 Binary files /dev/null and b/site/gifs/goal-en.gif differ diff --git a/site/gifs/palette-de.gif b/site/gifs/palette-de.gif new file mode 100644 index 0000000..039a0a9 Binary files /dev/null and b/site/gifs/palette-de.gif differ diff --git a/site/gifs/palette-en.gif b/site/gifs/palette-en.gif new file mode 100644 index 0000000..b2aaa82 Binary files /dev/null and b/site/gifs/palette-en.gif differ diff --git a/site/gifs/start-de.gif b/site/gifs/start-de.gif new file mode 100644 index 0000000..ae92be3 Binary files /dev/null and b/site/gifs/start-de.gif differ diff --git a/site/gifs/start-en.gif b/site/gifs/start-en.gif new file mode 100644 index 0000000..f1ce0d4 Binary files /dev/null and b/site/gifs/start-en.gif differ diff --git a/site/index.html b/site/index.html new file mode 100644 index 0000000..4daffec --- /dev/null +++ b/site/index.html @@ -0,0 +1,187 @@ + + + + + +sshTermy – SSH terminal with an AI copilot + + + + + + +
+
+ + +
EN · DE
+
+
+ +
+
+

SSH terminal with an AI copilot

+

One small file for Windows, macOS and Linux. Connection manager, real terminal, SFTP and tunnels, plus an AI that suggests commands, works towards a goal step by step and explains errors. Every command needs your confirmation.

+

Idea: Dominik Bornhäußer

+ +
+ Goal mode: the AI sets up nginx step by step, each command is confirmed with Enter +
Goal mode (F2): describe a goal, the AI suggests exactly one command at a time, you confirm.
+
+
+ +
+

Install

+

Pick your system. Every way installs the same release from GitHub.

+
+
+

Windows ARM64 · x64 · x86

+

With winget (Windows 11 and 10):

+
winget install db9979.sshTermy
+

Available as soon as the package is approved in the winget catalog.

+

Or download the .exe for your processor from the releases and start it in Windows Terminal.

+
+
+

macOS Apple Silicon · Intel

+

With Homebrew:

+
brew tap db9979/sshtermy https://github.com/db9979/sshtermy
+brew install sshtermy
+

Or with one line, which also creates ~/Applications/sshTermy.app:

+
curl -fsSL https://raw.githubusercontent.com/db9979/sshtermy/main/install.sh | sh
+
+
+

Linux amd64 · arm64

+

Debian, Ubuntu, Raspberry Pi OS 64-bit (apt):

+
echo "deb [trusted=yes] https://db9979.github.io/sshtermy/apt ./" | sudo tee /etc/apt/sources.list.d/sshtermy.list
+sudo apt update && sudo apt install sshtermy
+

Homebrew and the one-line installer above work on Linux too.

+
+
+

Then type sshtermy. On first start you choose a master password for your encrypted store.

+
+ +
+

Tour

+
+
+

Unlock, pick a host, go

+

Your connections, passwords and keys live in an encrypted store (AES-256-GCM, Argon2id, plus DPAPI on Windows). The manager shows folders, tags and details; Enter connects. The status line shows load, RAM and disk of the server right away.

+
+
Start animation, unlock with the master password, connect to web-01
+
+
+
+

Ghost text and errors explained

+

While you type, the AI completes the line in grey; Tab accepts. After every command it offers follow-ups (Alt+1…4). When a command fails, Alt+0 asks the AI why, with the output as context, and 1…9 inserts a suggested fix.

+
+
Ghost text completes systemctl status nginx, the command fails, Alt+0 explains why and inserts the fix
+
+
+
+

One palette for everything

+

Ctrl+Space opens the command palette: actions, tunnels, connections and runbooks. Plain text becomes a goal (Enter) or a question to the AI (Tab).

+
+
Command palette filters actions, then a question goes to the AI with terminal context
+
+
+ +
+

Features

+
+

Connection manager

Folders, tags, jump hosts, import from ~/.ssh/config, PuTTY and MobaXterm.

+

Real terminal

xterm-256color, truecolor, vim, htop and tmux, scrollback, tabs, split view, search.

+

Auto-reconnect

When Wi-Fi or VPN drops, the session comes back by itself, with tunnels and tmux/screen.

+

Files (F5)

SFTP over the same connection: local on the left, server on the right.

+

Host overview (F6)

CPU, load, RAM, disk and updates for servers; firmware, ports and VLANs for Aruba and Cisco switches, with config backup and diff.

+

Tunnels

-L, -R, -D (SOCKS5) and web services with one click.

+

Broadcast

One command or runbook on a whole group in parallel, results side by side.

+

Network scan

Find SSH devices in a subnet and create them as connections.

+

Danger rules

Fixed rules mark risky commands red; they need Enter twice, also when pasted.

+

Session log

Encrypted, searchable, with AI summary and Markdown export.

+

Sync

End-to-end encrypted via OneDrive, Dropbox, iCloud, Syncthing or WebDAV (Synology, Nextcloud).

+

System profile

Knows Linux distributions, macOS, Windows and network OS dialects, so the AI suggests matching commands.

+
+
+
Connection manager
Connection manager
+
Host overview of a switch
Host overview of a switch (F6)
+
Files via SFTP
Files via SFTP (F5)
+
Dangerous command needs confirmation
Danger rules
+
+

The screenshots show the German interface; the English one looks the same.

+
+ +
+

AI setup

+

sshTermy talks to any OpenAI-compatible endpoint (/v1/chat/completions): Ollama, vLLM, SGLang, LiteLLM, LocalAI or OpenAI itself. A local model keeps your terminal content on your own hardware.

+
    +
  1. In the manager press s (AI settings).
  2. +
  3. Enter the URL, e.g. http://localhost:11434/v1 for Ollama, and an API key if the endpoint needs one (stored encrypted).
  4. +
  5. Ctrl+T tests the endpoint, Ctrl+L lists the models to pick from.
  6. +
+

The dot in the top right shows whether the AI is reachable (green, yellow when slow, red on error). The AI has no tools of its own: it only suggests, you decide what runs. Passwords and secrets are removed from the context before it is sent.

+
+ +
+

Keys

+ + + + + + + + + + + + +
KeyEffect
Ctrl+SpaceCommand palette
Tab / →Accept ghost text
Alt+1…4Insert follow-up command
Alt+0After a failure: cause and fix
F2Goal mode (agent)
F3Ask AI with terminal context
F4 / F5 / F6Tunnels / files (SFTP) / host overview
F9, ⇧+F1…F8Quick commands
F10Back to the manager (sessions keep running)
F1 / F12 / Ctrl+QHelp / about and update / quit
+

All shortcuts can be changed: b in the manager. The full list is in the README and in the app (F1).

+
+ +
+

Updates

+

A direct download or the one-line installer updates itself: sshTermy checks GitHub once a day, verifies the checksum and swaps the file (F12 → u, or sshtermy --update).

+

Installed with a package manager, the package manager updates it:

+ + + + +
Homebrewbrew upgrade sshtermy
aptsudo apt update && sudo apt upgrade
wingetwinget upgrade db9979.sshTermy (the built-in update works as well)
+
+ +
+

FAQ

+
Windows says “Windows protected your PC”

The .exe is not code-signed yet, so SmartScreen warns on the first start. Click “More info” → “Run anyway”. Installing with winget usually avoids the warning.

+
macOS says the app “cannot be opened”

Files downloaded with the browser get a quarantine mark. Use Homebrew or the one-line installer, or remove the mark: xattr -d com.apple.quarantine sshtermy_darwin_arm64.

+
Where is my data?

Windows: %APPDATA%\sshtermy, macOS: ~/Library/Application Support/sshtermy, Linux: ~/.config/sshtermy. The environment variable SSHTERMY_HOME moves it, e.g. onto a USB stick.

+
Which terminal should I use?

Windows Terminal on Windows, Terminal or iTerm2 on macOS, any modern terminal on Linux. Function keys and truecolor should work.

+
Can I switch to German?

Yes: F12 → l or palette → “Language”. On first start sshTermy follows the system language.

+
+
+ + + + + diff --git a/site/site.js b/site/site.js new file mode 100644 index 0000000..5996351 --- /dev/null +++ b/site/site.js @@ -0,0 +1,11 @@ +// Kopier-Knöpfe an den Befehlen. +document.querySelectorAll('.cmd').forEach(function (box) { + var b = document.createElement('button'); + b.className = 'copy'; b.type = 'button'; b.textContent = box.dataset.copy || 'Copy'; + b.addEventListener('click', function () { + navigator.clipboard.writeText(box.querySelector('pre').innerText.trim()).then(function () { + var t = b.textContent; b.textContent = '✓'; setTimeout(function () { b.textContent = t; }, 1200); + }); + }); + box.appendChild(b); +}); diff --git a/site/style.css b/site/style.css new file mode 100644 index 0000000..7f90eba --- /dev/null +++ b/site/style.css @@ -0,0 +1,78 @@ +/* sshTermy – Webseite. Farben wie die App (dunkel). */ +:root { + --bg: #0d1117; --panel: #161b22; --line: #2a2e45; --fg: #c9d1d9; --dim: #8b949e; + --blue: #7aa2f7; --violet: #bb9af7; --green: #9ece6a; --yellow: #e0af68; --red: #f7768e; --cyan: #7dcfff; + --mono: "Cascadia Code", "JetBrains Mono", "DejaVu Sans Mono", ui-monospace, monospace; +} +* { box-sizing: border-box; } +html { scroll-behavior: smooth; scroll-padding-top: 64px; } +body { margin: 0; background: var(--bg); color: var(--fg); font: 16px/1.6 system-ui, -apple-system, "Segoe UI", sans-serif; } +a { color: var(--blue); text-decoration: none; } +a:hover { text-decoration: underline; } +code, pre, kbd { font-family: var(--mono); font-size: .92em; } +code { background: #1f2430; padding: .1em .35em; border-radius: 4px; } +kbd { background: #1f2430; border: 1px solid var(--line); border-bottom-width: 2px; padding: 0 .4em; border-radius: 4px; white-space: nowrap; } + +header { position: sticky; top: 0; z-index: 10; background: rgba(13,17,23,.92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); } +.bar { max-width: 1100px; margin: 0 auto; padding: 0 20px; height: 56px; display: flex; align-items: center; gap: 22px; } +.logo { font-family: var(--mono); font-weight: 700; color: var(--fg); font-size: 18px; } +.logo span { color: var(--violet); } +nav { display: flex; gap: 18px; flex: 1; overflow-x: auto; white-space: nowrap; } +nav a { color: var(--dim); font-size: 15px; } +nav a:hover { color: var(--fg); text-decoration: none; } +.lang { font-size: 14px; color: var(--dim); white-space: nowrap; } +.lang b { color: var(--fg); } + +main { max-width: 1100px; margin: 0 auto; padding: 0 20px 60px; } +section { padding: 56px 0 8px; } +h1 { font-size: clamp(34px, 6vw, 54px); line-height: 1.1; margin: 0 0 14px; } +h1 .accent { background: linear-gradient(90deg, var(--blue), var(--violet)); -webkit-background-clip: text; background-clip: text; color: transparent; } +h2 { font-size: 30px; margin: 0 0 12px; } +h3 { font-size: 19px; margin: 24px 0 6px; } +p.lead { font-size: 19px; color: var(--dim); max-width: 760px; margin: 0 0 8px; } +.credit { font-style: italic; color: var(--dim); margin: 0 0 22px; } + +.hero { padding-top: 56px; } +.buttons { display: flex; flex-wrap: wrap; gap: 12px; margin: 0 0 34px; } +.btn { display: inline-block; padding: 10px 18px; border-radius: 8px; border: 1px solid var(--line); color: var(--fg); background: var(--panel); font-weight: 600; } +.btn:hover { text-decoration: none; border-color: var(--blue); } +.btn.primary { background: var(--blue); border-color: var(--blue); color: #0d1117; } +.btn.coffee { background: #ffdd00; border-color: #ffdd00; color: #111; } + +figure { margin: 0; } +figure img { display: block; max-width: 100%; height: auto; border-radius: 10px; box-shadow: 0 18px 50px rgba(0,0,0,.5); } +figcaption { color: var(--dim); font-size: 14px; margin-top: 8px; } + +.os { display: grid; grid-template-columns: minmax(0, 1fr); gap: 18px; margin-top: 20px; } +.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 20px 22px; } +.card h3 { margin-top: 0; } +.card p { margin: 8px 0; color: var(--dim); font-size: 15px; } +.cmd { position: relative; background: #0b0e14; border: 1px solid var(--line); border-radius: 8px; padding: 10px 70px 10px 12px; margin: 8px 0 12px; } +.cmd pre { margin: 0; color: var(--green); white-space: pre; overflow-x: auto; } +.copy { position: absolute; top: 6px; right: 6px; background: var(--panel); color: var(--dim); border: 1px solid var(--line); border-radius: 6px; font-size: 12px; padding: 2px 8px; cursor: pointer; } +.copy:hover { color: var(--fg); } +.tag { display: inline-block; font-size: 12px; padding: 1px 8px; border-radius: 10px; background: #1f2430; color: var(--cyan); margin-left: 6px; vertical-align: middle; } + +.demo > * { min-width: 0; } +.demo { display: grid; grid-template-columns: 1fr 1.6fr; gap: 28px; align-items: center; margin: 34px 0; } +.demo:nth-of-type(even) { grid-template-columns: 1.6fr 1fr; } +.demo:nth-of-type(even) .text { order: 2; } +.demo .text p { color: var(--dim); } +@media (max-width: 860px) { .demo, .demo:nth-of-type(even) { grid-template-columns: 1fr; } .demo:nth-of-type(even) .text { order: 0; } } + +.features { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; margin-top: 18px; } +.features .card h3 { font-size: 16px; margin: 0 0 4px; } +.features .card p { margin: 0; font-size: 14.5px; } + +table { width: 100%; border-collapse: collapse; margin: 12px 0; font-size: 15px; } +th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; } +th { color: var(--dim); font-weight: 600; } +td:first-child { white-space: nowrap; } + +details { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px 16px; margin: 10px 0; } +summary { cursor: pointer; font-weight: 600; } +details p, details ul { color: var(--dim); } + +.shots { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 18px; margin-top: 18px; } +footer { border-top: 1px solid var(--line); color: var(--dim); font-size: 14px; } +footer .bar { height: auto; padding: 22px 20px; flex-wrap: wrap; } diff --git a/tools/changelog/main.go b/tools/changelog/main.go index 2ce8e61..f1886a5 100644 --- a/tools/changelog/main.go +++ b/tools/changelog/main.go @@ -4,7 +4,7 @@ // // Regeln (passen zu .github/workflows/release.yml): // - Jeder Commit auf main (first-parent) ist ein Release, außer er ändert -// nur docs/** oder *.md. Dessen Neuerungen wandern ins nächste Release. +// nur docs/**, site/**, Formula/** oder *.md. Dessen Neuerungen wandern ins nächste Release. // - Version = MAJOR.MINOR aus VERSION + Anzahl Commits bis dahin. // - Text: aus dem PR-Abschnitt „## Was ist neu“ (Stichpunkte für Nutzer). // Fehlt er, der PR-Titel. Steht dort nur „intern“ oder „-“, entfällt der @@ -139,13 +139,24 @@ func releases(c commit, root bool) bool { return true } for _, f := range strings.Fields(files) { - if !strings.HasPrefix(f, "docs/") && !strings.HasSuffix(f, ".md") { + if !noRelease(f) { return true } } return false } +// noRelease: Pfade aus paths-ignore in release.yml (Doku, Webseite, die +// vom Release selbst geschriebene Homebrew-Formel). +func noRelease(f string) bool { + for _, p := range []string{"docs/", "site/", "Formula/"} { + if strings.HasPrefix(f, p) { + return true + } + } + return strings.HasSuffix(f, ".md") +} + func itemsFor(c commit, gh *github) []string { m := mergeRe.FindStringSubmatch(c.subject) if m == nil { diff --git a/tools/changelog/main_test.go b/tools/changelog/main_test.go index b54f500..b196b32 100644 --- a/tools/changelog/main_test.go +++ b/tools/changelog/main_test.go @@ -16,3 +16,14 @@ func TestNewsSection(t *testing.T) { t.Fatal("ohne Abschnitt") } } + +func TestNoRelease(t *testing.T) { + for f, want := range map[string]bool{ + "docs/bilder/a.png": true, "site/index.html": true, "Formula/sshtermy.rb": true, + "README.md": true, "internal/ui/app.go": false, "packaging/deb.sh": false, + } { + if noRelease(f) != want { + t.Errorf("%s: %v", f, !want) + } + } +} diff --git a/tools/dev/gifs/README.md b/tools/dev/gifs/README.md new file mode 100644 index 0000000..ac31372 --- /dev/null +++ b/tools/dev/gifs/README.md @@ -0,0 +1,19 @@ +# GIFs für die Webseite (site/gifs) + +Aufnahme der echten App in tmux gegen den Test-SSH-Server und ein Demo-LLM, +Bild für Bild über Chromium (Playwright) gerendert und mit ffmpeg zum GIF gebaut. + +```sh +go build -ldflags "-X github.com/db9979/sshtermy/internal/version.Version=1.0.96" -o /tmp/st/sshtermy ./cmd/sshtermy +(cd tools/dev/devsshd && go build -o /tmp/st/devsshd .) +PATH=$PWD/tools/dev/gifs/fakebin:$PATH /tmp/st/devsshd & # docker, curl, systemctl … als Attrappen +cd tools/dev/gifs +DEMO_LANG=en python3 demollm.py & # Port 11434, Antworten auf Englisch (de = Deutsch) +python3 prepare.py en # Master-Passwort demo1234, drei Verbindungen +# einmal von Hand mit web-01 verbinden und den Host-Key bestätigen +python3 scenes.py en start goal ghost palette +cp out/*.gif ../../../site/gifs/ +``` + +Für Deutsch `demollm.py` mit `DEMO_LANG=de` neu starten und `prepare.py de` / `scenes.py de …`. +Braucht tmux, ffmpeg, Node mit Playwright und Python 3. diff --git a/tools/dev/gifs/ansiconv.py b/tools/dev/gifs/ansiconv.py new file mode 100644 index 0000000..3bc78fd --- /dev/null +++ b/tools/dev/gifs/ansiconv.py @@ -0,0 +1,62 @@ +import re, sys, html +PAL = ["#15161e","#f7768e","#9ece6a","#e0af68","#7aa2f7","#bb9af7","#7dcfff","#a9b1d6","#414868","#f7768e","#9ece6a","#e0af68","#7aa2f7","#bb9af7","#7dcfff","#c0caf5"] +def x256(n): + if n < 16: return PAL[n] + if n < 232: + n -= 16; r, g, b = n//36, (n//6)%6, n%6 + f = lambda v: 0 if v == 0 else 55 + v*40 + return "#%02x%02x%02x" % (f(r), f(g), f(b)) + v = 8 + (n-232)*10; return "#%02x%02x%02x" % (v, v, v) +DFG, DBG = "#c0caf5", "#1a1b26" +def conv(text): + out = []; st = {"fg": None, "bg": None, "b": False, "i": False, "u": False, "rev": False, "dim": False} + for line in text.split("\n"): + parts = re.split(r"(\x1b\[[0-9;:]*m)", line); spans = [] + for p in parts: + if p.startswith("\x1b["): + codes = p[2:-1].replace(":", ";").split(";") if p[2:-1] else ["0"]; i = 0 + while i < len(codes): + c = int(codes[i] or 0) + if c == 0: st = {"fg": None, "bg": None, "b": False, "i": False, "u": False, "rev": False, "dim": False} + elif c == 1: st["b"] = True + elif c == 2: st["dim"] = True + elif c == 3: st["i"] = True + elif c == 4: st["u"] = True + elif c == 7: st["rev"] = True + elif c == 22: st["b"] = st["dim"] = False + elif c == 23: st["i"] = False + elif c == 24: st["u"] = False + elif c == 27: st["rev"] = False + elif 30 <= c <= 37: st["fg"] = PAL[c-30] + elif 90 <= c <= 97: st["fg"] = PAL[c-90+8] + elif 40 <= c <= 47: st["bg"] = PAL[c-40] + elif 100 <= c <= 107: st["bg"] = PAL[c-100+8] + elif c == 39: st["fg"] = None + elif c == 49: st["bg"] = None + elif c in (38, 48): + key = "fg" if c == 38 else "bg" + if codes[i+1] == "5": st[key] = x256(int(codes[i+2])); i += 2 + elif codes[i+1] == "2": st[key] = "#%02x%02x%02x" % tuple(int(x) for x in codes[i+2:i+5]); i += 4 + i += 1 + continue + if not p: continue + fg, bg = st["fg"] or DFG, st["bg"] + if st["rev"]: fg, bg = (bg or DBG), fg + css = "color:%s;" % fg + ("background:%s;" % bg if bg else "") + if st["b"]: css += "font-weight:700;" + if st["i"]: css += "font-style:italic;" + if st["u"]: css += "text-decoration:underline;" + if st["dim"]: css += "opacity:.6;" + spans.append('%s' % (css, html.escape(p))) + out.append("".join(spans)) + return "\n".join(out) + +def page(text, title): + return """
%s
%s
""" % (ROWS*1.25, html.escape(title), conv(text)) +ROWS = 34 diff --git a/tools/dev/gifs/demollm.py b/tools/dev/gifs/demollm.py new file mode 100644 index 0000000..6325c98 --- /dev/null +++ b/tools/dev/gifs/demollm.py @@ -0,0 +1,64 @@ +# Demo-LLM für die GIFs (Englisch/Deutsch über DEMO_LANG). +import json, re, time, os +from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer +EN = os.environ.get("DEMO_LANG", "en") == "en" +T = (lambda en, de: en) if EN else (lambda en, de: de) +STEPS = [ + {"befehl": "docker --version", "grund": T("Check whether Docker is already installed.", "Prüfen, ob Docker schon installiert ist."), + "plan": [T("Check Docker", "Docker prüfen"), T("Start nginx container", "Nginx-Container starten"), T("Test with curl", "Test mit curl")]}, + {"befehl": "docker run -d --name proxy -p 80:80 -v ~/proxy/nginx.conf:/etc/nginx/conf.d/default.conf:ro nginx:stable", + "grund": T("Start nginx as reverse proxy with its own config.", "Nginx als Reverse Proxy mit eigener Konfiguration starten."), + "plan": [T("Start nginx container", "Nginx-Container starten"), T("Test with curl", "Test mit curl")]}, + {"befehl": "curl -sI http://localhost", "grund": T("Check that port 80 answers through the proxy.", "Prüfen, ob Port 80 über den Proxy antwortet."), + "plan": [T("Test with curl", "Test mit curl")]}, + {"fertig": True, "grund": T("nginx is running and forwards port 80 to the app on :3000.", "Nginx läuft und leitet Port 80 an die App auf :3000 weiter.")}, +] +ANSWER = T( + "nginx does not start because port 80 is already in use (`bind() failed`). Check who is listening:\n\n```sh\nsudo ss -tlnp | grep :80\n```\n\nIf it is an old Apache, stop it:\n\n```sh\nsudo systemctl stop apache2\n```\n", + "Nginx startet nicht, weil Port 80 schon belegt ist (`bind() failed`). Prüfe, wer lauscht:\n\n```sh\nsudo ss -tlnp | grep :80\n```\n\nIst es ein alter Apache, stoppe ihn:\n\n```sh\nsudo systemctl stop apache2\n```\n") + +DISK = T( + "`/` is 4% full, so the space is likely used by Docker images or logs. Find the biggest folders:\n\n```sh\nsudo du -xh / --max-depth=2 | sort -h | tail -15\n```\n\nOld images and stopped containers:\n\n```sh\ndocker system df\n```\n", + "`/` ist zu 4 % belegt, der Platz steckt also eher in Docker-Images oder Logs. Die größten Ordner finden:\n\n```sh\nsudo du -xh / --max-depth=2 | sort -h | tail -15\n```\n\nAlte Images und gestoppte Container:\n\n```sh\ndocker system df\n```\n") + +class H(BaseHTTPRequestHandler): + def log_message(self, *a): pass + def do_GET(self): + if self.path.rstrip("/").endswith("/models"): + out = json.dumps({"object": "list", "data": [{"id": m, "object": "model"} for m in ["qwen3-coder:30b", "gpt-oss:20b"]]}).encode() + self.send_response(200); self.send_header("Content-Type", "application/json"); self.send_header("Content-Length", str(len(out))); self.end_headers(); self.wfile.write(out) + else: + self.send_response(404); self.end_headers() + def do_POST(self): + body = json.loads(self.rfile.read(int(self.headers["Content-Length"]))) + sysm = body["messages"][0]["content"]; user = body["messages"][-1]["content"] + if "vervollständigst" in sysm: + typed = re.search(r"Bisher getippt: (.*)", user).group(1) + table = ["docker ps --format 'table {{.Names}}\\t{{.Status}}'", "systemctl status nginx --no-pager", "journalctl -u nginx -n 50 --no-pager", "free -h"] + out = typed + for v in table: + if typed and v.startswith(typed): out = v; break + text = json.dumps({"zeile": out}) + elif "2 bis 4" in sysm: + text = json.dumps([{"befehl": "journalctl -u nginx -n 50 --no-pager", "grund": T("last log lines", "letzte Logzeilen")}, + {"befehl": "sudo ss -tlnp | grep :80", "grund": T("who uses port 80", "wer belegt Port 80")}, + {"befehl": "sudo nginx -t", "grund": T("check config", "Konfiguration prüfen")}]) + elif "Ziel" in sysm: + n = len(re.findall(r"^\d+\. .*\((ausgeführt[^)]*|vom Menschen übersprungen)\)$", user, re.M)) + text = json.dumps(STEPS[min(n, len(STEPS)-1)]) + elif sysm.startswith("Antworte nur mit"): + text = "OK" + elif "disk" in user or "Platte" in user: + text = DISK + else: + text = ANSWER + if body.get("stream"): + self.send_response(200); self.send_header("Content-Type", "text/event-stream"); self.end_headers() + for i in range(0, len(text), 6): + self.wfile.write(("data: " + json.dumps({"choices": [{"delta": {"content": text[i:i+6]}}]}) + "\n\n").encode()); self.wfile.flush(); time.sleep(0.03) + self.wfile.write(b"data: [DONE]\n\n"); return + time.sleep(0.25) + out = json.dumps({"choices": [{"message": {"role": "assistant", "content": text}}]}).encode() + self.send_response(200); self.send_header("Content-Type", "application/json"); self.send_header("Content-Length", str(len(out))); self.end_headers(); self.wfile.write(out) + +ThreadingHTTPServer(("127.0.0.1", 11434), H).serve_forever() diff --git a/tools/dev/gifs/fakebin/curl b/tools/dev/gifs/fakebin/curl new file mode 100755 index 0000000..bc6c934 --- /dev/null +++ b/tools/dev/gifs/fakebin/curl @@ -0,0 +1,2 @@ +#!/bin/sh +printf 'HTTP/1.1 200 OK\nServer: nginx/1.26.2\nContent-Type: text/html; charset=utf-8\n' diff --git a/tools/dev/gifs/fakebin/docker b/tools/dev/gifs/fakebin/docker new file mode 100755 index 0000000..f2b8cdf --- /dev/null +++ b/tools/dev/gifs/fakebin/docker @@ -0,0 +1,7 @@ +#!/bin/sh +case "$1" in +--version) echo "Docker version 27.3.1, build ce12230" ;; +run) echo "Unable to find image 'nginx:stable' locally"; sleep 0.4; echo "stable: Pulling from library/nginx"; sleep 0.3; echo "Status: Downloaded newer image for nginx:stable"; echo "3f9c1e7b2a4d8e6f0c5b9a1d7e3f2c4b6a8d0e1f3c5b7a9d1e3f5c7b9a1d3e5f" ;; +ps) printf 'NAMES STATUS\nproxy Up 2 minutes\napp Up 3 days\n' ;; +*) echo "docker: '$1' is not a docker command." ;; +esac diff --git a/tools/dev/gifs/fakebin/free b/tools/dev/gifs/fakebin/free new file mode 100755 index 0000000..823ed34 --- /dev/null +++ b/tools/dev/gifs/fakebin/free @@ -0,0 +1,2 @@ +#!/bin/sh +printf ' total used free shared buff/cache available\nMem: 119Gi 14Gi 92Gi 1.1Gi 13Gi 104Gi\nSwap: 8.0Gi 0B 8.0Gi\n' diff --git a/tools/dev/gifs/fakebin/ss b/tools/dev/gifs/fakebin/ss new file mode 100755 index 0000000..25174df --- /dev/null +++ b/tools/dev/gifs/fakebin/ss @@ -0,0 +1,2 @@ +#!/bin/sh +echo 'LISTEN 0 511 0.0.0.0:80 0.0.0.0:* users:(("apache2",pid=912,fd=4))' diff --git a/tools/dev/gifs/fakebin/sudo b/tools/dev/gifs/fakebin/sudo new file mode 100755 index 0000000..311cb8c --- /dev/null +++ b/tools/dev/gifs/fakebin/sudo @@ -0,0 +1,2 @@ +#!/bin/sh +exec "$@" diff --git a/tools/dev/gifs/fakebin/systemctl b/tools/dev/gifs/fakebin/systemctl new file mode 100755 index 0000000..0496685 --- /dev/null +++ b/tools/dev/gifs/fakebin/systemctl @@ -0,0 +1,3 @@ +#!/bin/sh +printf '\033[1;31m×\033[0m nginx.service - A high performance web server and a reverse proxy server\n Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled)\n Active: \033[1;31mfailed\033[0m (Result: exit-code) since Fri 2026-11-06 07:12:41 CET; 4s ago\n Process: 4711 ExecStart=/usr/sbin/nginx (code=exited, status=1/FAILURE)\n\nNov 06 07:12:41 web-01 nginx[4711]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)\nNov 06 07:12:41 web-01 systemd[1]: nginx.service: Failed with result '"'"'exit-code'"'"'.\n' +exit 3 diff --git a/tools/dev/gifs/prepare.py b/tools/dev/gifs/prepare.py new file mode 100644 index 0000000..247a936 --- /dev/null +++ b/tools/dev/gifs/prepare.py @@ -0,0 +1,11 @@ +import sys, shutil +from record import Rec +lang = sys.argv[1]; home = f"/tmp/st/home-{lang}" +shutil.rmtree(home, ignore_errors=True) +r = Rec(lang, home, "--no-intro") +r.wait(2); r.type("demo1234", 0.02); r.k("Tab"); r.type("demo1234", 0.02); r.k("Enter", d=2); r.k("Escape", d=0.8) +for alias, host, user, tags in [("web-01", "127.0.0.1", "dominik", "web"), ("db-01", "127.0.0.2", "postgres", "db"), ("spark", "127.0.0.3", "dominik", "lab")]: + r.k("n", d=1); r.type(alias, 0.01); r.k("Tab"); r.type(host, 0.01); r.k("Tab"); r.k("BSpace", "BSpace", d=0.2); r.type("2222", 0.01); r.k("Tab") + r.type(user, 0.01); r.k("Tab"); r.k("Right", "Right", d=0.3); r.k("Tab"); r.type("secret", 0.01); r.k("Tab", "Tab", d=0.3); r.type(tags, 0.01); r.k("C-s", d=1) +print(r.screen()) +r.stop = True; import subprocess; subprocess.run(["tmux", "kill-session", "-t", "g"]) diff --git a/tools/dev/gifs/record.py b/tools/dev/gifs/record.py new file mode 100644 index 0000000..f06dcdf --- /dev/null +++ b/tools/dev/gifs/record.py @@ -0,0 +1,61 @@ +import subprocess as sp, time, threading, sys, os, shutil, json +sys.path.insert(0, os.path.dirname(__file__)) +import ansiconv +S = os.path.dirname(os.path.abspath(__file__)) +BIN = os.environ.get("SSHTERMY_BIN", "/tmp/st/sshtermy") +OUT = os.environ.get("GIF_OUT", os.path.join(S, "out")) +COLS, ROWS = 120, 34 +ansiconv.ROWS = ROWS + +def tm(*a): return sp.run(["tmux", *a], capture_output=True, text=True).stdout + +class Rec: + def __init__(self, lang, home, args=""): + self.lang = lang + tm("kill-session", "-t", "g") + loc = "en_US.UTF-8" if lang == "en" else "de_DE.UTF-8" + tm("new-session", "-d", "-s", "g", "-x", str(COLS), "-y", str(ROWS), + f"SSHTERMY_HOME={home} LANG={loc} LC_ALL={loc} TERM=xterm-256color {BIN} {args}") + self.frames, self.on, self.stop = [], False, False + self.t = threading.Thread(target=self.loop, daemon=True); self.t.start() + def loop(self): + while not self.stop: + if self.on: + s = tm("capture-pane", "-e", "-p", "-t", "g") + if not self.frames or self.frames[-1][1] != s: + self.frames.append((time.time(), s)) + time.sleep(0.08) + def k(self, *keys, d=0.5): + for key in keys: tm("send-keys", "-t", "g", key) + time.sleep(d) + def type(self, text, d=0.07, after=0.4): + for ch in text: + tm("send-keys", "-t", "g", "-l", ch); time.sleep(d) + time.sleep(after) + def wait(self, s): time.sleep(s) + def screen(self): return tm("capture-pane", "-p", "-t", "g") + def until(self, text, timeout=10): + end = time.time() + timeout + while time.time() < end: + if text in self.screen(): return True + time.sleep(0.1) + print("TIMEOUT waiting for", repr(text)); print(self.screen()); return False + def finish(self, name, hold=3.0): + time.sleep(0.3); self.stop = True; self.t.join() + tm("kill-session", "-t", "g") + render(self.frames, name, hold) + +def render(frames, name, hold): + d = os.path.join(OUT, "frames", name); shutil.rmtree(d, ignore_errors=True); os.makedirs(d) + lines = [] + for i, (ts, s) in enumerate(frames): + open(f"{d}/{i:04d}.html", "w", encoding="utf-8").write(ansiconv.page(s, "sshTermy")) + dur = (frames[i+1][0] - ts) if i + 1 < len(frames) else hold + lines += [f"file '{d}/{i:04d}.png'", f"duration {max(dur, 0.04):.3f}"] + sp.run(["node", os.path.join(S, "shot.js"), d, str(len(frames))], check=True) + lines.append(f"file '{d}/{len(frames)-1:04d}.png'") + open(f"{d}/list.txt", "w").write("\n".join(lines) + "\n") + out = os.path.join(OUT, name + ".gif"); os.makedirs(os.path.dirname(out), exist_ok=True) + sp.run(["ffmpeg", "-y", "-loglevel", "error", "-f", "concat", "-safe", "0", "-i", f"{d}/list.txt", + "-vf", "split[a][b];[a]palettegen=max_colors=128:stats_mode=full[p];[b][p]paletteuse=dither=none", "-loop", "0", out], check=True) + print(name, len(frames), "frames", os.path.getsize(out) // 1024, "KB") diff --git a/tools/dev/gifs/scenes.py b/tools/dev/gifs/scenes.py new file mode 100644 index 0000000..82b190c --- /dev/null +++ b/tools/dev/gifs/scenes.py @@ -0,0 +1,45 @@ +import sys +from record import Rec +lang = sys.argv[1]; which = sys.argv[2:] +home = f"/tmp/st/home-{lang}" +L = lambda en, de: en if lang == "en" else de + +def connected(args="--no-intro"): + r = Rec(lang, home, args) + r.wait(1.5); r.type("demo1234", 0.01); r.k("Enter", d=1.5) + r.k("Down", "Down", "Down", d=0.3); r.k("Enter"); r.until("dgx-spark"); r.wait(1.5) + return r + +def start(): + r = Rec(lang, home, ""); r.on = True + r.wait(4.5); r.type("demo1234", 0.09, 0.4); r.k("Enter", d=2) + r.k("Down", d=0.6); r.k("Down", d=0.6); r.k("Down", d=1); r.k("Enter"); r.until("dgx-spark"); r.wait(1.5) + r.type("free -h", 0.1, 0.8); r.k("Enter", d=2.5) + r.finish("start-" + lang) + +def goal(): + r = connected(); r.on = True; r.wait(0.8) + r.k("F2", d=0.8); r.type(L("Set up nginx as reverse proxy for my app on :3000", "Nginx als Reverse Proxy für meine App auf :3000 einrichten"), 0.045, 0.6) + r.k("Enter"); r.until("docker --version"); r.wait(2) + r.k("Enter"); r.until("docker run"); r.wait(2.5) + r.k("Enter"); r.until("curl -sI"); r.wait(2.5) + r.k("Enter"); r.until(L("forwards port 80", "leitet Port 80"), 15); r.wait(1) + r.finish("goal-" + lang, 4) + +def ghost(): + r = connected(); r.on = True; r.wait(0.8) + r.type("sys", 0.25, 1.6); r.k("Tab", d=1.2); r.k("Enter", d=3.5) + r.k("M-0", d=5) + r.k("1", d=1.5); r.k("Enter", d=3) + r.finish("ghost-" + lang, 4) + +def palette(): + r = connected(); r.on = True; r.wait(0.8) + r.k("C-Space", d=2) + r.type("tun", 0.25, 2) + r.k("C-u", d=0.6) + r.type(L("why is the disk full", "warum ist die Platte voll"), 0.06, 1.5) + r.k("Tab"); r.until("docker system df", 10); r.wait(1) + r.finish("palette-" + lang, 4) + +for w in which: globals()[w]() diff --git a/tools/dev/gifs/shot.js b/tools/dev/gifs/shot.js new file mode 100644 index 0000000..40d852d --- /dev/null +++ b/tools/dev/gifs/shot.js @@ -0,0 +1,12 @@ +const { chromium } = require('playwright'); +(async () => { + const dir = process.argv[2], n = +process.argv[3]; + const b = await chromium.launch(); const p = await b.newPage({ deviceScaleFactor: 1, viewport: { width: 1200, height: 900 } }); + const fs = require('fs'); + for (let i = 0; i < n; i++) { + const f = `${dir}/${String(i).padStart(4, '0')}`; + await p.setContent(fs.readFileSync(f + '.html', 'utf8')); + await p.locator('.win').screenshot({ path: f + '.png' }); + } + await b.close(); +})();