You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在tmux中为退出复制模式绑定自定义按键(如Esc)?

How to Bind Esc to Exit tmux Copy-Mode

Absolutely you can bind the Esc key to exit copy-mode in tmux—this is fully configurable, even if that resource you checked didn’t explicitly list the command you needed. Here’s how to set it up:

  • First, open your tmux configuration file (usually located at ~/.tmux.conf) in your favorite text editor. For example:
    nano ~/.tmux.conf
    
  • Add this line to the file. This binds the Escape key to the command that exits copy-mode:
    bind-key -T copy-mode Escape send-keys -X cancel
    
    Let’s break this down:
    • bind-key -T copy-mode: Tells tmux we’re creating a binding that only applies when we’re in copy-mode.
    • Escape: The key we want to use for this action.
    • send-keys -X cancel: The underlying tmux command that exits copy-mode (this is what the default prefix+q is mapped to under the hood).
  • Save the file and reload your tmux configuration to apply the changes. You can do this by running this command inside a tmux session (press your prefix key first, then type : to open the command prompt):
    source-file ~/.tmux.conf
    

Now, whenever you enter copy-mode (e.g., with prefix+[), pressing the Esc key will immediately exit you back to normal tmux mode. No need to use the prefix key first for this action anymore!

内容的提问来源于stack exchange,提问作者Luke Davis

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.27 09:18:14