cheatsheets/hledger.html

363 lines
10 KiB
HTML

<!doctype html>
<html lang='en' class='no-js '>
<head>
<meta charset='utf-8'>
<meta content='width=device-width, initial-scale=1.0' name='viewport'>
<link href='./assets/favicon.png' rel='shortcut icon'>
<meta content='/hledger.html' name='app:pageurl'>
<title>Hledger cheatsheet</title>
<meta content='Hledger cheatsheet' property='og:title'>
<meta content='Hledger cheatsheet' property='twitter:title'>
<meta content='article' property='og:type'>
<meta content='https://assets.devhints.io/previews/hledger.jpg?t=20200705143936' property='og:image'>
<meta content='https://assets.devhints.io/previews/hledger.jpg?t=20200705143936' property='twitter:image'>
<meta content='900' property='og:image:width'>
<meta content='471' property='og:image:height'>
<meta content="The one-page guide to Hledger: usage, examples, links, snippets, and more." name="description">
<meta content="The one-page guide to Hledger: usage, examples, links, snippets, and more." property="og:description">
<meta content="The one-page guide to Hledger: usage, examples, links, snippets, and more." property="twitter:description">
<link rel="canonical" href="https://devhints.io/hledger">
<meta name="og:url" content="https://devhints.io/hledger">
<meta content='Devhints.io cheatsheets' property='og:site_name'>
<meta content='Ledger' property='article:section'>
<script async src='https://www.googletagmanager.com/gtag/js?id=UA-106902774-1'></script>
<script>
window.dataLayer=window.dataLayer||[];
function gtag(){dataLayer.push(arguments)};
gtag('js',new Date());
gtag('config','UA-106902774-1');
</script>
<meta property='page:depth' content='1'>
<script>(function(H){H.className=H.className.replace(/\bno-js\b/,'js')})(document.documentElement)</script>
<script>(function(H){H.className=H.className.replace(/\bNoJs\b/,'WithJs')})(document.documentElement)</script>
<script>(function(d,s){if(window.Promise&&[].includes&&Object.assign&&window.Map)return;var js,sc=d.getElementsByTagName(s)[0];js=d.createElement(s);js.src='https://cdn.polyfill.io/v2/polyfill.min.js';sc.parentNode.insertBefore(js, sc);}(document,'script'))</script>
<!--[if lt IE 9]><script src='https://cdnjs.cloudflare.com/ajax/libs/nwmatcher/1.2.5/nwmatcher.min.js'></script><script src='https://cdnjs.cloudflare.com/ajax/libs/json2/20140204/json2.js'></script><script src='https://cdn.rawgit.com/gisu/selectivizr/1.0.3/selectivizr.js'></script><script src='https://cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv.min.js'></script><script src='https://cdnjs.cloudflare.com/ajax/libs/respond.js/1.4.2/respond.js'></script><![endif]-->
<style>html{opacity:0}</style>
<link rel="stylesheet" href="./assets/2015/style.css?t=20200705143936">
<link href="./assets/style.css?t=20200705143936" rel="stylesheet" />
<link href="./assets/print.css?t=20200705143936" rel="stylesheet" media="print" />
</head>
<body>
<div class='all'>
<div class='site-header'>
<div class='container'>
This is <a href="."><em>Devhints.io cheatsheets</em></a> &mdash; a collection of cheatsheets I've written.
</div>
</div>
<script type='application/ld+json'>
{
"@context": "http://schema.org",
"@type": "NewsArticle",
"mainEntityOfPage": {
"@type": "WebPage",
"@id": "https://google.com/article"
},
"headline": "Hledger cheatsheet",
"image": [ "https://assets.devhints.io/previews/hledger.jpg?t=20200705143936" ],
"description": "The one-page guide to Hledger: usage, examples, links, snippets, and more."
}
</script>
<script type='application/ld+json'>
{
"@context": "http://schema.org",
"@type": "BreadcrumbList",
"itemListElement": [{
"@type": "ListItem",
"position": 1,
"item": {
"@id": "https://devhints.io/#ledger",
"name": "Ledger"
}
},{
"@type": "ListItem",
"position": 2,
"item": {
"@id": "https://devhints.io/hledger",
"name": "Hledger"
}
}]
}
</script>
<div class='post-list -single -cheatsheet'>
<div class='post-item'>
<div class='post-headline -cheatsheet'>
<p class='prelude'><span></span></p>
<h1><span>Hledger</span></h1>
<div class='pubbox'>
<div class='HeadlinePub' role='complementary'>
<script async src='https://pubsrv.devhints.io/carbon.js?serve=CE7IK5QM&placement=devhintsio' id="_carbonads_js"></script>
<span class='placeholder -one'></span>
<span class='placeholder -two'></span>
<span class='placeholder -three'></span>
<span class='placeholder -four'></span>
</div>
</div>
</div>
<div class='post-content -cheatsheet'>
<h2 id="reporting">Reporting</h2>
<pre class="large terminal"><code>hledger bal {query}
hledger reg {query}
</code></pre>
<h2 id="query">Query</h2>
<p>Queries are used on all commands (<code>bal</code>, <code>reg</code>, etc). <a href="http://hledger.org/manual.html#queries">(docs)</a></p>
<pre><code>Assets # An account (regex)
acct:Assets # same
^Assets # Starting with Assets (eg, not 'Expenses:Assets')
acctonly:A # no subaccounts
amt:2000 # amount (in absolute value)
amt:&lt;200 # amount comparison (in absolute value)
amt:&lt;+200 # amount comparison
# also: &lt;=, &gt;, &gt;=
desc:REGEX # description
code:REGEX # transaction code (check number?)
tag:REGEX
cur:'\$'
real: # real posts
real:0 # virtual posts
depth:N # --depth 2
not:... # eg, not:status:!
</code></pre>
<h3 id="filter-by-statustype">Filter by status/type</h3>
<pre><code>real:1 # -R, --real, no virtuals
status:! # --pending
status:* # -C, --cleared
status: # --uncleared
</code></pre>
<h3 id="periods">Periods</h3>
<p>For dates and intervals (see above).</p>
<pre><code>date:2015/01/01
date:2015/01/01- # -b, --begin
date:-2015/01/01 # -e, --end
date2:PERIODEXPR
</code></pre>
<pre><code>-p, --period=...
-p "2009/01/01"
-p "2009/01/01 to 2009/12/31"
-p "2009/01/01to2009/12/31" # spaces optional
-p "1/1 to 12/31"
-p "to 2009"
-p "weekly" # -W, --weekly
-p "weekly 2009/01/01 to 2009/12/31"
</code></pre>
<h3 id="intervals">Intervals</h3>
<p>Used on all commands (<code>bal</code>, <code>reg</code>, etc). Displays in multi-column mode. In <code>ledger-cli</code>, only <code>reg</code> is supported. Can also specified via <code>-p</code> (period).</p>
<pre><code>-D, --daily
-W, --weekly
-M, --monthly
-Q, --quarterly
-Y, --yearly
</code></pre>
<h3 id="smart-dates">Smart dates</h3>
<p>Used for <code>--period</code>, <code>--begin</code> and <code>--end</code> (<code>-p</code> <code>-b</code> <code>-e</code>).</p>
<pre><code>-p 2015/01/01
-p 2015/01
-p 2015
-p january
-p jan
-p 05/25
</code></pre>
<pre><code>-b today
-b yesterday
-e tomorrow
</code></pre>
<pre><code>-p this week
-p last month
-p this year
</code></pre>
<h2 id="display-formats">Display formats</h2>
<pre><code> --tree # only in bal
--flat
--depth 2 # collapse those under this depth
--drop 1 # drop top-level accounts
-B, --cost # convert to default currency
-E, --empty # don't strip out $0 accounts
--date2 # use date2 when available
</code></pre>
<h2 id="multi-column-mode">Multi-column mode</h2>
<p>When used with intervals (like <code>--weekly</code>):</p>
<pre><code>-T, --row-total
-N, --no-total
</code></pre>
<p>Also: (only in <code>bal</code>)</p>
<pre><code> --cumulative # show ending balance per period
-I, --historical # like --cumulative but only for --begin
-A, --average
</code></pre>
<h2 id="accounts">Accounts</h2>
<pre><code>hledger accounts [--tree]
</code></pre>
<h2 id="other-commands">Other commands</h2>
<pre><code>hledger balancesheet # bs
hledger incomestatement # is
hledger cashflow # cf
hledger print
hledger activity
hledger stats
</code></pre>
<h2 id="examples">Examples</h2>
<pre><code># Current balance
hledger bal Assets
hledger balancesheet
hledger balancesheet Assets [--cleared --cost --empty -e tomorrow]
# ...discard future stuff; convert foreign currencies
# Monthly changes in assets
hledger bal Assets Liabilities --monthly --tree --historical [--cleared --cost --empty -e tomorrow]
# Weekly expenses
hledger bal Expenses --weekly --average --tree -b 'last month' [--cleared --cost --empty -e tomorrow]
</code></pre>
<h2 id="see-also">See also</h2>
<ul>
<li><a href="http://hledger.org/manual.html">http://hledger.org/manual.html</a></li>
<li><a href="http://ledger-cli.org/3.0/doc/ledger3.html">http://ledger-cli.org/3.0/doc/ledger3.html</a></li>
</ul>
</div>
<ul class="social-list ">
<li class="facebook link hint--bottom" data-hint="Share on Facebook"><a href="https://www.facebook.com/sharer/sharer.php?u=https://devhints.io/hledger.html" target="share"><span class="text"></span></a></li>
<li class="twitter link hint--bottom" data-hint="Share on Twitter"><a href="https://twitter.com/intent/tweet?text=The%20ultimate%20cheatsheet%20for%20Hledger.%20https://devhints.io/hledger.html" target="share"><span class="text"></span></a></li>
</ul>
</div>
</div>
<div class="about-the-site">
<div class="container">
<p class='blurb'>
<strong><a href=".">Devhints.io cheatsheets</a></strong> is a collection of cheatsheets I've written over the years.
Suggestions and corrections? <a href='https://github.com/rstacruz/cheatsheets/issues/907'>Send them in</a>.
<i class='fleuron'></i>
I'm <a href="http://ricostacruz.com">Rico Sta. Cruz</a>.
Check out my <a href="http://ricostacruz.com/til">Today I learned blog</a> for more.
</p>
<p class='back'>
<a class='big-button -back -slim' href='.#toc'></a>
</p>
<p>
</p>
</div>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/8.5/highlight.min.js"></script>
<script src="https://cdn.rawgit.com/rstacruz/unorphan/v1.0.1/index.js"></script>
<script>hljs.initHighlightingOnLoad()</script>
<script>unorphan('h1, h2, h3, p, li, .unorphan')</script>
</body>
</html>