ænd*_*rük 6 rails auto-completion
当我尝试使用制表符完成时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/
Run Code Online (Sandbox Code Playgroud)
该软件包rake-0.8.7-2包括一个 Bash 完成配置文件,
$ debsums -e rake
/etc/bash_completion.d/rake OK
Run Code Online (Sandbox Code Playgroud)
所以我希望按 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
...
Run Code Online (Sandbox Code Playgroud)
我究竟做错了什么?
重新安装 rake 并重新启动计算机后问题仍然存在。我的~/.bashrc包含:
if [ -f /etc/bash_completion ] && ! shopt -oq posix; then
. /etc/bash_completion
fi
Run Code Online (Sandbox Code Playgroud)
但完成rake似乎没有被注册:
$ complete | grep rake
$
Run Code Online (Sandbox Code Playgroud)
. /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
...
Run Code Online (Sandbox Code Playgroud)
打开 shell 时会加载制表符补全。安装应用程序时,您需要重新打开 shell 或运行下一个命令来加载新的 bash 补全:
. /etc/bash_completion
Run Code Online (Sandbox Code Playgroud)
看起来这是一个错误rake。检查是否设置了[ -n "${have:-}" ]名为的变量。$have如果前一个调用失败,则此操作将不起作用。将其替换为have rake:
have rake && complete -F _rake $filenames rake
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1612 次 |
| 最近记录: |