From 9182dcf5ca8996c001d255432b2606f2e3f69c7f Mon Sep 17 00:00:00 2001 From: Jephte Clain Date: Mon, 23 Mar 2015 05:08:27 +0400 Subject: [PATCH] maj api chargement depuis ~/etc/completion.d --- lib/bashrc.d/bash_completion | 6 +++++- lib/completion.d/nutools | 5 ++--- lib/uinst/conf | 3 ++- lib/ulib/bash40/bash_completion | 6 +++--- lib/ulib/bash41/bash_completion | 10 +++++----- 5 files changed, 17 insertions(+), 13 deletions(-) diff --git a/lib/bashrc.d/bash_completion b/lib/bashrc.d/bash_completion index aed8e57..557bb2e 100644 --- a/lib/bashrc.d/bash_completion +++ b/lib/bashrc.d/bash_completion @@ -17,7 +17,11 @@ if [ -n "$UTOOLS_BASH_COMPLETION" ]; then esac fi if [ -n "$BASH_COMPLETION" ]; then - for i in "@@dest@@/lib/bash_completion.d/"*; do + for i in "@@dest@@/lib/completion.d/"*; do + [ -f "$i" ] || continue + source "$i" + done + for i in "$HOME/etc/completion.d/"*; do [ -f "$i" ] || continue source "$i" done diff --git a/lib/completion.d/nutools b/lib/completion.d/nutools index 1df64fb..a96851e 100644 --- a/lib/completion.d/nutools +++ b/lib/completion.d/nutools @@ -7,10 +7,9 @@ function __nutools_host_completion() { _known_hosts_real "$cur" fi } +complete -F __nutools_host_completion -o default ruinst runs rruns -if [ -n "$BASH_COMPLETION_DIR" -a -f "$BASH_COMPLETION_DIR/ssh" ]; then +if __bash_completion_module_enabled ssh; then shopt -u hostcomplete complete -F _ssh ussh cssh fi - -complete -F __nutools_host_completion -o default ruinst runs rruns diff --git a/lib/uinst/conf b/lib/uinst/conf index 514714d..af018ce 100644 --- a/lib/uinst/conf +++ b/lib/uinst/conf @@ -33,7 +33,8 @@ done ./ulink --nutools-makelinks # complétion programmable -bcdir=lib/bash_completion.d +mkdir -p ~/etc/completion.d +bcdir=lib/completion.d ./pdev --nutools-completion >"$bcdir/pdev" ./todo/prel --nutools-completion >"$bcdir/prel" #./pfix --nutools-completion >"$bcdir/pfix" diff --git a/lib/ulib/bash40/bash_completion b/lib/ulib/bash40/bash_completion index 26f73c6..a3607e0 100644 --- a/lib/ulib/bash40/bash_completion +++ b/lib/ulib/bash40/bash_completion @@ -7,14 +7,14 @@ ##@require base uprovide bash_completion -function __is_bash_completion_enabled() { +function __bash_completion_enabled() { [ -n "$BASH_COMPLETION" ] } -function __is_bash_completion_module_enabled() { +function __bash_completion_module_enabled() { [ -n "$BASH_COMPLETION_DIR" -a -f "$BASH_COMPLETION_DIR/$1" ] } -if ! __is_bash_completion_enabled; then +if ! __bash_completion_enabled; then BASH_COMPLETION=1 shopt -s extglob progcomp diff --git a/lib/ulib/bash41/bash_completion b/lib/ulib/bash41/bash_completion index ab79ef5..050bfe0 100644 --- a/lib/ulib/bash41/bash_completion +++ b/lib/ulib/bash41/bash_completion @@ -7,19 +7,19 @@ ##@require base uprovide bash_completion -function __is_bash_completion_enabled() { +function __bash_completion_enabled() { [ -n "$__NUTOOLS_BASH_COMPLETION" ] && return 0 grep -qE '^[ \t]*(\.|source)[ \t]*/usr/share/bash-completion/bash_completion' /etc/bash.bashrc && return 0 grep -qE '^[ \t]*(\.|source)[ \t]*/usr/share/bash-completion/bash_completion' ~/.bashrc && return 0 return 1 } -function __is_bash_completion_module_enabled() { +function __bash_completion_module_enabled() { [ -f "/usr/share/bash-completion/completions/$1" ] && return 0 [ -n "$BASH_COMPLETION_COMPAT_DIR" -a -f "$BASH_COMPLETION_COMPAT_DIR/$1" ] && return 0 return 1 } -if ! __is_bash_completion_enabled; then - export __NUTOOLS_BASH_COMPLETION=1 +if ! __bash_completion_enabled; then + __NUTOOLS_BASH_COMPLETION=1 fi -[ -n "$BASH_COMPLETION" ] || export BASH_COMPLETION=1 +[ -n "$BASH_COMPLETION" ] || BASH_COMPLETION=1