feat: bash completion cache
This commit is contained in:
parent
d6aece2460
commit
421674018f
@ -5,10 +5,10 @@ export XDG_STATE_HOME="$HOME/.local/state"
|
||||
export XDG_CONFIG_DIRS=/etc/xdg
|
||||
export XDG_DATA_DIRS="$XDG_DATA_HOME/flatpak/exports/share:/var/lib/flatpak/exports/share:/usr/local/share:/usr/share"
|
||||
|
||||
HISTFILE="$XDG_STATE_HOME/bash_history"
|
||||
HISTCONTROL=ignoreboth
|
||||
HISTSIZE=65536
|
||||
SAVEHIST=8192
|
||||
export HISTFILE="$XDG_STATE_HOME/bash_history"
|
||||
export HISTCONTROL=ignoreboth
|
||||
export HISTSIZE=65536
|
||||
export SAVEHIST=8192
|
||||
|
||||
export LESSHISTFILE='-'
|
||||
|
||||
|
@ -1,5 +1,3 @@
|
||||
function gi() {
|
||||
local IFS=,
|
||||
|
||||
curl -fL "https://www.toptal.com/developers/gitignore/api/$*"
|
||||
curl -fL "https://www.toptal.com/developers/gitignore/api/$(printf '%s\n' "$@" | sort -u | paste -sd,)"
|
||||
}
|
||||
|
@ -1,6 +1,10 @@
|
||||
function _ddev() {
|
||||
mapfile -t COMPREPLY < <(compgen -W \
|
||||
"$(curl -sfL 'https://api.github.com/repos/docker-library/official-images/git/trees/master?recursive=1' | sed -nE 's/.*"library\/(.+)",$/\1/p')" \
|
||||
-- "${COMP_WORDS[1]}")
|
||||
cache="/tmp/${FUNCNAME[0]}"
|
||||
|
||||
if ! [ -f "$cache" ]; then
|
||||
curl -sfL 'https://api.github.com/repos/docker-library/official-images/git/trees/master?recursive=1' | sed -nE 's/.*"library\/(.+)",$/\1/p' > "$cache"
|
||||
fi
|
||||
[ "$COMP_CWORD" -ne 1 ] && return
|
||||
mapfile -t COMPREPLY < <(compgen -W "$(cat "$cache")" -- "${COMP_WORDS[1]}")
|
||||
}
|
||||
complete -F _ddev ddev
|
||||
|
@ -1,6 +1,9 @@
|
||||
function _gi() {
|
||||
mapfile -t COMPREPLY < <(compgen -W \
|
||||
"$(curl -sfL https://www.toptal.com/developers/gitignore/api/list | tr ',' '\n')" \
|
||||
-- "${COMP_WORDS[1]}")
|
||||
cache="/tmp/${FUNCNAME[0]}"
|
||||
|
||||
if ! [ -f "$cache" ]; then
|
||||
curl -sfL https://www.toptal.com/developers/gitignore/api/list | tr ',' '\n' > "$cache"
|
||||
fi
|
||||
mapfile -t COMPREPLY < <(compgen -W "$(cat "$cache")" -- "${COMP_WORDS[$COMP_CWORD]}")
|
||||
}
|
||||
complete -F _gi gi
|
||||
|
Loading…
Reference in New Issue
Block a user