I created a detach script, being a wrapper around nohup:


/usr/bin/nohup "$@" &> /dev/null &

and I want to get bash-completion to work for this script.

I try to use complete -c detach, but for all arguments there is an addition from the utilities from PATH.

How to properly implement bash-completion for my detach utility?


1 Answer 1


Since you are using bash-completion, the easiest solution is probably to ask it how nohup is completed1:

$ complete -p nohup
complete -F _command nohup

and then apply the same completion recipe to detach:

$ complete -F _command detach

Refer to "Where should I install my own local completions?" in bash-completion's FAQ for the most suitable place for this command.

The _command function in turn invokes _command_offset, which is, according to a comment in bash_completion:

# A meta-command completion function for commands like sudo(8), which need to
# first complete on a command, then complete according to that command's own
# completion definition.

1 Assuming an interactive bash shell in which bash_completion has been sourced. If you are using Arch Linux, as a comment of yours seemed to suggest, this is true by default for every interactive Bash session (/etc/bash.bashrc sources /usr/share/bash-completion/bash_completion).

You must log in to answer this question.

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