当我尝试使用制表符完成时rake
,只建议使用文件:
$ rails test-app | grep -v create; cd test-app
$ rake <TAB><TAB>
app/ db/ lib/ public/ README test/ vendor/
config/ doc/ log/ Rakefile script/ tmp/
该软件包rake-0.8.7-2
包括一个 Bash 完成配置文件,
$ debsums -e rake
/etc/bash_completion.d/rake OK
所以我希望按 Tab 键应该会建议可以使用的任务:
$ rake --tasks
(in ~/sandbox/test-app)
rake db:abort_if_pending_migrations # Raises an error if there are pending migrations
rake db:charset # Retrieves the charset for the current environment's database
rake db:collation # Retrieves the collation for the current environment's database
rake db:create # Create the database defined in config/database.yml for the current RAIL...
rake db:create:all # Create all the local databases defined in config/database.yml
rake db:drop # Drops the database for the current RAILS_ENV
...
我究竟做错了什么?
重新安装 rake 并重新启动计算机后问题仍然存在。我的~/.bashrc
包含:
if [ -f /etc/bash_completion ] && ! shopt -oq posix; then
. /etc/bash_completion
fi
但完成rake
似乎没有被注册:
$ complete | grep rake
$
. /etc/bash_completion
在 shell 中显式运行并不能解决问题,但运行以下命令确实可以rake
暂时完成:
$ grep complete /etc/bash_completion.d/rake
[ -n "${have:-}" ] && complete -F _rake $filenames rake
$ complete -F _rake rake
$ rake <TAB><TAB>
db:abort_if_pending_migrations db:version rails:update
db:charset doc:app rails:update:application_controller
db:collation doc:clobber_app rails:update:configs
db:create doc:clobber_plugins rails:update:generate_dispatchers
db:create:all doc:clobber_rails rails:update:javascripts
db:drop doc:guides rails:update:scripts
...
打开 shell 时会加载 Tab 补全。安装应用程序时,您需要重新打开 shell 或运行下一个命令来加载新的 bash 完成:
. /etc/bash_completion
看起来是一个错误在rake
。[ -n "${have:-}" ]
检查是否$have
设置了命名变量。如果前一个 has 调用失败,这将不起作用。替换为have rake
:
have rake && complete -F _rake $filenames rake
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句