Florian WaltherandClaude Opus 5.5 7afcecd053 add colored prompt
- user@host in bold green (bold red for root), directory in bold blue
- colors are disabled with NO_COLOR, TERM=dumb or when stdout is not a terminal
- parts are sanitized before adding the color codes
- only replace the home directory with ~ on a path boundary

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-03 17:31:09 +02:00
2026-09-23 20:30:20 +02:00
2026-09-23 20:30:20 +02:00
2026-10-03 17:31:09 +02:00
2026-10-03 17:31:09 +02:00
2026-10-03 17:31:09 +02:00

gosh eine einfache Shell, geschrieben in golang.

gosh - Go Shell

Built-in commands:
  cd [dir]       - Change directory (cd with no args goes to home)
  pwd           - Print working directory
  echo [args]   - Echo arguments
  exit [code]   - Exit shell with optional status code
  quit [code]   - Quit shell with optional status code
  set VAR=val   - Set environment variable
  export VAR=val - Export environment variable
  help          - Show this help

Features:
  - Argument parsing with quotes and escapes ('...' is literal,
    "..." expands variables, \ escapes the next character)
  - Ctrl+D to exit, Ctrl+C to cancel the current line or command
  - Command history (up/down arrows), stored in
    $XDG_STATE_HOME/gosh/history (default ~/.local/state/gosh/history,
    override with $GOSH_HISTFILE); lines starting with a space are not saved
  - Tab completion for commands and file paths
  - Tilde expansion (~, ~/path) at the start of unquoted words
  - Colored prompt (user@host green, red for root; directory blue),
    disabled with $NO_COLOR, TERM=dumb or when output is not a terminal
  - Environment variable expansion ($VAR, ${VAR}, ${VAR:-default});
    using an unset variable is an error, use ${VAR:-} for an empty default

Sicherheitshinweise

  • Die History liegt in $XDG_STATE_HOME/gosh/history (Standard: ~/.local/state/gosh/history) und ist nur für den eigenen Benutzer lesbar (Verzeichnis 0700, Datei 0600). Mit GOSH_HISTFILE lässt sich ein anderer Pfad setzen, mit GOSH_HISTFILE= wird die History abgeschaltet.
  • Zeilen, die mit einem Leerzeichen beginnen, werden nicht in der History gespeichert – praktisch für Befehle mit Passwörtern oder Tokens.
  • Innerhalb von '...' wird nichts expandiert, \$ ergibt ein wörtliches $.
  • Eine nicht gesetzte Variable bricht den Befehl ab (wie set -u), damit z. B. rm -rf $DIR/out nie mit leerem $DIR ausgeführt wird. Für einen Standardwert ${VAR:-default} bzw. ${VAR:-} verwenden.
  • Variablenwerte werden nicht in mehrere Wörter aufgeteilt.
  • Steuerzeichen in Verzeichnisnamen werden im Prompt escaped angezeigt (z. B. \x1b), Dateien mit Steuerzeichen im Namen werden nicht vervollständigt.
  • Ctrl+C beendet nur den laufenden Befehl bzw. verwirft die aktuelle Zeile, nicht die Shell.

gosh is not meant for production use, it is just a proof of concept.

building

go build ./

Release

Binaries sowie .deb- und .rpm-Pakete werden mit GoReleaser gebaut (Konfiguration: .goreleaser.yaml).

# lokal testen, ohne etwas zu veröffentlichen (Ergebnis in dist/)
goreleaser release --snapshot --clean

# Release auf Gitea veröffentlichen
export GITEA_TOKEN=...
git tag -a v0.1.0 -m "v0.1.0"
git push origin v0.1.0
goreleaser release --clean

Das Paket installiert /usr/bin/gosh und trägt die Shell in /etc/shells ein, sodass sie mit chsh -s /usr/bin/gosh gesetzt werden kann.

S
Description
eine shell in golang
Readme
410 KiB
0 Stars 1 Watchers 0 Forks
v0.20.1
Latest
2026-10-06 11:16:44 +02:00
Languages
Go 93.9%
Roff 5.9%
Shell 0.2%