fnd is heavily inspired by fzf but it parses lines as json documents. This allows to search entries by field, output the value of a given field and many other field specific manipulations.
Quickly search through a list of entries parsed from stdin.
- Get a list of things.
- Search through them, filter them, pick one.
- Do something with it
See Full Example
-
Contains parsers to convert your input into documents.
line_format
.- JSON
curl https://api.exchangerate-api.com/v4/latest/EUR | \ jq -c '.rates | to_entries[] | {"Currency": .key, "Rate": .value }' | \ fnd --line_format json
- Tabular
ps aux | fnd --line_format tabular
- Plain
-
Customized command output:
- Choose wich column to output:
--output_column
# Kill the selected process kill -9 $(ps aux | fnd --line_format tabular --output_column 'PID') # fnd will output the PID column
- Choose output format with golang templates:
--output_template
echo $(ps aux | fnd --line_format tabular --output_template '{{.PID}}-{{.USER}}') # fnd will output PID-USER values
- Choose wich column to output:
-
Sort by column (column value is considered as a string):
ps aux | fnd --line_format tabular --output_column 'PID' --sorter bycolumn --sortby_column PID
Examples:
-
Open file with vi:
vi $(fnd-fdfind)
-
Pass tabular format (pass a table with a header and separated by spaces )
ps | fnd --line_format tabular
-
You can choose which column will be the output of the command. E.g this is how to kill the process that is chosen in fnd.
ps | kill -9 $(fnd --line_format tabular --output_column PID)
See other examples at commands/:
-
My command fails, how can I figure out what's happening ?
Error logs are by default logged to stderr. To get the detailed error message you can redirect stderr to a log file or pass --log_file. E.g:
$ fnd 2> out.log
- Get a list of running processes.
ps aux
- Pass them to fnd to allow searching through them.
ps aux | fnd
- Parse input to obtain processes' fields
ps aux | fnd --line_format tabular
- Do something with the output (E.g print the PID)
echo $(ps aux | fnd --line_format tabular --output_column)
The MIT License (MIT)
Copyright (c) 2019 Íñigo Mediavilla Saiz