diff --git a/bin/git-ignore b/bin/git-ignore index 723550c..217adda 100755 --- a/bin/git-ignore +++ b/bin/git-ignore @@ -11,19 +11,23 @@ function show_contents { fi } +function global_ignore() { + git config --global core.excludesfile || echo "$XDG_CONFIG_HOME/git/ignore" || echo "$HOME/.config/git/ignore" +} + function show_global { - show_contents Global `git config --global core.excludesfile` + show_contents Global "$(global_ignore)" } function add_global { - local global_gitignore=$(git config --global core.excludesfile) + local global_gitignore="$(global_ignore)" if [ -z "$global_gitignore" ]; then echo "Can't find global .gitignore." echo "" echo "Use 'git config --global --add core.excludesfile ~/.gitignore-global' to set the path to your global gitignore file to '~/.gitignore-global'." echo "" else - add_patterns `git config --global core.excludesfile` "$@" + add_patterns "$global_gitignore" "$@" fi } diff --git a/bin/git-ignore-io b/bin/git-ignore-io index cf594f0..048ed58 100755 --- a/bin/git-ignore-io +++ b/bin/git-ignore-io @@ -2,9 +2,13 @@ gitignore_io_url="https://www.gitignore.io/api/" default_path="$HOME/.gi_list" +if [[ -n "$XDG_CACHE_HOME" ]]; then + default_path="$XDG_CACHE_HOME/git-extras/gi_list" + mkdir -p "$XDG_CACHE_HOME/git-extras" +fi update_gi_list() { - curl -L -s "${gitignore_io_url}/list" > ~/.gi_list + curl -L -s "${gitignore_io_url}/list" > "$default_path" } print_in_alphabetical_order() { @@ -73,8 +77,8 @@ show_usage() { echo " [-l|--list-in-table] Print available types in table format" echo " [-L|--list-alphabetically] Print available types in alphabetical order " echo " [-s|--search] Search word in available types" - echo " [-t|--show-update-time] Show the last modified time of ~/.gi_list (where the list of available types is stored)" - echo " [-u|--update-list] Update ~/.gi_list" + echo " [-t|--show-update-time] Show the last modified time of $default_path (where the list of available types is stored)" + echo " [-u|--update-list] Update $default_path" }