Skip to content

Instantly share code, notes, and snippets.

@sneeu
Forked from judy2k/gitignore
Last active August 29, 2015 13:58
Show Gist options
  • Save sneeu/9931143 to your computer and use it in GitHub Desktop.
Save sneeu/9931143 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
# To add two items to the current .gitignore file:
# requirement Django South
#
# To sort and de-dupe the current .gitignore file:
# requirement
args=( $@ )
args_len=${#args[@]}
requirements_file=${args[args_$len-1]}
requirements=${args[@]:0:args_$len-1}
# Append each argument to its own line:
for item in "$requirements"; do
pip freeze | grep "$item" >> $requirements_file;
done
# Remove duplicates (and sort):
sort -u $requirements_file -o $requirements_file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment