9

Is it possible to disable Bash's autocompletion for a specific command only?

Use case: For obvious reasons, I would like to disable autocompletion for the rm command when I'm root. It would also be a terrible pain if I disabled autocompletion altogether, so I'd like to remove it for rm only.

Can this be done at all, preferably without hacking /etc/bash_completion and friends?

12

You can do this easily by setting rm's completion to an empty wordlist.

complete -W "" rm

Set it in /root/.bashrc if you only want it to apply to root.

  • Works just as advertised. Thank you very much! – Joseph R. Oct 17 '13 at 21:54
  • complete -C : rm and complete rm work too:) – Evgeny Vereshchagin Jun 28 '15 at 15:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.