2

I have a small debian package that includes a bash completion file which is copied in the /etc/bash_completion.d folder.

After installation, the bash completion file is not "loaded". I have to type in the terminal:

source /etc/bash_completion.d/mycompletionfile

I would like to avoid this with the postinst script. How should I do that?

Thank you

3
  • did you use dh_bash-completion for installation? Commented Mar 7, 2018 at 9:03
  • Thanks for the reply. dh_bash-completion /etc/bash_completion.d/mycompletionfile in the postinst would be the good way? Commented Mar 7, 2018 at 9:33
  • The manpage says: "If a file named debian/package.bash-completion exists, then different actions are performed". Sounds to me that it should work automagically if the file has the correct name, maybe needs a dependency to bash-completion in the DEBIAN file and maybe the line dh $@ --with bash-completion in the rules file, but I'm not sure as I never used it, just saw that this debhelper exists. It might also just copy the file, and you are where you started. Commented Mar 7, 2018 at 11:12

2 Answers 2

4

According to the Debian New Maintainers Guide, you have to

  1. add the bash-completion package in Build-Depends
  2. add dh $@ --with bash-completion to debian/rules
  3. create a file debian/package.bash-completion (and read man dh_bash-completion)
Sign up to request clarification or add additional context in comments.

1 Comment

As of debhelper compat level 12, there's no need to change the debian/rules file at all. You only have to add two packages to Build-Depends (or Build-Depends-Indep): bash-completion and dh-sequence-bash-completion, which has the same effect as adding the --with flag to the dh invocation in debian/rules. That, and adding a package.bash-completion to the debian folder, will also fix the destination folder for your completion file; packages are supposed to place them in /usr/share/bash-completion/completions, the folder in /etc is for user completion files only.
0

Bash completion files are loaded at shell startup. If you install a new completion file, it won't be automatically loaded in existing shells where you have no other choice than source it or source /etc/bash_completion. Your new completion should be available in new shells without any special operation, though.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.