I'm trying to create a completion script for buck . In essence, I want to be able to complete the following format: buck //path/to/my/buck/file:TargetName I managed to make completion work for the most part: I can complete everything up to the TargetName: buck //path/to/my/buck/file/ with the following script: if compset -P '//'; then _files -/ fi The problem is that _files adds this / in the end of the path. However, I want to have a check: if the path contains a BUCK file, I want this slash to be replaced with a colon: buck //path/to/my/buck/file: Is there any way to achieve this? -Pavel