
Kann zsh die Eingabeaufforderung auf den gesamten Pfad einstellenaußerdas aktuelle Verzeichnis? Also ~/a/b/c/
nur für ~/a/b/
?
Ich versuche, dieses Ergebnis ~/a/b/c
mit den Eingabeaufforderungen links und rechts zu erhalten:
c/: | ~/a/b/
im Gegensatz zu meinem aktuellen Duplikat c
:
c/: | ~/a/b/c/
Die Duplizierung verschwendet Speicherplatz, wenn der c
Verzeichnisname lang ist.
ImHandbuchIch habe alles andere gefunden als das, was ich wollte:
%-1~
- das erste Element des Pfades%1~
- das letzte Element des Pfades
statt alle außer dem letzten
Wie kann das gemacht werden?
Antwort1
# Before printing each prompt string, apply substitutions to it.
setopt promptsubst
# $PWD is always equal to the present working dir.
# :h chops off the last item of the path.
# (D) substitutes the start of the path with a named dir, such as ~, if possible.
# Note that this string is in 'single quotes'!
RPS1='${(D)PWD:h}'
Tada!
Dokumentation: