summaryrefslogtreecommitdiff
path: root/.config/nushell
diff options
context:
space:
mode:
authorWriterV2 <primary-v2@protonmail.com>2026-04-06 16:33:00 +0200
committerWriterV2 <primary-v2@protonmail.com>2026-04-13 20:02:52 +0200
commitfaf1dac649f4394fd71e648ec9ce87bcada8cf5e (patch)
treef49258f4af7c47e0b4798c118420868a77ca9aee /.config/nushell
parenta1ec4771740d321df4480e8a7224fa10b59f0569 (diff)
Nushell: Fix ripgrep wrapper for piped input
Diffstat (limited to '.config/nushell')
-rw-r--r--.config/nushell/config.nu11
1 files changed, 5 insertions, 6 deletions
diff --git a/.config/nushell/config.nu b/.config/nushell/config.nu
index 99f311b..d94dcda 100644
--- a/.config/nushell/config.nu
+++ b/.config/nushell/config.nu
@@ -866,13 +866,12 @@ $env.config = {
alias _rg = rg
export def --wrapped rg [...rest] {
- mut result = ''
- if ($in != null) {
- $result = (print $in | _rg ...$rest)
+ let piped = $in
+ if ($piped | describe) == 'string' {
+ $piped | _rg ...$rest
} else {
- $result = (_rg ...$rest)
- }
- $result | lines | parse "{File}:{Result}" | update Result { |row| ($row.Result | str replace --all $rest.0 $'(ansi gb)($rest.0)(ansi reset)') } | sort-by File
+ _rg ...$rest | lines | parse "{File}:{Result}" | update Result { |row| ($row.Result | str replace --all $rest.0 $'(ansi gb)($rest.0)(ansi reset)') } | sort-by File
+ }
}