Skip to content

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

Closed

Description

@mohak34

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

Activity

  1. cravenceiling commented on Jun 23, 2025

    @cravenceiling
    Contributor

    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

  2. adamdotdevin commented on Jun 23, 2025

    @adamdotdevin
    Member

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

  3. kaedendev commented on Jun 23, 2025

    @kaedendev

    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 😅

  4. benjaminwestern commented on Jun 24, 2025

    @benjaminwestern

    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

  5. mohak34 commented on Jun 24, 2025

    @mohak34
    ContributorAuthor

    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

  6. JezerM commented on Jun 24, 2025

    @JezerM

    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

  7. adamdotdevin commented on Jun 24, 2025

    @adamdotdevin
    Member

    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?

  8. mohak34 commented on Jun 24, 2025

    @mohak34
    ContributorAuthor
    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

  9. kaedendev commented on Jun 24, 2025

    @kaedendev
    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

  10. benjaminwestern commented on Jun 24, 2025

    @benjaminwestern
    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
    
  11. camescasse commented on Jun 25, 2025

    @camescasse

    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'
    
  12. greggannicott commented on Jun 26, 2025

    @greggannicott

    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.

  13. benjaminwestern commented on Jun 26, 2025

    @benjaminwestern

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

  14. lit-af commented on Jun 27, 2025

    @lit-af

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

  15. robin-moser commented on Jul 21, 2025

    @robin-moser
    Contributor

    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.

  16. benjaminwestern commented on Jul 21, 2025

    @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.

    Confirmed! This fixed it <3 :)

  17. mohak34 commented on Jul 21, 2025

    @mohak34
    ContributorAuthor

    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

  18. added a commit that references this issue on Jul 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions