문제

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