Go back to main site

prwd (reduced working directory)

Print a reduced working directory for your prompt shell (PS1). The path can be shortened using any of the following:

All of this is driven by your ~/.prwdrc file.

example terminals

The reason for prwd is that most shells read $PS1 differently and have a very rigid way to display the current working directory. prwd allows you to have one way to handle the display of your working directory and use it across multiple shells.

The syntax of the configuration files is described below, lines starting with '#' are ignored.

download

Source code: prwd-1.4.tar.gz (9K, SHA1=35622b848470a9debf81c29f988a091767844e4d)
Official Package for OpenPKG: prwd-1.4-20091212.src.rpm (12-Dec-2009 13:45 13K)
Distributed under an opensource, OSI-happy ISC license, not that there is *THAT* much code to cover ;)

aliases

Defines a replacement name for a long path, for example, if you had the following line in your prwdrc:

alias *prwd /home/tamentis/projects/prwd

Then if you are in "/home/tamentis/projects/prwd/doc/html/", prwd would return "*prwd/doc/html". If you have spaces in your directories, you can wrap your 'alias' parameters with double quotes:

alias winDocs "/mnt/Windows XP/My Documents/"

max length

Defines the maximum length to return, the default filler string is "...", the default length is 32, a value of 0 will disable the feature all together.

set maxlength 20

This setting would turn "~/projects/prwd/doc/html" into a shorter string: "...cts/prwd/doc/html". You can define the filler string with the 'filler' variable:

set filler "-"

Or if your font/terminal/shell supports UTF, use an ellipsis:

set filler "…"

If you want prwd to keep complete path elements instead of cutting as much as possible, you can use this setting:

set cleancut on

newsgroup style

This will shorten the path by only displaying the first letter of each path components, toggle it with:

set newsgroup on

This will turn the "/home/tamentis/projects/prwd/src/nowhere" path into "/h/t/p/s/nowhere". Note that the newsgroup style filter is applied before the path is trimmed with 'maxlength'.

install

make
sudo make install

setup

This will depend on your shell, but in general the following will do:

export PS1='\h:`prwd`\p '

Note that the single quote matters since you want to keep the command within the variable as-is (unresolved).

Last Update: Sun Dec 6 00:46:53 EST 2009 · Bertrand Janin <tamentis@neopulsar.org> · Powered by Python & Debian GNU/Linux