1
0
mirror of https://github.com/openSUSE/osc.git synced 2024-09-19 16:56:17 +02:00

Merge pull request #767 from Vogtinator/completion

Completion usability improvements
This commit is contained in:
Marco Strigl 2020-03-23 13:36:31 +01:00 committed by GitHub
commit 81d221242b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

30
dist/osc.complete vendored
View File

@ -26,6 +26,9 @@ typeset -i remove
typeset -i colon
typeset -r OIFS="$IFS"
# Do not pollute the terminal session with warnings or errors
exec 2>/dev/null
if test "/proc/$PPID/exe" -ef /bin/tcsh ; then
export COMP_TYPE=63
export COMP_KEY=9
@ -132,18 +135,21 @@ if test -n "$alias" ; then
command="$command -A $alias"
fi
if test -s "${projects}" ; then
typeset -i ctime=$(command date -d "$(command stat -c '%z' ${projects})" +'%s')
typeset -i now=$(command date -d now +'%s')
if ((now - ctime > 86400)) ; then
if tmp=$(mktemp ${projects}.XXXXXX) ; then
command ${command} ls / >| $tmp
mv -uf $tmp ${projects}
fi
update_projects_list ()
{
if test -s "${projects}" ; then
typeset -i ctime=$(command date -d "$(command stat -c '%z' ${projects})" +'%s')
typeset -i now=$(command date -d now +'%s')
if ((now - ctime > 86400)) ; then
if tmp=$(mktemp ${projects}.XXXXXX) ; then
command ${command} ls / >| $tmp
mv -uf $tmp ${projects}
fi
fi
else
command ${command} ls / >| "${projects}"
fi
else
command ${command} ls / >| "${projects}"
fi
}
projects ()
{
@ -159,6 +165,7 @@ projects ()
argv[argc++]=$arg
done
shift $argc
update_projects_list
cur="$1"
if ((colon)) ; then
local colon_word
@ -272,6 +279,7 @@ targets ()
users ()
{
update_projects_list
if test -s ${projects} ; then
command sed -rn "/^home:$1/{ s/^home:([^:]*):.*/\1/p}" ${projects}|command sort -u
elif test -s ~/.oscrc; then