Skip to content

Instantly share code, notes, and snippets.

@DerekV
Last active September 2, 2023 20:06

Revisions

  1. DerekV revised this gist Sep 2, 2023. 1 changed file with 4 additions and 3 deletions.
    7 changes: 4 additions & 3 deletions gitignores.bash
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    #!/bin/bash

    default_source=$HOME/.local/share/gitignores
    default_source=$HOME/.local/share

    IFS=$'\n'

    @@ -17,8 +17,8 @@ fi

    if [[ -z "$GITIGNORES" ]]
    then
    echo 'GITIGNORES not defined, defaulting to ' $default_source >&2
    source="$default_source"
    echo 'GITIGNORES not defined, defaulting to ' $default_source/gitignore >&2
    source="$default_source/gitignore"
    else
    source="$GITIGNORES"
    fi
    @@ -27,6 +27,7 @@ if [[ ! -e "$source" ]]
    then
    echo "$source not found... please set GITIGNORES to a directory containing gitignore files."
    echo "These files should end in .gitignore, and can be in subfolders."
    echo "Recommend you just do \"cd ${default_source}; git clone [email protected]:github/gitignore.git\""
    exit 1
    fi

  2. DerekV revised this gist Sep 2, 2023. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion gitignores.bash
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    #!/bin/bash

    default_source=$HOME/gitignores
    default_source=$HOME/.local/share/gitignores

    IFS=$'\n'

  3. DerekV revised this gist Oct 1, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion gitignores.bash
    Original file line number Diff line number Diff line change
    @@ -32,7 +32,7 @@ fi

    for arg in "$@"
    do
    for file in $( find "$source" -iname "$arg"*.gitignore )
    for file in $( find "$source" -iname "$arg".gitignore )
    do
    filedir=$(dirname "$file")
    repo_url=$(cd "$filedir"; git config --get remote.origin.url)
  4. DerekV revised this gist Sep 23, 2013. 1 changed file with 4 additions and 3 deletions.
    7 changes: 4 additions & 3 deletions gitignores.bash
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,5 @@
    #!/bin/bash

    repo_url="https://github.com/github/gitignore"
    default_source=$HOME/gitignores

    IFS=$'\n'
    @@ -35,10 +34,12 @@ for arg in "$@"
    do
    for file in $( find "$source" -iname "$arg"*.gitignore )
    do
    filedir=$(dirname "$file")
    repo_url=$(cd "$filedir"; git config --get remote.origin.url)
    echo
    echo "### $arg ( $repo_url ) "
    echo "### $arg $repo_url"
    echo
    cat "$file"
    echo
    done
    done
    done
  5. DerekV created this gist Sep 23, 2013.
    44 changes: 44 additions & 0 deletions gitignores.bash
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,44 @@
    #!/bin/bash

    repo_url="https://github.com/github/gitignore"
    default_source=$HOME/gitignores

    IFS=$'\n'

    if [[ $# == 0 ]]
    then
    echo "Usage Example : "
    echo " mkdir MyNewProject"
    echo " cd MyNewProject"
    echo " git init"
    echo " gitignore.sh Java Maven Intellij Eclipse Emacs vim OSX Linux Windows >> .gitignore"
    echo " git add .gitignore; git commit -m \"Import gitignores\""
    exit 1
    fi

    if [[ -z "$GITIGNORES" ]]
    then
    echo 'GITIGNORES not defined, defaulting to ' $default_source >&2
    source="$default_source"
    else
    source="$GITIGNORES"
    fi

    if [[ ! -e "$source" ]]
    then
    echo "$source not found... please set GITIGNORES to a directory containing gitignore files."
    echo "These files should end in .gitignore, and can be in subfolders."
    exit 1
    fi

    for arg in "$@"
    do
    for file in $( find "$source" -iname "$arg"*.gitignore )
    do
    echo
    echo "### $arg ( $repo_url ) "
    echo
    cat "$file"
    echo
    done
    done