Skip to content

Instantly share code, notes, and snippets.

@SirJson
Created February 5, 2020 23:56
Show Gist options
  • Save SirJson/fddb9c5c35a6f2227deaed60ae0c1809 to your computer and use it in GitHub Desktop.
Save SirJson/fddb9c5c35a6f2227deaed60ae0c1809 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Create useful gitignore files. Based on gi from fzf examples
# Usage: ignoreman [param]
# param is a comma separated list of ignore profiles.
# If param is ommited choose interactively.
# This version will modify or create a .gitignore file and provide a preview in interactive mode
# I also switched from sh to bash because I couldn't execute this script with sh.
function __gi() {
curl -L -s https://www.gitignore.io/api/"$@"
}
function __writeresult() {
__gi $1 >> .gitignore
}
if [ "$#" -eq 0 ]; then
IFS+=","
for item in $(__gi list); do
echo $item
done | fzf --multi --ansi --exact --header='Select the templates you want to add to your .gitignore file' --preview="curl -L -s https://www.gitignore.io/api/{}" | paste -s -d "," - |
{ read result && __writeresult "$result"; }
else
__gi "$@"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment