container: src: finance: change visidata default dir

The container environment's $DOCKER_FINANCE_CONTAINER_CONF is
bind-mounted and, by default, points to ~/.config/docker-finance.d

The parent dir (~/.config) is subsequently owned by root (Docker-ism).
Ergo, with visidata v3.2, visidata cannot create its default dir:

    "PermissionError: [Errno 13] Permission denied: for visidata config"

This commit fixes that by setting visidata's default dir to use the
calling profile's docker-finance.d (where profile customization occurs).

Also included is some related refactoring.
This commit is contained in:
2025-06-24 19:32:00 -07:00
parent b80978a026
commit 84ec085b8a
4 changed files with 15 additions and 10 deletions

View File

@@ -2,7 +2,7 @@
# docker-finance | modern accounting for the power-user
#
# Copyright (C) 2021-2024 Aaron Fiore (Founder, Evergreen Crypto LLC)
# Copyright (C) 2021-2025 Aaron Fiore (Founder, Evergreen Crypto LLC)
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -265,6 +265,7 @@ function lib_edit::__edit()
;;
meta)
[ -z "$global_conf_meta" ] && lib_utils::die_fatal
[ -z "$global_conf_visidata" ] && lib_utils::die_fatal
local _dir
_dir="$(dirname $global_conf_meta)"
@@ -282,10 +283,10 @@ function lib_edit::__edit()
# - If saved to original, opening with `--skip` will clobber the
# original file's comments.
local -r _skip="$(grep -E "^//!" $_path | wc -l)"
local -r _args=("--quitguard" "--motd-url" "file:///dev/null" "--filetype" "csv" "--skip" "$_skip" "$_path")
local -r _visidata=("--visidata-dir" "$global_conf_visidata" "--quitguard" "--motd-url" "file:///dev/null" "--filetype" "csv" "--skip" "$_skip" "$_path")
lib_utils::deps_check "visidata"
visidata "${_args[@]}" || lib_utils::die_fatal
visidata "${_visidata[@]}" || lib_utils::die_fatal
# TODO: HACK: visidata saves w/ DOS-style carriage...
# ...but there seems to be no option out of this.

View File

@@ -2,7 +2,7 @@
# docker-finance | modern accounting for the power-user
#
# Copyright (C) 2021-2024 Aaron Fiore (Founder, Evergreen Crypto LLC)
# Copyright (C) 2021-2025 Aaron Fiore (Founder, Evergreen Crypto LLC)
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -164,9 +164,10 @@ function lib_hledger::__hledger-ui()
function lib_hledger::__hledger-vui()
{
[ -z "${global_base_args[*]}" ] && lib_utils::die_fatal
[ -z "$global_conf_visidata" ] && lib_utils::die_fatal
hledger "${global_base_args[@]}" print -O csv "$@" \
| visidata --motd-url file:///dev/null --filetype csv
local -r _visidata=("--visidata-dir" "$global_conf_visidata" "--motd-url" "file:///dev/null" "--filetype" "csv")
visidata "${_visidata[@]}" < <(hledger "${global_base_args[@]}" print -O csv "$@")
}
function lib_hledger::__hledger-web()

View File

@@ -2,7 +2,7 @@
# docker-finance | modern accounting for the power-user
#
# Copyright (C) 2021-2024 Aaron Fiore (Founder, Evergreen Crypto LLC)
# Copyright (C) 2021-2025 Aaron Fiore (Founder, Evergreen Crypto LLC)
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -102,6 +102,8 @@ $(echo $global_meta_header | xsv headers -)
function lib_meta::__meta()
{
[ -z "$global_conf_visidata" ] && lib_utils::die_fatal
lib_utils::deps_check "visidata"
# TODO: can visidata regex multiple columns from the commandline?
@@ -130,8 +132,8 @@ function lib_meta::__meta()
done
# Display as stream
cat "$_base_file" \
| visidata --motd-url file:///dev/null --filetype csv
local -r _visidata=("--visidata-dir" "$global_conf_visidata" "--motd-url" "file:///dev/null" "--filetype" "csv")
visidata "${_visidata[@]}" < <(cat "$_base_file")
# Enforce cleanup
[ -d "$_tmp_dir" ] && rm -fr "$_tmp_dir"

View File

@@ -2,7 +2,7 @@
# docker-finance | modern accounting for the power-user
#
# Copyright (C) 2021-2024 Aaron Fiore (Founder, Evergreen Crypto LLC)
# Copyright (C) 2021-2025 Aaron Fiore (Founder, Evergreen Crypto LLC)
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -81,6 +81,7 @@ function lib_finance::finance()
declare -grx global_conf_hledger="${global_child_profile_flow}/docker-finance.d/hledger/hledger.conf"
declare -grx global_conf_meta="${global_child_profile_flow}/docker-finance.d/meta/meta.csv"
declare -grx global_conf_subscript="${global_child_profile_flow}/docker-finance.d/shell/subscript.bash"
declare -grx global_conf_visidata="${global_child_profile_flow}/docker-finance.d/visidata" # dir for config/addons
# Implementation "libraries" (requires previously set globals)
source "${DOCKER_FINANCE_CONTAINER_REPO}/src/finance/lib/internal/lib_edit.bash" || exit 1