Results 1 to 6 of 6

Thread: Set autocompleter for make alias

  1. #1

    Default Set autocompleter for make alias

    Hi,

    Back when I was under 12.1 (we recently migrated to Leap 15 at work), there were a convenient way to have autocompletion to a make alias:
    Code:
    # Make the alias:
    alias mj='make -j32 -k'
    # Make alias autocompletion
    complete -F _make mj
    But this does not work with Leap 15, indeed, with same code when typing mj<space> then tab in a console I have the following result:
    Code:
    mj bash: completion: function `_make' not found
    After some digging I've seen it seems there are some predefined auto completers that matches for make, gmake and others in 12.1:
    Code:
    $ complete -pr | grep make
    complete -F _make gnumake
    complete -F _filedir_xspec makeinfo
    complete -F _automake automake-1.11
    complete -F _make make
    complete -F _make gmake
    complete -F _automake automake
    complete -F _make pmake
    But they are not present in Leap 15:
    Code:
    $ complete -pr | grep make
    complete -F _filedir_xspec makeinfo
    Is there a way to have them installed ? And when I try to find from which package comes complete I can't figure it out:
    Code:
    $ which complete
    which: no complete in (/home/octopus/bin:/usr/local/bin:/usr/bin:/bin:/usr/lib/mit/sbin)
    I've also seen there is bash-completion package installed on both (1.3-3.1.1 on 12.1 and 2.7-lp151.4.1 on Leap 15), I assume this is from were it comes, and on Leap 15 there is an "extra" bash-completion-devel package I installed but it did not change anything.

    Anybody knows if it is possible to have autocompletion for make alias on Leap 15 ?

    Thanks

  2. #2

    Default Re: Set autocompleter for make alias

    Hi,

    complete is a shell builtin

    Code:
    type -a complete
    you could try finding which is the function value/definition of _make

    Code:
    type -a _make
    You can check the package e.g.
    Code:
    rpm -ql bash-completion
    "Unfortunately time is always against us" -- [Morpheus]

    .:https://github.com/Jetchisel:.

  3. #3

    Default Re: Set autocompleter for make alias

    Thanks for your answer, checking package with
    Code:
    rpm -ql bash-completion
    shows there are completion for some commands that are set in files, for make, in
    /usr/share/bash-completion/completions/make
    but I don't know why it does not work for me since it also uses
    Code:
    complete -F _make ...
    Anyway, I'll look into it, thanks again.

  4. #4

    Default Re: Set autocompleter for make alias

    Hi,

    You can check the change log about the relevant changes/date and who did it.

    Code:
    rpm -q --changelog bash-completion | less
    "Unfortunately time is always against us" -- [Morpheus]

    .:https://github.com/Jetchisel:.

  5. #5

    Default Re: Set autocompleter for make alias

    Thanks for this too, I also found another interesting folder around bash completion:
    /etc/bash_completion.d/
    In which, on 12.1 there is a make file present but not in Leap 15, I then copied it for Leap 15:
    Code:
    sudo cp /usr/share/bash-completion/completions/make /etc/bash_completion.d/.
    And then I was able to see
    Code:
    complete -F _make ...
    When running
    Code:
    $ complete -pr | grep make
    complete -F _make colormake
    complete -F _make gmake
    complete -F _make gnumake
    complete -F _filedir_xspec makeinfo
    complete -F _make pmake
    complete -F _make make
    But after having run
    Code:
    complete -F _make mj
    Just nothing happens when I type mj <tab>.

  6. #6

    Default Re: Set autocompleter for make alias

    @antoinep:

    Quote Originally Posted by antoinep View Post
    Just nothing happens when I type mj <tab>.
    A quick GFI (Google for it) came up with
    https://unix.stackexchange.com/quest...ommand-aliases
    which lead me to https://github.com/cykerway/complete-alias

    I have a file named 'Makefile' in the current directory with content:
    Code:
    .PHONY: help
    help:
    <TAB>@echo 'Help text'
    (Replace '<TAB>' with a real <TAB>-character!)

    I did this:
    Code:
    alias mj='make -j32 -k'
    # With mj <TAB> I got:
    mj Makefile
    That is not what you want. The solution:
    Code:
    wget -O- 'https://raw.githubusercontent.com/cykerway/complete-alias/master/complete_alias' >> ~/.complete_alias
    # Always check first when getting executable content from the web:
    less ~/.complete_alias
    . ~/.complete_alias
    complete -F _complete_alias mj
    # Now with mj <TAB> I got:
    mj help
    That is the kind of behavior you want.

    To make things permanent:
    Code:
    echo 'complete -F _complete_alias mj' >> ~/.bash_completion
    cat >> ~/.bashrc <<EOF
    . ~/.complete_alias
    . ~/.bash_completion
    EOF
    Kind regards,
    Leen

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •