hg-prompt/documentation/samples/index.html @ 36f30b33ea49

hg-prompt: Update documentation.
author Steve Losh <steve@stevelosh.com>
date Wed, 02 Dec 2009 02:13:39 -0500
parents (none)
children 310c8feb5645
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
    "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
  <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="/hg-prompt/media/css/reset.css" media="screen, projection" />
    <link rel="stylesheet" type="text/css" href="/hg-prompt/media/css/layout.css" media="screen, projection" />
    <link rel="stylesheet" type="text/css" href="/hg-prompt/media/css/typography.css" media="screen, projection" />
    <link rel="stylesheet" type="text/css" href="/hg-prompt/media/css/pygments.css" media="screen, projection" />
  </head>
  
  <body>
    
        <div id="breadcrumbs">
          <p>
              
                
                  <a href="/hg-prompt/">index</a> &#187;
                
              
                
                  <a href="/hg-prompt/documentation/">documentation</a> &#187;
                
              
                
                  samples
                
              
          </p>
        </div> <!-- div#breadcrumbs -->
      
      
    <div id="content">
      
      
  <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">&#39;\u in \w`hg prompt &quot;{on {branch}}{status}{update}&quot; 2&gt;/dev/null` $&#39;</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 &#39;Add a file.&#39;
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&gt;/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">&#39;\w`hg prompt &quot;[{branch}{status}{update}]&quot; 2&gt;/dev/null` $&#39;</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 &#39;Add a file.&#39;
~/src/project[feature-branch] $ hg update default
~/src/project[default] $ hg update 0
~/src/project[default^] $
</pre></div>

    
    </div> <!-- div#content -->
    <div id="footer">
        <p>
            
            hg-prompt &mdash;
            
            Powered by <a href="http://bitbucket.org/zacharyvoase/markdoc">Markdoc</a>.
        </p>
    </div>
    
  </body>
</html>