Skip to content

Instantly share code, notes, and snippets.

@beeksiwaais
Created December 28, 2024 11:48
Show Gist options
  • Select an option

  • Save beeksiwaais/0aea748437c829cacec646a11aaff63e to your computer and use it in GitHub Desktop.

Select an option

Save beeksiwaais/0aea748437c829cacec646a11aaff63e to your computer and use it in GitHub Desktop.
Lib Helper
#!/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