Last active
November 8, 2019 20:18
-
-
Save simonmichael/89ffa2154ee71e046300547021105497 to your computer and use it in GitHub Desktop.
bash scripts for starting hledger(-ui) in various ways
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# short aliases for hledger commands | |
alias h='hledger' | |
alias acc='hledger accounts' | |
alias act='hledger activity' | |
alias add='hledger add' | |
alias bal='hledger balance' | |
alias close='hledger close' | |
alias iadd='hledger-iadd --date-format %Y/%m/%d' | |
alias print='hledger print' | |
alias reg='hledger register' | |
alias stats='hledger stats' | |
alias tags='hledger tags' | |
alias bs='hledger bs' | |
alias bse='hledger bse' | |
alias is='hledger is' | |
alias cf='hledger cashflow' | |
alias budget='hledger bal --budget' | |
# save typing. Not used in the scripts below, to keep them introspectable ("which bsui"). | |
alias uiw='hledger-ui --watch' | |
alias uiwr='hledger-ui --watch --register' | |
############################################################################### | |
# Reports using hledger-ui. | |
# | |
# These are designed for a multi-entity account tree, where the | |
# top-level accounts represent entities to be reported separately | |
# ("JS" and "sm" here), each with ALERX or ALEIX accounts below (and | |
# appropriate account type declarations). | |
# | |
# When calling these, you can add extra options and query arguments. | |
# You can override the default accounts with "not:not:DESIREDACCT". | |
# common account patterns and options for balance sheets, income statements, and expense summaries | |
BSACCTS="(ass|lia|todo)" | |
ISACCTS="(rev|inc|exp)" | |
EXACCTS="exp" | |
BSOPTS="--tree -5 -V" # show hierarchy, to depth 5, convert to home currency | |
ISOPTS="--change --tree -3 --theme=greenterm" # show changes not end balances, with hierarchy, to depth 3, with a different theme | |
EXOPTS="$ISOPTS date:thismonth" # just this month | |
# a few more local args/opts: hide some stuff, make important balances clearer | |
BSOPTS2="not:(deposit|investments|prepaid|tax) cur:[\$E]" | |
# list the below hledger-ui report commands | |
function uihelp() { | |
cat <<EOF | |
hledger-ui reports: | |
all merged sm JS | |
---- ------ ------ ------ | |
balance sheet bsui bsuime bsuism bsuijs | |
income statement isui isuime isuism isuijs | |
expense summary exui exuime exuism exuijs | |
EOF | |
} | |
############################## | |
# ALL ENTITIES, SEPARATELY: | |
# balance sheet ui showing assets/liabilities for each top-level entity | |
function bsui() { | |
hledger-ui --watch $BSACCTS $BSOPTS "$@" | |
} | |
# income statement ui showing revenues/expenses for each entity | |
function isui() { | |
hledger-ui --watch $ISACCTS $ISOPTS "$@" | |
} | |
# expenses summary ui for each entity | |
function exui() { | |
hledger-ui --watch $EXACCTS $EXOPTS "$@" | |
} | |
############################## | |
# ALL ENTITIES, MERGED AS ONE: | |
# balance sheet ui for all entities merged | |
function bsuime() { | |
hledger-ui --watch --alias='/^(JS|sm):/=' --alias='/:(bofi|unify|wf):/=:' $BSACCTS $BSOPTS "$@" # XXX try without bofi arg | |
} | |
# income statement ui for all entities merged | |
function isuime() { | |
hledger-ui --watch --alias='/^(JS|sm):/=' $ISACCTS $ISOPTS -2 "$@" | |
} | |
# expenses summary ui for all entities merged | |
function exuime() { | |
hledger-ui --watch --alias='/^(JS|sm):/=' $EXACCTS $EXOPTS -2 "$@" | |
} | |
# reconcile ui showing all frequently-reconciled, cleared balances. | |
# alias bsuire="bsuime not:not:'(bank|paypal|wallet|household)' -C -3 --flat" | |
############################## | |
# PERSONAL | |
# personal balance sheet ui | |
function bsuism() { | |
hledger-ui --watch "sm:$BSACCTS" $BSOPTS $BSOPTS2 "$@" | |
} | |
# personal income statement ui | |
function isuism() { | |
hledger-ui --watch "sm:$ISACCTS" $ISOPTS "$@" | |
} | |
# personal expenses summary ui | |
function exuism() { | |
hledger-ui --watch "sm:$EXACCTS" $EXOPTS "$@" | |
} | |
############################## | |
# JOYFUL SYSTEMS BUSINESS | |
# joyful systems balance sheet ui | |
function bsuijs() { | |
hledger-ui --watch "JS:$BSACCTS" $BSOPTS $BSOPTS2 "$@" | |
} | |
# joyful systems income statement ui | |
function isuijs() { | |
hledger-ui --watch "JS:$ISACCTS" $ISOPTS "$@" | |
} | |
# joyful systems expenses summary ui | |
function exuijs() { | |
hledger-ui --watch "JS:$EXACCTS" $EXOPTS "$@" | |
} | |
############################################################################### |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment