complete
내 gnome-terminal 에서 명령을 실행하는 동안 몇 가지 명령이 표시됩니다. 그리고 complete
명령 의 사용은 무엇 입니까?
$ complete
complete -F _minimal
complete -F _filedir_xspec oodraw
complete -F _filedir_xspec elinks
complete -F _filedir_xspec freeamp
complete -F _longopt split
complete -F _longopt sed
complete -F _longopt ld
complete -F _longopt grep
complete -F _service /etc/init.d/vboxweb-service
complete -F _service /etc/init.d/vboxballoonctrl-service
complete -F _service /etc/init.d/rc
complete -F _service /etc/init.d/nmbd
complete -F _service /etc/init.d/halt
complete -j -P '"%' -S '"' jobs
complete -d pushd
목록이 길어 지므로 일부를 게시했습니다.
답변
complete
bash 내장 함수입니다. 따라서 시스템에는 바이너리가 없습니다. 를 누를 때 명령이 완료되는 방법을 처리합니다 tab.
예 : 다음을 입력하면 :
user@host:~$ pidof <tab><tab>
…이 명령에 가능한 모든 값이있는 목록이 나타납니다. 이 경우 실행중인 모든 프로세스를 의미합니다. complete
함수 의 출력을보십시오 :
user@host:~$ complete | grep pidof
complete -F _pgrep pidof
이는 _pgrep
명령을 탭할 때 기능 (-F)이 실행 됨을 의미합니다 pidof
. 이 함수의 정의는에 /etc/bash_completion.d/procps
있습니다.
다른 예 : 다음을 입력하면 :
user@host:~$ cd /usr/<tab><tab>
bin/ games/ include/ lib/ lib32/ local/ sbin/ share/ src/
… cd
아래 에 가능한 폴더 목록이 표시 됩니다 /usr/
. 어떤 기능이 실행됩니까? greping complete
(위와 같이) 함수하면이 funtction의 우리에게 알려줍니다 _cd
에서 /etc/bash_completion
.
스스로해라 : 당신은 프로그램 / 스크립트를 가지고 있고 /bin/myprog
다음과 같이 실행하면 그것을 원한다.
user@host:~$ myprog /home/user/<tab><tab>
… 파일이 아닌 폴더 만 나열해야합니다. 따라서 다음 명령으로 bash 완성을 확장하십시오.
user@host:~$ complete -F _cd myprog
그게 다야. 또한 특정 파일이나 숫자 또는 정적 값 목록 만 완성하는 등 사용자 정의 기능을 완성하는 자체 함수를 작성할 수도 있습니다.
답변
complete
사용자가 TAB터미널 에서 키를 누를 때 자동 완성 동작을 수행하는 데 사용되는 bash 명령 입니다.
호출 complete
하면 명령 또는 서비스 옵션의 자동 완성을 위해 등록 된 모든 기능이 나열됩니다.
bash 매뉴얼 페이지에서 :
complete: complete [-abcdefgjksuv] [-pr] [-DE] [-o option] [-A action] [-G globpat]
[-W wordlist] [-F function] [-C command] [-X filterpat] [-P prefix]
[-S suffix] [name ...]
Specify how arguments are to be completed by Readline.
For each NAME, specify how arguments are to be completed. If no options
are supplied, existing completion specifications are printed in a way that
allows them to be reused as input.
Options:
-p print existing completion specifications in a reusable format
-r remove a completion specification for each NAME, or, if no
NAMEs are supplied, all completion specifications
-D apply the completions and actions as the default for commands
without any specific completion defined
-E apply the completions and actions to "empty" commands --
completion attempted on a blank line
When completion is attempted, the actions are applied in the order the
uppercase-letter options are listed above. The -D option takes
precedence over -E.
Exit Status:
Returns success unless an invalid option is supplied or an error occurs.
/usr/share/bash-completion/bash_completion
bash와 함께 제공되는 기본 완료를 확인 하십시오.
이 명령에 대한 전체 자습서를 보려면 http://www.linuxjournal.com/content/more-using-bash-complete-command 를 방문 하십시오 .