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