commit 3cf28aa7a498f766828e2fa51011ca2435552995 Author: Marat Kharitonov Date: Thu Aug 6 23:26:42 2026 +0300 tmux: перенос конфига (бинды, мышь, темы, автосохранение) + README diff --git a/README.md b/README.md new file mode 100644 index 0000000..f68e6d7 --- /dev/null +++ b/README.md @@ -0,0 +1,103 @@ +# dotenv + +Персональный конфиг терминального воркспейса: tmux + (опционально) VS Code. + +Содержимое: + +- `tmux.conf` — конфиг tmux: бинды, мышь, тема, сохранитель сессий. +- `vscode-keybindings.json` — переопределение клавиш VS Code, чтобы `Alt+стрелки` + уходили в tmux как навигация по панелям (нужно только если используешь VS Code). + +## Установка tmux + +### 1. Скопировать конфиг + +```bash +mkdir -p ~/.config/tmux/plugins +cp tmux.conf ~/.config/tmux/tmux.conf +``` + +### 2. Поставить TPM (менеджер плагинов — единственное ставится вручную) + +```bash +git clone https://github.com/tmux-plugins/tpm ~/.config/tmux/plugins/tpm +``` + +### 3. Запустить tmux и доустановить плагины + +```bash +tmux new -s main +``` + +Внутри tmux нажми: + +``` +Ctrl+b , затем I +``` + +TPM прочитает строки `@plugin '...'` из `tmux.conf` и поставит: + +- `egel/tmux-gruvbox` — тема оформления; +- `tmux-plugins/tmux-resurrect` — сохранение/восстановление сессии (`Ctrl+b Ctrl+s` / `Ctrl+b Ctrl+r`); +- `tmux-plugins/tmux-continuum` — автосохранение каждые 15 сек и автовосстановление при старте. + +Если что-то не подхватилось — перезапусти tmux (или `Ctrl+b I` ещё раз). + +## Горячие клавиши tmux (из tmux.conf) + +| Комбинация | Действие | +|---|---| +| `Alt+h` / `Alt+v` | сплит панели (вертикаль / горизонталь) | +| `Alt+←↑→↓` | переключение панели | +| `Alt+Shift+←↑→↓` | resize панели | +| `Alt+1..9` | выбор окна | +| `Alt+n` | новое окно | +| `Alt+c` / `Alt+q` | убить панель / окно | +| `Alt+d` | detach | +| `Alt+x` | перезагрузить конфиг | +| в copy-mode: `v` выделить, `y` скопировать | копирование в буфер | + +> `Alt+r` (старый reload) и `Alt+Enter` (новое окно) **не используются** — их ест +> терминал/ОС (полноэкранный режим Windows). Поэтому reload = `Alt+x`, окно = `Alt+n`. + +Мышь включена (`set -g mouse on`): клик по панели, скролл колесом, resize границей. + +## Проблема с копированием в буфер + +Копирование идёт через команду: + +``` +clip.exe || wl-copy || xclip -in -selection clipboard +``` + +- на **WSL** (Windows) работает `clip.exe` — текст попадает в Windows-буфер; +- на чистом **Linux** понадобится `wl-clipboard` (`wl-copy`) или `xclip`: + ```bash + sudo apt install xclip # или: sudo apt install wl-clipboard + ``` + +## (Опционально) VS Code — чтобы работали `Alt+стрелки` + +Без этого в терминале VS Code голые `Alt+←→` перехватываются как word-jump и не +доходят до tmux. Решение — скопировать `vscode-keybindings.json` в конфиг VS Code: + +**Windows:** `%APPDATA%\Code\User\keybindings.json` +**Linux:** `~/.config/Code/User/keybindings.json` + +```bash +cp vscode-keybindings.json "$APPDATA/Code/User/keybindings.json" # Windows +# или на Linux: +cp vscode-keybindings.json ~/.config/Code/User/keybindings.json +``` + +Затем в VS Code: `Ctrl+Shift+P` → **Reload Window**. + +> Файл дополняет, а не заменяет: если в ключбиндингах уже что-то есть — слей вручную, +> а не перезаписывай вслепую. + +## Обновление/правки + +Держи `tmux.conf` в репе и правишь его как код. Перенос на другую машину = `git clone` +этого репо + шаги 1–3 выше. + +Сам `tmux.conf` в репе — актуальный «живой» конфиг с этого компа. diff --git a/tmux.conf b/tmux.conf new file mode 100644 index 0000000..79536a2 --- /dev/null +++ b/tmux.conf @@ -0,0 +1,60 @@ +set -g pane-border-lines "double" +set -g default-terminal "xterm-256color" +set -g base-index 1 +setw -g pane-base-index 1 +set -g renumber-windows on + +#setw -g mode-keys nano + +set -g mouse on + +set -s escape-time 0 + +set -g history-limit 2000 + +bind -n M-r source-file ~/.config/tmux/tmux.conf \; display "Config reloaded!" +bind -n M-x source-file ~/.config/tmux/tmux.conf \; display "Config reloaded!" +bind -n M-s choose-tree -s + +bind -n M-1 select-window -t 1 +bind -n M-2 select-window -t 2 +bind -n M-3 select-window -t 3 +bind -n M-4 select-window -t 4 +bind -n M-5 select-window -t 5 +bind -n M-6 select-window -t 6 +bind -n M-7 select-window -t 7 +bind -n M-8 select-window -t 8 +bind -n M-9 select-window -t 9 + +bind -n M-Left select-pane -L +bind -n M-Right select-pane -R +bind -n M-Up select-pane -U +bind -n M-Down select-pane -D + +bind -n M-S-Left resize-pane -L 5 +bind -n M-S-Right resize-pane -R 5 +bind -n M-S-Up resize-pane -U 3 +bind -n M-S-Down resize-pane -D 3 + +bind -n M-h split-window -v +bind -n M-v split-window -h + +bind -n M-n new-window +bind -n M-c kill-pane +bind -n M-q kill-window +bind -n M-d detach +bind -n M-Q confirm-before -p "Kill entire session? (y/n)" kill-session + +bind -T copy-mode-vi v send -X begin-selection +bind -T copy-mode-vi y send -X copy-pipe-and-cancel "clip.exe || wl-copy || xclip -in -selection clipboard" +bind -T copy-mode-vi MouseDragEnd1Pane send -X copy-pipe-and-cancel "clip.exe || wl-copy || xclip -in -selection clipboard" +bind -n M-/ copy-mode \; command-prompt -p "(search down)" "send -X search-forward '%%%'" +bind -n M-? copy-mode \; command-prompt -p "(search up)" "send -X search-backward '%%%'" + +set -g @plugin 'tmux-plugins/tpm' +set -g @plugin 'egel/tmux-gruvbox' +set -g @plugin 'tmux-plugins/tmux-resurrect' +set -g @plugin 'tmux-plugins/tmux-continuum' +set -g @continuum-restore 'on' +set -g @continuum-save-interval '15' +run '~/.config/tmux/plugins/tpm/tpm' diff --git a/vscode-keybindings.json b/vscode-keybindings.json new file mode 100755 index 0000000..0188d3b --- /dev/null +++ b/vscode-keybindings.json @@ -0,0 +1,49 @@ +// Поместите настраиваемые сочетания клавиш в этот файл, чтобы переопределить сочетания клавиш по умолчанию. +[ + { + "key": "ctrl+shift+p", + "command": "-workbench.action.showCommands" + }, + { + "key": "ctrl+p", + "command": "-workbench.action.quickOpen" + }, + { + "key": "ctrl+p", + "command": "-workbench.action.quickOpenNavigateNextInFilePicker", + "when": "inFilesPicker && inQuickOpen" + }, + { + "key": "ctrl+shift+p", + "command": "-workbench.action.quickOpenNavigatePreviousInFilePicker", + "when": "inFilesPicker && inQuickOpen" + }, + { + "key": "ctrl+m", + "command": "-editor.action.toggleTabFocusMode" + }, + { + "key": "alt+left", + "command": "workbench.action.terminal.sendSequence", + "args": { "text": "\u001b[1;3D" }, + "when": "terminalFocus" + }, + { + "key": "alt+right", + "command": "workbench.action.terminal.sendSequence", + "args": { "text": "\u001b[1;3C" }, + "when": "terminalFocus" + }, + { + "key": "alt+up", + "command": "workbench.action.terminal.sendSequence", + "args": { "text": "\u001b[1;3A" }, + "when": "terminalFocus" + }, + { + "key": "alt+down", + "command": "workbench.action.terminal.sendSequence", + "args": { "text": "\u001b[1;3B" }, + "when": "terminalFocus" + } +] \ No newline at end of file