Nei*_*eil 8 bash vim tab-completion
如果我输入cat ~/.bashr<TAB>
然后它完成到cat ~/.bashrc
.
如果我输入vim ~/.bashr<TAB>
然后它完成vim /home/neil/.bashrc
...
(它与 相同vi
,别名为"vim"
。)
我可以关掉它吗?
bash
可以为某些命令提供更复杂的自动完成(例如自动完成除文件名之外的程序参数)。系统上为命令定义了这样一个可编程完成功能vim
。
打字complete
在命令提示符将显示使用您哪些功能为提供自动完成bash
。
$ complete
complete -o default -F _complete_open open
Run Code Online (Sandbox Code Playgroud)
键入type function_name
以了解其定义。
$ type _complete_open
_complete_open is a function
_complete_open ()
{
# function definition
}
Run Code Online (Sandbox Code Playgroud)
找出函数的定义位置。使用以下内容:
$ shopt -s extdebug
$ declare -F _complete_open
_complete_open 70 /Users/danielbeck/.bash_profile
Run Code Online (Sandbox Code Playgroud)
这是由 /etc/bash_completion 控制的
如果你不喜欢它,你可以在 _expand() 中注释掉扩展代码。
这是我在 Fedora 17 中的版本,但你的应该是类似的:
# This function expands tildes in pathnames
#
_expand()
{
# FIXME: Why was this here?
#[ "$cur" != "${cur%\\}" ] && cur="$cur\\"
# Expand ~username type directory specifications. We want to expand
# ~foo/... to /home/foo/... to avoid problems when $cur starting with
# a tilde is fed to commands and ending up quoted instead of expanded.
if [[ "$cur" == \~*/* ]]; then
eval cur=$cur
elif [[ "$cur" == \~* ]]; then
cur=${cur#\~}
COMPREPLY=( $( compgen -P '~' -u "$cur" ) )
[ ${#COMPREPLY[@]} -eq 1 ] && eval COMPREPLY[0]=${COMPREPLY[0]}
return ${#COMPREPLY[@]}
fi
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
1460 次 |
最近记录: |