Created
December 28, 2024 11:48
-
-
Save beeksiwaais/0aea748437c829cacec646a11aaff63e to your computer and use it in GitHub Desktop.
Lib Helper
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
| #!/usr/bin/env fish | |
| function compiler_helper | |
| set results (pkg-config --list-all | fzf -m | awk '{print $1}' | xargs -I{} pkg-config --cflags --libs {} | tr '\n' ' ' | sed 's/ $/\n/') | |
| echo $results | |
| end | |
| # Header function open | |
| function explore_library_headers | |
| set libraries (pkg-config --list-all | fzf -m | awk '{print $1}') | |
| set include_dirs (pkg-config --cflags $libraries | sed 's/-I//g') | |
| set header_file (for dir in $include_dirs | |
| find $dir -type f -name "*.h" | |
| end | fzf) | |
| set function_lines (grep -nE '^[a-zA-Z_][a-zA-Z0-9_]*\(.*\)' $header_file) | |
| if test -z "$function_lines" | |
| vim $header_file | |
| return | |
| end | |
| set selected_function (echo $function_lines | sed 's|/\*[^*]*\*/||g' | sed 's|//.*||g' | tr ';' '\n' | fzf) | |
| set line_number (echo $selected_function | awk -F: '{print $1}') | |
| if test -n "$line_number" | |
| vim +$line_number $header_file | |
| else | |
| echo "No function selected." | |
| end | |
| end | |
| # Call the function | |
| explore_library_headers |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment