mirror of
https://github.com/openSUSE/osc.git
synced 2025-01-24 22:06:14 +01:00
Use XDG locations in completion
This commit is contained in:
parent
c22aceb28d
commit
f4a4728068
@ -58,6 +58,22 @@ let count--
|
|||||||
test "${COMMAND_LINE:$last}" = " " && let count++
|
test "${COMMAND_LINE:$last}" = " " && let count++
|
||||||
unset last
|
unset last
|
||||||
|
|
||||||
|
XDG_CACHE_HOME="${XDG_CACHE_HOME:-$HOME/.cache}"
|
||||||
|
XDG_CONFIG_HOME="${XDG_CONFIG_HOME:-$HOME/.config}"
|
||||||
|
|
||||||
|
for xdg_dir in "${XDG_CACHE_HOME}" "${XDG_CONFIG_HOME}"; do
|
||||||
|
if [ ! -d "${xdg_dir}" ]; then
|
||||||
|
mkdir -p "${xdg_dir}"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
projects="${XDG_CACHE_HOME}/osc.projects"
|
||||||
|
if [ -f ~/.osc.projects ]; then
|
||||||
|
rm ~/.osc.projects -f
|
||||||
|
fi
|
||||||
|
oscrc="${XDG_CONFIG_HOME}/osc/oscrc"
|
||||||
|
|
||||||
|
command=osc
|
||||||
oscopts=(--version --help --debugger --post-mortem --traceback --http-full-debug
|
oscopts=(--version --help --debugger --post-mortem --traceback --http-full-debug
|
||||||
--debug --apiurl -A --config -c --no-keyring --no-gnome-keyring --verbose --quiet)
|
--debug --apiurl -A --config -c --no-keyring --no-gnome-keyring --verbose --quiet)
|
||||||
osccmds=(abortbuild add addremove aggregatepac api ar bco bl blt branch branchco
|
osccmds=(abortbuild add addremove aggregatepac api ar bco bl blt branch branchco
|
||||||
@ -96,25 +112,23 @@ if test -s "${PWD}/.osc/_files" ; then
|
|||||||
lnkprj=$(command sed -rn '/<linkinfo/{s@.*[[:blank:]]project="([^"]+)".*@\1@p;}' < "${PWD}/.osc/_files")
|
lnkprj=$(command sed -rn '/<linkinfo/{s@.*[[:blank:]]project="([^"]+)".*@\1@p;}' < "${PWD}/.osc/_files")
|
||||||
lnkpkg=$(command sed -rn '/<linkinfo/{s@.*[[:blank:]]package="([^"]+)".*@\1@p;}' < "${PWD}/.osc/_files")
|
lnkpkg=$(command sed -rn '/<linkinfo/{s@.*[[:blank:]]package="([^"]+)".*@\1@p;}' < "${PWD}/.osc/_files")
|
||||||
fi
|
fi
|
||||||
if test -s "${PWD}/.osc/_apiurl" -a -s ~/.oscrc ; then
|
if test -s "${PWD}/.osc/_apiurl" -a -s "${oscrc}" ; then
|
||||||
read apiurl < "${PWD}/.osc/_apiurl"
|
read apiurl < "${PWD}/.osc/_apiurl"
|
||||||
alias=$(sed -rn '\@^\['${apiurl}'@,\@=@{\@^aliases=@{s@[^=]+=([^,]+),.*@\1@p};}' < ~/.oscrc 2> /dev/null)
|
alias=$(sed -rn '\@^\['${apiurl}'@,\@=@{\@^aliases=@{s@[^=]+=([^,]+),.*@\1@p};}' < "${oscrc}" 2> /dev/null)
|
||||||
fi
|
fi
|
||||||
if test "${cmdline[0]}" = isc ; then
|
if test "${cmdline[0]}" = isc ; then
|
||||||
alias=internal
|
alias=internal
|
||||||
fi
|
fi
|
||||||
|
|
||||||
projects=~/.osc.projects
|
|
||||||
command=osc
|
|
||||||
|
|
||||||
case "${cmdline[1]}" in
|
case "${cmdline[1]}" in
|
||||||
-A|--apiurl)
|
-A|--apiurl)
|
||||||
if test -n "${cmdline[2]}" -a -s ~/.oscrc ; then
|
if test -n "${cmdline[2]}" -a -s "${oscrc}" ; then
|
||||||
hints=($(sed -rn '/^(aliases=|\[http)/{s/,/ /g;s/(aliases=|\[|\])//gp}' < ~/.oscrc 2> /dev/null))
|
hints=($(sed -rn '/^(aliases=|\[http)/{s/,/ /g;s/(aliases=|\[|\])//gp}' < "${oscrc}" 2> /dev/null))
|
||||||
for h in ${hints[@]} ; do
|
for h in ${hints[@]} ; do
|
||||||
case "$h" in
|
case "$h" in
|
||||||
http*)
|
http*)
|
||||||
tmp=$(sed -rn '\@^\['${h}'@,\@=@{\@^aliases=@{s@[^=]+=([^,]+),.*@\1@p};}' < ~/.oscrc 2> /dev/null)
|
tmp=$(sed -rn '\@^\['${h}'@,\@=@{\@^aliases=@{s@[^=]+=([^,]+),.*@\1@p};}' < "${oscrc}" 2> /dev/null)
|
||||||
if test "${cmdline[2]}" = "$h" ; then
|
if test "${cmdline[2]}" = "$h" ; then
|
||||||
alias=$tmp
|
alias=$tmp
|
||||||
break
|
break
|
||||||
@ -282,8 +296,8 @@ users ()
|
|||||||
update_projects_list
|
update_projects_list
|
||||||
if test -s ${projects} ; then
|
if test -s ${projects} ; then
|
||||||
command sed -rn "/^home:$1/{ s/^home:([^:]*):.*/\1/p}" ${projects}|command sort -u
|
command sed -rn "/^home:$1/{ s/^home:([^:]*):.*/\1/p}" ${projects}|command sort -u
|
||||||
elif test -s ~/.oscrc; then
|
elif test -s "${oscrc}"; then
|
||||||
command sed -rn '/^(user=)/{s/(user=)//p}' ~/.oscrc|command sort -u
|
command sed -rn '/^(user=)/{s/(user=)//p}' "${oscrc}" | command sort -u
|
||||||
else
|
else
|
||||||
command id -un
|
command id -un
|
||||||
fi
|
fi
|
||||||
@ -342,8 +356,8 @@ while test "${cmdline[1+remove]::1}" = "-" ; do
|
|||||||
builtin compgen -W "${oscopts[*]}" -- "${cmdline[1+remove]}"
|
builtin compgen -W "${oscopts[*]}" -- "${cmdline[1+remove]}"
|
||||||
exit
|
exit
|
||||||
elif ((count-remove == 2)); then
|
elif ((count-remove == 2)); then
|
||||||
if test -s ~/.oscrc ; then
|
if test -s "${oscrc}" ; then
|
||||||
hints=($(sed -rn '/^(aliases=|\[http)/{s/,/ /g;s/(aliases=|\[|\])//gp}' ~/.oscrc|sort -u))
|
hints=($(sed -rn '/^(aliases=|\[http)/{s/,/ /g;s/(aliases=|\[|\])//gp}' "${oscrc}" | sort -u))
|
||||||
builtin compgen -W "${hints[*]}" -- "${cmdline[2+remove]}"
|
builtin compgen -W "${hints[*]}" -- "${cmdline[2+remove]}"
|
||||||
else
|
else
|
||||||
builtin compgen -P https:// -A hostname
|
builtin compgen -P https:// -A hostname
|
||||||
|
Loading…
Reference in New Issue
Block a user