From mboxrd@z Thu Jan 1 00:00:00 1970 Return-path: Received: from ptx.hi.pengutronix.de ([2001:6f8:1178:2:5054:ff:fec0:8e10] ident=Debian-exim) by metis.ext.pengutronix.de with esmtp (Exim 4.72) (envelope-from ) id 1TIJ9p-0006RP-KA for ptxdist@pengutronix.de; Sun, 30 Sep 2012 15:02:05 +0200 Received: from mol by ptx.hi.pengutronix.de with local (Exim 4.72) (envelope-from ) id 1TIJ9p-00059F-KC for ptxdist@pengutronix.de; Sun, 30 Sep 2012 15:02:05 +0200 Date: Sun, 30 Sep 2012 15:02:05 +0200 From: Michael Olbrich Message-ID: <20120930130205.GC19651@pengutronix.de> References: <1348844873-23722-1-git-send-email-benoit.burnichon@airtag.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1348844873-23722-1-git-send-email-benoit.burnichon@airtag.com> Subject: Re: [ptxdist] [PATCH] Allow p link to be completed Reply-To: ptxdist@pengutronix.de List-Id: PTXdist Development Mailing List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Sender: ptxdist-bounces@pengutronix.de Errors-To: ptxdist-bounces@pengutronix.de To: ptxdist@pengutronix.de On Fri, Sep 28, 2012 at 05:07:53PM +0200, Beno=EEt Burnichon wrote: > using this bash_completion allows using p to complete commands > even if ptxdist is installed on the system > = > Signed-off-by: Beno=EEt Burnichon > --- > scripts/bash_completion | 15 +++++++++++---- > 1 files changed, 11 insertions(+), 4 deletions(-) > = > diff --git a/scripts/bash_completion b/scripts/bash_completion > index 3d4bc38..57d80a7 100644 > --- a/scripts/bash_completion > +++ b/scripts/bash_completion > @@ -8,7 +8,13 @@ if have ptxdist; then > = > _ptxdist_completion() > { > - local cur cmds opts > + local cur cmds opts _ptxdist_cmd > + > + if [ -h './p' ]; then > + _ptxdist_cmd=3D$(readlink ./p) > + else > + _ptxdist_cmd=3Dptxdist > + fi if [ "${COMP_WORDS[0]}" =3D "ptxdist ]; then _ptxdist_cmd=3Dptxdist else _ptxdist_cmd=3D"$(readlink "${COMP_WORDS[0]}")" fi I think. This way we're not limited to ./p Or maybe just '_ptxdist_cmd=3D"${COMP_WORDS[0]}"'. I'm not sure if there is actually a case when the readlink is needed. > = > COMPREPLY=3D() > cur=3D( $(_get_cword) ) > @@ -41,13 +47,13 @@ _ptxdist_completion() > [ $COMP_CWORD -lt 3 ] && _filedir > ;; > get|extract|prepare|compile|install|targetinstall|tags) > - COMPREPLY=3D( $( compgen -W "${opts} $( ptxdist print PTX_PACKAGES_SEL= ECTED )" -- $cur ) ) > + COMPREPLY=3D( $( compgen -W "${opts} $( $_ptxdist_cmd print PTX_PACKAG= ES_SELECTED )" -- $cur ) ) > ;; > clean) > - COMPREPLY=3D( $( compgen -W "${opts} $( ptxdist print PTX_PACKAGES_SEL= ECTED ) root" -- $cur ) ) > + COMPREPLY=3D( $( compgen -W "${opts} $( $_ptxdist_cmd print PTX_PACKAG= ES_SELECTED ) root" -- $cur ) ) > ;; > drop) > - COMPREPLY=3D( $( compgen -W "${opts} $( pushd $(ptxdist print PTXDIST_= PLATFORMDIR)/state >/dev/null; ls +(*.get|*.extract|*.prepare|*.compile|*.i= nstall|*.targetinstall); popd >/dev/null )" -- $cur ) ) > + COMPREPLY=3D( $( compgen -W "${opts} $( pushd $($_ptxdist_cmd print PT= XDIST_PLATFORMDIR)/state >/dev/null; ls +(*.get|*.extract|*.prepare|*.compi= le|*.install|*.targetinstall); popd >/dev/null )" -- $cur ) ) > ;; > newpackage) > COMPREPLY=3D( $( compgen -W "${opts} target host cross klibc src-autoc= onf-lib src-autoconf-prog src-autoconf-proglib src-cmake-prog src-qmake-pro= g src-make-prog src-linux-driver src-stellaris font simple kernel image-tgz= image-genimage" -- $cur) ) > @@ -57,6 +63,7 @@ _ptxdist_completion() > } > = > complete -F _ptxdist_completion ptxdist > +complete -F _ptxdist_completion p I'm not sure if this last change is a good idea by default. 'p' is rather ambiguous. But if we merge the rest, then it's easy to add just this line to ~/.bash_completion michael > = > fi > = > -- = > 1.7.2.5 > = > = > -- = > ptxdist mailing list > ptxdist@pengutronix.de -- = ptxdist mailing list ptxdist@pengutronix.de