최근에 효율적인 텍스트 완성 시스템에 빠져 들었습니다. 내가 좋아하는 완성 유형 중 하나는 소위 퍼지 완성입니다. 이것은 프로그램이 파일 이름 또는 경로에서 ‘거의’어디에서나 발생할 수있는 두 문자 만 기반으로 사용자 입력을 완료하는 모드입니다. 이 기능은 최소한 다음 프로그램에 존재합니다.
- 텍스트 메이트
- Vim Command-T 플러그인 https://github.com/wincent/Command-T
- Vim 완성 시스템 https://github.com/Shougo/neocomplcache
- 다양한 최신 IDE
텍스트 편집기에서이 모드의 사용 예 :
사용자는 longWordNameThatTheyDontWantToWriteByHand라는 단어를 완성하려고하는데, 예를 들어 첫 글자와 대문자를 입력하면됩니다. lwnt를 입력 하면 전체 단어를 완성 할 수 있습니다.
내 질문은 : zsh 셸과 함께 사용할 수있는 모드 또는 비슷한 것이 있습니까?
답변
나는 이것을 내 .zshrc
# 0 -- vanilla completion (abc => abc)
# 1 -- smart case completion (abc => Abc)
# 2 -- word flex completion (abc => A-big-Car)
# 3 -- full flex completion (abc => ABraCadabra)
zstyle ':completion:*' matcher-list '' \
'm:{a-z\-}={A-Z\_}' \
'r:[^[:alpha:]]||[[:alpha:]]=** r:|=* m:{a-z\-}={A-Z\_}' \
'r:|?=** m:{a-z\-}={A-Z\_}'
zsh
의 완성 엔진에 전체 퍼지 매칭을 추가합니다 . 숭고한 텍스트의 장점은 없지만, 그렇습니다 lwnt -> longWordNameThatTheyDontWantToWriteByHand
.
답변
내 프로젝트 fzf를 확인하십시오 .
Golang으로 작성된 범용 퍼지 파인더로 파일, 프로세스, 명령 기록, 자식 분기 등 모든 항목과 함께 사용할 수 있습니다.
zsh의 경우 다음 키 바인딩을 제공합니다.
CTRL-T
-선택한 파일 경로를 명령 줄에 붙여 넣기CTRL-R
-히스토리에서 선택된 명령을 명령 행에 붙여 넣기ALT-C
-선택한 디렉토리로 cd
퍼지 완료 모드 :
# Files under current directory
# - You can select multiple items with TAB key
vim **<TAB>
# Files under parent directory
vim ../**<TAB>
# Files under parent directory that match `fzf`
vim ../fzf**<TAB>
# Files under your home directory
vim ~/**<TAB>
# Directories under current directory (single-selection)
cd **<TAB>
# Directories under ~/github that match `fzf`
cd ~/github/fzf**<TAB>
# Process IDs. Can select multiple processes with TAB or Shift-TAB
kill -9 <TAB>
# Host names
ssh **<TAB>
telnet **<TAB>
# Environment variables / aliases
unset **<TAB>
export **<TAB>
unalias **<TAB>