在 MySQL 屏幕中拥有类似 Vim 的 K

发布于 2024-07-25 17:22:02 字数 309 浏览 8 评论 0原文

这个问题基于此线程

问题:当光标位于单词开头时访问MySQL手册,其中

Ctrl-A Esc Ctrl-m

m提醒Mysql。

如何在 Screen 中为 MySQL 手册构建类似 Vim 的 K?

This question is based on this thread.

Problem: to access MySQL's manual when the cursor is at the beginning of the word by

Ctrl-A Esc Ctrl-m

where m reminds about Mysql.

How can you build a Vim-like K in Screen for MySQL's manuals?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

绝不放开 2024-08-01 17:22:02

假设您已经安装了 MySQL 文档站点 中的手册页:

将以下内容放入 / path/to/mysql-help.screen

# mysql-help.screen

# prevent messages from slowing this down
msgminwait 0
# copy term starting at cursor
copy
stuff " e "
# write term to a file
writebuf /tmp/screen-copied-term
# open that file in man in a new screen window
# (use `read` to pause on error, so user can see error message)
screen /bin/sh -c 'man `cat /tmp/screen-copied-term` || read'
# turn message waiting back on
msgminwait 1

# vi: ft=screen

然后将其添加到您的 ~/.screenrc

# Have CTRL-A ESC put you in a mode to accept commands in the 'escaped' class
bind \033 command -c escaped
# add CTRL-M as an 'escaped' class command to run the given screen script
bind -c escaped ^M source /path/to/mysql-help.screen

然后您的键绑定应该可以工作。 如果您使用不同的程序来显示
除了 man 之外的手册,您必须相应地更改脚本。

我在上面的链接中找到的 mysql 手册页仅包含文档
对于以下命令:

mysqlbug mysqlhotcopy perror mysqldump resolveip mysqltest_embedded > mysql_setpermission mysql_client_test mysql_find_rows mysql_fix_privilege_tables mysql_waitpid mysql_config <代码>mysql_client_test_embedded myisampack 替换 msql2mysql make_win_bin_dist my_print_defaults mysql-压力-测试pl mysqlaccess mysql_secure_installation mysql.服务器 mysql_convert_table_format mysql_zap mysql_fix_extensions myisamlog myisam_ftdump mysqlbinlog mysql_install_db resolve_stack_dump mysqlslap mysql-测试-运行pl mysqld_safe mysqladmin mysqlshow mysql_tzinfo_to_sql mysqltest mysqlbackup mysqld_multi mysql mysqldumpslow mysqlcheck代码> mysql_upgrade mysqlimport comp_err mysqld myisamchk innochecksum

您也可以想要考虑添加

zombie kr

到您的 .screenrc 中,这样,如果您使用它无法识别的术语运行手册,screen 不会自动关闭窗口(并隐藏错误消息)。

Assuming you've installed the man pages from MySQL's documentation site:

Put the following in /path/to/mysql-help.screen:

# mysql-help.screen

# prevent messages from slowing this down
msgminwait 0
# copy term starting at cursor
copy
stuff " e "
# write term to a file
writebuf /tmp/screen-copied-term
# open that file in man in a new screen window
# (use `read` to pause on error, so user can see error message)
screen /bin/sh -c 'man `cat /tmp/screen-copied-term` || read'
# turn message waiting back on
msgminwait 1

# vi: ft=screen

Then add this to your ~/.screenrc

# Have CTRL-A ESC put you in a mode to accept commands in the 'escaped' class
bind \033 command -c escaped
# add CTRL-M as an 'escaped' class command to run the given screen script
bind -c escaped ^M source /path/to/mysql-help.screen

Then your keybinding should work. If you're using a different program to display
the manual other than man, you'll have to change the script accordingly.

The man pages for mysql that I found at the link above only include documentation
for the following commands:

mysqlbug mysqlhotcopy perror mysqldump resolveip mysqltest_embedded mysql_setpermission mysql_client_test mysql_find_rows mysql_fix_privilege_tables mysql_waitpid mysql_config mysql_client_test_embedded myisampack replace msql2mysql make_win_bin_dist my_print_defaults mysql-stress-test.pl mysqlaccess mysql_secure_installation mysql.server mysql_convert_table_format mysql_zap mysql_fix_extensions myisamlog myisam_ftdump mysqlbinlog mysql_install_db resolve_stack_dump mysqlslap mysql-test-run.pl mysqld_safe mysqladmin mysqlshow mysql_tzinfo_to_sql mysqltest mysqlbackup mysqld_multi mysql mysqldumpslow mysqlcheck mysql_upgrade mysqlimport comp_err mysqld myisamchk innochecksum

You may also want to consider adding

zombie kr

to your .screenrc, so that if you run the manual on a term that it doesn't recognize, screen doesn't automatically close the window (and hide the error message).

若水微香 2024-08-01 17:22:02

虽然我不确定如何开始为 vim 创建一个包装器来完全执行您想要的操作,但我可能会建议您如何使用 vim 内置的函数实现类似的效果。

<代码>:!将允许您使用与 vim 的 K 命令类似的界面来运行 shell 命令。 这可能不是最干净的方法,但是通过使用 :! 你应该能够快速调用给定术语的 MySQL 手册,而无需完全离开 vim。

如果您确实需要为 vim 编写自己的插件,这篇文章也许能为您提供一些指导和从哪里开始的指导。

我希望这有帮助!

While I'm not sure how to start you off creating a wrapper for vim to do exactly what you want, I might make a suggestion on how you can achieve a similar effect with a function built into vim.

:! <command> will allow you to run shell commands with a similar interface to vim's K command. It might not be the cleanest way to do it, but by using :! you should be able to call the MySQL manuals for a given term quickly without completely leaving vim.

If you really need to write your own plugin for vim, this article might be able to give you some pointers and a handhold on where to start.

I hope this helps!

ぃ弥猫深巷。 2024-08-01 17:22:02

我喜欢回收我的手册页,这样我就可以轻松阅读手册。
我建议对 Rampion 的命令进行以下改进。

Rampion

screen /bin/sh -c 'man `cat /tmp/screen-copied-term` || read'

screen /bin/sh -c 'man `cat /tmp/screen-copied-term` > /tmp/manual | less /tmp/manual'

我的代码为您提供了手册底部的百分号

I love to recycle my Man -pages such that I can read easily manuals.
I suggests the following improvement to Rampion's command.

Rampion

screen /bin/sh -c 'man `cat /tmp/screen-copied-term` || read'

Me

screen /bin/sh -c 'man `cat /tmp/screen-copied-term` > /tmp/manual | less /tmp/manual'

My code gives you the percent sign to the bottom of a manual.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文