Pfadanzeige in der Shell

Christian Brabandt cblists at 256bit.org
Mon Nov 26 18:30:03 GMT 2007


Hi Michael!

On Mon, 26 Nov 2007, Michael Kleinschnitker wrote:

> wenn ich mit der Shell arbeite und tief ins Dateiverzeichnis
> herabsteige, dann wirde der komplette Pfad angezeigt, was zu Folge hat,
> das die ganze Zeile mit dem Pfad gefüllt ist.
> Gibt es eine Möglichkeit, dass aber einer gewissen Verzeichnistiefe der
> Pfad abgekürzt wird?

Für die zsh wurde ja schon ein Beispiel gepostet. Mit der bash geht
das so:

,----
|  # Trim Prompt to max 1/4 of the screen width
|  function trim_prompt()
|  {
|   local maxlen=$((COLUMNS/4))
|   local trunc_symbol="[ ]"
|   if [ ${#PWD} -gt $maxlen ]; then
|       local offset=$((${#PWD} - $maxlen + 3))
|       PS1="${trunc_symbol}${PWD:$offset:$maxlen}$ "
|   fi
| }
`----

Eine umfangreichere Lösung liefert
http://www.debian-administration.org/articles/205

Aber man kann es auch übertreiben ;)
 

Mit freundlichen Grüßen
Christian
-- 
ARTHUR:       You are indeed brave Sir knight, but the fight is mine.
BLACK KNIGHT: Had enough?
ARTHUR:       You stupid bastard.  You havn't got any arms left.
                 "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD