Try syntax highlighting on BitBucket.
author |
Steve Losh <steve@stevelosh.com> |
date |
Fri, 19 Jun 2009 22:12:48 -0400 |
parents |
64e12f95da2e
|
children |
e6b8aa2d8b66
|
branches/tags |
(none) |
files |
README |
Changes
--- a/README Fri Jun 19 22:09:21 2009 -0400
+++ b/README Fri Jun 19 22:12:48 2009 -0400
@@ -10,10 +10,12 @@
Clone the repository:
+ :::console
$ hg clone hg clone https://sjl@bitbucket.org/sjl/hg-prompt/
Edit the `[extensions]` section in your `~/.hgrc` file:
+ :::text
[extensions]
prompt = (path to)/hg-prompt/prompt.py
@@ -22,20 +24,24 @@
The `hg prompt` command takes a single string as an argument and outputs it. A simple (and useless) example:
+ :::console
$ hg prompt "test"
test
Keywords in curly braces can be used to output repository information:
+ :::text
$ hg prompt "currently on {branch}"
currently on default
Keywords also have an extended form:
+ :::text
{optional text{branch}more optional text}
This form will output the text and the expanded keyword **only** if the keyword successfully expands. This can be useful for displaying extra text only if it's applicable:
+ :::text
$ hg prompt "currently on {branch} and at {bookmark}"
currently on branch default and at
@@ -64,6 +70,7 @@
To put it in your bash prompt, edit your `~/.bashrc` file to include something like this:
+ #!bash
hg_ps1() {
hg prompt "{ on {branch}}{ at {bookmark}}{status}" 2> /dev/null
}
@@ -72,14 +79,15 @@
Putting the call in a separate function helps keep things readable if you start adding color codes:
+ #!bash
D=$'\e[37;40m'
MAGENTA=$'\e[35;40m'
GREEN=$'\e[32;40m'
YELLOW=$'\e[33;40m'
-
+
hg_ps1() {
hg prompt "{${D} on ${MAGENTA}{branch}}{${D} at ${YELLOW}{bookmark}}{${GREEN}{status}}" 2> /dev/null
}
-
+
export PS1='\n${MAGENTA}\u ${D}at ${YELLOW}\h ${D}in ${GREEN}\w$(hg_ps1)\
${D}\n$ '
\ No newline at end of file