I am using bash and what I'm trying to do is achieve autocompletion in a nested command. For example, typing:

kill $(cat tmp/p|

followed by <tab> would yield

kill $(cat tmp/pids/

And I'd like to type s<tab>)to get to

kill $(cat tmp/pids/server.pid)

Unfortunately, my bash autocompletion is not working in this particular situation.

Is there a way to fix this?

Here's my bash version:

GNU bash, version 4.4.23(1)-release (x86_64-apple-darwin17.5.0)
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later 

You must be using the completion settings from bash-completion. Tab completion in command substitution does not work with that. It does work without those, using the default settings, though. Comment out wherever you have sourced /usr/local/etc/bash_completion (assuming default homebrew, given the version string), start a new shell and try again.

| improve this answer | |
  • Indeed I'm using bash-completion@2 from brew. I just tested a bash instance without those lines and I confirm it's working correctly. Is there a way to keep the bash-completion@2 functionality while still having path completion working in nested commands? – nerfologist Oct 10 '18 at 12:58
  • @nerfologist Try pressing Esc-/ instead of tab. According to the bash-completion FAQ, using M-/ (Meta+/, Meta is Esc by default, IIRC) bypasses bash-completion. – Olorin Oct 11 '18 at 7:04

Use this command to read PID from file and kill the process:

pkill -F /path/to/file
| improve this answer | |
  • Unfortunately it won't work in the version of pkill that's available from brew at this time. – nerfologist Oct 12 '18 at 10:27

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.