diff --git a/README.de.md b/README.de.md index ad1a233..7342f63 100644 --- a/README.de.md +++ b/README.de.md @@ -17,6 +17,7 @@ sshTermy ist eine schlanke Terminal-Anwendung (TUI, eine einzige Datei, ~9 MB, k - **echtem SSH-Terminal** (xterm-256color, Truecolor, vim/htop/tmux, Scrollback, Tabs, Jump-Host) - **Auto-Reconnect**: reißt die Leitung ab (WLAN, VPN, Standby), verbindet sshTermy die Sitzung von selbst neu, startet laufende Tunnel wieder und hängt tmux/screen wieder an (abschaltbar über die Palette) - **Feste Sitzung** (Idee: Dominik Bornhäußer): pro Verbindung beim Verbinden immer in dieselbe tmux-/screen-Sitzung, auch von einem anderen Rechner aus. Laufen schon andere Sitzungen, fragt sshTermy, welche. Gleicher Sitzungsname in zwei Tabs oder auf zwei Rechnern = gespiegelter Bildschirm; „nur zuschauen“ hängt tmux schreibgeschützt an. Die Palette öffnet einen zweiten Tab zum Zuschauen oder kopiert einen `ssh … tmux attach -r`-Befehl für Kollegen. Nicht bei Switches, Telnet und Konsole. +- **Lokale Shell** (Alt+L): deine eigene PowerShell (Windows, über ConPTY), zsh oder bash (macOS/Linux) als Tab, mit KI-Hilfe, Ziel-/Agent-/Plan-Modus, geteilter Ansicht, Tabs und Sitzungsprotokoll. Gefahren-Check und Agent-Stufen gelten auch auf dem eigenen Rechner; der Agent legt seine Skripte in `~/.sshtermy-agent` ab. Oder als Verbindung speichern („Verbindung über: Lokal“) mit eigener Shell (`pwsh`, `cmd`, `wsl`, `bash -l` …) und Startordner - **Schnellverbinden**: `user@host:port` oder `ssh -p 2222 user@host` in die Palette tippen, ohne die Verbindung anzulegen (Agent/Standard-Keys, sonst Passwort) - **Fertig im Hintergrund**: Ein Befehl, der 10 s oder länger in einem verdeckten Tab lief, markiert den Tab (✓ / ×) und meldet sich mit einer Einblendung; ist das sshTermy-Fenster im Hintergrund, kommt zusätzlich eine Desktop-Benachrichtigung (Windows, macOS, Linux). Die Terminal-Glocke markiert den Tab ebenso. Beides ist in der Palette abschaltbar - **Agent-Weiterleitung** pro Verbindung (wie `ssh -A`): `git pull`, `ssh` und `scp` auf dem Server nutzen deine lokalen Keys aus ssh-agent, Pageant oder dem Windows-OpenSSH-Agent, die Keys verlassen deinen Rechner nie @@ -176,6 +177,7 @@ sshtermy --no-intro # ohne Startanimation (dauerhaft: Palette „Startanimatio | | F7 / F8 | vorheriger / nächster Tab | | | Alt+T | alle Tabs (Liste: springen, schließen, umbenennen, duplizieren, verschieben) | | | Alt+N / Alt+W | neuer Tab / Tab schließen (auch `+` und `×` in der Tab-Leiste, Rechtsklick auf einen Tab öffnet sein Menü) | +| | Alt+L | lokale Shell in neuem Tab (auch im Manager; Palette: `lokal`, `pwsh`, `cmd`, `wsl`, `zsh` …) | | | F9 / ⇧F1…F8 | Schnellbefehle: Liste / direkt ausführen | | | F10 | zurück zum Manager (Sitzungen laufen weiter) | | | ⇧F9 | Tastenzeile erklärt die Tasten des Bereichs | @@ -248,6 +250,14 @@ Palette → „Break senden“ schickt ein serielles Break. Host-Übersicht (F6) laufen wie bei SSH; Dateien, Tunnel und Broadcast brauchen SSH. Linux: Benutzer muss in der Gruppe `dialout` sein. Telnet ist unverschlüsselt, nur in vertrauenswürdigen Netzen verwenden. +**Lokale Shell:** Alt+L (oder der erste Eintrag unter Alt+N, oder Palette → „Lokale Shell öffnen“) öffnet die Shell +des eigenen Rechners in einem Tab: unter Windows PowerShell 7 (`pwsh`), sonst Windows PowerShell oder cmd (ConPTY, ab +Windows 10 1809), unter macOS die Login-Shell, unter Linux `$SHELL`. `pwsh`, `cmd`, `wsl -d Ubuntu` oder `zsh` in der +Palette startet genau diese. Als gespeicherte Verbindung („Verbindung über: Lokal (dieser Rechner)“) lassen sich Shell +und Startordner einstellen; leer nimmt jeder Rechner seinen eigenen Standard, ein gesyncter Eintrag passt also unter +Windows wie auf dem Mac. Die KI weiß, ob sie mit PowerShell, cmd oder einer Unix-Shell spricht; Gefahren-Check und +Agent-Stufen arbeiten wie auf einem Server. Dateien (F5), Tunnel und Broadcast brauchen SSH. + ## Screens | Entsperren | Verbindungs-Manager | diff --git a/README.md b/README.md index 80c0cfd..b8df50b 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,7 @@ sshTermy is a lean terminal application (TUI, a single file, ~9 MB, no installer - **a real SSH terminal** (xterm-256color, truecolor, vim/htop/tmux, scrollback, tabs, jump hosts) - **Auto-reconnect**: if the line drops (Wi-Fi, VPN, standby), sshTermy reconnects the session by itself, restarts running tunnels and reattaches tmux/screen (can be turned off in the palette) - **Persistent session** (idea: Dominik Bornhäußer): per connection, always land in the same tmux/screen session on connect, even from another computer. Other sessions already running? sshTermy asks which one. Same session name in two tabs or on two computers = mirrored screen; "view only" attaches tmux read-only. The palette opens a second watching tab or copies an `ssh … tmux attach -r` command for colleagues. Not on switches, Telnet or console. +- **Local shell** (Alt+L): your own PowerShell (Windows, via ConPTY), zsh or bash (macOS/Linux) as a tab, with AI help, goal/agent/plan mode, split view, tabs and session log. Danger rules and agent levels apply on your own computer too; the agent drops its scripts in `~/.sshtermy-agent`. Or save it as a connection („Connect via: Local“) with its own shell (`pwsh`, `cmd`, `wsl`, `bash -l` …) and start folder - **Quick connect**: type `user@host:port` or `ssh -p 2222 user@host` into the palette without saving the connection (agent/default keys, otherwise password) - **Finished in the background**: a command that ran 10 s or longer in a hidden tab marks the tab (✓ / ×) and shows a toast; if the sshTermy window is in the background you also get a desktop notification (Windows, macOS, Linux). The terminal bell marks the tab too. Both can be switched off in the palette - **Agent forwarding** per connection (like `ssh -A`): `git pull`, `ssh` and `scp` on the server use your local keys from ssh-agent, Pageant or the Windows OpenSSH agent, the keys never leave your computer @@ -175,6 +176,7 @@ sshtermy --no-intro # without the start animation (permanently: palette „Sta | | F7 / F8 | previous / next tab | | | Alt+T | all tabs (list: jump, close, rename, duplicate, move) | | | Alt+N / Alt+W | new tab / close tab (also `+` and `×` in the tab bar, right-click a tab for its menu) | +| | Alt+L | local shell in a new tab (also in the manager; palette: `local`, `pwsh`, `cmd`, `wsl`, `zsh` …) | | | F9 / ⇧F1…F8 | quick commands: list / run directly | | | F10 | back to the manager (sessions keep running) | | | ⇧F9 | key bar explains the keys of the current area | @@ -246,6 +248,14 @@ sshTermy types them as soon as the device asks (and answers „Press any key to break. Host overview (F6), config backup, quick commands and the AI work as with SSH; files, tunnels and broadcast need SSH. Linux: the user needs to be in the `dialout` group. Telnet is unencrypted, use it only in trusted networks. +**Local shell:** Alt+L (or the first entry under Alt+N, or palette → „Open local shell“) opens the shell of your own +computer in a tab: PowerShell 7 (`pwsh`), otherwise Windows PowerShell or cmd on Windows (ConPTY, Windows 10 1809 or +newer), your login shell on macOS and `$SHELL` on Linux. Typing `pwsh`, `cmd`, `wsl -d Ubuntu` or `zsh` in the palette +starts that one. As a saved connection („Connect via: Local (this computer)“) you can set the shell and a start folder; +left empty, each computer uses its own default, so a synced entry works on Windows and Mac alike. The AI knows whether it +is talking to PowerShell, cmd or a Unix shell; danger rules and the agent levels work as on a server. Files (F5), +tunnels and broadcast need SSH. + ## Screens The screenshots show the German interface; the English one looks the same. diff --git a/go.mod b/go.mod index 117dbb2..c1f921a 100644 --- a/go.mod +++ b/go.mod @@ -13,7 +13,9 @@ require ( github.com/charmbracelet/x/ansi v0.11.9 github.com/charmbracelet/x/term v0.2.2 github.com/charmbracelet/x/vt v0.1.0 + github.com/charmbracelet/x/xpty v0.1.4 github.com/coder/websocket v1.8.15 + github.com/creack/pty v1.1.24 github.com/jcmturner/gofork v1.7.6 github.com/jcmturner/gokrb5/v8 v8.4.4 github.com/pkg/sftp v1.13.12 @@ -24,6 +26,7 @@ require ( require ( github.com/charmbracelet/colorprofile v0.4.3 // indirect + github.com/charmbracelet/x/conpty v0.2.0 // indirect github.com/charmbracelet/x/exp/ordered v0.1.0 // indirect github.com/charmbracelet/x/termios v0.1.1 // indirect github.com/charmbracelet/x/windows v0.2.2 // indirect diff --git a/go.sum b/go.sum index c785415..2834f61 100644 --- a/go.sum +++ b/go.sum @@ -20,6 +20,8 @@ github.com/charmbracelet/ultraviolet v0.0.0-20261008173134-6b8d4baf91b4 h1:hISLz github.com/charmbracelet/ultraviolet v0.0.0-20261008173134-6b8d4baf91b4/go.mod h1:aJDVk+WOVM1K04rdc/71PMPoUGfjxjhvXfP3Pjz1Zio= github.com/charmbracelet/x/ansi v0.11.9 h1:kIrqLBxtTVbLyyHO2Evoi93EjQo1mylWmpNEsfPxXAM= github.com/charmbracelet/x/ansi v0.11.9/go.mod h1:DG/hpOnaI2QJ/KMMqLL2h0KVhluuJLazf8973P+Vy5w= +github.com/charmbracelet/x/conpty v0.2.0 h1:eKtA2hm34qNfgJCDp/M6Dc0gLy7e07YEK4qAdNGOvVY= +github.com/charmbracelet/x/conpty v0.2.0/go.mod h1:fexgUnVrZgw8scD49f6VSi0Ggj9GWYIrpedRthAwW/8= github.com/charmbracelet/x/exp/golden v0.0.0-20250806222409-83e3a29d542f h1:pk6gmGpCE7F3FcjaOEKYriCvpmIN4+6OS/RD0vm4uIA= github.com/charmbracelet/x/exp/golden v0.0.0-20250806222409-83e3a29d542f/go.mod h1:IfZAMTHB6XkZSeXUqriemErjAWCCzT0LwjKFYCZyw0I= github.com/charmbracelet/x/exp/ordered v0.1.0 h1:55/qLwjIh0gL0Vni+QAWk7T/qRVP6sBf+2agPBgnOFE= @@ -30,12 +32,16 @@ github.com/charmbracelet/x/termios v0.1.1 h1:o3Q2bT8eqzGnGPOYheoYS8eEleT5ZVNYNy8 github.com/charmbracelet/x/termios v0.1.1/go.mod h1:rB7fnv1TgOPOyyKRJ9o+AsTU/vK5WHJ2ivHeut/Pcwo= github.com/charmbracelet/x/windows v0.2.2 h1:IofanmuvaxnKHuV04sC0eBy/smG6kIKrWG2/jYn2GuM= github.com/charmbracelet/x/windows v0.2.2/go.mod h1:/8XtdKZzedat74NQFn0NGlGL4soHB0YQZrETF96h75k= +github.com/charmbracelet/x/xpty v0.1.4 h1:4jaW7u+8AHQMxesiVc+zUMsspu7GyDwtJO+gy/tFtW4= +github.com/charmbracelet/x/xpty v0.1.4/go.mod h1:7t8P7BpPiolHJ1pLzz7/4ujDbD+sUxI9yA3CBOLOIcU= github.com/clipperhouse/displaywidth v0.11.0 h1:lBc6kY44VFw+TDx4I8opi/EtL9m20WSEFgwIwO+UVM8= github.com/clipperhouse/displaywidth v0.11.0/go.mod h1:bkrFNkf81G8HyVqmKGxsPufD3JhNl3dSqnGhOoSD/o0= github.com/clipperhouse/uax29/v2 v2.7.0 h1:+gs4oBZ2gPfVrKPthwbMzWZDaAFPGYK72F0NJv2v7Vk= github.com/clipperhouse/uax29/v2 v2.7.0/go.mod h1:EFJ2TJMRUaplDxHKj1qAEhCtQPW2tJSwu5BF98AuoVM= github.com/coder/websocket v1.8.15 h1:6B2JPeOGlpff2Uz6vOEH1Vzpi0iUz20A+lPVhPHtNUA= github.com/coder/websocket v1.8.15/go.mod h1:NX3SzP+inril6yawo5CQXx8+fk145lPDC6pumgx0mVg= +github.com/creack/pty v1.1.24 h1:bJrF4RRfyJnbTJqzRLHzcGaZK1NeM5kTC9jGgovnR1s= +github.com/creack/pty v1.1.24/go.mod h1:08sCNb52WyoAwi2QDyzUCTgcvVFhUzewun7wtTfvcwE= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= diff --git a/internal/domain/model.go b/internal/domain/model.go index 7bdc966..d62ba08 100644 --- a/internal/domain/model.go +++ b/internal/domain/model.go @@ -9,7 +9,10 @@ package domain import ( "fmt" + "strings" "time" + + "github.com/db9979/sshtermy/internal/i18n" ) // Secret ist ein Geheimnis im Klartext, nur im Arbeitsspeicher. String() und @@ -130,6 +133,12 @@ type Connection struct { Baud int `json:"baud,omitempty"` // 0 = 9600 Frame string `json:"frame,omitempty"` // Datenbits, Parität, Stoppbits, leer = "8N1" + // Lokale Shell (Protocol "local"): Programm samt Argumenten, leer = Standard + // des jeweiligen Rechners (Windows: PowerShell, macOS/Linux: Login-Shell), + // damit der Eintrag nach dem Sync auf jedem Rechner passt. LocalDir: Startordner. + LocalShell string `json:"local_shell,omitempty"` + LocalDir string `json:"local_dir,omitempty"` + CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at,omitempty"` // letzte Änderung (Sync: neuere gewinnt) LastUsed time.Time `json:"last_used,omitempty"` @@ -165,10 +174,17 @@ const ( ProtoSSH Protocol = "" // Standard ProtoTelnet Protocol = "telnet" // unverschlüsselt, für ältere Switches ProtoSerial Protocol = "serial" // serielle Konsole (USB-Konsolenkabel) + ProtoLocal Protocol = "local" // Shell auf diesem Rechner (PTY / ConPTY) ) // Raw: kein SSH, also keine Exec-Abfragen, kein SFTP und keine Tunnel. -func (p Protocol) Raw() bool { return p == ProtoTelnet || p == ProtoSerial } +func (p Protocol) Raw() bool { return p == ProtoTelnet || p == ProtoSerial || p == ProtoLocal } + +// NoHost: Verbindung ohne Host-Angabe (Konsolenkabel, lokale Shell). +func (p Protocol) NoHost() bool { return p == ProtoSerial || p == ProtoLocal } + +// Device: Gegenstelle ist ein Gerät mit eigener Anmeldung (Telnet, Konsole). +func (p Protocol) Device() bool { return p == ProtoTelnet || p == ProtoSerial } // DefaultBaud: übliche Geschwindigkeit von Switch-Konsolen (Aruba, Cisco, HPE). const DefaultBaud = 9600 @@ -198,6 +214,9 @@ func (c Connection) DefaultPort() int { // Target: Anzeige des Ziels, z. B. „admin@10.0.0.1:22“ oder bei seriellen // Verbindungen „COM3 · 9600 8N1“. func (c Connection) Target() string { + if c.Protocol == ProtoLocal { + return c.Addr() + } a := c.ShowAddr() if c.Protocol != ProtoSerial && c.Username != "" { a = c.Username + "@" + a @@ -222,6 +241,13 @@ func (c Connection) Addr() string { } return fmt.Sprintf("%s · %d %s", port, c.SerialBaud(), c.SerialFrame()) } + if c.Protocol == ProtoLocal { + sh := strings.TrimSpace(c.LocalShell) + if sh == "" { + sh = i18n.T("Standard-Shell") + } + return i18n.T("lokal") + " · " + sh + } p := c.Port if p == 0 { p = c.DefaultPort() diff --git a/internal/i18n/en_local.go b/internal/i18n/en_local.go new file mode 100644 index 0000000..10188a8 --- /dev/null +++ b/internal/i18n/en_local.go @@ -0,0 +1,29 @@ +package i18n + +// Texte für die lokale Shell (eigene Datei, damit parallele Änderungen an +// en.go nicht kollidieren). +var enLocal = map[string]string{ + ") · z. B. pwsh, cmd, wsl, zsh, bash -l": ") · e.g. pwsh, cmd, wsl, zsh, bash -l", + "Lokal": "Local", + "lokal": "local", + "Lokal (dieser Rechner)": "Local (this computer)", + "lokale Shell (neuer Tab)": "local shell (new tab)", + "Lokale Shell": "Local shell", + "Lokale Shell in neuem Tab": "Local shell in a new tab", + "Lokale Shell startet nicht: ": "Local shell does not start: ", + "Lokale Shell öffnen": "Open local shell", + "Lokale Shell öffnen: ": "Open local shell: ", + "Standard-Shell": "default shell", + "Startordner": "Start folder", + "Telnet = unverschlüsselt (ältere Switches) · Seriell = USB-Konsolenkabel · Lokal = Shell auf diesem Rechner": "Telnet = unencrypted (older switches) · Serial = USB console cable · Local = shell on this computer", + "dieser Rechner": "this computer", + "leer = Benutzerordner · z. B. ~/projekte": "empty = home folder · e.g. ~/projects", + "leer = Standard dieses Rechners (jetzt: ": "empty = this computer's default (now: ", + "● dieser Rechner": "● this computer", +} + +func init() { + for k, v := range enLocal { + en[k] = v + } +} diff --git a/internal/localsh/localsh.go b/internal/localsh/localsh.go new file mode 100644 index 0000000..03d7581 --- /dev/null +++ b/internal/localsh/localsh.go @@ -0,0 +1,268 @@ +// Package localsh startet die Shell des eigenen Rechners in einem +// Pseudo-Terminal: unter macOS/Linux ein klassisches PTY, unter Windows +// ConPTY (ab Windows 10 1809). sshTermy behandelt den Strom wie eine +// SSH-Shell (Emulator, KI, Protokoll), nur ohne Netz dazwischen. +package localsh + +import ( + "errors" + "io" + "os" + "os/exec" + "path/filepath" + "runtime" + "strings" + "sync" + "sync/atomic" + "time" +) + +// ptyFile: Pseudo-Terminal je System (pty_unix.go, pty_windows.go). +type ptyFile interface { + io.ReadWriteCloser + Resize(cols, rows int) error +} + +// Stream: eine laufende lokale Shell. +type Stream struct { + Shell string // gestartetes Programm (Pfad) + Done chan error // nil = normal beendet (exit) oder von uns geschlossen + + pty ptyFile + cmd *exec.Cmd + mu sync.Mutex + closed atomic.Bool + once sync.Once +} + +// Start startet shell (leer = Standard-Shell des Systems) im Ordner dir +// (leer = Benutzerordner). Alles, was die Shell ausgibt, geht an out. +func Start(shell, dir string, cols, rows int, out io.Writer) (*Stream, error) { + argv, err := Command(shell) + if err != nil { + return nil, err + } + if cols <= 0 { + cols = 80 + } + if rows <= 0 { + rows = 24 + } + cmd := exec.Command(argv[0], argv[1:]...) + if runtime.GOOS == "darwin" && len(argv) == 1 { + // Wie Terminal.app: Login-Shell (lädt .zprofile, Homebrew-Pfad …) + cmd.Args[0] = "-" + filepath.Base(argv[0]) + } + cmd.Dir = StartDir(dir) + cmd.Env = Env(os.Environ()) + p, err := startPty(cmd, cols, rows) + if err != nil { + return nil, err + } + s := &Stream{Shell: argv[0], Done: make(chan error, 1), pty: p, cmd: cmd} + readDone := make(chan struct{}) + go func() { + defer close(readDone) + _, _ = io.Copy(out, p) + }() + go func() { + err := waitProcess(cmd) + // Nach dem Ende der Shell den Rest der Ausgabe noch abholen. Hält ein + // Hintergrundprozess das Terminal offen (oder bei ConPTY, das erst + // nach Close ein EOF liefert), nicht ewig warten. + select { + case <-readDone: + case <-time.After(300 * time.Millisecond): + } + _ = p.Close() + <-readDone + if s.closed.Load() { + err = nil + } + var ee *exec.ExitError + if errors.As(err, &ee) { + err = nil // exit 1 o. ä. ist ein normales Ende + } + s.Done <- err + }() + return s, nil +} + +// Write: Tastendrücke an die Shell. +func (s *Stream) Write(p []byte) (int, error) { + s.mu.Lock() + defer s.mu.Unlock() + return s.pty.Write(p) +} + +// Resize: Fenstergröße weitergeben. +func (s *Stream) Resize(cols, rows int) error { + if cols <= 0 || rows <= 0 { + return nil + } + return s.pty.Resize(cols, rows) +} + +// Close beendet die Shell (samt Kindprozessen, soweit das System sie mitnimmt). +func (s *Stream) Close() error { + s.once.Do(func() { + s.closed.Store(true) + if s.cmd.Process != nil { + _ = s.cmd.Process.Kill() + } + _ = s.pty.Close() + }) + return nil +} + +// Name: kurzer Anzeigename der Shell („pwsh“, „zsh“). +func (s *Stream) Name() string { return ShortName(s.Shell) } + +// ShortName: „C:\…\pwsh.exe“ → „pwsh“, „/bin/zsh“ → „zsh“. +func ShortName(shell string) string { + b := filepath.Base(strings.ReplaceAll(shell, `\`, "/")) + if i := strings.LastIndex(b, "/"); i >= 0 { + b = b[i+1:] + } + return strings.TrimSuffix(strings.TrimSuffix(b, ".exe"), ".EXE") +} + +// Env: Umgebung der Shell. TERM passt zum Emulator von sshTermy; +// SSHTERMY=1 erlaubt eigene Anpassungen im Profil. +func Env(base []string) []string { + out := make([]string, 0, len(base)+3) + for _, e := range base { + k, _, _ := strings.Cut(e, "=") + switch strings.ToUpper(k) { + case "TERM", "COLORTERM", "SSHTERMY": + continue + } + out = append(out, e) + } + return append(out, "TERM=xterm-256color", "COLORTERM=truecolor", "SSHTERMY=1") +} + +// StartDir: gewünschter Ordner, falls es ihn gibt, sonst der Benutzerordner. +func StartDir(dir string) string { + if dir = expandHome(strings.TrimSpace(dir)); dir != "" { + if st, err := os.Stat(dir); err == nil && st.IsDir() { + return dir + } + } + if h, err := os.UserHomeDir(); err == nil { + return h + } + return "" +} + +func expandHome(p string) string { + if p == "~" || strings.HasPrefix(p, "~/") || strings.HasPrefix(p, `~\`) { + if h, err := os.UserHomeDir(); err == nil { + return filepath.Join(h, p[1:]) + } + } + return p +} + +// lookPath ist austauschbar, damit Tests die Auswahl ohne echte Shells prüfen. +var lookPath = exec.LookPath + +// Command zerlegt die Shell-Angabe in Programm und Argumente. Leer = Standard. +// Ein Pfad mit Leerzeichen („C:\Program Files\PowerShell\7\pwsh.exe“) geht +// ohne Anführungszeichen, wenn es die Datei gibt; sonst trennen Leerzeichen +// die Argumente, "…" hält zusammen. +func Command(shell string) ([]string, error) { + shell = strings.TrimSpace(shell) + if shell == "" { + d := Default() + if d == "" { + return nil, errors.New("keine Shell gefunden") + } + return []string{d}, nil + } + if st, err := os.Stat(expandHome(shell)); err == nil && !st.IsDir() { + return []string{expandHome(shell)}, nil + } + argv := splitArgs(shell) + p, err := lookPath(expandHome(argv[0])) + if err != nil { + return nil, err + } + argv[0] = p + return argv, nil +} + +func splitArgs(s string) []string { + var out []string + var cur strings.Builder + quote, have := false, false + for _, r := range s { + switch { + case r == '"': + quote, have = !quote, true + case (r == ' ' || r == '\t') && !quote: + if have { + out = append(out, cur.String()) + cur.Reset() + have = false + } + default: + cur.WriteRune(r) + have = true + } + } + if have { + out = append(out, cur.String()) + } + return out +} + +// Default: Standard-Shell. Windows: PowerShell 7 (pwsh), sonst Windows +// PowerShell, sonst cmd.exe. Unix: $SHELL, sonst zsh/bash/sh. +func Default() string { return defaultFor(runtime.GOOS, os.Getenv) } + +func defaultFor(goos string, env func(string) string) string { + if goos == "windows" { + for _, c := range []string{"pwsh.exe", "powershell.exe"} { + if p, err := lookPath(c); err == nil { + return p + } + } + if c := env("COMSPEC"); c != "" { + return c + } + return "cmd.exe" + } + if sh := env("SHELL"); sh != "" { + if _, err := os.Stat(sh); err == nil { + return sh + } + } + for _, c := range []string{"zsh", "bash", "sh"} { + if p, err := lookPath(c); err == nil { + return p + } + } + return "/bin/sh" +} + +// Dialect: Befehlssatz für die KI zur Shell („powershell“, „cmd“, „macos“, +// „posix“). +func Dialect(goos, shell string) string { + n := strings.ToLower(ShortName(shell)) + switch { + case n == "pwsh" || n == "powershell": + return "powershell" + case n == "cmd": + return "cmd" + case goos == "windows" && (n == "wsl" || n == "bash"): + return "posix" // WSL oder Git-Bash + case goos == "darwin": + return "macos" + case goos == "windows": + return "powershell" + case strings.HasSuffix(goos, "bsd"): + return "bsd" + } + return "posix" +} diff --git a/internal/localsh/localsh_test.go b/internal/localsh/localsh_test.go new file mode 100644 index 0000000..1569b98 --- /dev/null +++ b/internal/localsh/localsh_test.go @@ -0,0 +1,145 @@ +package localsh + +import ( + "bytes" + "errors" + "os/exec" + "runtime" + "strings" + "sync" + "testing" + "time" +) + +type syncBuf struct { + mu sync.Mutex + b bytes.Buffer +} + +func (s *syncBuf) Write(p []byte) (int, error) { + s.mu.Lock() + defer s.mu.Unlock() + return s.b.Write(p) +} +func (s *syncBuf) String() string { + s.mu.Lock() + defer s.mu.Unlock() + return s.b.String() +} + +func TestStartEchoExit(t *testing.T) { + if runtime.GOOS == "windows" { + t.Skip("ConPTY wird von Hand getestet") + } + sh, err := exec.LookPath("sh") + if err != nil { + t.Skip("kein sh") + } + var out syncBuf + s, err := Start(sh, t.TempDir(), 100, 30, &out) + if err != nil { + t.Fatal(err) + } + _, _ = s.Write([]byte("echo sp$((40+2))cols:$(stty size) $TERM; exit\r")) + select { + case err := <-s.Done: + if err != nil { + t.Fatalf("Done: %v", err) + } + case <-time.After(5 * time.Second): + s.Close() + t.Fatalf("Shell endet nicht, Ausgabe: %q", out.String()) + } + got := out.String() + if !strings.Contains(got, "sp42") || !strings.Contains(got, "30 100") || !strings.Contains(got, "xterm-256color") { + t.Fatalf("Ausgabe: %q", got) + } +} + +func TestCloseEndsShell(t *testing.T) { + if runtime.GOOS == "windows" { + t.Skip() + } + sh, err := exec.LookPath("sh") + if err != nil { + t.Skip("kein sh") + } + s, err := Start(sh, "", 80, 24, &syncBuf{}) + if err != nil { + t.Fatal(err) + } + if err := s.Resize(120, 40); err != nil { + t.Fatal(err) + } + s.Close() + select { + case err := <-s.Done: + if err != nil { + t.Fatalf("Done nach Close: %v", err) + } + case <-time.After(5 * time.Second): + t.Fatal("Close beendet die Shell nicht") + } +} + +func TestDialect(t *testing.T) { + cases := []struct{ goos, shell, want string }{ + {"windows", `C:\Program Files\PowerShell\7\pwsh.exe`, "powershell"}, + {"windows", `C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe`, "powershell"}, + {"windows", `C:\WINDOWS\system32\cmd.exe`, "cmd"}, + {"windows", `C:\WINDOWS\system32\wsl.exe`, "posix"}, + {"darwin", "/bin/zsh", "macos"}, + {"linux", "/usr/bin/fish", "posix"}, + {"freebsd", "/bin/sh", "bsd"}, + {"linux", "/usr/bin/pwsh", "powershell"}, + } + for _, c := range cases { + if got := Dialect(c.goos, c.shell); got != c.want { + t.Errorf("Dialect(%s, %s) = %s, want %s", c.goos, c.shell, got, c.want) + } + } +} + +func TestDefaultWindows(t *testing.T) { + old := lookPath + defer func() { lookPath = old }() + have := map[string]bool{} + lookPath = func(f string) (string, error) { + if have[f] { + return `C:\x\` + f, nil + } + return "", errors.New("nicht da") + } + env := func(k string) string { + if k == "COMSPEC" { + return `C:\WINDOWS\system32\cmd.exe` + } + return "" + } + if got := defaultFor("windows", env); got != `C:\WINDOWS\system32\cmd.exe` { + t.Errorf("ohne PowerShell: %s", got) + } + have["powershell.exe"] = true + if got := defaultFor("windows", env); got != `C:\x\powershell.exe` { + t.Errorf("Windows PowerShell: %s", got) + } + have["pwsh.exe"] = true + if got := defaultFor("windows", env); got != `C:\x\pwsh.exe` { + t.Errorf("PowerShell 7: %s", got) + } +} + +func TestSplitArgsAndEnv(t *testing.T) { + got := splitArgs(`wsl.exe -d "Ubuntu 24.04" --cd ~`) + want := []string{"wsl.exe", "-d", "Ubuntu 24.04", "--cd", "~"} + if strings.Join(got, "|") != strings.Join(want, "|") { + t.Fatalf("splitArgs: %q", got) + } + env := strings.Join(Env([]string{"TERM=dumb", "PATH=/bin", "term=x"}), " ") + if strings.Contains(env, "dumb") || !strings.Contains(env, "PATH=/bin") || !strings.Contains(env, "TERM=xterm-256color") { + t.Fatalf("Env: %s", env) + } + if ShortName(`C:\a b\pwsh.exe`) != "pwsh" || ShortName("/bin/zsh") != "zsh" { + t.Fatal("ShortName") + } +} diff --git a/internal/localsh/pty_unix.go b/internal/localsh/pty_unix.go new file mode 100644 index 0000000..f207cd1 --- /dev/null +++ b/internal/localsh/pty_unix.go @@ -0,0 +1,27 @@ +//go:build !windows + +package localsh + +import ( + "os" + "os/exec" + + "github.com/creack/pty" +) + +type unixPty struct{ *os.File } + +func (u unixPty) Resize(cols, rows int) error { + return pty.Setsize(u.File, &pty.Winsize{Cols: uint16(cols), Rows: uint16(rows)}) //nolint:gosec +} + +// startPty: eigene Sitzung mit Steuerterminal (Strg+C, Job-Control). +func startPty(cmd *exec.Cmd, cols, rows int) (ptyFile, error) { + f, err := pty.StartWithSize(cmd, &pty.Winsize{Cols: uint16(cols), Rows: uint16(rows)}) //nolint:gosec + if err != nil { + return nil, err + } + return unixPty{f}, nil +} + +func waitProcess(cmd *exec.Cmd) error { return cmd.Wait() } diff --git a/internal/localsh/pty_windows.go b/internal/localsh/pty_windows.go new file mode 100644 index 0000000..f0d9a90 --- /dev/null +++ b/internal/localsh/pty_windows.go @@ -0,0 +1,26 @@ +//go:build windows + +package localsh + +import ( + "context" + "os/exec" + + "github.com/charmbracelet/x/xpty" +) + +// startPty: ConPTY (Windows 10 1809 und neuer). +func startPty(cmd *exec.Cmd, cols, rows int) (ptyFile, error) { + p, err := xpty.NewConPty(cols, rows) + if err != nil { + return nil, err + } + if err := p.Start(cmd); err != nil { + _ = p.Close() + return nil, err + } + return p, nil +} + +// waitProcess: cmd.Wait funktioniert mit ConPTY nicht (golang/go#62710). +func waitProcess(cmd *exec.Cmd) error { return xpty.WaitProcess(context.Background(), cmd) } diff --git a/internal/store/store.go b/internal/store/store.go index 71a05e5..e7b8330 100644 --- a/internal/store/store.go +++ b/internal/store/store.go @@ -309,7 +309,7 @@ func Validate(c domain.Connection) error { switch { case strings.TrimSpace(c.Alias) == "": return errors.New(i18n.T("Alias fehlt")) - case strings.TrimSpace(c.Host) == "" && c.Protocol != domain.ProtoSerial: + case strings.TrimSpace(c.Host) == "" && !c.Protocol.NoHost(): return errors.New(i18n.T("Host fehlt")) case c.Port < 0 || c.Port > 65535: return errors.New(i18n.T("Port ungültig")) diff --git a/internal/ui/accent.go b/internal/ui/accent.go index c037c1e..16dfb08 100644 --- a/internal/ui/accent.go +++ b/internal/ui/accent.go @@ -184,6 +184,8 @@ func deviceClass(c domain.Connection) devClass { var p domain.SystemProfile if c.Profile != nil { p = *c.Profile + } else if c.Protocol == domain.ProtoLocal { + p = localProfile(c.LocalShell) } hay := strings.ToLower(p.OS + " " + p.Model + " " + p.Banner) for _, k := range []string{"fortigate", "fortios", "pfsense", "opnsense", "firewall", "sophos", "palo alto", "pan-os", "asa", "checkpoint", "sonicwall", "watchguard"} { diff --git a/internal/ui/agentmode.go b/internal/ui/agentmode.go index a3572b5..024d6b2 100644 --- a/internal/ui/agentmode.go +++ b/internal/ui/agentmode.go @@ -82,7 +82,7 @@ func newRunID() string { // agentFilesOK: kann der Agent hier Dateien anlegen? Nur über SSH mit SFTP // auf Unix-Systemen; Switches, Telnet und serielle Konsolen bekommen nur Befehle. func (a *App) agentFilesOK(s *session) bool { - return s.client != nil && !s.netDevice() && a.safetyKind(s) == "unix" + return (s.client != nil || s.isLocal()) && !s.netDevice() && a.safetyKind(s) == "unix" } // agentInit: neuer Lauf (aus startGoalWith). @@ -298,8 +298,7 @@ func (a *App) writeAgentFile(s *session) tea.Cmd { } f := *g.cur.File g.cur, g.armed = nil, false - cl := s.client - if cl == nil || !a.agentFilesOK(s) { + if !a.agentFilesOK(s) { g.steps = append(g.steps, agent.DoneStep{Command: i18n.T("Datei ") + f.Name, File: f.Name, ExitHint: i18n.T("Dateien gehen hier nicht")}) return a.agentNext(s) } @@ -309,12 +308,13 @@ func (a *App) writeAgentFile(s *session) tea.Cmd { } g.writing = true sid, seq, run := s.id, g.seq, g.runID + local, cl := s.agentFSOf() return func() tea.Msg { - fs, err := cl.OpenSFTP() + fs, done, err := agentFS(local, cl) if err != nil { return agentFileMsg{sid, seq, f, err} } - defer fs.Close() + defer done() dir := fs.Join(fs.Home(), agentDirBase, run) if err := fs.Mkdir(dir); err != nil { return agentFileMsg{sid, seq, f, err} @@ -375,17 +375,17 @@ func (a *App) agentFileDone(m agentFileMsg) tea.Cmd { // agentCleanup löscht den Arbeitsordner des Laufs auf dem Host. func (a *App) agentCleanup(s *session) tea.Cmd { g := &s.goal - cl := s.client - if cl == nil || len(g.files) == 0 || g.cleaned { + if (s.client == nil && !s.isLocal()) || len(g.files) == 0 || g.cleaned { return nil } sid, run, show := s.id, g.runID, g.agentDir() + local, cl := s.agentFSOf() return func() tea.Msg { - fs, err := cl.OpenSFTP() + fs, done, err := agentFS(local, cl) if err != nil { return agentCleanMsg{sid, show, err} } - defer fs.Close() + defer done() return agentCleanMsg{sid, show, fs.RemoveAll(fs.Join(fs.Home(), agentDirBase, run))} } } diff --git a/internal/ui/app.go b/internal/ui/app.go index 6fded37..40978c6 100644 --- a/internal/ui/app.go +++ b/internal/ui/app.go @@ -456,6 +456,9 @@ func (a *App) update(msg tea.Msg) (tea.Model, tea.Cmd) { if a.keys.is(actPalette, k.String()) && (a.scr == scrTerminal || a.scr == scrManager || a.scr == scrLogs) { return a, a.openPalette() } + if a.keys.is(actLocal, k.String()) && (a.scr == scrTerminal || a.scr == scrManager) && a.lock == nil { + return a, a.openLocal("") + } } if pm, ok := msg.(tea.PasteMsg); ok && a.modal != nil { // Einfügen in einen offenen Dialog: nur das Eingabefeld nimmt es an. diff --git a/internal/ui/help.go b/internal/ui/help.go index 18e70c4..b2c4cfb 100644 --- a/internal/ui/help.go +++ b/internal/ui/help.go @@ -107,6 +107,7 @@ var helpSections = []helpSection{ {"F7 / F8", "Tab wechseln"}, {"Alt+T", "alle Tabs (Liste)"}, {"Alt+N", "neuer Tab"}, + {"Alt+L", "lokale Shell (neuer Tab)"}, {"Alt+W", "Tab schließen"}, {"F10", "zum Manager"}, {"Abbruch", "verbindet neu (⏎ / Esc)"}, diff --git a/internal/ui/keymap.go b/internal/ui/keymap.go index b91cf54..3191706 100644 --- a/internal/ui/keymap.go +++ b/internal/ui/keymap.go @@ -60,6 +60,7 @@ const ( actNewTab action = "new_tab" actCloseTab action = "close_tab" actTabList action = "tab_list" + actLocal action = "local_shell" actZoom action = "zoom" actGrowLeft action = "pane_left" actGrowRight action = "pane_right" @@ -86,6 +87,7 @@ var actionDefs = []actionDef{ {actAbout, "Über & Update", "Überall", []string{"f12"}}, {actCheat, "Tastenzeile erklären an/aus", "Überall", []string{"shift+f9", "f21"}}, {actQuit, "Beenden", "Überall", []string{"ctrl+q"}}, + {actLocal, "Lokale Shell öffnen", "Überall", []string{"alt+l"}}, {actGoal, "Ziel-Modus (Agent)", "Terminal", []string{"f2"}}, {actAsk, "KI fragen", "Terminal", []string{"f3"}}, {actTunnels, "Tunnel", "Terminal", []string{"f4"}}, diff --git a/internal/ui/localconn.go b/internal/ui/localconn.go new file mode 100644 index 0000000..fef7699 --- /dev/null +++ b/internal/ui/localconn.go @@ -0,0 +1,150 @@ +package ui + +import ( + "runtime" + "strings" + + tea "charm.land/bubbletea/v2" + + "github.com/db9979/sshtermy/internal/domain" + "github.com/db9979/sshtermy/internal/i18n" + "github.com/db9979/sshtermy/internal/localsh" + "github.com/db9979/sshtermy/internal/sshx" +) + +// Lokale Shell: ein Tab mit der Shell dieses Rechners (PowerShell unter +// Windows über ConPTY, zsh/bash unter macOS/Linux über ein PTY). Sie läuft +// wie Telnet/Konsole ohne SSH-Client (s.client == nil), bekommt aber ein +// Systemprofil aus dem eigenen Rechner, damit KI, Gefahren-Check und +// Agent-Stufen den richtigen Befehlssatz (Windows/Unix) kennen. + +// localQuickID: Kennung der Ad-hoc-Shell (Palette, neuer Tab, Alt+L). +const localQuickID = "quick:local" + +// localConn: Ad-hoc-Verbindung für die Standard-Shell (oder eine bestimmte). +func localConn(shell string) domain.Connection { + alias := i18n.T("Lokal") + id := localQuickID + if shell != "" { + alias = i18n.T("Lokal") + " · " + localsh.ShortName(shell) + id += ":" + shell + } + return domain.Connection{ID: id, Alias: alias, Protocol: domain.ProtoLocal, LocalShell: shell} +} + +// openLocal: neuer Tab mit der lokalen Shell (immer ein neuer, mehrere +// lokale Tabs nebeneinander sind normal). +func (a *App) openLocal(shell string) tea.Cmd { + return a.connect(localConn(shell)) +} + +func (s *session) isLocal() bool { return s.conn.Protocol == domain.ProtoLocal } + +// localShellName: Name der laufenden (oder eingestellten) Shell. +func (s *session) localShellName() string { + if st, ok := s.shell.(*localsh.Stream); ok { + return st.Name() + } + return localShellLabel(s.conn.LocalShell) +} + +func localShellLabel(shell string) string { + if strings.TrimSpace(shell) == "" { + shell = localsh.Default() + } + return localsh.ShortName(shell) +} + +// localProfile: Systemprofil dieses Rechners für die gewählte Shell. +func localProfile(shellPath string) domain.SystemProfile { + if strings.TrimSpace(shellPath) == "" { + shellPath = localsh.Default() + } + p := domain.SystemProfile{Dialect: localsh.Dialect(runtime.GOOS, shellPath), Shell: shellPath} + switch runtime.GOOS { + case "windows": + p.Family, p.OS = domain.FamilyWindows, "Windows" + case "darwin": + p.Family, p.OS = domain.FamilyMacOS, "macOS" + case "linux": + p.Family, p.OS = domain.FamilyLinux, "Linux" + default: + p.Family, p.OS = domain.FamilyBSD, runtime.GOOS + } + if p.Dialect == "posix" && runtime.GOOS == "windows" { + p.OS = "Windows (WSL/Git-Bash)" + } + p.OS += " · " + i18n.T("dieser Rechner") + return p +} + +// localWindowsShell: PowerShell oder cmd (Regeln für Windows statt Unix). +func localWindowsShell(p domain.SystemProfile) bool { + return p.Dialect == "powershell" || p.Dialect == "cmd" +} + +// agentFS: Dateisystem, in dem der Agent seine Skripte ablegt (SFTP über +// SSH, bei der lokalen Shell die eigene Platte). close räumt auf. +// Aufruf im Hintergrund, daher mit vorher gelesenem Zustand (agentFSOf). +func agentFS(local bool, cl *sshx.Client) (fs sshx.FS, closeFn func(), err error) { + if local { + return sshx.LocalFS{}, func() {}, nil + } + if cl == nil { + return nil, nil, errNoFiles + } + r, err := cl.OpenSFTP() + if err != nil { + return nil, nil, err + } + return r, func() { _ = r.Close() }, nil +} + +func (s *session) agentFSOf() (bool, *sshx.Client) { return s.isLocal(), s.client } + +var errNoFiles = i18n.NewError("Dateien gehen hier nicht") + +// localPalette: Einträge „Lokale Shell öffnen“ in der Befehlspalette. +func (a *App) localPalette() []palItem { + return []palItem{{group: pgConnect, icon: ic("command"), label: i18n.T("Lokale Shell öffnen"), + hint: a.keys.label(actLocal), keys: "local lokal shell terminal powershell pwsh cmd zsh bash", + run: func() tea.Cmd { return a.openLocal("") }}} +} + +// parseQuickLocal: „lokal“, „local“, „shell“ oder ein Shell-Name („pwsh“, +// „cmd“, „zsh“, „wsl“ …) in der Palette. +func parseQuickLocal(q string) (domain.Connection, bool) { + f := strings.Fields(strings.TrimSpace(q)) + if len(f) == 0 { + return domain.Connection{}, false + } + switch w := strings.ToLower(f[0]); { + case len(f) == 1 && (w == "lokal" || w == "local" || w == "shell" || w == "localhost"): + return localConn(""), true + case knownShell(w): + return localConn(strings.TrimSpace(q)), true + } + return domain.Connection{}, false +} + +func knownShell(w string) bool { + switch strings.TrimSuffix(w, ".exe") { + case "pwsh", "powershell", "cmd", "wsl", "zsh", "bash", "fish", "sh", "nu", "tcsh", "ksh": + return true + } + return false +} + +// quickLocalItems: Palette-Einträge für eine getippte Shell. +func (a *App) quickLocalItems(c domain.Connection) []palItem { + return []palItem{ + {group: pgConnect, icon: ic("command"), label: i18n.T("Lokale Shell öffnen: ") + localShellLabel(c.LocalShell), hint: i18n.T("dieser Rechner"), + run: func() tea.Cmd { return a.connect(c) }}, + {group: pgConnect, icon: ic("new"), label: i18n.T("Als Verbindung speichern: ") + c.Alias, hint: i18n.T("anlegen"), + run: func() tea.Cmd { + n := c + n.ID = "" + return a.openConnForm(n) + }}, + } +} diff --git a/internal/ui/localconn_unix_test.go b/internal/ui/localconn_unix_test.go new file mode 100644 index 0000000..a7c275e --- /dev/null +++ b/internal/ui/localconn_unix_test.go @@ -0,0 +1,77 @@ +//go:build linux || darwin + +package ui + +import ( + "os/exec" + "strings" + "testing" + "time" + + "github.com/db9979/sshtermy/internal/domain" + "github.com/db9979/sshtermy/internal/safety" +) + +// Lokale Shell: Tab startet, Befehle laufen, Profil kommt vom eigenen +// Rechner (Unix-Regeln, kein Netzwerkgerät), exit beendet ohne Auto-Reconnect. +func TestLocalSession(t *testing.T) { + sh, err := exec.LookPath("sh") + if err != nil { + t.Skip("kein sh") + } + a, st := rawTestApp(t) + closed := make(chan shellClosedMsg, 1) + go func() { + for m := range a.events { + if c, ok := m.(shellClosedMsg); ok { + closed <- c + } + } + }() + dir := t.TempDir() + c, err := st.UpsertConnection(domain.Connection{Alias: "Hier", Protocol: domain.ProtoLocal, LocalShell: sh, LocalDir: dir}) + if err != nil { + t.Fatal(err) + } + s := &session{id: 1, conn: c, chipArmed: -1} + a.sessions = []*session{s} + msg := a.connectCmd(s)() + if e, ok := msg.(connectErrMsg); ok { + t.Fatal(e.err) + } + a.Update(msg) + if s.state != stConnected || s.netDev() || s.netDevice() { + t.Fatalf("Zustand %v, netDev %v", s.state, s.netDev()) + } + if s.prof.Dialect == "" || s.prof.Shell != sh || a.safetyKind(s) != "unix" { + t.Fatalf("Profil %+v, Regeln %s", s.prof, a.safetyKind(s)) + } + if !a.agentFilesOK(s) { + t.Fatal("Agent soll lokal Skripte ablegen dürfen") + } + if got := safety.Check("rm -rf /", a.safetyKind(s)); len(got) == 0 { + t.Fatal("Gefahren-Check greift lokal nicht") + } + ctx := a.agentContext(s, false) + if ctx.Net || !strings.Contains(ctx.Profile, "Shell: "+sh) || ctx.Shell != "sh" { + t.Fatalf("KI-Kontext: %+v", ctx) + } + s.term.SendText("echo lo$((1+1))cal; pwd\r") + waitFor(t, func() bool { + scr := s.term.PlainLines(20) + return strings.Contains(scr, "lo2cal") && strings.Contains(scr, dir) + }) + s.term.SendText("exit\r") + select { + case m := <-closed: + if m.dropped { + t.Fatal("exit gilt als Abriss") + } + a.onShellClosed(s, m) + if s.state != stClosed || s.rc.active { + t.Fatalf("nach exit: %v, reconnect %v", s.state, s.rc.active) + } + case <-time.After(5 * time.Second): + t.Fatal("Shell endet nicht") + } +} diff --git a/internal/ui/manager.go b/internal/ui/manager.go index e91e3a9..9211e0a 100644 --- a/internal/ui/manager.go +++ b/internal/ui/manager.go @@ -562,7 +562,13 @@ func (a *App) viewManager() string { auth = i18n.T("automatisch, sobald das Gerät fragt") } } - row(i18n.T("Anmeldung"), auth) + if c.Protocol == domain.ProtoLocal { + if c.LocalDir != "" { + row(i18n.T("Startordner"), c.LocalDir) + } + } else { + row(i18n.T("Anmeldung"), auth) + } if c.JumpHostID != "" { row(i18n.T("Jump-Host"), a.jumpChainText(c)) } @@ -643,12 +649,16 @@ func (a *App) openConnForm(c domain.Connection) tea.Cmd { } f.section("s_conn", i18n.T("Verbindung"), func(t Theme) color.Color { return t.Accent }) f.text("alias", "Alias", c.Alias, i18n.T("Anzeigename, z. B. „DGX Spark“")) - f.choice("proto", i18n.T("Verbindungsart"), protoLabels, protoLabel(c.Protocol), i18n.T("Telnet = unverschlüsselt (ältere Switches) · Seriell = USB-Konsolenkabel")).value = protoLabel(c.Protocol) + f.choice("proto", i18n.T("Verbindungsart"), protoLabels, protoLabel(c.Protocol), i18n.T("Telnet = unverschlüsselt (ältere Switches) · Seriell = USB-Konsolenkabel · Lokal = Shell auf diesem Rechner")).value = protoLabel(c.Protocol) isProto := func(p domain.Protocol) bool { return protoFromLabel(f.sel("proto")) == p } raw := func(*form) bool { return protoFromLabel(f.sel("proto")).Raw() } notSerial := func(*form) bool { return !isProto(domain.ProtoSerial) } - f.text("host", "Host", c.Host, i18n.T("Name oder IP")).hidden = func(*form) bool { return isProto(domain.ProtoSerial) } - f.number("port", "Port", c.Port, i18n.T("Standard 22 · Telnet 23")).hidden = func(*form) bool { return isProto(domain.ProtoSerial) } + notLocal := func(*form) bool { return !isProto(domain.ProtoLocal) } + noHost := func(*form) bool { return protoFromLabel(f.sel("proto")).NoHost() } + f.text("host", "Host", c.Host, i18n.T("Name oder IP")).hidden = noHost + f.number("port", "Port", c.Port, i18n.T("Standard 22 · Telnet 23")).hidden = noHost + f.text("lshell", "Shell", c.LocalShell, i18n.T("leer = Standard dieses Rechners (jetzt: ")+localShellLabel("")+i18n.T(") · z. B. pwsh, cmd, wsl, zsh, bash -l")).hidden = notLocal + f.text("ldir", i18n.T("Startordner"), c.LocalDir, i18n.T("leer = Benutzerordner · z. B. ~/projekte")).hidden = notLocal sports, scur := serialPortOptions(c.SerialPort) f.choice("sport", i18n.T("Schnittstelle"), sports, scur, serialPortHelp()).hidden = notSerial f.choice("baud", "Baud", baudOpts(c.SerialBaud()), strconv.Itoa(c.SerialBaud()), i18n.T("Aruba/HPE/Cisco: 9600 · viele neuere Geräte: 115200")).hidden = notSerial @@ -658,8 +668,10 @@ func (a *App) openConnForm(c domain.Connection) tea.Cmd { func() tea.Cmd { return a.pickJumpField(self) }, i18n.T("wie ssh -J · ⏎ öffnet die Liste aller Verbindungen mit Suche")).hidden = raw a.addRelayField(f, c) - f.section("s_auth", i18n.T("Anmeldung"), func(t Theme) color.Color { return t.Warn }) - f.text("user", i18n.T("Benutzer"), c.Username, "").help = i18n.T("Telnet/Konsole: optional, wird eingetippt, sobald das Gerät fragt") + f.section("s_auth", i18n.T("Anmeldung"), func(t Theme) color.Color { return t.Warn }).hidden = func(*form) bool { return isProto(domain.ProtoLocal) } + uf := f.text("user", i18n.T("Benutzer"), c.Username, "") + uf.help = i18n.T("Telnet/Konsole: optional, wird eingetippt, sobald das Gerät fragt") + uf.hidden = func(*form) bool { return isProto(domain.ProtoLocal) } f.choice("auth", i18n.T("Verfahren"), []string{"agent", "keyfile", "password", "kerberos"}, string(c.Auth), i18n.T("agent = ssh-agent / Windows OpenSSH-Agent (empfohlen) · kerberos = Ticket der Firmen-Domäne (Windows-Anmeldung oder kinit)")).hidden = raw isAuth := func(v string) func(*form) bool { return func(f *form) bool { return raw(f) || f.sel("auth") != v } @@ -671,7 +683,7 @@ func (a *App) openConnForm(c domain.Connection) tea.Cmd { pw, pp = a.formKC[0], a.formKC[1] } f.secret("password", i18n.T("Passwort"), pw, i18n.T("wird mit AES-256-GCM verschlüsselt gespeichert")).hidden = func(f *form) bool { - return !raw(f) && f.sel("auth") != "password" + return isProto(domain.ProtoLocal) || !raw(f) && f.sel("auth") != "password" } f.text("keypath", "Keyfile", c.KeyPath, i18n.T("z. B. ~/.ssh/id_ed25519 (leer lassen bei eingebettetem Key)")).hidden = isAuth("keyfile") f.secret("keypass", "Passphrase", pp, i18n.T("optional; leer = beim Verbinden fragen")).hidden = isAuth("keyfile") @@ -876,6 +888,14 @@ func (a *App) saveConn() error { c.Alias, c.Host, c.Port, c.Username = f.str("alias"), f.str("host"), f.num("port"), f.str("user") c.Protocol = protoFromLabel(f.sel("proto")) c.SerialPort, c.Baud, c.Frame = "", 0, "" + c.LocalShell, c.LocalDir = "", "" + if c.Protocol == domain.ProtoLocal { + c.LocalShell, c.LocalDir = f.str("lshell"), f.str("ldir") + c.Host, c.Port, c.Username = "", 0, "" + if c.Alias == "" { + c.Alias = i18n.T("Lokal") + } + } if c.Protocol == domain.ProtoSerial { if p := f.sel("sport"); p != serialAuto { c.SerialPort = p @@ -890,7 +910,7 @@ func (a *App) saveConn() error { if c.Protocol == domain.ProtoTelnet && c.Port == 22 && a.formBase.Protocol != domain.ProtoTelnet { c.Port = 23 // Vorbelegung für SSH stehen gelassen } - if c.Port == 0 && c.Protocol != domain.ProtoSerial { + if c.Port == 0 && !c.Protocol.NoHost() { c.Port = c.DefaultPort() } c.Auth = domain.AuthMethod(f.sel("auth")) @@ -900,7 +920,9 @@ func (a *App) saveConn() error { } switch c.Auth { case domain.AuthPassword: - c.Password = domain.Secret(f.raw("password")) + if c.Protocol != domain.ProtoLocal { + c.Password = domain.Secret(f.raw("password")) + } case domain.AuthKeyFile: c.KeyPath, c.KeyPassphrase = f.str("keypath"), domain.Secret(f.raw("keypass")) c.CertPath = f.str("certpath") diff --git a/internal/ui/palette.go b/internal/ui/palette.go index a9412fb..44f5a3d 100644 --- a/internal/ui/palette.go +++ b/internal/ui/palette.go @@ -335,11 +335,13 @@ func (a *App) paletteItems() []palItem { actions = append(actions, palItem{icon: ic("tabs"), label: i18n.T("Alle Tabs zeigen"), hint: a.keys.label(actTabList), run: func() tea.Cmd { return a.openTabList() }}, palItem{icon: ic("new"), label: i18n.T("Neuer Tab"), hint: a.keys.label(actNewTab), run: func() tea.Cmd { return a.openNewTab() }}, + palItem{icon: ic("command"), label: i18n.T("Lokale Shell in neuem Tab"), hint: a.keys.label(actLocal), keys: "local lokal shell terminal powershell pwsh cmd zsh bash", run: func() tea.Cmd { return a.openLocal("") }}, palItem{icon: ic("rename"), label: i18n.T("Tab umbenennen"), hint: trunc(s.tabName(), 16), run: func() tea.Cmd { return a.renameTab(s, nil) }}, palItem{icon: ic("tabs"), label: i18n.T("Tab duplizieren"), hint: trunc(s.conn.Alias, 16), run: func() tea.Cmd { return a.duplicateTab(s) }}, palItem{icon: ic("close"), label: i18n.T("Tab schließen"), hint: a.keys.label(actCloseTab), run: func() tea.Cmd { return a.closeTabAsk(s, nil) }}) } if a.scr == scrManager { + actions = append(actions, a.localPalette()...) actions = append(actions, palItem{icon: ic("split"), label: i18n.T("Arbeitsplätze …"), hint: a.keys.label(actWorkspace), keys: "workspace layout", run: func() tea.Cmd { return a.openWorkspaces() }}) } actions = append(actions, palItem{icon: ic("sshkey"), label: i18n.T("Jetzt sperren"), hint: i18n.T("Master-Passwort"), run: func() tea.Cmd { return a.lockNow() }}) diff --git a/internal/ui/profile.go b/internal/ui/profile.go index 1c4bca1..8986572 100644 --- a/internal/ui/profile.go +++ b/internal/ui/profile.go @@ -11,6 +11,7 @@ import ( "github.com/db9979/sshtermy/internal/domain" "github.com/db9979/sshtermy/internal/hostinfo" "github.com/db9979/sshtermy/internal/i18n" + "github.com/db9979/sshtermy/internal/localsh" "github.com/db9979/sshtermy/internal/sysprof" ) @@ -27,6 +28,16 @@ func (a *App) profileConnected(s *session) { var fresh domain.SystemProfile if s.client != nil { fresh = s.client.Profile + } else if s.isLocal() { + sh := s.conn.LocalShell + if st, ok := s.shell.(*localsh.Stream); ok { + sh = st.Shell + } + // Eigener Rechner: Profil steht fest (Shell kann je Rechner anders sein) + fresh = localProfile(sh) + if !old.Manual { + old.Family, old.OS, old.Dialect, old.Shell = "", "", "", "" + } } else if s.netDev() { fresh.Family = domain.FamilyNetwork // Telnet/Konsole: Rest kommt aus dem Bildschirm } diff --git a/internal/ui/quick.go b/internal/ui/quick.go index 9172070..f6c1b26 100644 --- a/internal/ui/quick.go +++ b/internal/ui/quick.go @@ -100,6 +100,9 @@ func (a *App) remoteText(s *session) string { if s.client != nil { return s.profileSummary() + " " + s.client.Remote.String() } + if s.isLocal() && localWindowsShell(s.prof) { + return "Windows" // PowerShell/cmd: Windows-Regeln; WSL/Git-Bash: Unix + } return "" } diff --git a/internal/ui/quickconnect.go b/internal/ui/quickconnect.go index e5031d2..1d921f6 100644 --- a/internal/ui/quickconnect.go +++ b/internal/ui/quickconnect.go @@ -162,6 +162,9 @@ func (a *App) quickItems(q string) (items []palItem, strong bool) { if rc, ok := parseQuickRaw(q); ok { return a.quickRawItems(rc), true } + if lc, ok := parseQuickLocal(q); ok { + return a.quickLocalItems(lc), true + } c, strong, ok := parseQuick(q) if !ok { return nil, false diff --git a/internal/ui/rawconn.go b/internal/ui/rawconn.go index 6ac7eaf..4ad6e8a 100644 --- a/internal/ui/rawconn.go +++ b/internal/ui/rawconn.go @@ -13,6 +13,7 @@ import ( "github.com/db9979/sshtermy/internal/autologin" "github.com/db9979/sshtermy/internal/domain" "github.com/db9979/sshtermy/internal/i18n" + "github.com/db9979/sshtermy/internal/localsh" "github.com/db9979/sshtermy/internal/serialx" "github.com/db9979/sshtermy/internal/telnet" "github.com/db9979/sshtermy/internal/termemu" @@ -36,7 +37,7 @@ func (s *session) netDev() bool { if s.client != nil { return s.client.NetDevice } - return s.conn.Protocol.Raw() && s.conn.Device != domain.DeviceServer + return s.conn.Protocol.Device() && s.conn.Device != domain.DeviceServer } // serialPorts ist austauschbar, damit Tests ohne Kabel auskommen. @@ -70,6 +71,9 @@ func (a *App) connectRawCmd(s *session, cols, rows int, keepTerm bool) tea.Cmd { }() }) out := io.MultiWriter(outWriter{s, ev}, login) + if c.Protocol == domain.ProtoLocal { + out = outWriter{s, ev} // keine Anmeldung + } var done <-chan error note := "" @@ -95,6 +99,12 @@ func (a *App) connectRawCmd(s *session, cols, rows int, keepTerm bool) tea.Cmd { if guessed { note = i18n.F("Konsolenkabel an %s gefunden (gespeichert: %s)", name, c.SerialPort) } + case domain.ProtoLocal: + l, err := localsh.Start(c.LocalShell, c.LocalDir, cols, rows, out) + if err != nil { + return fail(errors.New(i18n.T("Lokale Shell startet nicht: ") + err.Error())) + } + st, done = l, l.Done default: return fail(errors.New("unknown protocol " + string(c.Protocol))) } @@ -105,7 +115,8 @@ func (a *App) connectRawCmd(s *session, cols, rows int, keepTerm bool) tea.Cmd { } go func() { err := <-done - ev <- shellClosedMsg{s.id, st, err, err != nil} + // exit in der lokalen Shell ist ein gewolltes Ende, kein Abriss + ev <- shellClosedMsg{s.id, st, err, err != nil && c.Protocol != domain.ProtoLocal} }() return connectedMsg{sid: s.id, shell: st, note: note} } @@ -164,6 +175,8 @@ func (a *App) protoBadge(s *session) string { } name = strings.TrimPrefix(name, "/dev/") return st.Badge.Foreground(st.T.Accent).Render("≈ " + name + " " + strconv.Itoa(s.conn.SerialBaud())) + case domain.ProtoLocal: + return st.Badge.Foreground(st.T.Accent).Render("$ " + s.localShellName() + " · " + i18n.T("lokal")) } return "" } @@ -187,6 +200,8 @@ func shortTarget(c domain.Connection) string { p = "USB" } return "≈ " + p + case domain.ProtoLocal: + return "$ " + localShellLabel(c.LocalShell) + " · " + i18n.T("lokal") } return t } @@ -194,10 +209,12 @@ func shortTarget(c domain.Connection) string { // ---------------------------------------------------------------- Formular // protoLabels: Auswahl im Verbindungsformular. -var protoLabels = []string{"SSH", "Telnet", "Seriell (Konsolenkabel)"} +var protoLabels = []string{"SSH", "Telnet", "Seriell (Konsolenkabel)", "Lokal (dieser Rechner)"} func protoLabel(p domain.Protocol) string { switch p { + case domain.ProtoLocal: + return protoLabels[3] case domain.ProtoTelnet: return protoLabels[1] case domain.ProtoSerial: @@ -212,6 +229,8 @@ func protoFromLabel(l string) domain.Protocol { return domain.ProtoTelnet case protoLabels[2]: return domain.ProtoSerial + case protoLabels[3]: + return domain.ProtoLocal } return domain.ProtoSSH } @@ -398,6 +417,9 @@ func (s *session) remoteString() string { if s.client != nil { return s.client.Remote.String() } + if s.isLocal() && localWindowsShell(s.prof) { + return "Windows " + s.profileSummary() + } return s.profileSummary() } diff --git a/internal/ui/rawconn_test.go b/internal/ui/rawconn_test.go index eb761d7..92633ee 100644 --- a/internal/ui/rawconn_test.go +++ b/internal/ui/rawconn_test.go @@ -196,3 +196,20 @@ func setChoice(t *testing.T, f *form, key, val string) { } t.Fatalf("%s: keine Option %q in %v", key, val, fl.options) } + +func TestParseQuickLocal(t *testing.T) { + for q, want := range map[string]string{"lokal": "", "Local": "", "pwsh": "pwsh", "wsl -d Ubuntu": "wsl -d Ubuntu", "cmd.exe": "cmd.exe"} { + c, ok := parseQuickLocal(q) + if !ok || c.Protocol != domain.ProtoLocal || c.LocalShell != want { + t.Errorf("%q: %+v %v", q, c, ok) + } + } + for _, q := range []string{"lokalserver", "pwsh.example.com", "admin@host", ""} { + if _, ok := parseQuickLocal(q); ok { + t.Errorf("%q gilt fälschlich als lokale Shell", q) + } + } + if err := store.Validate(domain.Connection{Alias: "x", Protocol: domain.ProtoLocal}); err != nil { + t.Fatal(err) + } +} diff --git a/internal/ui/reach.go b/internal/ui/reach.go index 1695a41..ddbacd7 100644 --- a/internal/ui/reach.go +++ b/internal/ui/reach.go @@ -135,6 +135,9 @@ func (a *App) reachDot(c domain.Connection) (string, color.Color) { if a.connected(c.ID) { return "◉", t.OK } + if c.Protocol == domain.ProtoLocal { + return "●", t.OK + } r, ok := a.reach.res[c.ID] switch { case !a.reachEnabled() || !ok: @@ -157,6 +160,9 @@ func (a *App) reachText(c domain.Connection) string { if c.Protocol == domain.ProtoSerial { return s.Muted.Render(i18n.T("○ serielle Konsole, Kabel wird beim Verbinden gesucht")) } + if c.Protocol == domain.ProtoLocal { + return s.OK.Render(i18n.T("● dieser Rechner")) + s.Muted.Render(" · "+localShellLabel(c.LocalShell)) + } if !a.reachEnabled() { return s.Muted.Render(i18n.T("○ Prüfung aus (Befehlspalette)")) } diff --git a/internal/ui/restore.go b/internal/ui/restore.go index b5403f3..fabb92a 100644 --- a/internal/ui/restore.go +++ b/internal/ui/restore.go @@ -52,6 +52,7 @@ func adhocCopy(c domain.Connection) *domain.Connection { Alias: c.Alias, Host: c.Host, Port: c.Port, Username: c.Username, Auth: c.Auth, KeyPath: c.KeyPath, JumpHostID: c.JumpHostID, RelayID: c.RelayID, RelaySystem: c.RelaySystem, Device: c.Device, Protocol: c.Protocol, SerialPort: c.SerialPort, Baud: c.Baud, Frame: c.Frame, + LocalShell: c.LocalShell, LocalDir: c.LocalDir, Persist: c.Persist, PersistName: c.PersistName, PersistView: c.PersistView, ForwardAgent: c.ForwardAgent, ForwardX11: c.ForwardX11, CertPath: c.CertPath, } @@ -139,7 +140,7 @@ func (a *App) restoreTabs() tea.Cmd { continue // inzwischen gelöscht (z. B. per Sync) } c = cc - case t.Adhoc != nil && (t.Adhoc.Host != "" || t.Adhoc.Protocol == domain.ProtoSerial): + case t.Adhoc != nil && (t.Adhoc.Host != "" || t.Adhoc.Protocol.NoHost()): c = *t.Adhoc default: continue diff --git a/internal/ui/session.go b/internal/ui/session.go index 9978231..a531804 100644 --- a/internal/ui/session.go +++ b/internal/ui/session.go @@ -294,6 +294,9 @@ func (a *App) agentContext(s *session, withScreen bool) agent.Context { c.OS = s.profileSummary() c.Profile = s.prof.Prompt() c.Net = s.netDevice() + if s.isLocal() { + c.Shell = s.localShellName() + } } if withScreen && cfg.SendScreen && s.term != nil { n := cfg.ContextLines diff --git a/internal/ui/tabs.go b/internal/ui/tabs.go index 6308feb..8b8d10f 100644 --- a/internal/ui/tabs.go +++ b/internal/ui/tabs.go @@ -173,10 +173,6 @@ func (a *App) tabMenu(s *session, x, y int, after func()) *modal { // die Verbindung schon offen ist (zweite Shell auf demselben Server). func (a *App) openNewTab() tea.Cmd { all := a.st.Connections() - if len(all) == 0 { - a.scr = scrManager - return a.openConnForm(newConnDefaults()) - } rank := func(c domain.Connection) int { switch { case a.connected(c.ID): @@ -194,7 +190,11 @@ func (a *App) openNewTab() tea.Cmd { return all[i].LastUsed.After(all[j].LastUsed) }) byID := map[string]domain.Connection{} - var items []pickItem + // oben: Shell dieses Rechners (immer ein neuer Tab) + lc := localConn("") + byID[lc.ID] = lc + items := []pickItem{{value: lc.ID, label: ic("command") + " " + i18n.T("Lokale Shell"), detail: i18n.T("dieser Rechner"), + hint: shortTarget(lc), search: "local lokal shell terminal powershell pwsh cmd zsh bash"}} for _, c := range all { byID[c.ID] = c icon, _ := a.devIcon(c) diff --git a/internal/ui/testdata/golden/keys.de.txt b/internal/ui/testdata/golden/keys.de.txt index 25aea0a..dd8fbd0 100644 --- a/internal/ui/testdata/golden/keys.de.txt +++ b/internal/ui/testdata/golden/keys.de.txt @@ -8,6 +8,7 @@ Über & Update F12 Tastenzeile erklären an/aus Shift+F9 / F21 Beenden Strg+Q + Lokale Shell öffnen Alt+L TERMINAL Ziel-Modus (Agent) F2 KI fragen F3 @@ -26,7 +27,6 @@ Schnellbefehl 4 Shift+F4 / F16 Schnellbefehl 5 Shift+F5 / F17 Schnellbefehl 6 Shift+F6 / F18 - Schnellbefehl 7 Shift+F7 / F19 Alt+⏎ ist gesperrt: Windows Terminal schaltet damit auf Vollbild. Schriftgröße: Strg + Plus/Minus im Terminalfenster (macOS: ⌘ + / −) diff --git a/internal/ui/testdata/golden/keys.en.txt b/internal/ui/testdata/golden/keys.en.txt index 6626d24..3099626 100644 --- a/internal/ui/testdata/golden/keys.en.txt +++ b/internal/ui/testdata/golden/keys.en.txt @@ -8,6 +8,7 @@ About & update F12 Explain key bar on/off Shift+F9 / F21 Quit Ctrl+Q + Open local shell Alt+L TERMINAL Goal mode (agent) F2 Ask AI F3 @@ -26,7 +27,6 @@ Quick command 4 Shift+F4 / F16 Quick command 5 Shift+F5 / F17 Quick command 6 Shift+F6 / F18 - Quick command 7 Shift+F7 / F19 Alt+⏎ is blocked: Windows Terminal uses it for full screen. Font size: Ctrl + plus/minus in the terminal window (macOS: ⌘ + / −) diff --git a/internal/ui/testdata/golden/palette.de.txt b/internal/ui/testdata/golden/palette.de.txt index d8ab7b7..318057d 100644 --- a/internal/ui/testdata/golden/palette.de.txt +++ b/internal/ui/testdata/golden/palette.de.txt @@ -1,6 +1,6 @@ >_ sshTermy vdev Idee: Dominik Bornhäußer ● KI Verbindungen 6 / suchen │ ▾ Netzwerk - ┌─ ◆ Befehlspalette 20 Einträge ────────────────────────────────────── × ─┐ + ┌─ ◆ Befehlspalette 21 Einträge ────────────────────────────────────── × ─┐ ▾ Netzwerk │ $ Ziel, Frage, Befehl, Tunnel, Verbindung oder user@host:port … │ ○ # switc│ ──────────────────────────────────────────────────────────────────────── │ ▾ Produktio│ // verbindungen │ @@ -21,8 +21,8 @@ │ [&] Team-Paket übernehmen Team │ │ [&] Team-Ordner (veröffentlicht / abonniert) Team │ │ [#] Sitzungsprotokolle durchsuchen l │ + │ [$] Lokale Shell öffnen Alt+L │ │ [|] Arbeitsplätze … w │ - │ [k] Jetzt sperren Master-Passwort │ │ │ │ ↑↓ wählen ⏎ ausführen Esc schließen │ └──────────────────────────────────────────────────────────────────────────┘ diff --git a/internal/ui/testdata/golden/palette.en.txt b/internal/ui/testdata/golden/palette.en.txt index 7b3ec89..f1e8a70 100644 --- a/internal/ui/testdata/golden/palette.en.txt +++ b/internal/ui/testdata/golden/palette.en.txt @@ -1,6 +1,6 @@ >_ sshTermy vdev Idea: Dominik Bornhäußer ● AI connections 6 / search │ ▾ Netzwerk - ┌─ ◆ Command palette 20 entries ────────────────────────────────────── × ─┐ + ┌─ ◆ Command palette 21 entries ────────────────────────────────────── × ─┐ ▾ Netzwerk │ $ Goal, question, command, tunnel, connection or user@host:port … │ ○ # switc│ ──────────────────────────────────────────────────────────────────────── │ ▾ Produktio│ // connections │ @@ -21,8 +21,8 @@ │ [&] Import team package Team │ │ [&] Team folders (published / subscribed) Team │ │ [#] Search session logs l │ + │ [$] Open local shell Alt+L │ │ [|] Workspaces … w │ - │ [k] Lock now Master password │ │ │ │ ↑↓ select ⏎ run Esc close │ └──────────────────────────────────────────────────────────────────────────┘ diff --git a/site/de/index.html b/site/de/index.html index 24ac832..312e2f1 100644 --- a/site/de/index.html +++ b/site/de/index.html @@ -131,6 +131,7 @@ sudo apt update && sudo apt install sshtermy

Agent- & Plan-Modus

Die KI arbeitet selbstständig aufs Ziel hin, legt Skripte an und führt sie aus; drei Stufen, gefährliche Schritte warten immer auf dich. Erst planen: den ganzen Plan prüfen und freigeben.

Geteilte Ansicht & Tabs

Sieben Aufteilungen mit bis zu sechs Sitzungen, Zoom, Tauschen, Eingabe an alle; Tab-Leiste mit +, ×, Rechtsklick-Menü und Tab-Liste (Alt+T).

Telnet & Konsole

Telnet und USB-Konsolenkabel (z. B. Aruba-Switches), Kabel wird automatisch gewählt, Anmeldung getippt.

+

Lokale Shell

Deine eigene PowerShell, cmd, zsh oder bash als Tab (Alt+L), mit KI, Agent- und Plan-Modus, geteilter Ansicht und Protokoll; der Gefahren-Check gilt auch hier.

Profi-SSH

Agent-Weiterleitung, X11-Weiterleitung, FIDO2-Sicherheitsschlüssel, Kerberos/GSSAPI, SSH-Zertifikate, feste tmux/screen-Sitzungen.

Dateien im Terminal

tsz/trz (trzsz) auch durch sudo su und mehrere Sprünge, Zwischenablage vom Server per OSC 52.

Team-Freigabe

Verschlüsselte .sshteam-Pakete und Team-Ordner, die die Verbindungen aller aktuell halten, ohne Passwörter.

@@ -172,6 +173,7 @@ sudo apt update && sudo apt install sshtermy F4 / F5 / F6Tunnel / Dateien (SFTP) / Host-Übersicht F7 / F8Tab zurück / vor Alt+T / Alt+N / Alt+WTab-Liste / neuer Tab / Tab schließen + Alt+LLokale Shell in neuem Tab (PowerShell, zsh, bash) F9, ⇧+F1…F8Schnellbefehle Strg+TGeteilte Ansicht: Aufteilung wählen (1…7) Alt+Z / Alt+IBereich zoomen / in alle Bereiche tippen diff --git a/site/handout/sshtermy-kurzreferenz-de.pdf b/site/handout/sshtermy-kurzreferenz-de.pdf index 5a3f7d5..a5ba3c4 100644 Binary files a/site/handout/sshtermy-kurzreferenz-de.pdf and b/site/handout/sshtermy-kurzreferenz-de.pdf differ diff --git a/site/handout/sshtermy-quickref-en.pdf b/site/handout/sshtermy-quickref-en.pdf index 8bc973b..5229188 100644 Binary files a/site/handout/sshtermy-quickref-en.pdf and b/site/handout/sshtermy-quickref-en.pdf differ diff --git a/site/index.html b/site/index.html index 6130f88..0af4e27 100644 --- a/site/index.html +++ b/site/index.html @@ -131,6 +131,7 @@ sudo apt update && sudo apt install sshtermy

Agent & plan mode

The AI works towards a goal on its own, writes and runs scripts; three levels, dangerous steps always wait for you. Plan first: review and approve the whole plan.

Split view & tabs

Seven layouts with up to six sessions, zoom, swap, type into all; tab bar with +, ×, right-click menu and tab list (Alt+T).

Telnet & serial

Telnet and USB console cables (e.g. Aruba switches), cable picked automatically, login typed for you.

+

Local shell

Your own PowerShell, cmd, zsh or bash as a tab (Alt+L), with AI, agent and plan mode, split view and session log; danger rules apply here too.

Pro SSH

Agent forwarding, X11 forwarding, FIDO2 security keys, Kerberos/GSSAPI, SSH certificates, persistent tmux/screen sessions.

Files in the terminal

tsz/trz (trzsz) through sudo su and several hops, clipboard from the server via OSC 52.

Team sharing

Encrypted .sshteam packages and team folders that keep everyone's connections up to date, without passwords.

@@ -171,6 +172,7 @@ sudo apt update && sudo apt install sshtermy F4 / F5 / F6Tunnels / files (SFTP) / host overview F7 / F8Previous / next tab Alt+T / Alt+N / Alt+WTab list / new tab / close tab + Alt+LLocal shell in a new tab (PowerShell, zsh, bash) F9, ⇧+F1…F8Quick commands Ctrl+TSplit view: choose a layout (1…7) Alt+Z / Alt+IZoom a pane / type into all panes diff --git a/tools/handout/content.mjs b/tools/handout/content.mjs index 8411787..be585fd 100644 --- a/tools/handout/content.mjs +++ b/tools/handout/content.mjs @@ -59,6 +59,7 @@ export const de = { { t: 'Tabs', ic: '▭', rows: [ ['F7 / F8', 'Tab zurück / vor'], ['Alt+N / Alt+W', 'neuer Tab / Tab schließen'], + ['Alt+L', 'lokale Shell (PowerShell, zsh …)'], ['Alt+T', 'Tab-Liste: ⏎ springen, 1…9 direkt'], ['Strg+R', '(Liste) umbenennen'], ['Strg+D', '(Liste) duplizieren'], @@ -241,6 +242,7 @@ export const en = { { t: 'Tabs', ic: '▭', rows: [ ['F7 / F8', 'previous / next tab'], ['Alt+N / Alt+W', 'new tab / close tab'], + ['Alt+L', 'local shell (PowerShell, zsh …)'], ['Alt+T', 'tab list: ⏎ jump, 1…9 direct'], ['Ctrl+R', '(list) rename'], ['Ctrl+D', '(list) duplicate'], diff --git a/tools/handout/keys.sha256 b/tools/handout/keys.sha256 index 0c3a1a1..8fa1535 100644 --- a/tools/handout/keys.sha256 +++ b/tools/handout/keys.sha256 @@ -1 +1 @@ -f24313219a3bd36a5487e1b99fac4070316f469879d64a795c9a3e1007a36f37 +bfea4ecc956970640b90b0ddf4ae75ed3a7d43e133c114a4f000cc85d2ac16be