Console tab completion for rake teams

I am very happy to get tab completion with the following code snippet in my .bashrc:

cd () {
    command cd "$@";
    if [ -f ./Rakefile ]; then
        complete -W "$(rake -T | awk 'NR != 1 {print $2}')" rake
    else
        complete -r rake
    fi
}

This command will be loaded when entering the directory using cd. If the directory does not contain a rakefile, the message "bash: complete: rake: no specification specification" appears. Is it possible to omit this message?

Thanks for your help Matthias

+3
source share
1 answer

I would just do this:

complete -r rake 2>/dev/null

It throws an error when it tries to remove the completion specification when it is not present (already deleted). Just redirect stderr to clear the error message.

+1
source

Source: https://habr.com/ru/post/1788650/


All Articles