mirror of
https://github.com/openSUSE/osc.git
synced 2025-08-23 14:48:53 +02:00
Fetch list of all projects lazily
Currently osc <TAB><TAB> takes a long time to complete, which is incredibly annoying. Only run "osc ls" if it is necessary for proper completion.
This commit is contained in:
11
dist/osc.complete
vendored
11
dist/osc.complete
vendored
@@ -132,7 +132,9 @@ if test -n "$alias" ; then
|
|||||||
command="$command -A $alias"
|
command="$command -A $alias"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if test -s "${projects}" ; then
|
update_projects_list ()
|
||||||
|
{
|
||||||
|
if test -s "${projects}" ; then
|
||||||
typeset -i ctime=$(command date -d "$(command stat -c '%z' ${projects})" +'%s')
|
typeset -i ctime=$(command date -d "$(command stat -c '%z' ${projects})" +'%s')
|
||||||
typeset -i now=$(command date -d now +'%s')
|
typeset -i now=$(command date -d now +'%s')
|
||||||
if ((now - ctime > 86400)) ; then
|
if ((now - ctime > 86400)) ; then
|
||||||
@@ -141,9 +143,10 @@ if test -s "${projects}" ; then
|
|||||||
mv -uf $tmp ${projects}
|
mv -uf $tmp ${projects}
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
command ${command} ls / >| "${projects}"
|
command ${command} ls / >| "${projects}"
|
||||||
fi
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
projects ()
|
projects ()
|
||||||
{
|
{
|
||||||
@@ -159,6 +162,7 @@ projects ()
|
|||||||
argv[argc++]=$arg
|
argv[argc++]=$arg
|
||||||
done
|
done
|
||||||
shift $argc
|
shift $argc
|
||||||
|
update_projects_list
|
||||||
cur="$1"
|
cur="$1"
|
||||||
if test -n "${cur}" ; then
|
if test -n "${cur}" ; then
|
||||||
list=($(command grep -E "^${cur}" ${projects}))
|
list=($(command grep -E "^${cur}" ${projects}))
|
||||||
@@ -273,6 +277,7 @@ targets ()
|
|||||||
|
|
||||||
users ()
|
users ()
|
||||||
{
|
{
|
||||||
|
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
|
||||||
|
Reference in New Issue
Block a user