Coder Social home page Coder Social logo

vcprompt's Introduction

vcprompt

Version control information in your prompt.

INSTALL

Download vcprompt, make it executable and add it to your prompt:

$ curl -sL https://github.com/djl/vcprompt/raw/master/bin/vcprompt > ~/bin/vcprompt
$ chmod 755 ~/bin/vcprompt

For bash, you'll want to do something like this:

$ export PS1='\u@\h:\w \$(vcprompt)\$'

ZSH users should be aware that they will have to set the PROMPT_SUBST option first:

$ setopt prompt_subst
$ export PS1='%n@%m:%~ $(vcprompt)$ '

OPTIONS

  • -f, --format FORMAT

    Passes a custom output format to vcprompt. Defaults to %s:%b. See below for more details.

  • -p, --path PATH

    The path on which to run vcprompt. Defaults to the current directory.

  • -d, --max-depth

    The maximum number of directories vcprompt should traverse while looking for version control systems.

  • -s, --systems

    Prints all available version control systems to standard out.

  • -h, --help

    Prints the help message and exists.

  • -v, --version

    Prints the current version number and exits.

Each version control system also has it's own formatting option. The options take the form of --format-SYSTEM. The available options are currently:

  • --format-bzr
  • --format-cvs
  • --format-darcs
  • --format-fossil
  • --format-git
  • --format-hg
  • --format-svn

FORMATS

vcprompt comes with a number of formatting tokens. What follows is a list of all the available tokens:

  • %s or %n

    The "short name" of the version control system currently in use. E.g. git, hg, svn

  • %h

    The hash of the repository. If no hash is available it will show the revision number instead.

  • %r

    The revision number of the repository. If no revision number is available it will return the hash instead.

  • %b

    The current branch. If branch is available it will be the directory where the version control system was first encountered.

  • %m

    Displays a plus symbol (+) if the repository has any modified files.

  • %u

    Displays an exclamtion mark (!) if there is any untracked files in the repository.

REQUIREMENTS

  • Python 2.4 or later. Python >= 2.5 recommended.

    Python 2.4 is experimental at best but should work for the most part. Expect it to break or change in the future.

    Use of Python 2.5 or later is recommended.

  • Python 3 isn't supported yet but 2to3 produces a tiny diff which seems to work.

  • Fossil support requires the SQLite3 module to be installed (built in on Python 2.5+).

TESTING

To run the tests, use the provided Makefile:

make test

A few notes on testing:

  • Tests have to fetch remote repositories, so network access is required
  • Fetching remote repositories requires each VCS to be installed

NOTES

vcprompt was heavily inspired by Greg Ward's original implementation in C.

This version of vcprompt attempts to stay mostly compatible with the original although there may be some notable differences.

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.