From a8cec1de3c6cb449abbcc47dc15adc0524bf8361 Mon Sep 17 00:00:00 2001 From: RGBCube Date: Fri, 18 Jul 2025 21:06:52 +0300 Subject: [PATCH] nushell: add jc --- modules/common/nushell/config.nu | 21 +++++++++++++++++++++ modules/common/packages.nix | 1 + 2 files changed, 22 insertions(+) diff --git a/modules/common/nushell/config.nu b/modules/common/nushell/config.nu index 482a816..9a28cbf 100644 --- a/modules/common/nushell/config.nu +++ b/modules/common/nushell/config.nu @@ -24,6 +24,27 @@ def --env mcg [path: path]: nothing -> nothing { jj git init --colocate } +# Run `jc` (JSON Converter). +def --wrapped jc [...arguments]: [any -> table, any -> record, any -> string] { + let run = ^jc ...$arguments | complete + + if $run.exit_code != 0 { + error make { + msg: $run.stderr, + label: { + text: "jc execution failed", + span: (metadata $arguments).span + } + } + } + + if "--help" in $arguments or "-h" in $arguments { + $run.stdout + } else { + $run.stdout | from json + } +} + # `nu-highlight` with default colors # # Custom themes can produce a lot more ansi color codes and make the output diff --git a/modules/common/packages.nix b/modules/common/packages.nix index 38784a5..93bebad 100644 --- a/modules/common/packages.nix +++ b/modules/common/packages.nix @@ -14,6 +14,7 @@ in { fastfetch fd hyperfine + jc moreutils openssl p7zip