fd
fd copied to clipboard
Suggestion: optional index numbering for search results?
This may be out of scope of fd
, but I think it'd be cool to have an indexed results list. I'm imagining a workflow like this, with -I
for -Index
:
> fd -I main.rs ~/Code/GitHub
[0] /Users/peterkos/Code/GitHub/dura/src/main.rs
[1] /Users/peterkos/Code/GitHub/rolex/src/main.rs
[2] /Users/peterkos/Code/GitHub/rusty-chess-engine/src/main.rs
[3] /Users/peterkos/Code/GitHub/SwiftToPlantUMLConverter/main.rs
[4] /Users/peterkos/Code/GitHub/calcdnd/src/main.rs
[5] /Users/peterkos/Code/GitHub/ta-mixer-bots/team-reset-bot/src/main.rs
[6] /Users/peterkos/Code/GitHub/clef/src/main.rs
[7] /Users/peterkos/Code/GitHub/alda-rust-lib/src/main.rs
[8] /Users/peterkos/Code/GitHub/rusty-chess/src/main.rs
[9] /Users/peterkos/Code/GitHub/depshow/src/main.rs
[10] /Users/peterkos/Code/GitHub/zola/src/main.rs
> fd cd 10
> pwd
/Users/peterkos/Code/GitHub/zola/src/main.rs
This way you can easily jump to a result w/o having to select a specific directory or file.
Would piping the fd output to nl
work?
fd -I main.rs ~/Code/GitHub | nl
or
fd -l main.r ~/Code/GitHub | nl | awk '{ $1 = "[" $1 "]"; print}'
if you want the square brackets.
Yes for numbering, but then to use that as a shortcut for a cd
afterwards; something like "Jump to result 5" and it auto-copies the path in, if that makes sense
Ah I see. You can do something like:
fd -l main.r ~/Code/GitHub | nl | awk '{$1 = "[" $1 "]"; print}' | fzf | sed -E 's/^\[[0-9]+\] //'
I also recommend looking into fzf.