UInIQ
3/10/2018 - 10:05 PM

Add indeterminate number of files to .gitignore at specific hierarchy, then condense and purge duplicates.

Add indeterminate number of files to .gitignore at specific hierarchy, then condense and purge duplicates.

#!/bin/bash
# Usage:
# gig path_to_file path_to_other_file

function gig(){
  # Iterate the function arguments
  for item in "$@"; do
      # Append each to .gitignore at current folder level
      echo "$item" >> .gitignore;
  done

  # Purge duplicates while sorting contents, ultimately overwriting original with revision.
  sort -u .gitignore -o .gitignore
}