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

View File

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

View File

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