Basic Usage

basic usage

Digit 1 on 3rd line is false(1) exit code. Also on non-zero exit code terminal bell is sounded. Bell is turnned off by default (to set softer terminal bell use setterm).

GIT

Branch and files are colored according to state. "M" stands for master.

git module screenshot

Table 1: Branch and Files Colors
Branch File Meaning

dark blue

Clean repo

green

green

Modified or new file. Modifications are in index but not in repo yet.

dark red

dark red

Modified and tracked by repo, but modifications not added to index yet.

light blue

light blue

Untracked file.

light red

Detached Head

magenta

In middle of doing something

Subversion/SVN

svn module screenshot

SVN module disabled by default because even on moderate sized working directories there is noticeable delay for prompt display. SVN is slower than GIT. Enable if needed in config

Mercurial/HG

HG module was developed by Lee Nussbaum <wln AT scrunch.org>.

Labels

Labels are visual cues to help figure out what terminal is running what command. It is generalization of xterm-title but differ from xterm-title that it can be displayed in other places (on Screen(1) windows titles for example). Also label can display currently executed command (when bash prompt obviously is not displayed). Because labels have less space then prompt, instead of full path only last dir is shown. On screenshot below labels are in red ovals.

labels screenshot

The screen(1) status line at bottom of smaller gnome-terminal is displayed with following line in ~/.screenrc:

caption always "%{= kw}%-w%{= bw}%n %t%{-}%+w %-= @%H - %LD %d %LM - %c"

Simple AutoJump

This is reimplementation of Joel Schaerer’s AutoJump. It is only ~10 lines of code, there is no database. It remembers only directories from current session. It selects not most frequent dir, but last visited. Matches are done from beginning of of dir name.

cd /tmp
cd "~/long dir mp3"
cd "~/long dir mp4"
cd /tmp
cd /var/tmp
cd /etc
j t     # same as  cd /var/tmp
j .*3   # same as  cd "~/long dir mp3"

Install

Download git-prompt.sh or get it with GIT:

  git clone git://github.com/lvv/git-prompt.git

Put following command in your profile (~/.bash_profile or ~/.profile) in interactive section:

  . /path/to/git-prompt.sh

If there are no interactivity test in your profile or you don’t know what it is, then above command should be:

  [[ $- == *i* ]]   &&   . /path/to/git-prompt.sh

There might be your old prompt defined too. You need to comment it out. Some distros also have /etc/bashrc or /etc/bash/bashrc with distro default prompt.

Config

Is optional. If config file is not found then git-prompt uses defaults. Defaults are listed in example git-prompt.conf. Git-prompt looks (in listed order) for config file in following locations:

Copy example config git-prompt.conf to any of above locations and customize as needed.

Limitations

Dependencies

Most probably you don’t need to install anything because not optional dependencies are standard unix utils.

Todo

How to submit patch

Just mail patch to leonid@volnitsky.com. Bug-reports, suggestions are welcome too.

If you are on Github it is even easier. See github patch-submit HOWTOs ( 1, 2, 3 ) if you don’t know yet how to do this.

There is no hard set style rules. I am trying to keep tabstops=8 and expandtab (tab character replaced with 8 spaces).

People will not use git-prompt if there will be delay in prompt display. Try to avoid use of external commands and subshells (backticks) in prompt_command_function. It is ok to use time consuming ops in postconfig which is executed only once.

Authors

References