commit d34e5aad31968e8915deb18f92626c29e15cfc44 Author: Tomasz Kapias Date: Sun Mar 19 01:35:56 2023 +0700 first commit diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..bd9bd54 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,15 @@ +[submodule "plugins/tpm"] + path = plugins/tpm + url = https://github.com/tmux-plugins/tpm +[submodule "plugins/tmux-prefix-highlight"] + path = plugins/tmux-prefix-highlight + url = https://github.com/tmux-plugins/tmux-prefix-highlight +[submodule "plugins/tmux-menus"] + path = plugins/tmux-menus + url = https://github.com/jaclu/tmux-menus +[submodule "plugins/extrakto"] + path = plugins/extrakto + url = https://github.com/laktak/extrakto +[submodule "plugins/tmux-sidebar"] + path = plugins/tmux-sidebar + url = https://github.com/tmux-plugins/tmux-sidebar diff --git a/README.md b/README.md new file mode 100644 index 0000000..20971a7 --- /dev/null +++ b/README.md @@ -0,0 +1,141 @@ +# [tmuxrc][tmuxrc_repo] + +![Tmux](https://img.shields.io/badge/tmux-v3.3-brightgreen) +![Fzf](https://img.shields.io/badge/fzf-v0.35-green) + +**tmuxrc** is a collection of [RUNCOM][RUNCOM] & plugins dedicated to the terminal multiplexer [Tmux][TMUX_repo]. + +- I use this configuration with my custom [bash environment][bashrc_repo] to always work in Tmux locally and in SSH sessions. + +---- + +## Features + +- Plugins: + - [tpm][tpm]: Plugin Manager + - [tmux-prefix-highlight][tmux-prefix-highlight]: highlights when you press tmux prefix key + - [tmux-menus][tmux-menus]: Popup menus + - [extrakto][extrakto]: quickly select, copy/insert/complete text without a mouse + - [tmux-sidebar][tmux-sidebar]: directory tree for the current path +- Usage of popups and fzf +- Some defaults are now toggle modes, like sync or zoom +- Simple true color theme +- Compatible withe my environment config: [bashrc][bashrc_repo] +- Check more in the conf file ... + +## Requirements + +- [Tmux][TMUX_repo] 3.3+: + - libevent 2.x (apt or [build][libevent_repo]) + - ncurses (apt or [build][ncurses_repo]) +- [Gitmux][gitmux_repo] +- [Fzf][fzf_repo] 0.35+ for `fzf-tmux` + +### Recommended + +- bash 5+ +- bash_completion +- My environment config: [bashrc][bashrc_repo] + +## Installation + +### Tmux + +- With APT: + +```bash +# chech version with apt +sudo apt show tmux 2> /dev/null | grep Version: + +# if your apt repositories deliver at least 3.3, you can install it +sudo apt install tmux +``` + +- Or build & install: + +```bash +mkdir -p $HOME/Builds && cd $HOME/Builds +wget https://github.com/tmux/tmux/releases/download/3.3a/tmux-3.3a.tar.gz +tar -zxf tmux-*.tar.gz +cd tmux-*/ +./configure +make && make install +``` + +### Gitmux + +- Copy it manually to /usr/local/bin: https://github.com/arl/gitmux/releases + +- Or you need jq to parse the latest release in cli: + +```bash +# for linux_amd64 +sudo apt install jq +_RELEASES=$(curl -s https://api.github.com/repos/arl/gitmux/releases/latest) +_URL=$(echo "$_RELEASES" | jq -r '.assets[] | select( .name | match("linux_amd64")) | .browser_download_url') +wget -c -nv "$_URL" -O - | sudo tar --no-same-owner -xzv -C /usr/local/bin gitmux +``` + +### Fzf + +- With APT: + +```bash +# chech version with apt +sudo apt show fzf 2> /dev/null | grep Version: + +# if your apt repositories deliver at least 0.35, you can install it +sudo apt install tmux +``` + +- Or build & install: + +```bash +mkdir -p $HOME/Builds && cd $HOME/Builds +git clone --depth 1 https://github.com/junegunn/fzf.git +cd fzf +sudo ./install --all --no-bash --no-zsh --no-fish +sudo cp shell/completion.bash /etc/bash_completion.d/fzf +sudo cp bin/* /usr/local/bin/ +``` + +### TmuxRC + +```bash +# backup current files +mkdir -p $HOME/.backups +cp -r --backup=t {"$HOME"/.tmux/,"$HOME"/.tmux,"$HOME"/.config/tmux/} $HOME/.backups/ +rm -Rf "$HOME"/.tmux/ "$HOME"/.tmux "$HOME"/.config/tmux/ + +mkdir -p $HOME/.config +cd $HOME/.config +git clone --depth=1 --recurse-submodules https://git.tkapias.net/tkapias/tmuxrc +``` + +## Configuration + +### SSH/Remote + +If you install this configuration on a remote system you want another prefix than on the local tmux (ctrl+x). + +You can change the prefix to ctrl+w on the remote like this: + +```bash +sed -i -e 's/C-x/C-w/g' -e 's/Ctrl-x/Ctrl-w/g' $HOME/.tmux.conf +``` + +---- + +[//]: # (LINKS) +[tmuxrc_repo]: https://git.tkapias.net/tkapias/tmuxrc +[TMUX_repo]: https://github.com/tmux/tmux +[bashrc_repo]: https://git.tkapias.net/tkapias/bashrc +[RUNCOM]: https://en.wikipedia.org/wiki/RUNCOM +[libevent_repo]: https://github.com/libevent/libevent/releases/latest +[ncurses_repo]: https://invisible-mirror.net/archives/ncurses/ +[gitmux_repo]: https://github.com/arl/gitmux +[tpm]: https://github.com/tmux-plugins/tpm +[tmux-prefix-highlight]: https://github.com/tmux-plugins/tmux-prefix-highlight +[tmux-menus]: https://github.com/jaclu/tmux-menus +[extrakto]: https://github.com/laktak/extrakto +[tmux-sidebar]: https://github.com/tmux-plugins/tmux-sidebar diff --git a/plugins/extrakto b/plugins/extrakto new file mode 160000 index 0000000..efca898 --- /dev/null +++ b/plugins/extrakto @@ -0,0 +1 @@ +Subproject commit efca89800293cbb8224463d82eeecffdb2f7036a diff --git a/plugins/tmux-menus b/plugins/tmux-menus new file mode 160000 index 0000000..ab82aee --- /dev/null +++ b/plugins/tmux-menus @@ -0,0 +1 @@ +Subproject commit ab82aee4845899d75943dd3ad46296f542ec471f diff --git a/plugins/tmux-prefix-highlight b/plugins/tmux-prefix-highlight new file mode 160000 index 0000000..15acc61 --- /dev/null +++ b/plugins/tmux-prefix-highlight @@ -0,0 +1 @@ +Subproject commit 15acc6172300bc2eb13c81718dc53da6ae69de4f diff --git a/plugins/tmux-sidebar b/plugins/tmux-sidebar new file mode 160000 index 0000000..a41d72c --- /dev/null +++ b/plugins/tmux-sidebar @@ -0,0 +1 @@ +Subproject commit a41d72c019093fd6a1216b044e111dd300684f1a diff --git a/plugins/tpm b/plugins/tpm new file mode 160000 index 0000000..99469c4 --- /dev/null +++ b/plugins/tpm @@ -0,0 +1 @@ +Subproject commit 99469c4a9b1ccf77fade25842dc7bafbc8ce9946 diff --git a/sidebar/directory_widths.txt b/sidebar/directory_widths.txt new file mode 100644 index 0000000..e69de29 diff --git a/tmux.conf b/tmux.conf new file mode 100644 index 0000000..8771667 --- /dev/null +++ b/tmux.conf @@ -0,0 +1,192 @@ +# git init $HOME/.config/tmux/plugins +# cd $HOME/.config/tmux/plugins +# git submodule init +# git submodule add https://github.com/tmux-plugins/tpm +# git submodule add https://github.com/tmux-plugins/tmux-prefix-highlight +# git submodule add https://github.com/jaclu/tmux-menus +# git submodule add https://github.com/laktak/extrakto +# git submodule add https://github.com/tmux-plugins/tmux-sidebar + +# ----- Prefix ----- + +# Rebind the prefix to Ctrl+x +unbind-key C-b +set-option -g prefix C-x +bind-key C-x send-prefix + +# ----- Panes ----- + +# Splits open in the current working directory +bind-key '"' split-window -c "#{pane_current_path}" +bind-key '%' split-window -h -c "#{pane_current_path}" + +# Bind "a" to toggle sync mode on all panes with an active border color +bind-key a if -F '#{pane_synchronized}' \ + 'set-window-option synchronize-panes off; \ + set-window-option pane-active-border-style fg=colour02; \ + set-window-option pane-border-style fg=colour04' \ + 'set-window-option synchronize-panes on; \ + set-window-option pane-active-border-style fg=colour02; \ + set-window-option pane-border-style fg=colour02' + +# Bind 2 repeatable keys to switch panes and zoom in. Just zomming in is rebinded to "Z" +unbind-key z +bind-key Z resize-pane -Z +bind-key -r e select-pane -t .+1 \; resize-pane -Z +bind-key -r z select-pane -t .-1 \; resize-pane -Z + +# Add a status for each pane with index, title and command +set -g pane-border-status bottom +set -g pane-border-format '#{pane_index} #{pane_title} > #(sleep 1; ps -t #{pane_tty} --no-headers -o command | tail -1)' + +# Add a shortcup to interactively rename the title of the current pane +bind-key P command-prompt -I 'select-pane -T ' + +# Seperator colors for current pane +set-option -g pane-active-border-style fg=colour02 + +# Seperator color for other panes +set-option -g pane-border-style fg=colour04 + +# ----- Status Bar ----- + +# Colors for the status bar +set -g status-bg 'colour00' +set -g status-fg 'colour08' + +# Contents on the right of the status bar +set -g status-right '#(gitmux -timeout 3s -cfg ~/.config/gitmux.conf "#{pane_current_path}") #{prefix_highlight}' +set -g status-interval 1 +set -g status-right-length 45 + +# Contents on the left of the status bar +set -g status-left '#[fg=colour03,bg=colour08,bold][#S]#[bg=default] ' +set -g status-left-length 32 + +# Position of the status bar +# (top/bottom) +set -g status-position bottom + +# Position of the window status +# (left/centre/right) +set -g status-justify left + +# Color of the status bar message +set-option -g message-style bg=colour04,fg=colour08 + +# ----- Windows ----- + +# open a fzf popup session changer +bind-key C-j display-popup -E "tmux list-sessions | sed -E 's/:.*$//' | grep -v \"^$(tmux display-message -p '#S')\$\" | fzf --reverse | xargs tmux switch-client -t" + +# open/close a popup scratch session +#bind-key C-g display-popup -E "tmux new-session -A -s scratch" +bind-key C-g if-shell -F '#{==:#{session_name},scratch}' { + detach-client +} { + display-popup -E "tmux new-session -A -s scratch" +} + +# Status format for the current window +setw -g window-status-current-format '#[fg=colour06,bg=colour08,bold] #I #W ' + +# Status format for other windows +setw -g window-status-format '#[fg=colour04,bg=colour08] #I #W ' + +# Seperator between each window names +set -wg window-status-separator ' ' + +# Show alert if other window changes? +setw -g monitor-activity off + +# Should automatically rename other windows based on the current program? +set -g automatic-rename on + +# ----- More options ----- + +# Emacs key bindings in tmux command prompt (prefix + :) are better than +# vi keys, even for vim users +set -g status-keys emacs + +# Focus events enabled for terminals that support them +set -g focus-events on + +# Super useful when using "grouped sessions" and multi-monitor setup +setw -g aggressive-resize on + +# Delay for the repeat key (-r) to be available, default is 500 +set-option -g repeat-time 1000 + +# History limit for scrolling back +set -g history-limit 10000 + +# Increase tmux messages display duration from 750ms to 4s +set -g display-time 4000 + +# Use mouse to switch windows, adjust panes, etc... +set -g mouse off + +# True color support +set -g default-terminal tmux-256color +set-option -ga terminal-overrides ',*-256colo*:Tc' + +# Delay after escape key is passed into the program +set -s escape-time 0 + +# Use vi styled keys for scrolling & copying +set-window-option -g mode-keys vi + +# set-clipboard for copying with OSC 52 +set -g allow-passthrough on +set -s set-clipboard on +set -as terminal-features ',rxvt-unicode-256color:clipboard' + +# modified copy mode with clipboard output +bind-key -T prefix v copy-mode +bind-key -T copy-mode-vi v send-keys -X begin-selection +bind-key -T copy-mode-vi y send-keys -X rectangle-toggle + +# ----- Plugins ----- + +# Tmux plugin manager +set -g @plugin 'tmux-plugins/tpm' +set-environment -g TMUX_PLUGIN_MANAGER_PATH "~/.config/tmux/plugins/" + +# Import plugins +set -g @plugin 'tmux-plugins/tmux-prefix-highlight' +set -g @plugin 'jaclu/tmux-menus' +set -g @plugin 'tmux-plugins/tmux-sidebar' +set -g @plugin 'laktak/extrakto' + +# tmux-prefix_highlight configs +set -g @prefix_highlight_prefix_prompt 'Wait' +set -g @prefix_highlight_copy_prompt 'Copy' +set -g @prefix_highlight_sync_prompt 'Sync' +set -g @prefix_highlight_fg 'colour05' +set -g @prefix_highlight_bg 'colour08' +set -g @prefix_highlight_show_copy_mode 'on' +set -g @prefix_highlight_copy_mode_attr 'fg=colour08,bg=colour03,bold' +set -g @prefix_highlight_show_sync_mode 'on' +set -g @prefix_highlight_sync_mode_attr 'fg=colour08,bg=colour02,bold' + +# extrakto configs +set -g @extrakto_grab_area 'recent' +set -g @extrakto_filter_order 'line word all' +set -g @extrakto_popup_size '90%,60%' +set -g @extrakto_clip_tool_run 'tmux_osc52' +set -g @extrakto_copy_key 'ctrl-y' +set -g @extrakto_insert_key 'enter' +set -g @extrakto_filter_key 'ctrl-f' +set -g @extrakto_grab_key 'ctrl-g' +set -g @extrakto_edit_key 'ctrl-e' +set -g @extrakto_open_key 'ctrl-o' + +# tmux-sidebar configs +set -g @sidebar-tree-width '40' +set -g @sidebar-tree-command 'exa -abTL 2 --long --color always --icons --sort Name --group-directories-first --no-permissions --no-time --no-user' +set -g @sidebar-tree 'C-e' +set -g @sidebar-tree-focus 'C-z' + +# Initialize TMUX plugin manager +# (keep this line at the very bottom of tmux.conf) +run -b '~/.config/tmux/plugins/tpm/tpm'