سؤال

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:

  1. the output of ls contains slashes (/), which clash with the syntax of the complete command. To bypass, use a different separator, e.g. @
  2. ~ is not replaced when appearing inside single quotes. Use $HOME instead.
  3. (just guessing) if by any chance you have 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`@'
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top