zellij-org / zellij

A terminal workspace with batteries included
https://zellij.dev
MIT License
19.46k stars 613 forks source link

Provide a config option to disable all keybindings and leave the tmux mode #2125

Open rumpelsepp opened 1 year ago

rumpelsepp commented 1 year ago

You can get Zellij to behave exactly like tmux with a little bit of config (namely using clear-defaults=true on the main keybinds node and only leaving the tmux mode keys).

Would it be complicated to provide a config option (e.g. tmux-emulation-mode or similar) which does exactly that what you're saying? Then people could just flip that switch.

Originally posted by @rumpelsepp in https://github.com/zellij-org/zellij/issues/1399#issuecomment-1409914423

t3hmrman commented 1 week ago

For people who might run into this, you can actually piece together a decent config pretty quickly by referencing the default default.kdl config (hopefully that link doesn't break in the future!).

To get you started quickly here's what I've hacked together to mirror my own tmux setup:

My tmux-like config so far ```kdl // If you'd like to override the default keybindings completely, be sure to change "keybinds" to "keybinds clear-defaults=true" keybinds clear-defaults=true { tmux { bind "[" { SwitchToMode "Scroll"; } // Leave tmux mode bind "Ctrl b" { Write 2; SwitchToMode "Normal"; } bind "z" { ToggleFocusFullscreen; SwitchToMode "Normal"; } // Tab creation bind "c" { NewTab; SwitchToMode "Normal"; } bind "t" { NewTab; SwitchToMode "Normal"; } // Session manager bind "s" "$" ":" { LaunchOrFocusPlugin "session-manager" { floating true move_to_focused_tab true }; SwitchToMode "Normal" } // Splitting panes // bind "\"" { NewPane "Down"; SwitchToMode "Normal"; } // bind "%" { NewPane "Right"; SwitchToMode "Normal"; } bind "|" { NewPane "Right"; SwitchToMode "Normal"; } bind "-" { NewPane "Down"; SwitchToMode "Normal"; } // Moving between tabs bind "p" { GoToPreviousTab; SwitchToMode "Normal"; } bind "n" { GoToNextTab; SwitchToMode "Normal"; } // Renaming tabs bind "," { SwitchToMode "RenameTab"; TabNameInput 0; } // Moving between panes bind "Left" { MoveFocus "Left"; SwitchToMode "Normal"; } bind "Right" { MoveFocus "Right"; SwitchToMode "Normal"; } bind "Down" { MoveFocus "Down"; SwitchToMode "Normal"; } bind "Up" { MoveFocus "Up"; SwitchToMode "Normal"; } bind "h" { MoveFocus "Left"; SwitchToMode "Normal"; } bind "l" { MoveFocus "Right"; SwitchToMode "Normal"; } bind "j" { MoveFocus "Down"; SwitchToMode "Normal"; } bind "k" { MoveFocus "Up"; SwitchToMode "Normal"; } // Renaming panes bind "." { SwitchToMode "RenamePane"; PaneNameInput 0; } // Resizing panes bind "H" { Resize "Increase Left"; } bind "L" { Resize "Increase Right"; } bind "K" { Resize "Increase Up"; } bind "J" { Resize "Increase Down"; } // bind "o" { FocusNextPane; } bind "d" { Detach; } bind "Space" { NextSwapLayout; } bind "x" { CloseFocus; SwitchToMode "Normal"; } } scroll { bind "j" "Down" { ScrollDown; } bind "k" "Up" { ScrollUp; } bind "PageDown" "l" { PageScrollDown; } bind "PageUp" "h" { PageScrollUp; } bind "d" { HalfPageScrollDown; } bind "u" { HalfPageScrollUp; } bind "Esc" { SwitchToMode "Normal"; } // uncomment this and adjust key if using copy_on_select=false // bind "Alt c" { Copy; } } session { bind "Ctrl o" { SwitchToMode "Normal"; } } renametab { bind "Ctrl b" { SwitchToMode "Normal"; } bind "Enter" { SwitchToMode "Normal"; } bind "Esc" { UndoRenameTab; SwitchToMode "Normal"; } } renamepane { bind "Enter" { SwitchToMode "Normal"; } bind "Ctrl c" { SwitchToMode "Normal"; } bind "Esc" { UndoRenamePane; SwitchToMode "Pane"; } } shared_except "tmux" "locked" { // Enter tmux mode bind "Ctrl b" { SwitchToMode "Tmux"; } } } plugins { tab-bar location="zellij:tab-bar" // note(2024/06/25): Don't need status bar with tmux bindings status-bar location="zellij:status-bar" strider location="zellij:strider" compact-bar location="zellij:compact-bar" session-manager location="zellij:session-manager" welcome-screen location="zellij:session-manager" { welcome_screen true } filepicker location="zellij:strider" { cwd "/" } } // Choose what to do when zellij receives SIGTERM, SIGINT, SIGQUIT or SIGHUP // eg. when terminal window with an active zellij session is closed // Options: // - detach (Default) // - quit // // on_force_close "quit" // Send a request for a simplified ui (without arrow fonts) to plugins // Options: // - true // - false (Default) // // simplified_ui true // Choose the path to the default shell that zellij will use for opening new panes // Default: $SHELL // // default_shell "fish" // Choose the path to override cwd that zellij will use for opening new panes // // default_cwd "" // Toggle between having pane frames around the panes // Options: // - true (default) // - false // // pane_frames true // Toggle between having Zellij lay out panes according to a predefined set of layouts whenever possible // Options: // - true (default) // - false // // auto_layout true // Whether sessions should be serialized to the cache folder (including their tabs/panes, cwds and running commands) so that they can later be resurrected // Options: // - true (default) // - false // // session_serialization false // Whether pane viewports are serialized along with the session, default is false // Options: // - true // - false (default) // serialize_pane_viewport true // Scrollback lines to serialize along with the pane viewport when serializing sessions, 0 // defaults to the scrollback size. If this number is higher than the scrollback size, it will // also default to the scrollback size. This does nothing if `serialize_pane_viewport` is not true. // // scrollback_lines_to_serialize 10000 // Define color themes for Zellij // For more examples, see: https://github.com/zellij-org/zellij/tree/main/example/themes // Once these themes are defined, one of them should to be selected in the "theme" section of this file // // themes { // dracula { // fg 248 248 242 // bg 40 42 54 // red 255 85 85 // green 80 250 123 // yellow 241 250 140 // blue 98 114 164 // magenta 255 121 198 // orange 255 184 108 // cyan 139 233 253 // black 0 0 0 // white 255 255 255 // } // } // Choose the theme that is specified in the themes section. // Default: default // // theme "default" // The name of the default layout to load on startup // Default: "default" // default_layout "disable-status-bar" // Choose the mode that zellij uses when starting up. // Default: normal // // default_mode "locked" // Toggle enabling the mouse mode. // On certain configurations, or terminals this could // potentially interfere with copying text. // Options: // - true (default) // - false // // mouse_mode false // Configure the scroll back buffer size // This is the number of lines zellij stores for each pane in the scroll back // buffer. Excess number of lines are discarded in a FIFO fashion. // Valid values: positive integers // Default value: 10000 // // scroll_buffer_size 10000 // Provide a command to execute when copying text. The text will be piped to // the stdin of the program to perform the copy. This can be used with // terminal emulators which do not support the OSC 52 ANSI control sequence // that will be used by default if this option is not set. // Examples: // // copy_command "xclip -selection clipboard" // x11 // copy_command "wl-copy" // wayland // copy_command "pbcopy" // osx // Choose the destination for copied text // Allows using the primary selection buffer (on x11/wayland) instead of the system clipboard. // Does not apply when using copy_command. // Options: // - system (default) // - primary // // copy_clipboard "primary" // Enable or disable automatic copy (and clear) of selection when releasing mouse // Default: true // // copy_on_select false // Path to the default editor to use to edit pane scrollbuffer // Default: $EDITOR or $VISUAL // // scrollback_editor "/usr/bin/vim" // When attaching to an existing session with other users, // should the session be mirrored (true) // or should each user have their own cursor (false) // Default: false // // mirror_session true // The folder in which Zellij will look for layouts // // layout_dir "/path/to/my/layout_dir" // The folder in which Zellij will look for themes // // theme_dir "/path/to/my/theme_dir" // Enable or disable the rendering of styled and colored underlines (undercurl). // May need to be disabled for certain unsupported terminals // Default: true // // styled_underlines false // Enable or disable writing of session metadata to disk (if disabled, other sessions might not know // metadata info on this session) // Default: false // // disable_session_metadata true ```

The few places I haven't checked (so they might need tweaks) so much are scroll, but happy with it so far. It's pretty easy to look at your tmux.conf and port custom keybindings to the format zellij expects.