hg-prompt/documentation/samples/index.html @ a567fe20c993
slurm: Update site.
| author | Steve Losh <steve@stevelosh.com> |
|---|---|
| date | Tue, 11 Oct 2016 16:27:20 +0000 |
| parents | abcf6f68470c |
| children | (none) |
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN" "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:foaf="http://xmlns.com/foaf/0.1/"> <head> <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=UTF-8" /> <title> hg-prompt » Sample Prompts </title> <link rel="stylesheet" type="text/css" href="../../media/css/reset.css" media="screen, projection" /> <link rel="stylesheet" type="text/css" href="../../media/css/layout.css" media="screen, projection" /> <link rel="stylesheet" type="text/css" href="../../media/css/typography.css" media="screen, projection" /> <link rel="stylesheet" type="text/css" href="../../media/css/pygments.css" media="screen, projection" /> </head> <body > <div id="content"> <div id="breadcrumbs"> <p> <a href="../../">index</a> » <a href="../">documentation</a> » samples </p> </div> <!-- div#breadcrumbs --> <h1 id="sample-prompts">Sample Prompts</h1> <p><code>hg-prompt</code> supports many keywords, but you probably don't want to use them all at once. Which keywords you'll find useful depends on the workflow(s) you commonly use.</p> <p>Here are some example prompts to get you started.</p> <h2 id="a-basic-prompt">A Basic Prompt</h2> <p>A very simple prompt could tell you:</p> <ul> <li>Which named branch you're currently working on.</li> <li>If there are any uncommitted changes in the working directory.</li> <li>If you're at a revision that's not a branch tip (i.e. if running <code>hg update</code> would do something).</li> </ul> <p>To get a prompt like this you could add this to your <code>~/.bashrc</code> file:</p> <div class="codehilite"><pre><span class="nb">export </span><span class="nv">PS1</span><span class="o">=</span><span class="s1">'\u in \w`hg prompt "{on {branch}}{status}{update}" 2>/dev/null` $'</span> </pre></div> <p>The result would look something like this:</p> <div class="codehilite"><pre>username in ~/src $ cd project username in ~/src/project on feature-branch $ touch sample username in ~/src/project on feature-branch? $ hg add sample username in ~/src/project on feature-branch! $ hg commit -m 'Add a file.' username in ~/src/project on feature-branch $ hg update default username in ~/src/project on default $ hg update 0 username in ~/src/project on default^ $ </pre></div> <p>The <code>2>/dev/null</code> part of the prompt command prevents errors from showing when you're not currently in a Mercurial repository.</p> <p>The keywords (<code>{branch}</code>, <code>{status}</code> and <code>{update}</code>) display the relevant information.</p> <p>The extra text in the <code>{branch}</code> keyword will only display if a branch exists, so you won't see the word "on" if you're not in a repository.</p> <h2 id="a-more-compact-basic-prompt">A More Compact Basic Prompt</h2> <p>Some people prefer a smaller, less obtrusive prompt. To get that kind of prompt you can omit some of the less important text:</p> <div class="codehilite"><pre><span class="nb">export </span><span class="nv">PS1</span><span class="o">=</span><span class="s1">'\w`hg prompt "[{branch}{status}{update}]" 2>/dev/null` $'</span> </pre></div> <p>That will give you something like this:</p> <div class="codehilite"><pre>~/src $ cd project ~/src/project[feature-branch] $ touch sample ~/src/project[feature-branch?] $ hg add sample ~/src/project[feature-branch!] $ hg commit -m 'Add a file.' ~/src/project[feature-branch] $ hg update default ~/src/project[default] $ hg update 0 ~/src/project[default^] $ </pre></div> <p id="footer"> hg-prompt — Powered by <a href="http://bitbucket.org/zacharyvoase/markdoc">Markdoc</a>. </p> </div> <!-- div#content --> </body> </html>