mirror of
https://github.com/tj/git-extras.git
synced 2026-09-10 15:36:21 -04:00
Merge pull request #888 from equt/master
Add support for XDG specifications
This commit is contained in:
commit
05ce91fb9e
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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] <word> 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"
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue