diff --git a/random/personal/tmux.md b/random/personal/tmux.md new file mode 100644 index 0000000..0bf5266 --- /dev/null +++ b/random/personal/tmux.md @@ -0,0 +1,114 @@ +# TMUX Configuration File + +# Use Vim-style key bindings for pane selection and copy-mode +setw -g mode-keys vi +set -g status-keys vi + +# Set prefix to Ctrl-A (alternative to the default Ctrl-B) +set-option -g prefix C-a +bind-key C-a send-prefix + +# Reload tmux config with prefix + r +bind r source-file ~/.tmux.conf + +# Improve pane navigation using Vim keys (h, j, k, l) with 'Alt' as modifier +bind-key -n M-h select-pane -L +bind-key -n M-j select-pane -D +bind-key -n M-k select-pane -U +bind-key -n M-l select-pane -R + +# Resize panes with 'Alt' + Arrow keys +bind-key -n M-Left resize-pane -L 2 +bind-key -n M-Down resize-pane -D 2 +bind-key -n M-Up resize-pane -U 2 +bind-key -n M-Right resize-pane -R 2 + +# Enable mouse support for pane selection, resizing, and scrolling +set -g mouse on + +# Open new tmux window with NeoVim using prefix + e +bind-key e new-window "nvim" + +# Status Line Customization +set -g status-style bg=colour235,fg=colour136 +set -g status-left "#[fg=green]Session: #S" +set -g status-right "#[fg=yellow]#H | %Y-%m-%d %H:%M" + +# Customize window list appearance +setw -g window-status-format "#[fg=blue]#I:#W" +setw -g window-status-current-format "#[fg=yellow]#I:#W" + +# Pane Border Colors +set -g pane-border-style fg=colour235 +set -g pane-active-border-style fg=colour136 + +# Synchronize panes: typing in one pane types in all panes +bind-key C-s setw synchronize-panes + +# Quick pane cycling with Ctrl-o +bind-key C-o select-pane -t :.+ +``` + +### Changes and Rationale: + +1. **Vim-style Key Bindings**: Retained for copy-mode and status-line interactions. + +2. **Pane Navigation**: Changed to use `Alt` (`M-`) combined with `h/j/k/l`. This reduces potential conflicts with NeoVim's keybindings. + +3. **Pane Resizing**: Also uses the `Alt` modifier to align with the pane navigation scheme. + +4. **Mouse Support**: No change, as it's essential for a seamless experience. + +5. **NeoVim Integration**: The shortcut for opening NeoVim in a new window (`prefix + e`) remains the same for convenience. + +6. **Status Line and Pane Border Colors**: Unchanged, as they are primarily aesthetic. + +After updating your `~/.tmux.conf`, reload the configuration in an active tmux session with `tmux source-file ~/.tmux.conf`. + +Next, you can share your current NeoVim configuration, and we can align it to complement your tmux setup, ensuring that the two tools work together harmoniously. +User +now provide me a cheatsheet for tmux for all my key-bindings and how to use tmux like starting sessions, getting layouts configured etc. +ChatGPT +Certainly! Below is a concise cheat sheet for tmux, focusing on your customized key-bindings and essential commands for managing sessions, windows, panes, and layouts. + +### Starting and Managing tmux Sessions + +- **Start a New Session**: `tmux` or `tmux new -s [session-name]` +- **List Sessions**: `tmux ls` +- **Attach to a Session**: `tmux attach -t [session-name]` +- **Detach from a Session**: `Ctrl-A` then `D` (while in tmux) +- **Kill a Session**: `tmux kill-session -t [session-name]` + +### Working with Windows + +- **Create a New Window**: `Ctrl-A` then `C` (capital C) +- **Open NeoVim in New Window**: `Ctrl-A` then `e` +- **Switch to Window by Number**: `Ctrl-A` then `[window-number]` +- **Rename Current Window**: `Ctrl-A` then `,` +- **Close Current Window**: Close all panes or `exit` from shell + +### Pane Management + +- **Split Pane Horizontally**: `Ctrl-A` then `"` +- **Split Pane Vertically**: `Ctrl-A` then `%` +- **Navigate Between Panes**: `Alt` + `h/j/k/l` +- **Resize Panes**: `Alt` + `Arrow keys` +- **Toggle Pane Synchronization**: `Ctrl-A` then `C-s` +- **Close Current Pane**: `exit` from shell in that pane + +### Copy Mode and Scrolling + +- **Enter Copy Mode**: `Ctrl-A` then `[` +- **Navigate in Copy Mode**: Vim-style navigation (`h/j/k/l`) +- **Scroll Up/Down**: `Ctrl-A` then `[`, then `PageUp/PageDown` or `Ctrl-B/Ctrl-F` + +### Miscellaneous + +- **Reload tmux Configuration**: `Ctrl-A` then `r` +- **Cycle Through Panes**: `Ctrl-A` then `C-o` +- **Show Shortcuts and Key Bindings**: `Ctrl-A` then `?` + +### Customizing Layouts + +- **Switching Layouts**: `Ctrl-A` then `Space` cycles through pre-set pane layouts. +- **Saving Custom Layouts**: tmux does not have a native layout saving feature, but you can script layouts or use plugins like `tmux-resurrect` or `tmuxinator` for more advanced layout management. \ No newline at end of file