From 29c921c62fea94c4204a75e12b3651c1446dd41c Mon Sep 17 00:00:00 2001 From: hasufell Date: Thu, 25 Jun 2015 21:07:09 +0200 Subject: [PATCH] saving uncommitted changes in /etc prior to emerge run --- bash_completion.d/gentoo-style-init | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 bash_completion.d/gentoo-style-init diff --git a/bash_completion.d/gentoo-style-init b/bash_completion.d/gentoo-style-init new file mode 100644 index 0000000..8545692 --- /dev/null +++ b/bash_completion.d/gentoo-style-init @@ -0,0 +1,27 @@ +# Gentoo init.d completion +# +# $Id$ +# +# Copyright 1999-2009 Gentoo Foundation +# Distributed under the terms of the GNU General Public License, v2 or later + +_gentoo_style_init() +{ + local script="${COMP_WORDS[0]}" + local cur="${COMP_WORDS[$COMP_CWORD]}" + + if [[ ( -f "${script}" || -h "${script}" ) && -r "${script}" ]] \ + && [[ "${script}" != *.sh ]] \ + && [[ "$(head -n 1 "${script}")" = "#!/sbin/runscript" ]] + then + [[ $COMP_CWORD -gt 1 ]] && return 1 + COMPREPLY=($(opts="start stop status restart pause zap ineed needsme iuse usesme broken"; \ + eval "$(grep '^opts=' "${script}")"; echo "${opts}")) + [[ -n "$COMPREPLY" ]] || COMPREPLY=(start stop restart zap) + COMPREPLY=($(compgen -W "${COMPREPLY[*]}" -- "${cur}")) + else + COMPREPLY=($(compgen -o default -- "${cur}")) + fi + return 0 +} +complete -F _gentoo_style_init /etc/init.d/*