12

I have a script for auto-completing my ssh-hosts. If I change my ~/.ssh/config the auto-completion is not updated automatically, though. This does not surprise me. In a new shell, the new entry is picked up and usable, of course.

How do I manually trigger a refresh of the completion in bash?

2 Answers 2

15

Try doing this :

exec bash

this will do the trick...

1
  • 2
    neat, that replaces the current shell... In a way, that like opening a new shell, but still nice.
    – kronn
    Oct 19, 2012 at 17:36
9

See reload bash completion functions file

. /etc/bash_completion.d/filename

(adapt /etc depending on where your bash_completion scripts are deployed, replace filename by the appropriate script)

3
  • 1
    Usually . /etc/bash_completion is my solution. Mar 2, 2018 at 11:03
  • Do any of you know why? Jan 15, 2021 at 21:30
  • @JoelBerger I could hazard a guess... the files mentioned here are themselves bash scripts, so by running them in this way, you're resetting the bash settings just as you would running any bash script. Running /etc/bash_completion is likely best if available, as it reruns all the completion scripts. Jun 16, 2021 at 10:18

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.