This commit is contained in:
Oystein Kristoffer Tveit 2022-11-26 06:02:52 +01:00
parent 36b5f5e5f7
commit a5d68057d0
Signed by: oysteikt
GPG Key ID: 9F2F7D8250F35146
3 changed files with 19 additions and 12 deletions

View File

@ -37,7 +37,8 @@ let
"<varname>([^>]*)</varname>" = "${red}$1${clear}";
"</para><para>" = "\\n";
"<link${s}xlink:href=\"([^>]*)\"${s}/>" = "${blue}$1${clear}";
"<link${s}xlink:href=\"([^>]*)\"${s}>([^<]*)</link>" = "${bold}$2 ${clear}(${blue}$1${clear})";
"<link${s}xlink:href=\"([^>]*)\"${s}>([^<]*)</link>" =
"${bold}$2 ${clear}(${blue}$1${clear})";
"<xref${s}linkend=\"opt-([^>]*)\"${s}/>" = "${blue}$1${clear}";
};
@ -83,13 +84,15 @@ let
${jq} -C ".\"$OPTION_KEY\"" $JSON_MANUAL_PATH
'';
previewGomplate = isColorized: let
# TODO: Color management here needs a refactoring badly...
pArgs = if isColorized then perlArgsColor else perlArgs;
colorSuffix = if isColorized then "-color" else "";
batColorArg = if isColorized then "--color=always " else "";
template = if isColorized then optionTemplateColor else optionTemplate;
in pkgs.writers.writeBash "preview-home-manager-attrs-gomplate${colorSuffix}" ''
previewGomplate = isColorized:
let
# TODO: Color management here needs a refactoring badly...
pArgs = if isColorized then perlArgsColor else perlArgs;
colorSuffix = if isColorized then "-color" else "";
batColorArg = if isColorized then "--color=always " else "";
template = if isColorized then optionTemplateColor else optionTemplate;
in pkgs.writers.writeBash
"preview-home-manager-attrs-gomplate${colorSuffix}" ''
OPTION_KEY=$1
JSON_MANUAL_PATH=$2
@ -169,9 +172,13 @@ in pkgs.writers.writeBash "search-home-manager-attrs" ''
elif [ -v PRINT_JSON ]; then
${jq} -r 'keys | .[] | .' $JSON_MANUAL_PATH | ${fzf} --preview "${previewJson} {} $JSON_MANUAL_PATH"
elif [ -v NO_COLOR ]; then
${jq} -r 'keys | .[] | .' $JSON_MANUAL_PATH | ${fzf} --preview "${previewGomplate false} {} $JSON_MANUAL_PATH"
${jq} -r 'keys | .[] | .' $JSON_MANUAL_PATH | ${fzf} --preview "${
previewGomplate false
} {} $JSON_MANUAL_PATH"
else
${jq} -r 'keys | .[] | .' $JSON_MANUAL_PATH | ${fzf} --preview "${previewGomplate true} {} $JSON_MANUAL_PATH"
${jq} -r 'keys | .[] | .' $JSON_MANUAL_PATH | ${fzf} --preview "${
previewGomplate true
} {} $JSON_MANUAL_PATH"
fi
''

View File

@ -1,3 +1,3 @@
# TODO:
{ pkgs, ... }:
pkgs.emptyFile
pkgs.emptyFile

View File

@ -1,3 +1,3 @@
# TODO:
{ pkgs, ... }:
pkgs.emptyFile
pkgs.emptyFile