On Sun, 30 Sep 2012, Michael Olbrich wrote:

On Fri, Sep 28, 2012 at 05:07:53PM +0200, Benoît Burnichon wrote:
 _ptxdist_completion()
 {
-       local cur cmds opts
+       local cur cmds opts _ptxdist_cmd
+
+       if [ -h './p' ]; then
+               _ptxdist_cmd=$(readlink ./p)
+       else
+               _ptxdist_cmd=ptxdist
+       fi

        if [ "${COMP_WORDS[0]}" = "ptxdist ]; then
                _ptxdist_cmd=ptxdist
        else
                _ptxdist_cmd="$(readlink "${COMP_WORDS[0]}")"
        fi

I think. This way we're not limited to ./p
Or maybe just '_ptxdist_cmd="${COMP_WORDS[0]}"'. I'm not sure if there is
actually a case when the readlink is needed.


Fine with removing limitation to only ./p

Kept the readlink command as there is a case where it does not work.

Suppose you are only type p in your project directory then press <Tab>, there will be an issue because the called ptxdist will be p in the current directory and bash will not find the ptxdist script as it is not in the current directory

 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


You're probably right, this is not good idea. Let the users configures their own bash_completion to whatever name they choose.

Benoît
-- 
ptxdist mailing list
[email protected]

Reply via email to