조회 수 8981 댓글 0
?

단축키

Prev이전 문서

Next다음 문서

+ - Up Down Comment Print
?

단축키

Prev이전 문서

Next다음 문서

+ - Up Down Comment Print

lunch 뒤에 옵션들을 자동으로 채워주는 예제.


# Tab completion for lunch.
function _lunch()
{
    local cur prev opts
    COMPREPLY=()
    cur="${COMP_WORDS[COMP_CWORD]}"
    prev="${COMP_WORDS[COMP_CWORD-1]}"

    COMPREPLY=( $(compgen -W "${LUNCH_MENU_CHOICES[*]}" -- ${cur}) )
    return 0
}
complete -F _lunch lunch



[bash-completion] shell 자동 완성 기능 확장하기


complete -pr [name ...]
Specify how arguments to each name should be completed. If the -p option is supplied, or if no options are supplied, existing completion specifications are printed in a way that allows them to be reused as input. The -r option removes a completion specification for each name, or, if nonames are supplied, all completion specifications.

The process of applying these completion specifications when word completion is attempted is described above under Programmable Completion.

Other options, if specified, have the following meanings. The arguments to the -G-W, and -Xoptions (and, if necessary, the -P and -S options) should be quoted to protect them from expansion before the complete builtin is invoked.

-o comp-option
The comp-option controls several aspects of the compspec's behavior beyond the simple generation of completions. comp-option may be one of:
default
Use readline's default filename completion if the compspec generates no matches.
dirnames
Perform directory name completion if the compspec generates no matches.
filenames
Tell readline that the compspec generates filenames, so it can perform any filename-specific processing (like adding a slash to directory names or suppressing trailing spaces). Intended to be used with shell functions.
nospace
Tell readline not to append a space (the default) to words completed at the end of the line.
-A action
The action may be one of the following to generate a list of possible completions:
alias
Alias names. May also be specified as -a.
arrayvar
Array variable names.
binding
Readline key binding names.
builtin
Names of shell builtin commands. May also be specified as -b.
command
Command names. May also be specified as -c.
directory
Directory names. May also be specified as -d.
disabled
Names of disabled shell builtins.
enabled
Names of enabled shell builtins.
export
Names of exported shell variables. May also be specified as -e.
file
File names. May also be specified as -f.
function
Names of shell functions.
group
Group names. May also be specified as -g.
helptopic
Help topics as accepted by the help builtin.
hostname
Hostnames, as taken from the file specified by the HOSTFILE shell variable.
job
Job names, if job control is active. May also be specified as -j.
keyword
Shell reserved words. May also be specified as -k.
running
Names of running jobs, if job control is active.
service
Service names. May also be specified as -s.
setopt
Valid arguments for the -o option to the set builtin.
shopt
Shell option names as accepted by the shopt builtin.
signal
Signal names.
stopped
Names of stopped jobs, if job control is active.
user
User names. May also be specified as -u.
variable
Names of all shell variables. May also be specified as -v.
-G globpat
The filename expansion pattern globpat is expanded to generate the possible completions.
-W wordlist
The wordlist is split using the characters in the IFS special variable as delimiters, and each resultant word is expanded. The possible completions are the members of the resultant list which match the word being completed.
-C command
command is executed in a subshell environment, and its output is used as the possible completions.
-F function
The shell function function is executed in the current shell environment. When it finishes, the possible completions are retrieved from the value of the COMPREPLYarray variable.
-X filterpat
filterpat is a pattern as used for filename expansion. It is applied to the list of possible completions generated by the preceding options and arguments, and each completion matching filterpat is removed from the list. A leading ! in filterpatnegates the pattern; in this case, any completion not matching filterpat is removed.
-P prefix
prefix is added at the beginning of each possible completion after all other options have been applied.
-S suffix
suffix is appended to each possible completion after all other options have been applied.

The return value is true unless an invalid option is supplied, an option other than -p or -ris supplied without a name argument, an attempt is made to remove a completion specification for a name for which no specification exists, or an error occurs adding a completion specification.


Dreamy의 코드 스크랩

내가 모으고 내가 보는

List of Articles
번호 분류 제목 날짜 조회 수 추천 수
371 LINUX 우분투(Ubuntu)에서 APM 웹서버 구축하기 2016.03.17 7528 0
370 LINUX 우분투(Ubuntu) 설치된 패키지 목록 확인하기 2016.03.17 6806 0
369 LINUX 리눅스 그룹관리 (groupadd, groupmod, groupdel) 2016.02.23 8428 0
368 LINUX 삼바(SAMBA)를 이용한 윈도우 접근 가능 공유폴더 만들기 2016.02.23 17958 0
367 JAVA 자바 리스트(List,ArrayList) 이용하는 방법 2016.02.22 28859 0
366 LINUX iptables 명령어 - 방화벽 설정 2016.02.01 12803 0
365 Python pygoogle 파이썬으로 구글 검색결과 가져오기 library 2016.01.20 9998 0
364 Python pyBest 소스 secret 2016.01.20 0 0
363 Android 실시간으로 폰의 pcap 보기 2016.01.05 7306 0
362 C# string array를 string으로 변환 2016.01.05 18250 0
361 C# C#에서 명령줄 인수(command line argument) 사용하기 2016.01.04 12552 0
360 일반 NirCmd 사용법 2015.12.08 7906 0
359 C# Best way to implement keyboard shortcuts in a Windows Forms application 2015.11.06 6772 0
358 Android 원격 linux 서버에서 local device로 adb 접속하기 secret 2015.11.05 1 0
357 일반 [HTML] 복사해서 사용가능한 5개의 실용적인 List Style 예제 2015.11.03 7199 0
목록
Board Pagination ‹ Prev 1 ... 5 6 7 8 9 10 11 12 13 14 ... 34 Next ›
/ 34

나눔글꼴 설치 안내


이 PC에는 나눔글꼴이 설치되어 있지 않습니다.

이 사이트를 나눔글꼴로 보기 위해서는
나눔글꼴을 설치해야 합니다.

설치 취소

Designed by sketchbooks.co.kr / sketchbook5 board skin

Sketchbook5, 스케치북5

Sketchbook5, 스케치북5

Sketchbook5, 스케치북5

Sketchbook5, 스케치북5