I'm trying to write a completion function for a command that requires that its argument be an absolute path. (No, I don't know why.) I thought it would be nice to allow typing a relative path, but completion would expand it to an absolute path — that way, if I forget the requirement for an absolute path, completion will fix it for me. For example, if my working directory is home and I have a file "foo" and I type
fo<TAB>, it would complete to
/usr/me/foo instead of just
_files would do.
Problem is, I have no idea how to do this. I've been through all the flags on
compadd, and nothing sounds relevant.
_canonical_paths sounds close, but I can't get it to do anything. Once the argument is an absolute path,
_files works just fine; it's that initial step that's the issue. Suggestions?