免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 3181 | 回复: 6

[其他] tcshrc中的complete是什么 [复制链接]

论坛徽章:
0
发表于 2012-07-25 09:04 |显示全部楼层
自己home下有个.tcshrc的配置文件,其中的complete是什么意思
求大侠们赐教。。。
  1. complete cd         'p/1/d/'        #cd <dir>
  2. complete man        'n/*/c/'        #man <command>
  3. complete which      'n/*/c/'        #which <command>
  4. complete whereis    'n/*/c/'        #whereis <command>
  5. complete where      'n/*/c/'        #whereis <command>
  6. complete set        'p/1/s/'        #set <shell-valiable>
  7. complete unset      'p/1/s/'        #unset <shell-valiable>
  8. .......................................
复制代码

论坛徽章:
5
2015年辞旧岁徽章
日期:2015-03-03 16:54:152015年迎新春徽章
日期:2015-03-04 09:50:282015年亚洲杯之朝鲜
日期:2015-03-13 22:47:33IT运维版块每日发帖之星
日期:2016-01-09 06:20:00IT运维版块每周发帖之星
日期:2016-03-07 16:27:44
发表于 2012-07-25 09:46 |显示全部楼层
回复 1# guoweiqust


    内置命令。

论坛徽章:
8
摩羯座
日期:2014-11-26 18:59:452015亚冠之浦和红钻
日期:2015-06-23 19:10:532015亚冠之西悉尼流浪者
日期:2015-08-21 08:40:5815-16赛季CBA联赛之山东
日期:2016-01-31 18:25:0515-16赛季CBA联赛之四川
日期:2016-02-16 16:08:30程序设计版块每日发帖之星
日期:2016-06-29 06:20:002017金鸡报晓
日期:2017-01-10 15:19:5615-16赛季CBA联赛之佛山
日期:2017-02-27 20:41:19
发表于 2012-07-25 10:19 |显示全部楼层
定义命令的补齐规则

论坛徽章:
15
2015年辞旧岁徽章
日期:2015-03-03 16:54:15双鱼座
日期:2015-01-15 17:29:44午马
日期:2015-01-06 17:06:51子鼠
日期:2014-11-24 10:11:13寅虎
日期:2014-08-18 07:10:55酉鸡
日期:2014-04-02 12:24:51双子座
日期:2014-04-02 12:19:44天秤座
日期:2014-03-17 11:43:36亥猪
日期:2014-03-13 08:13:51未羊
日期:2014-03-11 12:42:03白羊座
日期:2013-11-20 10:15:18CU大牛徽章
日期:2013-04-17 11:48:45
发表于 2012-07-26 08:20 |显示全部楼层
Completion and listing (+)

The shell is often able to complete words when given a unique abbreviation. Type part of a word (for example 'ls /usr/lost') and hit the tab key to run the complete-word editor command. The shell completes the filename '/usr/lost' to '/usr/lost+found/', replacing the incomplete word with the complete word in the input buffer. (Note the terminal '/'; completion adds a '/' to the end of completed directories and a space to the end of other completed words, to speed typing and provide a visual indicator of successful completion. The addsuffix shell variable can be unset to prevent this.) If no match is found (perhaps '/usr/lost+found' doesn't exist), the terminal bell rings. If the word is already complete (perhaps there is a '/usr/lost' on your system, or perhaps you were thinking too far ahead and typed the whole thing) a '/' or space is added to the end if it isn't already there.
Completion works anywhere in the line, not at just the end; completed text pushes the rest of the line to the right. Completion in the middle of a word often results in leftover characters to the right of the cursor that need to be deleted.

Commands and variables can be completed in much the same way. For example, typing 'em[tab]' would complete 'em' to 'emacs' if emacs were the only command on your system beginning with 'em'. Completion can find a command in any directory in path or if given a full pathname. Typing 'echo $ar[tab]' would complete '$ar' to '$argv' if no other variable began with 'ar'.

The shell parses the input buffer to determine whether the word you want to complete should be completed as a filename, command or variable. The first word in the buffer and the first word following ';', '|', '|&', '&&' or '||' is considered to be a command. A word beginning with '$' is considered to be a variable. Anything else is a filename. An empty line is 'completed' as a filename.

You can list the possible completions of a word at any time by typing '^D' to run the delete-char-or-list-or-eof editor command. The shell lists the possible completions using the ls-F builtin (q.v.) and reprints the prompt and unfinished command line, for example:

> ls /usr/l[^D]
lbin/ lib/ local/ lost+found/
> ls /usr/l
If the autolist shell variable is set, the shell lists the remaining choices (if any) whenever completion fails:
> set autolist
> nm /usr/lib/libt[tab]
libtermcap.a@ libtermlib.a@
> nm /usr/lib/libterm
If autolist is set to 'ambiguous', choices are listed only when completion fails and adds no new characters to the word being completed.
A filename to be completed can contain variables, your own or others' home directories abbreviated with '~' (see Filename substitution) and directory stack entries abbreviated with '=' (see Directory stack substitution). For example,

> ls ~k[^D]
kahn kas kellogg
> ls ~ke[tab]
> ls ~kellogg/
or
> set local = /usr/local
> ls $lo[tab]
> ls $local/[^D]
bin/ etc/ lib/ man/ src/
> ls $local/
Note that variables can also be expanded explicitly with the expand-variables editor command.
delete-char-or-list-or-eof lists at only the end of the line; in the middle of a line it deletes the character under the cursor and on an empty line it logs one out or, if ignoreeof is set, does nothing. 'M-^D', bound to the editor command list-choices, lists completion possibilities anywhere on a line, and list-choices (or any one of the related editor commands that do or don't delete, list and/or log out, listed under delete-char-or-list-or-eof) can be bound to '^D' with the bindkey builtin command if so desired.

The complete-word-fwd and complete-word-back editor commands (not bound to any keys by default) can be used to cycle up and down through the list of possible completions, replacing the current word with the next or previous word in the list.

The shell variable fignore can be set to a list of suffixes to be ignored by completion. Consider the following:

> ls
Makefile condiments.h~ main.o side.c
README main.c meal side.o
condiments.h main.c~
> set fignore = (.o \~)
> emacs ma[^D]
main.c main.c~ main.o
> emacs ma[tab]
> emacs main.c
'main.c~' and 'main.o' are ignored by completion (but not listing), because they end in suffixes in fignore. Note that a '\' was needed in front of '~' to prevent it from being expanded to home as described under Filename substitution. fignore is ignored if only one completion is possible.
If the complete shell variable is set to 'enhance', completion 1) ignores case and 2) considers periods, hyphens and underscores ('.', '-' and '_') to be word separators and hyphens and underscores to be equivalent. If you had the following files

comp.lang.c comp.lang.perl comp.std.c++
comp.lang.c++ comp.std.c
and typed 'mail -f c.l.c[tab]', it would be completed to 'mail -f comp.lang.c', and ^D would list 'comp.lang.c' and 'comp.lang.c++'. 'mail -f c..c++[^D]' would list 'comp.lang.c++' and 'comp.std.c++'. Typing 'rm a--file[^D]' in the following directory
A_silly_file a-hyphenated-file another_silly_file
would list all three files, because case is ignored and hyphens and underscores are equivalent. Periods, however, are not equivalent to hyphens or underscores.
Completion and listing are affected by several other shell variables: recexact can be set to complete on the shortest possible unique match, even if more typing might result in a longer match:

> ls
fodder foo food foonly
> set recexact
> rm fo[tab]
just beeps, because 'fo' could expand to 'fod' or 'foo', but if we type another 'o',
> rm foo[tab]
> rm foo
the completion completes on 'foo', even though 'food' and 'foonly' also match. autoexpand can be set to run the expand-history editor command before each completion attempt, autocorrect can be set to spelling-correct the word to be completed (see Spelling correction) before each completion attempt and correct can be set to complete commands automatically after one hits 'return'. matchbeep can be set to make completion beep or not beep in a variety of situations, and nobeep can be set to never beep at all. nostat can be set to a list of directories and/or patterns that match directories to prevent the completion mechanism from stat(2)ing those directories. listmax and listmaxrows can be set to limit the number of items and rows (respectively) that are listed without asking first. recognize_only_executables can be set to make the shell list only executables when listing commands, but it is quite slow.
Finally, the complete builtin command can be used to tell the shell how to complete words other than filenames, commands and variables. Completion and listing do not work on glob-patterns (see Filename substitution), but the list-glob and expand-glob editor commands perform equivalent functions for glob-patterns.

Spelling correction (+)

The shell can sometimes correct the spelling of filenames, commands and variable names as well as completing and listing them.
Individual words can be spelling-corrected with the spell-word editor command (usually bound to M-s and M-S) and the entire input buffer with spell-line (usually bound to M-$). The correct shell variable can be set to 'cmd' to correct the command name or 'all' to correct the entire line each time return is typed, and autocorrect can be set to correct the word to be completed before each completion attempt.

When spelling correction is invoked in any of these ways and the shell thinks that any part of the command line is misspelled, it prompts with the corrected line:

> set correct = cmd
> lz /usr/bin
CORRECT>ls /usr/bin (y|n|e|a)?
One can answer 'y' or space to execute the corrected line, 'e' to leave the uncorrected command in the input buffer, 'a' to abort the command as if '^C' had been hit, and anything else to execute the original line unchanged.
Spelling correction recognizes user-defined completions (see the complete builtin command). If an input word in a position for which a completion is defined resembles a word in the completion list, spelling correction registers a misspelling and suggests the latter word as a correction. However, if the input word does not match any of the possible completions for that position, spelling correction does not register a misspelling.

Like completion, spelling correction works anywhere in the line, pushing the rest of the line to the right and possibly leaving extra characters to the right of the cursor.

Beware: spelling correction is not guaranteed to work the way one intends, and is provided mostly as an experimental feature. Suggestions and improvements are welcome.

论坛徽章:
0
发表于 2012-07-26 13:28 |显示全部楼层
回复 4# rdcwayx


   一堆英语看着就头晕啊。。。

论坛徽章:
15
2015年辞旧岁徽章
日期:2015-03-03 16:54:15双鱼座
日期:2015-01-15 17:29:44午马
日期:2015-01-06 17:06:51子鼠
日期:2014-11-24 10:11:13寅虎
日期:2014-08-18 07:10:55酉鸡
日期:2014-04-02 12:24:51双子座
日期:2014-04-02 12:19:44天秤座
日期:2014-03-17 11:43:36亥猪
日期:2014-03-13 08:13:51未羊
日期:2014-03-11 12:42:03白羊座
日期:2013-11-20 10:15:18CU大牛徽章
日期:2013-04-17 11:48:45
发表于 2012-07-26 13:30 |显示全部楼层
本帖最后由 rdcwayx 于 2012-07-26 13:31 编辑

如果实在看不懂,用google translate, 可以大篇幅的翻译,而且本身都不是很难的英语。

论坛徽章:
0
发表于 2012-07-29 14:43 |显示全部楼层
回复 6# rdcwayx

好的,谢谢。。
   
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP