show the exit status of a failed command in the prompt
- user@host:dir [N] $ after a command failed with exit status N, the plain prompt again after a successful command - the status is colored bold red by default, configurable with the new GOSH_COLORS key error Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
b3311cbf94
commit
041406a340
3 files changed
+86
-28
No files matched your search
@@ -34,10 +34,13 @@ Features:
|
||||
- Wildcards: * ? [abc] [a-z] [!abc] match file names (not hidden files
|
||||
unless the pattern starts with a dot); quoted wildcards and values of
|
||||
variables are not expanded, a pattern without match is kept as is
|
||||
- Colored prompt (user@host green, red for root; directory blue),
|
||||
configurable with $GOSH_COLORS, e.g. GOSH_COLORS='user=1;33:path=36'
|
||||
(keys user, root, path; values are ANSI SGR codes, empty = no color);
|
||||
disabled with $NO_COLOR, TERM=dumb or when output is not a terminal
|
||||
- Prompt user@host:dir $, with [N] before the $ if the last command
|
||||
failed with exit status N
|
||||
- Colored prompt (user@host green, red for root; directory blue; exit
|
||||
status red), configurable with $GOSH_COLORS, e.g.
|
||||
GOSH_COLORS='user=1;33:path=36' (keys user, root, path, error; values
|
||||
are ANSI SGR codes, empty = no color); 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
|
||||
- Command lists: a ; b (run both), a && b (b only if a succeeded),
|
||||
@@ -289,6 +292,22 @@ $ bg %2 # oder: angehaltenen Job im Hintergrund weiterlauf
|
||||
- Wird ein angehaltener Job von außen fortgesetzt (`kill -CONT`), zeigt `jobs` ihn weiter als `Stopped`, bis er endet oder erneut angehalten wird; `fg` und `bg` funktionieren trotzdem.
|
||||
- Einen Job beenden lässt sich mit `kill` über die Prozess-ID (z. B. `kill 12345`); `kill %1` versteht gosh noch nicht.
|
||||
|
||||
### Prompt
|
||||
|
||||
Der Prompt zeigt Benutzer, Rechner und Verzeichnis. Ist der letzte Befehl fehlgeschlagen, steht sein Exit-Status in eckigen Klammern davor, bis wieder ein Befehl erfolgreich war:
|
||||
|
||||
```
|
||||
flow@host:~/src $ false
|
||||
flow@host:~/src [1] $ gibtsnicht
|
||||
gosh: gibtsnicht: command not found
|
||||
flow@host:~/src [127] $ sleep 100 # mit Ctrl+C abgebrochen
|
||||
^C
|
||||
flow@host:~/src [130] $ true
|
||||
flow@host:~/src $
|
||||
```
|
||||
|
||||
Typische Werte: `1` allgemeiner Fehler, `2` Syntaxfehler, `126` nicht ausführbar, `127` Befehl nicht gefunden, `128+n` durch Signal `n` beendet (`130` = Ctrl+C, `148` = mit Ctrl+Z angehalten unter Linux). Eine leere Eingabe ändert den Status nicht.
|
||||
|
||||
### Farben
|
||||
|
||||
Der Prompt wird über die Umgebungsvariable `GOSH_COLORS` eingefärbt. Sie besteht aus durch `:` getrennten Einträgen `schlüssel=code`:
|
||||
@@ -298,6 +317,7 @@ Der Prompt wird über die Umgebungsvariable `GOSH_COLORS` eingefärbt. Sie beste
|
||||
| `user` | `user@host` | `1;32` (fett grün) |
|
||||
| `root` | `user@host`, wenn man root ist | `1;31` (fett rot) |
|
||||
| `path` | aktuelles Verzeichnis | `1;34` (fett blau) |
|
||||
| `error` | Exit-Status `[N]` nach einem Fehler | `1;31` (fett rot) |
|
||||
|
||||
Die Werte sind [ANSI-SGR-Codes](https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_(Select_Graphic_Rendition)_parameters), mehrere werden mit `;` kombiniert:
|
||||
|
||||
@@ -335,6 +355,9 @@ GOSH_COLORS='user=1;38;2;136;192;208:path=38;2;216;222;233'
|
||||
# Ozean: türkis und kursiv blau
|
||||
GOSH_COLORS='user=1;96:path=3;94'
|
||||
|
||||
# Fehler-Status gelb auf rotem Hintergrund
|
||||
GOSH_COLORS='error=1;33;41'
|
||||
|
||||
# Root-Warnung: weiß auf rotem Hintergrund
|
||||
GOSH_COLORS='root=1;97;41'
|
||||
|
||||
|
||||
Reference in new issue
Block a user