Created
December 22, 2025 09:55
-
-
Save neverstew/da63c158381471bc6aa196ffb1bd6faf to your computer and use it in GitHub Desktop.
A fish script to download gitignore files from the GitHub template repo at https://github.com/github/gitignore
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 | |
| set -l repo_raw "https://raw.githubusercontent.com/github/gitignore/main" | |
| set -l repo_api "https://api.github.com/repos/github/gitignore/contents" | |
| # Fetch list of gitignore files (recursively flattened) | |
| set -l files ( | |
| curl -s $repo_api | \ | |
| jq -r ' | |
| .[] | | |
| if .type == "file" and (.name | endswith(".gitignore")) | |
| then .path | |
| else empty | |
| end | |
| ' | |
| ) | |
| # Abort if nothing found | |
| test (count $files) -eq 0; and exit 1 | |
| # Select via fzf | |
| set -l selected ( | |
| printf "%s\n" $files | fzf --prompt="gitignore> " | |
| ) | |
| test -z "$selected"; and exit 0 | |
| # Download to current directory | |
| set -l filename (basename $selected) | |
| curl -sSL "$repo_raw/$selected" -o "./.gitignore" | |
| echo "Downloaded $filename" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment