3

Outside tmux I use ctrl-k to erase the line in my terminal with zsh from the cursor to end of line. When I'm in tmux it doesn't work. Below is my tmux.conf:

set-option -g prefix C-a

# From: https://wiki.archlinux.org/title/Tmux
set -g set-titles on
set -g set-titles-string "#T"

set -g status-right '%Y%m%d | %H:%M '

setw -g mode-keys vi

bind C-a last-window
bind | split-window -h
bind - split-window -v
bind m command-prompt -p "join pane from:"  "join-pane -s '%%'"
#bind s command-prompt -p "send pane to:"  "join-pane -t '%%'"
bind s choose-session
bind a send-prefix

# Make tmux forward-word and backward-word with CTRL+arrow
# See http://stackoverflow.com/a/15988701/1679629
set-window-option -g xterm-keys on

What is going on and how to fix that?

2
  • Using tmux under bash, the C-k shortcut works as it always does under a non-tmux shell prompt. Not sure why it doesn't work for you under zsh. Commented Jun 15, 2016 at 0:10
  • 1
    It's up to you to tell the rest of the world what is going on. We're not telepathic. You need to tell us explicitly, in the question, what happens when you press control+k. We know what you did and what you expect as a result. But you haven't said what the computer is doing instead. Always follow the standard litany when asking for help. And for good measure, show people the output of bindkey "^K" in your question, too. Commented Jun 15, 2016 at 7:50

1 Answer 1

6

I had the same problem and realized that bindkey "^K" returns "^K" self-insert in tmux and "^K" kill-line otherwise. After adding explicitly

bindkey \^K kill-line

to my .zshrc it works

2
  • (to whomever changed the bindkey to bind-key, the command to configure key bindings in zsh is bindkey, there's no bind-key command in zsh, (though there is a bind-key directive in tmux configuration files)) Commented Aug 17, 2021 at 8:16
  • It would be interesting to know what changed the binding of ^K from it's default of kill-line. I suspect it's rather that zsh was put in vi mode instead of emacs mode. Possibly because $EDITOR or $VISUAL contains vi. In which case the correct approach would be to add bindkey -e (to get emacs style editing) in ~/.zshrc Commented Aug 17, 2021 at 8:19

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.