Last active
September 21, 2023 23:51
-
-
Save LinuxIsCool/8180e62d97a9fefbc0a4179b41ba2af1 to your computer and use it in GitHub Desktop.
Interactively search your systems python files with ripgrep, fzf, and fish shell. Open the result with nvim.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # This is a handy utility function to search your entire systems python files for search terms. Requires fzf ripgreg and fish shell | |
| function search-python-code | |
| set term $argv[1] | |
| set selected_line (rg --glob '*.py' --glob '*.ipynb' $term ~/ -n | fzf --preview 'echo {}' --preview-window=up:3:wrap) | |
| if test -n "$selected_line" | |
| set file (echo $selected_line | cut -d: -f1) | |
| set line (echo $selected_line | cut -d: -f2) | |
| nvim $file +$line | |
| end | |
| end |
Author
Author
Usage:
$ search-python-code delete_itemWill allow you to navigate files containing the term 'delete_item'.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Resources: