Skip to content

python scripting #21

@jake-stewart

Description

@jake-stewart

the script should be the final argument to jfind

for e.g:

ps aux | tail +2 | jfind 'interval(1, refresh)'

this would allow for easier customisation. for example there could be a lua function which highlights a line in the preview. this would make live grep work without the nasty --preview-line flag.

jfind '
    command("rg -n")

    map(ctrl_r, refresh)

    onItemChange(function(item)
        file, line = item:match("(.*):(.*):")
        preview("cat", file)
        highlightPreviewLine(line)
    end)'

and then while doing live grep you could enter fuzzy matching mode with the grepped results

jfind '
    local cmd = "rg -n"
    command(cmd)

    map(ctrl_r, refresh)

    onItemChange(function(item)
        file, line = item:match("(.*):(.*):")
        preview("cat", file)
        highlightPreviewLine(line)
    end)

    local fuzzyMode = false
    map(ctrl_f, function()
        if fuzzyMode then
            useMatcher(FUZZY)
        else
            command(cmd)
        end
        fuzzyMode = ~fuzzyMode
    end)'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions