To have Vim-like K in Screen for MySQL

后端 未结 3 2054
花落未央
花落未央 2020-12-20 10:03

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          


        
3条回答
  •  既然无缘
    2020-12-20 11:10

    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).

提交回复
热议问题