在 Linux 中将 shift-tab 重新映射到 bash/screen/putty 中的 tab?

在 Linux 中将 shift-tab 重新映射到 bash/screen/putty 中的 tab?

我通过 set -o vi 命令在 bash 中使用 vi 模式。令人恼火的是,当我输入大写单词,然后尝试使用 tab 完成,但没有足够快地释放 Shift 键时,它会让我退出插入模式并进入命令模式。我以为几个月后我会自然地调整并停止这样做,但似乎我不能。

现在,如果有办法将 shift-tab(我怀疑它在任何情况下都没有任何用处)重新映射到常规选项卡,那么我的命令行麻烦就结束了。

我的设置是 Windows -> Putty -> bash -> gnu screen

答案1

我在 Solaris 机器上遇到了同样的问题。

我通过在 .inputrc 文件中添加以下行来修复此问题。

"\e[Z": complete

事实上,这是我从网上某处复制的整个 .inputrc(注意:您需要将模式从 emacs 更改为 vi)文件:

# This file controls the behaviour of line input editing for
     # programs that use the GNU Readline library.  Existing
     # programs include FTP, Bash, and GDB.
     #
     # You can re-read the inputrc file with C-x C-r.
     # Lines beginning with '#' are comments.
     #
     # First, include any systemwide bindings and variable
     # assignments from /etc/Inputrc
     $include /etc/Inputrc
      
     #
     # Set various bindings for emacs mode.
      
     set editing-mode emacs
      
     $if mode=emacs
      
     Meta-Control-h:    backward-kill-word      Text after the function name is ignored
      
     #
     # Arrow keys in keypad mode
     #
     #"\M-OD":        backward-char
     #"\M-OC":        forward-char
     #"\M-OA":        previous-history
     #"\M-OB":        next-history
     #
     # Arrow keys in ANSI mode
     #
     "\M-[D":        backward-char
     "\M-[C":        forward-char
     "\M-[A":        previous-history
     "\M-[B":        next-history
     #
     # Arrow keys in 8 bit keypad mode
     #
     #"\M-\C-OD":       backward-char
     #"\M-\C-OC":       forward-char
     #"\M-\C-OA":       previous-history
     #"\M-\C-OB":       next-history
     #
     # Arrow keys in 8 bit ANSI mode
     #
     #"\M-\C-[D":       backward-char
     #"\M-\C-[C":       forward-char
     #"\M-\C-[A":       previous-history
     #"\M-\C-[B":       next-history
      
     C-q: quoted-insert
      
     $endif
      
     # An old-style binding.  This happens to be the default.
     TAB: complete
      
     # Macros that are convenient for shell interaction
     $if Bash
     # edit the path
     "\C-xp": "PATH=${PATH}\e\C-e\C-a\ef\C-f"
     # prepare to type a quoted word --
     # insert open and close double quotes
     # and move to just after the open quote
     "\C-x\"": "\"\"\C-b"
     # insert a backslash (testing backslash escapes
     # in sequences and macros)
     "\C-x\\": "\\"
     # Quote the current or previous word
     "\C-xq": "\eb\"\ef\""
     # Add a binding to refresh the line, which is unbound
     "\C-xr": redraw-current-line
     # Edit variable on current line.
     "\M-\C-v": "\C-a\C-k$\C-y\M-\C-e\C-a\C-y="
     $endif
      
     # use a visible bell if one is available
     set bell-style visible
      
     # don't strip characters to 7 bits when reading
     set input-meta on
      
     # allow iso-latin1 characters to be inserted rather
     # than converted to prefix-meta sequences
     set convert-meta off
      
     # display characters with the eighth bit set directly
     # rather than as meta-prefixed characters
     set output-meta on
      
     # if there are more than 150 possible completions for
     # a word, ask the user if he wants to see all of them
     set completion-query-items 150
      
     # For FTP
     $if Ftp
     "\C-xg": "get \M-?"
     "\C-xt": "put \M-?"
     "\M-.": yank-last-arg
     $endif

     # Make Shift-tab act like regular tab - ms4719 - 20120308
     "\e[Z": complete

相关内容