From 208b04c101859677c9936f15d192cbbaed521473 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moritz=20B=C3=B6hme?= Date: Sat, 18 Jun 2022 19:32:14 +0200 Subject: [PATCH] :rocket: make ledger its own module --- modules/cli/default.nix | 15 +- modules/cli/ledger/default.nix | 26 +++ modules/cli/ledger/ledger.fish | 344 +++++++++++++++++++++++++++++++++ modules/editors/emacs.nix | 3 - 4 files changed, 373 insertions(+), 15 deletions(-) create mode 100644 modules/cli/ledger/default.nix create mode 100644 modules/cli/ledger/ledger.fish diff --git a/modules/cli/default.nix b/modules/cli/default.nix index 144d448..101a5ea 100644 --- a/modules/cli/default.nix +++ b/modules/cli/default.nix @@ -6,10 +6,11 @@ ./bin ./direnv.nix ./git.nix + ./ledger ./nix.nix - ./ssh.nix ./shell ./spotify.nix + ./ssh.nix ./yubikey.nix ]; modules.cli.shell = let @@ -60,18 +61,8 @@ latexwatch = ''find -type f -name "*.tex" | entr -c latexmk -pdf -silent''; - ledger = "command ledger --strict --explicit"; - bal = "ledger -R bal"; - balcash = "bal -X € --current --flat ^assets:bank ^liabilities"; - balnet = "bal -X € --current --depth 2 ^assets ^liabilities"; - bud = "ledger --budget bal ^expenses"; - budr = ''ledger --budget --real reg -d "d>=[this month]" ^expenses''; - reg = "ledger reg -R --tail 15"; - }; - variables = { - EDITOR = editor; - LEDGER_FILE = "/home/moritz/Notes/ledger/main.ledger"; }; + variables = { EDITOR = editor; }; }; home-manager.users.moritz = { home.packages = with pkgs; [ diff --git a/modules/cli/ledger/default.nix b/modules/cli/ledger/default.nix new file mode 100644 index 0000000..4526aef --- /dev/null +++ b/modules/cli/ledger/default.nix @@ -0,0 +1,26 @@ +{ config, lib, pkgs, ... }: + +{ + modules.cli.shell.aliases = { + bal = "ledger bal"; + balcash = "ledger bal -R -X € --current --flat ^assets:bank ^liabilities"; + balnet = "ledger bal -R -X € --current --depth 2 ^assets ^liabilities"; + bud = ''ledger --budget --unbudgeted bal ^expenses -p "this month"''; + budr = ''ledger --budget reg -p "this month" ^expenses''; + reg = "ledger reg -R -V --tail 15"; + }; + home-manager.users.moritz = { + home.packages = with pkgs; [ ledger ]; + xdg.configFile = { + "fish/completions/ledger.fish" = { + text = builtins.readFile ./ledger.fish; + }; + "ledger/ledgerrc".text = '' + --pedantic + --explicit + --payee note + --file ~/Notes/ledger/main.ledger + ''; + }; + }; +} diff --git a/modules/cli/ledger/ledger.fish b/modules/cli/ledger/ledger.fish new file mode 100644 index 0000000..edb0804 --- /dev/null +++ b/modules/cli/ledger/ledger.fish @@ -0,0 +1,344 @@ +# ledger completion + +function __fish_ledger_needs_command + set cmd (commandline -opc) + set skip_next 0 + test (count $cmd) -eq 1 + and return 0 + for item in $cmd[2..-1] + test $skip_next -eq 1 + and set skip_next 0 + and continue + switch $item + case '-D' '-F' + # These take an argument + set skip_next 1 + case '-*' '*:*' + # Do nothing + case '*' + # Action found + echo $item + return 1 + end + end + return 0 +end + +function __fish_ledger_command_is + set cmd (__fish_ledger_needs_command) + test -z "$cmd" + and return 1 + contains -- $cmd $argv + and return 0 + return 1 +end + +function __fish_complete_ledger_commands + for target in \ + "accounts\\tList accounts of matching postings\\n" \ + "args\\tPrint how args are evaluated\\n" \ + "balance\\tBalance report\\n" \ + "budget\\tBudget report\\n" \ + "cleared\\tCleared report\\n" \ + "commodities\\tCommodities report\\n" \ + "convert\\tConvert from CSV\\n" \ + "csv\\tPrint output in CSV format\\n" \ + "emacs\\tPrint output in Lisp form\\n" \ + "entry\\tGenerate entry from template\\n" \ + "equity\\tEquity report\\n" \ + "eval\\tEvaluate the arguments\\n" \ + "expr\\tPrint how given value expr is evaluated\\n" \ + "format\\tPrint how given format is evaluated\\n" \ + "generate\\tGenerate random ledger data for tests\\n" \ + "org\\tExport to Org Mode\\n" \ + "parse\\tPrint how given value expr is evaluated\\n" \ + "payees\\tList payees of matching posting\\n" \ + "period\\tPrint how given period is interpreted\\n" \ + "pop\\tUnset option in the REPL\\n" \ + "pricedb\\tPrices report based on ~/.pricedb\\n" \ + "pricemap\\tGraph of commodities relationships\\n" \ + "prices\\tPrices report\\n" \ + "print\\tPrint full transactions\\n" \ + "push\\tSet option in the REPL\\n" \ + "python\\tRun given file in Python inerpreter\\n" \ + "query\\tPrint how args are evaluated\\n" \ + "register\\tList matching postings\\n" \ + "reload\\tReload all data files for current session\\n" \ + "select\\tUse an SQL query to print postings\\n" \ + "server\\tStarts HTTP server\\n" \ + "source\\tCheck journal file for errors\\n" \ + "stats\\tPrint summary info on matching postings\\n" \ + "template\\tShow insertion template generated by xcat command\\n" \ + "xact\\tGenerate entry from template\\n" \ + "xml\\tPrint report in XML format\\n" \ + + printf $target + end +end + +function __fish_complete_ledger_expr + set -l tail (commandline -tc) + string match -q -r -- '^-' "$tail" + and return 0 + string match -q -r -- '[()!]' "$tail" + # Complete "ledger echo \(foo" + and set -l head (string match -r -- '.*[()!]' "$tail"; true) + and set head (string replace -r -a -- '[\\\]' '\\' "$head"; true) + and set tail (string match -r -- '[^()!]*$' "$tail"; true) + and set -l items (complete -C"ledger echo $tail") + and for item in $items + printf '%s%s\n' "$head" "$item" + end + and return 0 + # Expression words + printf '(\tStart enclosed expression\n' + printf ')\tEnd enclosed expression\n' + printf '!\tLogical negation\n' + printf 'and\tLogical conjunction\n' + printf 'or\tLogical disjunction\n' + printf 'not\tLogical negation\n' + # Pseudo-portnames + set -l pseudo "all" "current" "active" "inactive" "installed" "uninstalled" \ + "outdated" "obsolete" "requested" "unrequested" "leaves" + for item in $pseudo + printf '%s\tPseudo-portname\n' $item + end + # Pseudo-portname selectors + set -l selectors "depof:" "rdepof:" "depends:" "rdepends:" "dependentof:" \ + "rdependentof:" "name:" "version:" "revision:" "epoch:" "variant:" \ + "variants:" "category:" "categories:" "maintainer:" "maintainers:" \ + "platform:" "platforms:" "description:" "long_description:" "homepage:" \ + "license:" "portdir:" + for item in $selectors + printf '%s\tSelector\n' $item + end + test -z "$tail" + # Listing all ports is too slow, just stop here if empty + and return 0 + # Globbing characters + printf '%s*\tGlob pattern\n' "$tail" + printf '%s?\tGlob pattern\n' "$tail" + # Portnames + test "$argv[1]" = "all" + # This might take long, try to limit the output + and set -l portexpr "*$tail*" + or set -l portexpr $argv[1] + set portnames (ledger -q echo $portexpr | string replace -r -- ' *@.*' '' \ + | string replace -a -- ' ' '') + for item in $portnames + printf '%s\tPortname\n' $item + end + return 0 +end + +function __fish_complete_ledger_help + complete -C"ledger " + printf '%s\t%s\n' macports.conf "Configuration file of the MacPorts system" + printf '%s\t%s\n' portfile "MacPorts description file reference" + printf '%s\t%s\n' portgroup "MacPorts PortGroup command reference" + printf '%s\t%s\n' portstyle "Style guide for Portfiles" + printf '%s\t%s\n' porthier "Layout of the ports-filesystems" +end + +function __fish_complete_ledger_select + set cmd (commandline -opc) + set count 0 + for item in $cmd + switch $item + case '-*' + test $item = "--set" + and set is_set 1 + or set is_set = 0 + set count 0 + case '*' + set count (math $count + 1) + set group $item + end + end + test $count -eq 0 + and for name in (ledger select --summary | awk 'NR>2{print $1}') + printf '%s\tGroup name\n' $name + end + and return 0 + test $count -eq 1 + and test "$is_set" -eq 1 + and for name in (ledger -q select --list $group) + string match -q -r -- '(active)' "$name" + and printf '%s\tActive\n' (string match -r -- '^\s*[^ \t]+' "$name") + or printf '%s\tInactive\n' "$name" + end +end + +complete -e -c ledger +complete -f -c ledger + +# --option | -o +complete -f -c ledger -s A -l average -d "Print average values over the number of transactions instead of running totals." +complete -f -c ledger -s B -l basis -d "Report the cost basis on all posting. Alias for --cost" +complete -f -c ledger -s L -l actual -d "Report only real transactions, with no automated or virtual transactions used." +complete -f -c ledger -s j -l amount-data -d "On a register report print only the dates and amount of post- ings. Useful for graphing and spreadsheet applications." +complete -f -c ledger -s P -l by-payee -d "Group postings in the register report by common payee names." +complete -f -c ledger -s C -l cleared -d "Display only cleared postings." +complete -f -c ledger -s n -l collapse -d "Print only the top level accounts." +complete -f -c ledger -s c -l current -d "Shorthand for --limit 'date <= today'." +complete -f -c ledger -s D -l daily -d "Shorthand for --period daily." +complete -f -c ledger -s E -l empty -d "Include empty accounts in report." +complete -f -c ledger -s G -l gain -d "Report net gain or loss for commodities that have a price his- tory." +complete -f -c ledger -s V -l market -d "Use the latest market value for all commodities." +complete -f -c ledger -s M -l monthly -d "Shorthand for --period monthly." +complete -f -c ledger -s % -l percent -d "Calculate the percentage value of each account in a balance reports. Only works for account that have a single commodity." +complete -f -c ledger -s I -l price -d "Use the price of the commodity purchase for performing calcula- tions." +complete -f -c ledger -s O -l quantity -d "Report commodity totals (this is the default)." +complete -f -c ledger -s R -l real -d "Account using only real transactions ignoring virtual and auto- matic transactions." +complete -f -c ledger -s r -l related -d "In a register report show the related account. This is the other side of the transaction." +complete -f -c ledger -s s -l subtotal -d "Report register as a single subtotal." +complete -f -c ledger -s J -l total-data -d "Show only dates and totals to format the output for plots." +complete -f -c ledger -s U -l uncleared -d "Use only uncleared transactions in calculations and reports." +complete -f -c ledger -s Y -l yearly -d "Shorthand for --period yearly." +complete -f -c ledger -s w -l wide -d "Assume 132 columns instead of the TTY width." +complete -f -c ledger -s W -l weekly -d "Shorthand for --period weekly." + +# --option +complete -f -c ledger -l version -d "Print version information and exit." +complete -f -c ledger -l verify-memory -d "Verify that every constructed object is properly destructed. This is for debugging purposes only." +complete -f -c ledger -l verify -d "Enable additional assertions during run-time. This causes a significant slowdown. When combined with --debug CODE ledger will produce memory trace information." +complete -f -c ledger -l verbose -d "Print detailed information on the execution of ledger." +complete -f -c ledger -l values -d "Show the values used by each tag when used in combination with the tags command." +complete -f -c ledger -l unround -d "Perform all calculations without rounding and display results to full precision." +complete -f -c ledger -l unrealized-losses -d "Allow the user to specify what account name should be used for unrealized losses. Defaults to Equity:Unrealized Losses. Often set in one's ~/.ledgerrc file to change the default." +complete -f -c ledger -l unrealized-gains -d "Allow the user to specify what account name should be used for unrealized gains. Defaults to Equity:Unrealized Gains. Often set in one's ~/.ledgerrc file to change the default." +complete -f -c ledger -l unrealized -d "Show generated unrealized gain and loss accounts in the balance report." +complete -f -c ledger -l unbudgeted -d "Show only un-budgeted postings." +complete -f -c ledger -l time-report -d "Add two columns to the balance report to show the earliest checkin and checkout times for timelog entries." +complete -f -c ledger -l time-colon -d "Display the value for commodities based on seconds as hours and minutes. Thus 8100s will be displayed as 2:15h instead of 2.25h." +complete -f -c ledger -l strict -d "Accounts, tags or commodities not previously declared will cause warnings." +complete -f -c ledger -l sort-xacts -d "Sort the posting within transactions using the given value expression." +complete -f -c ledger -l rich-data -d "When generating a ledger transaction from a CSV file using the convert command, add CSV, Imported, and UUID meta-data." +complete -f -c ledger -l revalued-total -d "Display the sum of the revalued postings as the running total, which serves to show unrealized capital in a gain/losses report." +complete -f -c ledger -l revalued-only -d "Show only postings." +complete -f -c ledger -l revalued -d "Report discrepancy in values for manual reports by inserting postings. This is implied when using the --exchange (-X) or --market (-V) option." +complete -f -c ledger -l related-all -d "Show all postings in a transaction, similar to --related but show both sides of each transaction." +complete -f -c ledger -l recursive-aliases -d "Causes ledger to try to expand aliases recursively, i.e. try to expand the result of an earlier expansion again, until no more expansions apply." +complete -f -c ledger -l raw -d "In the print report, show transactions using the exact same syn- tax as specified by the user in their data file. Don't do any massaging or interpreting. Can be useful for minor cleanups, like just aligning amounts." +complete -f -c ledger -l quarterly -d "Shorthand for --period quarterly." +complete -f -c ledger -l primary-date -d "Show primary dates for all calculations. Alias for --actual-dates" +complete -f -c ledger -l permissive -d "Quiet balance assertions." +complete -f -c ledger -l period-sort -d "Sort the posting within transactions using the given value expression." +complete -f -c ledger -l pending -d "Use only postings that are marked pending." +complete -f -c ledger -l pedantic -d "Accounts, tags or commodities not previously declared will cause errors." +complete -f -c ledger -l payee -d "Sets a value expression for formatting the payee. In the register report this prevents the second entry from having a date and payee for each transaction." +complete -f -c ledger -l options -d "Display the options in effect for this ledger invocation, along with their values and the source of those values." +complete -f -c ledger -l no-total -d "Suppress printing the final total line in a balance report." +complete -f -c ledger -l no-titles -d "Suppress the output of group titles." +complete -f -c ledger -l no-rounding -d "Don't output \"\" postings. Note that this will cause the running total to often not add up! Its main use is for --amount-data (-j) and --total-data (-J) reports." +complete -f -c ledger -l no-revalued -d "Stop ledger from showing postings." +complete -f -c ledger -l no-pager -d "Disables the pager on TTY output." +complete -f -c ledger -l no-color -d "Suppress any color TTY output." +complete -f -c ledger -l no-aliases -d "Aliases are completely ignored." +complete -f -c ledger -l lots-actual -d "Preserve the uniqueness of commodities so they aren't merged during reporting without printing the lot annotations." +complete -f -c ledger -l lots -d "Report the date and price at which each commodity was purchased in a balance report." +complete -f -c ledger -l lot-prices -d "Report the price at which each commodity in a balance report was purchased." +complete -f -c ledger -l lot-notes -d "Report the tag attached to each commodity in a balance report." +complete -f -c ledger -l lot-dates -d "Report the date on which each commodity in a balance report was purchased." +complete -f -c ledger -l invert -d "Change the sign of all reported values." +complete -f -c ledger -l immediate -d "Evaluate calculations immediately rather than lazily." +complete -f -c ledger -l help -d "Print this man page. --generated Include auto-generated postings (such as those from automated transactions) in the report, in cases where you normally wouldn't want them." +complete -f -c ledger -l force-pager -d "Force ledger to paginate its output." +complete -f -c ledger -l force-color -d "Output TTY color codes even if the TTY doesn't support them. Useful for TTYs that don't advertise their capabilities cor- rectly." +complete -f -c ledger -l flat -d "Force the full names of accounts to be used in the balance report. The balance report will not use an indented tree." +complete -f -c ledger -l explicit -d "Direct ledger to require pre-declarations for entities (such as accounts, commodities and tags) rather than taking entities from cleared transactions as defined." +complete -f -c ledger -l exact -d "Report beginning and ending of periods by the date of the first and last posting occurring in that period." +complete -f -c ledger -l equity -d "Related to the equity command. Gives current account balances in the form of a register report." +complete -f -c ledger -l effective -d "Show auxiliary dates for all calculations. Alias for --aux-date." +complete -f -c ledger -l download -d "Cause quotes to be automagically downloaded, as needed, by run- ning a script named getquote and expecting that script to return a value understood by ledger. A sample implementation of a getquote script, implemented in Perl, is provided in the distri- bution. Downloaded quote price are then appended to the price database, usually specified using the environment variable LEDGER_PRICE_DB." +complete -f -c ledger -l dow -d "Group transactions by the days of the week. Alias for --days-of-week." +complete -f -c ledger -l deviation -d "Report each posting's deviation from the average. It is only meaningful in the register and prices reports." +complete -f -c ledger -l detail -d "Related to convert command. Synonym to --rich-data option." +complete -f -c ledger -l decimal-comma -d "Direct ledger to parse journals using the European standard comma as decimal separator, vice a period." +complete -f -c ledger -l dc -d "Display register or balance in debit/credit format If you use --dc with either the register or balance commands, you will now get separate columns for debits and credits." +complete -f -c ledger -l days-of-week -d "Group transactions by the days of the week. Alias for --dow." +complete -f -c ledger -l day-break -d "Break up register report of timelog entries that span multiple days by day." +complete -f -c ledger -l count -d "Direct ledger to report the number of items when appended to the commodities, accounts or payees commands." +complete -f -c ledger -l cost -d "Report the cost basis on all posting. Alias for --basis. --color Use color if the terminal supports it. Alias for --ansi" +complete -f -c ledger -l collapse-if-zero -d "Collapse the account display only if it has a zero balance." +complete -f -c ledger -l check-payees -d "Enable strict and pedantic checking for payees as well as accounts, commodities and tags." +complete -f -c ledger -l budget -d "Only display budgeted items. In a register report this displays transaction in the budget, in a balance report this displays accounts in the budget." +complete -f -c ledger -l base -d "Reduce convertible commodities down the bottom of the conver- sion, e.g. display time in seconds." +complete -f -c ledger -l aux-date -d "Show auxiliary dates for all calculations. Alias for --effective" +complete -f -c ledger -l auto-match -d "When generating a ledger transaction from a CSV file using the convert command, automatically match an account from the Ledger journal." +complete -f -c ledger -l args-only -d "Ignore init files and environment variables for the ledger run." +complete -f -c ledger -l ansi -d "Use color if the terminal supports it. Alias for --color --anon Anonymize registry output, mostly for sending in bug reports." +complete -f -c ledger -l add-budget -d "Show only un-budgeted postings." +complete -f -c ledger -l abbrev-len -d "INT Set the minimum length an account can be abbreviated to if it doesn't fit inside the account-width. If INT is zero, then the account name will be truncated on the right. If INT is greater than account-width then the account will be truncated on the left, with no shortening of the account names in order to fit into the desired width." + +complete -f -c ledger -l account -a "(__fish_complete_ledger_opt_args EXPR)" -d "Prepend EXPR to all accounts reported. That is, the option --account \"'Personal'\" would tack Personal: and --account \"tag('VAT')\" would tack the value of the VAT tag to the begin- ning of every account reported in a balance or register report." +complete -f -c ledger -l value-expr -a "(__fish_complete_ledger_opt_args EXPR)" -d "Set a global value expression annotation." +complete -f -c ledger -l only -a "(__fish_complete_ledger_opt_args EXPR)" -d "This is a postings predicate that applies after certain trans- forms have been executed, such as periodic gathering." +complete -f -c ledger -l group-by -a "(__fish_complete_ledger_opt_args EXPR)" -d "Group transaction together in the register report. EXPR can be anything, although most common would be payee or commodity. The tag() function is also useful here." +complete -f -c ledger -l forecast-while -a "(__fish_complete_ledger_opt_args EXPR)" -d "Continue forecasting while VEXPR is true. Alias for --forecast." +complete -f -c ledger -l display-total -a "(__fish_complete_ledger_opt_args EXPR)" -d "Apply a transformation to the displayed total. This occurs after calculations occur." +complete -f -c ledger -l display-amount -a "(__fish_complete_ledger_opt_args EXPR)" -d "Apply a transformation to the displayed amount. This occurs after calculations occur." +complete -f -c ledger -l date -a "(__fish_complete_ledger_opt_args EXPR)" -d "Transform the date of the transaction using EXPR." +complete -f -c ledger -l bold-if -a "(__fish_complete_ledger_opt_args EXPR)" -d "Print the entire line in bold if the given value expression is true." +complete -f -c ledger -l group-title-format -a "(__fish_complete_ledger_opt_args FMT)" -d "Set the format for the headers that separate reports section of a grouped report. Only has effect with a --group-by EXPR regis- ter report." +complete -f -c ledger -l register-format -a "(__fish_complete_ledger_opt_args FMT)" -d "Define the output format for the register report." +complete -f -c ledger -l pricedb-format -a "(__fish_complete_ledger_opt_args FMT)" -d "Set the format expected for the historical price file." +complete -f -c ledger -l prices-format -a "(__fish_complete_ledger_opt_args FMT)" -d "Set the format for the prices report." +complete -f -c ledger -l prepend-format -a "(__fish_complete_ledger_opt_args FMT)" -d "Prepend FMT to every line of the output." +complete -f -c ledger -l plot-total-format -a "(__fish_complete_ledger_opt_args FMT)" -d "Define the output format for a total data plot." +complete -f -c ledger -l plot-amount-format -a "(__fish_complete_ledger_opt_args FMT)" -d "Define the output format for an amount data plot." +complete -f -c ledger -l csv-format -a "(__fish_complete_ledger_opt_args FMT)" -d "Format csv report according to FMT." +complete -f -c ledger -l cleared-format -a "(__fish_complete_ledger_opt_args FMT)" -d "Specify the format to use for the cleared report" +complete -f -c ledger -l budget-format -a "(__fish_complete_ledger_opt_args FMT)" -d "Specify the format to use for the budget report." +complete -f -c ledger -l balance-format -a "(__fish_complete_ledger_opt_args FMT)" -d "Specify the format to use for the balance report." +complete -f -c ledger -l account-width -a "(__fish_complete_ledger_opt_args INT)" -d "Set the width of the account column in the register report to INT characters." +complete -f -c ledger -l trace -a "(__fish_complete_ledger_opt_args INT)" -d "Enable tracing. The INT specifies the level of trace desired." +complete -f -c ledger -l total-width -a "(__fish_complete_ledger_opt_args INT)" -d "Set the width of the total field in the register report." +complete -f -c ledger -l tail -a "(__fish_complete_ledger_opt_args INT)" -d "Report only the last INT entries. Only useful on a register report. Alias for --last INT" +complete -f -c ledger -l seed -a "(__fish_complete_ledger_opt_args INT)" -d "Set the random seed to INT for the generate command. Used as part of development testing." +complete -f -c ledger -l prepend-width -a "(__fish_complete_ledger_opt_args INT)" -d "Reserve INT spaces at the beginning of each line of the output." +complete -f -c ledger -l payee-width -a "(__fish_complete_ledger_opt_args INT)" -d "Set the number of columns dedicated to the payee in the register report to INT." +complete -f -c ledger -l meta-width -a "(__fish_complete_ledger_opt_args INT)" -d "Specify the width of the Meta column used for the --meta TAG options." +complete -f -c ledger -l last -a "(__fish_complete_ledger_opt_args INT)" -d "Report only the last INT entries. Opposite of --first INT. Only useful on a register report. Alias for --tail." +complete -f -c ledger -l head -a "(__fish_complete_ledger_opt_args INT)" -d "Print the first INT entries. Opposite of --tail INT. Alias for --first" +complete -f -c ledger -l forecast-years -a "(__fish_complete_ledger_opt_args INT)" -d "Forecast at most INT years into the future." +complete -f -c ledger -l first -a "(__fish_complete_ledger_opt_args INT)" -d "Print the first INT entries. Opposite of --last INT. Alias for --head." +complete -f -c ledger -l depth -a "(__fish_complete_ledger_opt_args INT)" -d "Limit the depth of the account tree. In a balance report, for example, --depth 2 will print balances only for accounts with two levels, i.e. Expenses:Entertainment but not Expenses:Entertainment:Dining. This is a display predicate, which means it only affects display, not the total calculations." +complete -f -c ledger -l date-width -a "(__fish_complete_ledger_opt_args INT)" -d "Specify the width, in characters, of the date column in the register report." +complete -f -c ledger -l columns -a "(__fish_complete_ledger_opt_args INT)" -d "Make the register report INT characters wide. By default ledger will use all available columns in your terminal." +complete -f -c ledger -l amount-width -a "(__fish_complete_ledger_opt_args INT)" -d "Set the width in characters of the amount column in the register report." +complete -f -c ledger -l datetime-format -a "(__fish_complete_ledger_opt_args DATETIMEFMT)" -d "Print datetimes using DATETIMEFMT. Refer to strftime(3) for details on the format string syntax." +complete -f -c ledger -l debug -a "(__fish_complete_ledger_opt_args STR)" -d "If ledger has been built with debug options this will provide extra data during the run." +complete -f -c ledger -l truncate -a "(__fish_complete_ledger_opt_args STR)" -d "Indicates how truncation should happen when the contents of col- umns exceed their width. Valid arguments for STR are leading, middle, and trailing. The default is smarter than any of these three, as it considers sub-names within the account name (that style is called \"abbreviate\")." +complete -f -c ledger -l start-of-week -a "(__fish_complete_ledger_opt_args STR)" -d "Use STR as the particular day of the week to start when using the --weekly option. STR can be day names, their abbreviations like \"Mon\", or the weekday number starting at 0 for Sunday." +complete -f -c ledger -l pager -a "(__fish_complete_ledger_opt_args STR)" -d "Use STR as the pager program." +complete -f -c ledger -l meta -a "(__fish_complete_ledger_opt_args STR)" -d "In the register report, prepend the transaction with the value of the given tag STR." +complete -f -c ledger -l master-account -a "(__fish_complete_ledger_opt_args STR)" -d "Prepend all account names with STR" +complete -f -c ledger -l inject -a "(__fish_complete_ledger_opt_args STR)" -d "Use STR amounts in calculations. In case you know what amount a transaction should be, but the actual transaction has the wrong value you can use metadata STR to specify the expected amount." +complete -f -c ledger -l script -a "(__fish_complete_ledger_opt_args FILE)" -d "Execute a ledger script." +complete -f -c ledger -l import -a "(__fish_complete_ledger_opt_args FILE)" -d "Import FILE as Python module." +complete -f -c ledger -l input-date-format -a "(__fish_complete_ledger_opt_args DATEFMT)" -d "Specify the input date format for journal entries." +complete -f -c ledger -l now -a "(__fish_complete_ledger_opt_args DATE)" -d "Use DATE as the current date. This affects the output when using --period, --begin, --end, or --current to decide which dates lie in the past or future." +complete -f -c ledger -l pivot -a "(__fish_complete_ledger_opt_args TAG)" -d "Produce a balance pivot report "around" the given TAG." + +complete -f -c ledger -s T -l total -a "(__fish_complete_ledger_opt_args EXPR)" -d "Define a value expression used to calculate the total in reports." +complete -f -c ledger -s t -l amount -a "(__fish_complete_ledger_opt_args EXPR)" -d "Apply the given value expression to the posting amount. Using --amount EXPR you can apply an arbitrary transformation to the postings." +complete -f -c ledger -s d -l display -a "(__fish_complete_ledger_opt_args EXPR)" -d "Display lines that satisfy the expression EXPR." +complete -f -c ledger -s l -l limit -a "(__fish_complete_ledger_opt_args EXPR)" -d "Limit postings in calculations." +complete -f -c ledger -s S -l sort -a "(__fish_complete_ledger_opt_args EXPR)" -d "Sort the register report based on the value expression EXPR." +complete -f -c ledger -s f -l file -a "(__fish_complete_ledger_opt_args FILE)" -d "Read journal data from FILE." +complete -f -c ledger -s Z -l price-db -a "(__fish_complete_ledger_opt_args FILE)" -d "Set the expected freshness of price quotes, in INT minutes. That is, if the last known quote for any commodity is older than this value, and if --download is being used, then the Internet will be consulted again for a newer price. Otherwise, the old price is still considered to be fresh enough. Alias for --leeway." +complete -f -c ledger -s i -l init-file -a "(__fish_complete_ledger_opt_args FILE)" -d "Read FILE before any other ledger file. This file may not con- tain any postings, but it may contain option settings. To spec- ify options in the init file, use the same syntax as the com- mand-line, but put each option on its own line." +complete -f -c ledger -s o -l output -a "(__fish_complete_ledger_opt_args FILE)" -d "Redirect the output of ledger to FILE." +complete -f -c ledger -s Z -l price-exp -a "(__fish_complete_ledger_opt_args STR)" -d "Set the expected freshness of price quotes, in INT minutes. That is, if the last known quote for any commodity is older than this value, and if --download is being used, then the Internet will be consulted again for a newer price. Otherwise, the old price is still considered to be fresh enough. Alias for --leeway." +complete -f -c ledger -s p -l period -a "(__fish_complete_ledger_opt_args PERIOD)" -d "Define a period expression that sets the time period during which transactions are to be accounted. For a register report only the transactions that satisfy the period expression with be displayed. For a balance report only those transactions will be accounted in the final balances." +complete -f -c ledger -s Z -l leeway -a "(__fish_complete_ledger_opt_args INT)" -d "Alias for --price-expr." +complete -f -c ledger -s F -l format -a "(__fish_complete_ledger_opt_args FMT)" -d "Use the given format string FMT to print output." +complete -f -c ledger -s X -l exchange -a "(__fish_complete_ledger_opt_args COMMODITY)" -d "Display values in terms of the given COMMODITY. The latest available price is used." +complete -f -c ledger -s e -l end -a "(__fish_complete_ledger_opt_args DATE)" -d "Constrain the report so that transactions on or after DATE are not considered." +complete -f -c ledger -s b -l begin -a "(__fish_complete_ledger_opt_args DATE)" -d "Specify the start DATE of all calculations. Transactions before that date will be ignored." +complete -f -c ledger -s y -l date-format -a "(__fish_complete_ledger_opt_args DATEFMT)" -d "Print dates using DATEFMT. Refer to strftime(3) for details on the format string syntax." + + +complete -f -c ledger -n '__fish_ledger_needs_command' -a '(__fish_complete_ledger_commands)' +complete -f -c ledger -n "__fish_ledger_command_is search" -a "(__fish_complete_ledger_expr all)" diff --git a/modules/editors/emacs.nix b/modules/editors/emacs.nix index 2be3f2d..9514f06 100644 --- a/modules/editors/emacs.nix +++ b/modules/editors/emacs.nix @@ -81,9 +81,6 @@ in { # :email mu isync - - # :lang ledger - ledger ]; }; };