Personal Nix flake
nixos home-manager nix
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

feat: Nushell-friendly fzf wrapper

Nushell has a built-in picker, but it's quite barebones, so I made this
to make use of fzf's niceties

Supports plain lists and tables, optionally takes a cell path to show a
desired column from a table

+22 -8
+22 -8
nix/home/modules/cli/nushell/commands.nu
··· 14 14 __get_completions git branch 15 15 } 16 16 17 - # More nu-friendly fzf wrapper 17 + # Nushell-friendly fzf wrapper 18 + # 19 + # Supports plain lists and tables with optional cell path 18 20 def --wrapped fzf [ 19 - path: cell-path, 21 + --path: cell-path, # The cell path to use for the description 20 22 ...rest: string@__fzf_completions, 21 23 ]: list -> list { 22 - let picked = $in 23 - | get $path 24 - | to text 25 - | ^fzf ...$rest 24 + let input = $in; 25 + let hasPath = $path != null 26 + let isRecord = ($input | first | describe --detailed | get type) == "record" 27 + $input 28 + | if ($isRecord and not $hasPath) { 29 + enumerate 30 + | each { |it| {...$it.item, index: $it.index} } 31 + | to tsv 32 + | ^fzf --with-nth 1..-2 --delimiter "\t" --header-lines 1 ...$rest 33 + } else { 34 + each { if ($path != null) { get $path } else { $in } | to nuon } 35 + | enumerate 36 + | each { $"($in.item)\t($in.index)" } 37 + | to text 38 + | ^fzf --with-nth 1..-2 --delimiter "\t" ...$rest 39 + } 26 40 | lines 27 - $in 28 - | where { |$it| ($it | get $path) in $picked } 41 + | each { split row "\t" | last | into int } 42 + | each { |index| $input | get $index } 29 43 } 30 44 31 45 def __fzf_completions [] {