Конфигурация Zsh - линейная навигация а-ля VSCode

Есть несколько способов решить эту проблему:

  • вы можете поместить эту функцию в свой.zshrc;
  • вы можете получить свой сценарий;
  • вы можете поместить код вашей функции непосредственно в файл с именем Extract в каталоге, который находится в вашем PATH.
1
05.02.2020, 16:25
1 ответ

Вы можете удалить _и /из$WORDCHARS(или любой другой символ, который вы не хотите рассматривать как часть слова для тех виджетов, которые работают с словами)и определяют виджет, который удаляет последовательности слов или не -словесных символов для привязки к Alt+Del

delete-word-or-non-word() {
  emulate -L zsh       # restore default zsh options locally to the function
  set -o extendedglob  # extended glob needed for the ## operator (locally)

  # ${var##pattern} ksh operator to remove the longest string that matches
  # the pattern off the start of $var. Here applied to $RBUFFER which in a
  # zle widget is the part of the line editor buffer to the right of the
  # cursor. [[:WORD:]] matches a *word* character (alnums + $WORDCHARS),
  # ## is *one or more* (like ERE's + or ksh's +(...))
  RBUFFER=${RBUFFER##([[:WORD:]]##|[^[:WORD:]]##)}
}

zle -N delete-word-or-non-word # define a new zle widget using that function

# bind that new widget
bindkey '\ed' delete-word-or-non-word      # Alt+D
bindkey '^[[3;3~' delete-word-or-non-word  # Alt+Del on xterm at least

WORDCHARS=${WORDCHARS//[\/_]}  # remove _ and / from WORDCHARS
                               # using the ${var//pattern/replacement} ksh
                               # operator

WORDCHARS=                     # or make it empty so that the only *word*
                               # characters are alphanumerics

(не требуетselect-word-style)

1
28.04.2021, 23:24

Теги

Похожие вопросы