opencode icon indicating copy to clipboard operation
opencode copied to clipboard

New line does not work with Shift+Enter or Ctrl+j

Open mohak34 opened this issue 1 year ago • 17 comments

In the TUI, the new line keybind does not work as mentioned in the docs "input_newline": "shift+enter,ctrl+j",. Thought this might have had something to do with some clashes with terminal or tmux commands but it still does not work without tmux also. When the keybind is used, it just sends the text like the "input_submit": "enter", keybind.

versions Arch Linux 6.15.3 tmux 3.5a Ghostty 1.1.3 opencode v0.1.123

mohak34 avatar Jun 23 '25 19:06 mohak34

The keybind works fine for me in kitty (v0.21.2) with and without tmux (v3.4). In ghostty (v1.0.0-dev+0000000), I can insert a new line by simply pressing shift+enter with or without tmux. If I use shift+enter,ctrl+j, two newlines are inserted.

opencode version 0.1.123

cravenceiling avatar Jun 23 '25 20:06 cravenceiling

as a workaround, you can configure a custom keybind for newline

adamdotdevin avatar Jun 23 '25 21:06 adamdotdevin

~~Weirdest thing, it wasn't working for me (macos, ghostty, tmux) so I added ctrl+j alongside shift+enter, and suddenly shift+enter worked as well. I'm certain opencode was on 0.1.124 the whole time despite restarting it.~~

Edit: I wasn't paying attention, I was detached from tmux 😅

kaedendev avatar Jun 23 '25 23:06 kaedendev

Same issue, only commenting for visibility macos v15.5 tmux v3.5a ghostty v1.1.3 fish v4.0.2 opencode v0.1.126

Pressing Shift + Enter for me simply sends the message to the model

benjaminwestern avatar Jun 24 '25 04:06 benjaminwestern

With tmux detached,

  • Shift+enter and ctrl+j works to create a new line

With tmux attached,

  • Shift+enter submits the prompt
  • ctrl+j does nothing when pressing the keybind

I tried to unbind the shift+enter keybind in tmux and in ghostty and it still does not work in the tmux. I tried adding custom keybinds and no luck with tmux attached.

tmux 3.5a Ghostty 1.1.3 opencode v0.1.123

mohak34 avatar Jun 24 '25 05:06 mohak34

Same issue happens with Zellij. Outside of tmux or zellij, in a normal shell in Ghostty, the Shift+Enter combination in open code works.

zellij 0.42.2 opencode 0.1.126 Ghostty 1.1.3

JezerM avatar Jun 24 '25 09:06 JezerM

so interesting, both keybinds work for me on macos, ghostty, with and without tmux (haven't tried zellij but i will). anyone care to share tmux configs?

adamdotdevin avatar Jun 24 '25 09:06 adamdotdevin

unbind r
bind r source-file ~/.tmux.conf

set -g prefix C-s

set -g mouse on
set-option -g status-position bottom
set -g base-index 1
setw -g pane-base-index 1

# Pane navigation
bind-key h select-pane -L
bind-key j select-pane -D
bind-key k select-pane -U
bind-key l select-pane -R

# Window navigation (without prefix)
bind-key -n M-h previous-window
bind-key -n M-l next-window

# Switch to windows using Alt + number (no prefix)
bind-key -n M-1 select-window -t :1
bind-key -n M-2 select-window -t :2
bind-key -n M-3 select-window -t :3
bind-key -n M-4 select-window -t :4
bind-key -n M-5 select-window -t :5
bind-key -n M-6 select-window -t :6
bind-key -n M-7 select-window -t :7
bind-key -n M-8 select-window -t :8
bind-key -n M-9 select-window -t :9
bind-key -n M-0 select-window -t :0

#Plugins setup
set -g @plugin 'tmux-plugins/tpm'
# set -g @plugin 'catppuccin/tmux#v0.3.0'
set -g @plugin 'tmux-plugins/tmux-resurrect'
set -g @plugin "adibhanna/gruvbox-tmux"
set -g @gruvbox-theme dark # dark or light
set -g @plugin 'christoomey/vim-tmux-navigator'

# set -g @catppuccin_window_left_separator ""
# set -g @catppuccin_window_right_separator " "
# set -g @catppuccin_window_middle_separator " █"
# set -g @catppuccin_window_number_position "right"
#
# set -g @catppuccin_window_default_fill "number"
# set -g @catppuccin_window_default_text "#W"
#
# set -g @catppuccin_window_current_fill "number"
# set -g @catppuccin_window_current_text "#W"
#
# set -g @catppuccin_status_modules_right "directory session"
# set -g @catppuccin_status_left_separator  " "
# set -g @catppuccin_status_right_separator ""
# set -g @catppuccin_status_fill "icon"
# set -g @catppuccin_status_connect_separator "no"
#
# set -g @catppuccin_directory_text "#{pane_current_path}"
#
# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
run '~/.tmux/plugins/tpm/tpm'

tmux version tmux 3.5a

mohak34 avatar Jun 24 '25 09:06 mohak34

set -g mouse on
set -sg escape-time 10
setw -g prefix C-s

unbind r
bind r source-file ~/.tmux.conf \; display "Reloaded!"

setw -g mode-keys vi
bind-key h select-pane -L
bind-key j select-pane -D
bind-key k select-pane -U
bind-key l select-pane -R
bind-key s choose-session

# Plugins
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-sensible'
 
set -g @plugin 'tmux-plugins/tmux-resurrect'
set -g @plugin 'tmux-plugins/tmux-continuum'
set -g @resurrect-strategy-nvim 'session'
set -g @continuum-restore 'on'
set -g @resurrect-save 'Z'

# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
run '~/.tmux/plugins/tpm/tpm'

tmux version 3.5a

kaedendev avatar Jun 24 '25 21:06 kaedendev

set-option -sa terminal-overrides ",xterm*:Tc"
set-option -g focus-events on
set -g mouse on

# Start windows and panes at 1, not 0
set -g base-index 1
set -g pane-base-index 1
set-window-option -g pane-base-index 1
set-option -g renumber-windows on

# Shift arrow to switch windows
bind -n S-Left  previous-window
bind -n S-Right next-window

# Reorder windows with Shift Left/Right
bind-key -n C-S-Left swap-window -t -1\; select-window -t -1
bind-key -n C-S-Right swap-window -t +1\; select-window -t +1

# Move between panes
bind -n C-h select-pane -L
bind -n C-j select-pane -D
bind -n C-k select-pane -U
bind -n C-l select-pane -R

# Resize panes
bind -n C-M-h resize-pane -L 5
bind -n C-M-j resize-pane -D 5
bind -n C-M-k resize-pane -U 5
bind -n C-M-l resize-pane -R 5

set -g @plugin 'dracula/tmux'

set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-sensible'

set -g @dracula-plugins " "

set -g @dracula-show-flags false
set -g @dracula-show-empty-plugins false
set -g @dracula-show-left-icon session

benjaminwestern avatar Jun 24 '25 22:06 benjaminwestern

here's mine:

set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-sensible'
set -g @plugin 'Nybkox/tmux-kanagawa'

unbind C-b
set -g prefix C-a
bind C-a send-prefix

set -g base-index 1
setw -g pane-base-index 1
set -g mouse on

set -g @kanagawa-plugins "time"
set -g @kanagawa-show-powerline true
set -g @kanagawa-show-left-icon session
set -g @kanagawa-time-format "%R"
set -g @kanagawa-refresh-rate 2
set -g @kanagawa-theme 'dragon'
set -g @kanagawa-ignore-window-colors true

if "test ! -d ~/.tmux/plugins/tpm" \
   "run 'git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm && ~/.tmux/plugins/tpm/bin/install_plugins'"

run '~/.tmux/plugins/tpm/tpm'

camescasse avatar Jun 25 '25 19:06 camescasse

If it helps, I didn't have this issue until I just updated to MacOS 15.5. I was on 14.n (not sure which sorry) prior to this.

There was no update of OpenCode between it working and not working.

shift+enter fails for me when inside of tmux but works fine outside of it.

Thanks.

greggannicott avatar Jun 26 '25 12:06 greggannicott

If it helps, gemini-cli has the same issue :)

benjaminwestern avatar Jun 26 '25 22:06 benjaminwestern

shift+enter fails for me on ubuntu 22.04 inside Terminator v2.1.1 but ctrl+j works fine.

lit-af avatar Jun 27 '25 20:06 lit-af

i fixed Shift+Enter on MacOS, Ghostty and tmux 3.5a by setting following option in my .tmux.conf:

set -g extended-keys always

as far as I could tell while testing, this replicates the exact behaviour I would get without running tmux.

robin-moser avatar Jul 21 '25 10:07 robin-moser

i fixed Shift+Enter on MacOS, Ghostty and tmux 3.5a by setting following option in my .tmux.conf:

set -g extended-keys always as far as I could tell while testing, this replicates the exact behaviour I would get if I without running tmux.

Confirmed! This fixed it <3 :)

benjaminwestern avatar Jul 21 '25 10:07 benjaminwestern

i fixed Shift+Enter on MacOS, Ghostty and tmux 3.5a by setting following option in my .tmux.conf:

set -g extended-keys always

as far as I could tell while testing, this replicates the exact behaviour I would get if I without running tmux.

Yup! This fixed it. Closing this issue

mohak34 avatar Jul 21 '25 12:07 mohak34