Skip to content

Instantly share code, notes, and snippets.

@Michaelliv
Created May 2, 2024 09:30
Show Gist options
  • Select an option

  • Save Michaelliv/3db2b86aebf37bd43666bd6e95f75669 to your computer and use it in GitHub Desktop.

Select an option

Save Michaelliv/3db2b86aebf37bd43666bd6e95f75669 to your computer and use it in GitHub Desktop.
Useful commands for investigating code bases with LLMs

Copy Code to Clipboard

This command searches for specific file types in the current directory and its subdirectories, extracts the code content (excluding comment lines), and copies the result to the clipboard.

Command Template

find . -type f \( -name "*.<file_extension_1>" -o -name "*.<file_extension_2>" \) -print0 | xargs -0 -I {} sh -c 'echo {}; grep -v "^//" {}' | pbcopy

Example (JavaScript)

$ find . -type f \( -name "*.js" -o -name "*.jsx" \) -print0 | xargs -0 -I {} sh -c 'echo {}; grep -v "^//" {}' | pbcopy

This example searches for all .js and .jsx files in the current directory and its subdirectories, prints the file paths, extracts the code content (excluding comment lines starting with //), and copies the result to the clipboard, ready to be pasted into another application.

Copy Git Diff to Clipboard

This command compares the current branch with the 'develop' branch, showing the differences between them, and copies the output to the clipboard.

Command Template

git diff <branch_name> | pbcopy

Example

$ git diff develop | pbcopy

This example compares the current branch with the 'develop' branch, and copies the differences (added, modified, or deleted lines) to the clipboard, ready to be pasted into another application.

Copy Directory Structure to Clipboard

This command prints the directory structure of the current directory and its subdirectories in a tree-like format and copies the output to the clipboard.

Command Template

tree | pbcopy

This example prints the directory structure of the current directory and its subdirectories in a tree-like format and copies the output to the clipboard, ready to be pasted into another application.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment