Skip to content

Commit 7a2a76b

Browse files
committed
fix(tmux.conf): send shift+enter to allow newlines in opencode
1 parent 50a8f75 commit 7a2a76b

1 file changed

Lines changed: 16 additions & 4 deletions

File tree

‎home/.config/tmux/tmux.conf‎

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,14 +86,26 @@ bind-key r source-file ~/.config/tmux/tmux.conf \; display "Reloaded!"
8686
# See: https://github.com/christoomey/vim-tmux-navigator#additional-customization
8787
send_pattern='(n?vim|fzf|lazygit)'
8888

89+
# Allows apps like Opencode to distinguish Shift+Enter from plain Enter
90+
# by sending Shift+Enter as CSI u escape sequence (\e[13;2u):
91+
# - 13=Enter
92+
# - 2=Shift
93+
# Encoded as hex bytes:
94+
# As hex bytes:
95+
# - 1b=ESC, 5b=[, 31 33=13, 3b=;, 32=2, 75=u
96+
# → \e[13;2u
97+
#
98+
# See https://github.com/anomalyco/opencode/issues/167#issuecomment-3921500916
99+
bind-key -n S-Enter send-keys -H 1b 5b 31 33 3b 32 75
100+
89101
# More efficient process check
90102
should_send="ps -o comm= -t '#{pane_tty}' | grep -iqE '${send_pattern}'"
91103

92104
# Cleaner bind commands using tmux's conditional syntax
93-
bind-key -n 'C-h' if-shell "$should_send" 'send-keys C-h' 'select-pane -L'
94-
bind-key -n 'C-j' if-shell "$should_send" 'send-keys C-j' 'select-pane -D'
95-
bind-key -n 'C-k' if-shell "$should_send" 'send-keys C-k' 'select-pane -U'
96-
bind-key -n 'C-l' if-shell "$should_send" 'send-keys C-l' 'select-pane -R'
105+
bind-key -n C-h if-shell "$should_send" 'send-keys C-h' 'select-pane -L'
106+
bind-key -n C-j if-shell "$should_send" 'send-keys C-j' 'select-pane -D'
107+
bind-key -n C-k if-shell "$should_send" 'send-keys C-k' 'select-pane -U'
108+
bind-key -n C-l if-shell "$should_send" 'send-keys C-l' 'select-pane -R'
97109

98110
# Allow for switching panes using Vim commands when in copy mode
99111
bind-key -T copy-mode-vi 'C-h' select-pane -L

0 commit comments

Comments
 (0)