带有 tmux 集成的 Iterm2 不使用来自 .tmux.conf 的键绑定 [英] Iterm2 with tmux intergration not using keybindings from .tmux.conf

查看:31
本文介绍了带有 tmux 集成的 Iterm2 不使用来自 .tmux.conf 的键绑定的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 iTerm2 中使用 tmux 已经有一段时间了,但我没有使用 iTerm2 现在附带的 tmux 集成.

I have been using tmux in iTerm2 for a while now but I have not been using the tmux integration that now comes with iTerm2.

我开始考虑使用 tmux 集成,因为它允许您在 tmux 中使用 shell 集成.

I started looking at using the tmux intergration as it allows you to use the shell intergration inside tmux.

我遇到的问题是,在我执行 tmux -CC 之后,我的 .tmux.conf 中没有任何键绑定工作......我什至无法让任何默认值工作.我真的很想使用 tmux 集成,但不能使用,除非我可以让 .tmux.conf 中的键绑定工作.

The problem i am encountering is that after i do tmux -CC none of the key bindings inside my .tmux.conf work... I cant even get any of the defaults to work. I would really like to use tmux integration but cant unless i can get the key bindings in my .tmux.conf to work.

一些不起作用的绑定是;

Some of the bindings that are not working are;

  • 将前缀键反弹到C-s
  • bind-key \ split-window -v -c '#{pane_current_path}'
  • bind-key - split-window -h -c '#{pane_current_path}'

这些只是几个例子,但基本上没有任何效果......

These are just a couple of examples but basically nothing seems to be working...

我的 .tmux.conf 是

My .tmux.conf is

# improve colors
set-option -g default-terminal "screen-256color"

# set base Prefix key to ctrl-s
unbind C-b
set -g prefix C-s
bind-key -r C-s send-prefix

# reload the source config
bind-key r source-file ~/.tmux.conf \; display-message "~/.tmux.conf reloaded"

# Smart pane switching with awareness of Vim splits.
# See: https://github.com/christoomey/vim-tmux-navigator
is_vim="ps -o state= -o comm= -t '#{pane_tty}' \
    | grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|n?vim?x?)(diff)?$'"
bind-key -n C-h if-shell "$is_vim" "send-keys C-h"  "select-pane -L"
bind-key -n C-j if-shell "$is_vim" "send-keys C-j"  "select-pane -D"
bind-key -n C-k if-shell "$is_vim" "send-keys C-k"  "select-pane -U"
bind-key -n C-l if-shell "$is_vim" "send-keys C-l"  "select-pane -R"
bind-key -n C-\ if-shell "$is_vim" "send-keys C-\\" "select-pane -l"

set-option -g status-keys "emacs"

#change colour of status bar
set-option -g status-bg '#666666'
set-option -g status-fg '#aaaaaa'

# set window split
bind-key - split-window -v  -c '#{pane_current_path}'
bind-key \ split-window -h  -c '#{pane_current_path}'

# set text in status bar
set -g status-interval 1
set -g status-justify centre # center align window list
set -g status-left-length 50
set -g status-right-length 140
set -g status-left '#[fg=green]#H #[fg=black]• #[fg=green,bright]#(uname -r | cut -c 1-6)#[default]'
set -g status-right '#[fg=green,bg=default,bright]#(tmux-mem-cpu-load -i 1) #[fg=red,dim,bg=default]#(battery -at) #[fg=white,bg=default]%a%l:%M:%S %p#[default] #[fg=blue]%Y-%m-%d'

# Fine adjustment (1 or 2 cursor cells per bump)
bind -n S-Left resize-pane -L 2
bind -n S-Right resize-pane -R 2
bind -n S-Down resize-pane -D 1
bind -n S-Up resize-pane -U 1

# new window opens in same directory
bind c new-window -c "#{pane_current_path}"

# set window numbering to start from 1
set -g base-index 1
set -g renumber-windows on

# allow to take a pane and put it into new window
bind-key b break-pane -d

# allows ctrl-j to open tree of tmux sessions
bind-key C-j choose-tree

# Use vim keybindings in copy mode
setw -g mode-keys vi

# Setup 'v' to begin selection as in Vim
bind-key -t vi-copy v begin-selection
bind-key -t vi-copy y copy-pipe "reattach-to-user-namespace pbcopy"

# Update default binding of `Enter` to also use copy-pipe
unbind -t vi-copy Enter
bind-key -t vi-copy Enter copy-pipe "reattach-to-user-namespace pbcopy"

# History
set -g history-limit 10000

# Mouse mode
set-option -g mouse on

# Rename Tab
set-option -g set-titles on

# Terminal notifier doesnt work with tmux
set -g default-command "which reattach-to-user-namespace > /dev/null && reattach-to-user-namespace -l $SHELL || $SHELL -l"

set-option -sg escape-time 10

推荐答案

Copying my answer at https://stackoverflow.com/a/47171067/4200039 结束:

Copying my answer at https://stackoverflow.com/a/47171067/4200039 over:

有人在 2015 年 iTerm2 Tmux Integration Default Keybindings not working 报告了类似的错误. 来自开发人员 George Nachman 的回应表明不支持键绑定:

Someone reported a similar bug at iTerm2 Tmux Integration Default Keybindings not working in 2015. The response from the developer George Nachman suggests that keybindings are not supported:

tmux 集成的主要目标之一是您使用 iTerm2 的击键,而不是 tmux.如果您无法执行特定的工作流程本地完成,让我知道——有很多力量在在 iTerm2 中重新映射键的能力.

One of the main goals of the tmux integration is that you use iTerm2's keystrokes, not tmux's. If there's a specific workflow that you can't accomplish natively, let me know--there is a lot of power in the ability to remap keys in iTerm2.

这应该被标记为与 iTerm 的重复2 不遵守 .tmux.conf 中声明的键绑定,但在得到接受或赞成的答案之前,我无法对其进行标记.

This should be flagged as a duplicate of iTerm 2 not honoring key bindings declared in .tmux.conf but I can't flag it until it has an accepted or upvoted answer.

这篇关于带有 tmux 集成的 Iterm2 不使用来自 .tmux.conf 的键绑定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆