расширение истории в zsh

согласно документу, !! должно расширяться до последней команды при нажатии <tab> после нее. Однако это не относится к моей настройке (я использовал oh-my-zsh по умолчанию). Вот пример: $ echo 1 1 $ echo 2 2 $ !!<tab> $ echo 1

Более того, !# не расширяется до того, что вводится в текущей строке. Вместо этого он расширяется до последней команды $ echo 1 1 $ echo 2 2 $ echo 3 !#<tab> $ echo 3 echo 2

Есть ли какая-либо опция, управляющая этим?


person doraemon    schedule 04.08.2017    source источник


Ответы (1)


Я посмотрел настройки завершения oh-my-zsh по умолчанию на github. и похоже, что расширение параметров не включено по умолчанию. Согласно oh-my-zsh документации, любые переопределения должны идти в custom/ каталог, в файлах, оканчивающихся на *.zsh. Заставить расширение параметра работать должно быть так же просто, как добавить туда файл с чем-то вроде этого:

zstyle ':completion:*' completer _expand _complete

Полная функция, которую вы ищете, называется _expand, вот что man zshcompsys говорит о ней:

_expand

This completer function does not really perform completion, but instead 
checks if the word on the command line is eligible for
expansion and, if it is, gives detailed control over how this
expansion is done. For this to happen, the completion system needs to
be invoked with complete-word, not expand-or-complete (the default
binding for TAB), as otherwise the string will be expanded by the
shell's internal mechanism before the completion system is started.
Note also this completer should be called before the _complete
completer function.

The tags used when generating expansions are all-expansions for the
string containing all possible expansions, expansions when adding the
possible expansions as single matches and original when adding the
original string from the line. The order in which these strings are
generated, if at all, can be controlled by the group-order and
tag-order styles, as usual.

The format string for all-expansions and for expansions may contain
the sequence '%o' which will be replaced by the original string from
the line.

The kind of expansion to be tried is controlled by the substitute,
glob and subst-globs-only styles.

It is also possible to call _expand as a function, in which case the
different modes may be selected with options: -s for substitute, -g
for glob and -o for subst-globs-only.
person boojum    schedule 10.08.2017