From 278ede552736d0e87bf5799f60c7981b6a503a21 Mon Sep 17 00:00:00 2001 From: gxlin Date: Sun, 7 Mar 2021 11:43:21 +0800 Subject: Add ledger report binary --- .zshrc | 4 +++- bin/ledger | 26 ++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 bin/ledger diff --git a/.zshrc b/.zshrc index 1d67e8f..fea0494 100644 --- a/.zshrc +++ b/.zshrc @@ -14,6 +14,8 @@ HISTSIZE=1000 SAVEHIST=1000 HISTFILE=~/.zsh_history +[ -f ~/.dotfiles/bin ] && export PATH="$HOME/.dotfiles/bin:$PATH" + [[ -s /etc/profile.d/autojump.sh ]] && source /etc/profile.d/autojump.sh # proxy @@ -36,7 +38,7 @@ Darwin) # Alias alias ls='ls -G' - alias ll='ls -lG' + alias ll='ls -lhG' ;; Linux) # commands for Linux diff --git a/bin/ledger b/bin/ledger new file mode 100644 index 0000000..c3aa3b5 --- /dev/null +++ b/bin/ledger @@ -0,0 +1,26 @@ +#!/usr/bin/env bash + +[ -f /usr/local/bin/ledger ] && prog=/usr/local/bin/ledger + +subcommand=$1 +extra_options=${@:2} + +case $subcommand in + bs) # Balance Sheet + $prog --current --aux-date --no-pager bal ^Assets ^Liabilities $extra_options + ;; + cf) # Cash Flow + $prog --no-pager reg ^Assets ^Liabilities --daily --collapse $extra_options + ;; + is) # Income Statement + $prog --current --aux-date --no-pager reg ^Expenses ^Revenues --daily --collapse $extra_options + $prog --current --aux-date --no-pager bal ^Expenses ^Revenues --collapse $extra_options + ;; + exp) # Expense Compare + $prog --current --aux-date --no-pager bal ^Expenses --depth 1 --sort amount -X USD $extra_options + $prog --current --aux-date --no-pager bal ^Expenses -% --depth 2 --sort amount -X USD $extra_options + ;; + *) + $prog $@ + ;; +esac -- cgit v1.2.3