-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tmux navigator, wezterm and tmux configs
- Loading branch information
Showing
5 changed files
with
253 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
set-option -g history-limit 125000 | ||
set-option -g default-shell /bin/zsh | ||
|
||
bind-key "T" run-shell "sesh connect \"$( | ||
sesh list | fzf-tmux -p 55%,60% \ | ||
--no-sort --ansi --border-label ' sesh ' --prompt '⚡ ' \ | ||
--header ' ^a all ^t tmux ^g configs ^x zoxide ^d tmux kill ^f find' \ | ||
--bind 'tab:down,btab:up' \ | ||
--bind 'ctrl-a:change-prompt(⚡ )+reload(sesh list)' \ | ||
--bind 'ctrl-t:change-prompt(🪟 )+reload(sesh list -t)' \ | ||
--bind 'ctrl-g:change-prompt(⚙️ )+reload(sesh list -c)' \ | ||
--bind 'ctrl-x:change-prompt(📁 )+reload(sesh list -z)' \ | ||
--bind 'ctrl-f:change-prompt(🔎 )+reload(fd -H -d 2 -t d -E .Trash . ~)' \ | ||
--bind 'ctrl-d:execute(tmux kill-session -t {})+change-prompt(⚡ )+reload(sesh list)' | ||
)\"" | ||
|
||
bind-key x kill-pane # skip "kill-pane 1? (y/n)" prompt | ||
set -g detach-on-destroy off # don't exit from tmux when closing a session | ||
|
||
# set prefix | ||
unbind C-b | ||
set-option -g prefix C-a | ||
bind C-a send-prefix | ||
|
||
# start counting from 1 | ||
set -g base-index 1 | ||
setw -g pane-base-index 1 | ||
set -g set-titles on # set terminal title | ||
set -g set-titles-string "#{session_name} - #{pane_title}#{?#{==:#{pane_title},#{host}},, - #{host}}" # title format | ||
setw -g automatic-rename on # rename window to reflect current program | ||
set -g renumber-windows on # renumber windows when a window is closed | ||
set -g status-left-length 20 | ||
set -g status-style 'bg=#333333 fg=#5eacd3' | ||
|
||
# vim-like pane switching | ||
bind -r ^ last-window | ||
bind -r k select-pane -U | ||
bind -r j select-pane -D | ||
bind -r h select-pane -L | ||
bind -r l select-pane -R | ||
|
||
# enable vi-mode | ||
setw -g mode-keys vi | ||
|
||
# Mouse | ||
set -g mouse on | ||
|
||
# Attempt to set the terminal clipboard content using the xterm escape sequence | ||
set -g set-clipboard on | ||
|
||
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 | ||
bind-key @ choose-window 'join-pane -h -s "%%"' | ||
bind-key C-@ choose-window 'join-pane -s "%%"' | ||
bind-key ! break-pane -t : | ||
set -g repeat-time 300 | ||
set-option -g default-terminal "tmux-256color" | ||
set -sa terminal-overrides ",*:RGB" # utf8/color hack | ||
set -sa terminal-overrides ',*:Smulx=\E[4::%p1%dm' # undercurl support | ||
set -sa terminal-overrides ',*:Setulc=\E[58::2::%p1%{65536}%/%d::%p1%{256}%/%{255}%&%d::%p1%{255}%&%d%;m' # underscore colors - needs tmux-3.0 | ||
|
||
# to get the output to /tmp/tmux from https://superuser.com/questions/231002/how-can-i-search-within-the-output-buffer-of-a-tmux-shell | ||
bind-key P 'capture-pane' \; capture-pane -S - \; save-buffer /tmp/tmux \; delete-buffer | ||
# don't exit copy mode after marking with mouse | ||
bind-key -T copy-mode-vi MouseDragEnd1Pane send-keys -X copy-selection -x | ||
|
||
bind m set -g mouse on \; display 'Mouse: ON' | ||
bind M set -g mouse off \; display 'Mouse: OFF' | ||
|
||
bind-key D switch -t default | ||
|
||
bind -n C-l send-keys C-l \; run-shell "sleep .2s" \; clear-history | ||
|
||
if-shell -b '[ `tmux -V | cut -d" " -f2 | tr -d " |\-|.|[:alpha:]"` -ge 33 ]' \ | ||
'set-option -g allow-passthrough on' | ||
|
||
# seamless navigation between nvim and tmux based on https://www.reddit.com/r/vim/comments/c11cad/comment/eran9h5/ | ||
is_vim="ps -o state= -o comm= -t '#{pane_tty}' \ | ||
| grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|l?n?vim?x?|fzf)(diff)?$'" | ||
bind-key -n C-w if-shell "$is_vim || [ $(tmux list-panes | wc -l) -eq 1 ]" "send-keys C-w" "switch-client -Ttable1" | ||
bind-key -Ttable1 'h' select-pane -L | ||
bind-key -Ttable1 'C-h' select-pane -L | ||
bind-key -Ttable1 'j' select-pane -D | ||
bind-key -Ttable1 'C-j' select-pane -D | ||
bind-key -Ttable1 'k' select-pane -U | ||
bind-key -Ttable1 'C-k' select-pane -U | ||
bind-key -Ttable1 'l' select-pane -R | ||
bind-key -Ttable1 'C-l' select-pane -R | ||
bind-key -Ttable1 '\' select-pane -l | ||
bind-key -Ttable1 's' split-window -v | ||
bind-key -Ttable1 'v' split-window -h | ||
bind-key -Ttable1 'q' kill-pane | ||
bind-key -Ttable1 'C-q' kill-pane | ||
bind-key -Ttable1 'C-w' send-keys C-w | ||
|
||
set -ga update-environment EDITOR | ||
set -g @plugin 'artemave/tmux_super_fingers' # <prefix> f - select mark to open file in $EDITOR | ||
set -g @plugin 'laktak/extrakto' # <prefix> tab - select the text to paste, then: tab - insert, enter - copy | ||
set -g @extrakto_fzf_header "f g h" # for small screens shorten the fzf header | ||
|
||
# important - put the run tpm command below all the plugins | ||
if "test ! -d ~/.tmux/plugins/tpm && command -v git >/dev/null 2>&1" \ | ||
"run 'git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm && ~/.tmux/plugins/tpm/bin/install_plugins'" | ||
run '~/.tmux/plugins/tpm/tpm' | ||
|
||
# to override default settings edit ~/.tmux.conf.local | ||
if-shell "test -f ~/.tmux.conf.local" "source-file ~/.tmux.conf.local" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
-- Pull in the wezterm API | ||
local wezterm = require 'wezterm' | ||
|
||
-- This table will hold the configuration. | ||
local config = {} | ||
|
||
-- In newer versions of wezterm, use the config_builder which will | ||
-- help provide clearer error messages | ||
if wezterm.config_builder then | ||
config = wezterm.config_builder() | ||
end | ||
|
||
-- This is where you actually apply your config choices | ||
|
||
-- For example, changing the color scheme: | ||
-- config.color_scheme = 'OneHalfDark' | ||
config.color_scheme = 'Dracula' | ||
|
||
-- config.enable_tab_bar = false | ||
config.window_background_opacity = 0.97 | ||
-- config.font = wezterm.font('Source Code Pro', { weight = 'Medium'}) | ||
-- config.font_size = 11.5 | ||
config.font = wezterm.font_with_fallback { | ||
'SFMono Nerd Font', | ||
'BerkeleyMonoTrial-Regular', | ||
{ | ||
family = 'MonaspaceNeon-Regular', | ||
harfbuzz_features = { 'ss07', 'calt' }, | ||
}, | ||
} | ||
config.font_size = 11 | ||
if wezterm.target_triple == 'aarch64-apple-darwin' then | ||
config.window_close_confirmation = 'NeverPrompt' | ||
config.window_decorations = "RESIZE" | ||
config.font = wezterm.font{ | ||
family = 'Monaco Nerd Font', | ||
harfbuzz_features = { 'ss07', 'calt', 'liga=0' }, | ||
} | ||
config.font_size = 12 | ||
else | ||
-- disable the window title bar | ||
config.window_decorations = "NONE" | ||
-- Spawn a zsh shell in login mode | ||
config.default_prog = { '/usr/bin/zsh', '-l' } | ||
end | ||
-- I don't care about missing glyphs | ||
config.warn_about_missing_glyphs = false | ||
-- Default keybindings for panes not needed, I use tmux | ||
-- Get default key bindings with wezterm show-keys --lua | ||
-- config.disable_default_key_bindings = true | ||
local act = wezterm.action | ||
-- Set the keybindings I actually need | ||
config.keys = { | ||
-- { key = 'C', mods = 'CTRL', action = act.CopyTo 'Clipboard' }, | ||
-- { key = 'C', mods = 'SHIFT|CTRL', action = act.CopyTo 'Clipboard' }, | ||
-- { key = 'P', mods = 'CTRL', action = act.ActivateCommandPalette }, | ||
-- { key = 'P', mods = 'SHIFT|CTRL', action = act.ActivateCommandPalette }, | ||
-- { key = 'Copy', mods = 'NONE', action = act.CopyTo 'Clipboard' }, | ||
-- { key = 'Paste', mods = 'NONE', action = act.PasteFrom 'Clipboard' }, | ||
-- { key = 'v', mods = 'SHIFT|CTRL', action = act.PasteFrom 'Clipboard' }, | ||
-- { key = 'v', mods = 'SUPER', action = act.PasteFrom 'Clipboard' }, | ||
-- { key = 'V', mods = 'CTRL', action = act.PasteFrom 'Clipboard' }, | ||
-- { key = 'V', mods = 'SHIFT|CTRL', action = act.PasteFrom 'Clipboard' }, | ||
-- { key = 'Insert', mods = 'SHIFT', action = act.PasteFrom 'PrimarySelection' }, | ||
-- { key = 'Insert', mods = 'CTRL', action = act.CopyTo 'PrimarySelection' }, | ||
-- { key = 'L', mods = 'CTRL', action = act.ShowDebugOverlay }, -- CTRL-SHIFT-l activates the debug overlay | ||
-- On mac make Option-Left equivalent to Alt-b which many line editors interpret as backward-word | ||
{ key = "LeftArrow", mods = "OPT", action = wezterm.action { SendString = "\x1bb" } }, | ||
-- Make Option-Right equivalent to Alt-f; forward-word | ||
{ key = "RightArrow", mods = "OPT", action = wezterm.action { SendString = "\x1bf" } }, | ||
} | ||
config.mouse_bindings = { | ||
-- Change the default click behavior so that it only selects | ||
-- text and doesn't open hyperlinks | ||
{ | ||
event = { Up = { streak = 1, button = 'Left' } }, | ||
mods = 'NONE', | ||
action = act.CompleteSelection 'ClipboardAndPrimarySelection', | ||
}, | ||
|
||
-- and make CTRL-Click or CMD open hyperlinks | ||
{ | ||
event = { Up = { streak = 1, button = 'Left' } }, | ||
mods = 'CTRL', | ||
action = act.OpenLinkAtMouseCursor, | ||
}, | ||
{ | ||
event = { Up = { streak = 1, button = 'Left' } }, | ||
mods = 'CMD', | ||
action = act.OpenLinkAtMouseCursor, | ||
}, | ||
-- NOTE that binding only the 'Up' event can give unexpected behaviors. | ||
-- Read more below on the gotcha of binding an 'Up' event only. | ||
} | ||
|
||
-- and finally, return the configuration to wezterm | ||
return config |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters