17

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

18

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
    Commented Oct 19, 2012 at 17:36
10

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
  • 2
    Usually . /etc/bash_completion is my solution. Commented Mar 2, 2018 at 11:03
  • Do any of you know why? Commented Jan 15, 2021 at 21:30
  • 1
    @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. Commented Jun 16, 2021 at 10:18

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .