prwd - templated PS1 remplacement
Fork me on GitHub

prwd is a replacement for your shell's PS1, it provides a simple templating language with commands to customize your prompt. prwd keeps your prompt consistent between shells, provides fast template commands to get your hostname, git or mercurial branch without an inordinate amount of slow shell scripting.

setup

Add the following line in your shell's config file (e.g. .profile or .bashrc):

export PS1='`prwd`'

template syntax

All the commands start with ${ and end with }, anything else is considered static. Commands within the brackets have flags similarly to standard UNIX tools. Here is an example template definition:

${date} ${hostname}:${branch}:${path -l 24}${uid}

Which would render as:

18:29:22 prometheus:master:/tmp$

Your prompt template can be defined in three different places:

  • using a PRWD environment variable
  • using the "template" keyword in your ~/.prwdrc file
  • using the -t parameter to prwd

template commands

Check the prwdrc(5) man page for detailed command information. The following commands are available:

  • path
  • branch
  • date
  • hostname
  • uid
  • color
  • sep

path and aliases

If you use the path command in your prompt template, defining aliases will allow path to shorten your current path using your own defined keywords. For example, add the following to your .prwdrc file:

alias *prwd /home/tamentis/projects/prwd

And navigating to /home/tamentis/projects/prwd/doc will allow prwd to reduce your current path to *prwd/doc. Another good example is that "~" is a default alias for prwd, you can create more of these ultra-short aliases if you want.

download

Latest tarball: prwd-1.9.tar.gz (66K, signature)

GitHub: github.com/tamentis/prwd/
Fedora packages (by Christopher "cicku" Meng): apps.fedoraproject.org/packages/prwd
OpenPKG package: prwd-1.7-20130527.src.rpm (28K)

install

$ ./configure
$ make
$ sudo make install
Bertrand Janin <b@janin.com> · Powered by Python, OpenBSD, a teashpoon of WTF & the spirit of the UNIX gods.
This page was last updated: 2015-04-12