Code Monkey home page Code Monkey logo

prwd's Introduction

prwd - universal shell prompt

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:

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

Template commands

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

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

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.

Installation

./configure
make
sudo make install

Hacking on prwd

  • Start from OpenBSD's style(9) man page.
  • Use parenthesis with your returns.
  • Use brackets even for one-line blocks or at least add a new line after.
  • Unless a value is only used as boolean, do not use '!', explicitely check for the value (e.g. !strcmp to test equality is not explicit).
  • No malloc/free, all the memory should be automatically allocated in prwd.

prwd's People

Contributors

cicku avatar tamentis avatar twidi avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.