diff --git a/dist/osc.complete b/dist/osc.complete index a1899c88..e3272efc 100755 --- a/dist/osc.complete +++ b/dist/osc.complete @@ -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