I'm trying to configure programmable tab completion for a certain command alias:
when hitting tab after command notes
i want the shell to complete from existing file names under specific path ~/notes/notes_db/{some,files,here}
in my .cshrc.user file i have set up the following complete
declaration:
complete note 'p/1/`ls ~/notes/notes_db/`/'
alas when I test this by typing note [TAB]
, tcshell responds with:
note [TAB] Unmatched `.
I tried various forms of escaping the ls command within the backtics but non of my attempts worked.
please, can anyone explain how should i properly escape this declaration? Thanks!
There are (at least) two problems:
ls
contains slashes (/
), which clash with the syntax of the complete
command. To bypass, use a different separator, e.g. @
~
is not replaced when appearing inside single quotes. Use $HOME
instead.ls
defined to be some alias (very common), inside your complete
you'd want the unaliased ls
. So use \ls
.We get:
complete note 'p@1@`\ls $HOME/notes/notes_db`@'