This is a script that will popup a window with a list of windows in a fzf promp. When selected the window will be focused. If the window is in another session the session will also be switched and the window focused
145 lines
4.8 KiB
Bash
145 lines
4.8 KiB
Bash
# split windows like vim
|
|
# vim's definition of a horizontal/vertical split is reversed from tmux's
|
|
bind s split-window -v -c "#{pane_current_path}"
|
|
bind v split-window -h -c "#{pane_current_path}"
|
|
|
|
# Smart pane switching with awareness of vim splits
|
|
# See: https://github.com/christoomey/vim-tmux-navigator
|
|
is_vim="ps -o state= -o comm= -t '#{pane_tty}' \
|
|
| grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|n?vim?x?)(diff)?$|emacs'"
|
|
bind-key -n C-h if-shell "$is_vim" "send-keys C-h" "select-pane -L"
|
|
bind-key -n C-j if-shell "$is_vim" "send-keys C-j" "select-pane -D"
|
|
bind-key -n C-k if-shell "$is_vim" "send-keys C-k" "select-pane -U"
|
|
bind-key -n C-l if-shell "$is_vim" "send-keys C-l" "select-pane -R"
|
|
bind-key -T copy-mode-vi C-h select-pane -L
|
|
bind-key -T copy-mode-vi C-j select-pane -D
|
|
bind-key -T copy-mode-vi C-k select-pane -U
|
|
bind-key -T copy-mode-vi C-l select-pane -R
|
|
|
|
#
|
|
# Set color term
|
|
#
|
|
set -g default-terminal "xterm-256color"
|
|
set-option -sg escape-time 10
|
|
set-option -ga terminal-overrides ",tmux-256color:Tc"
|
|
|
|
#
|
|
# Set long history
|
|
#
|
|
set-option -g history-limit 5000
|
|
|
|
# resize panes like vim
|
|
# feel free to change the "1" to however many lines you want to resize by, only
|
|
# one at a time can be slow
|
|
bind < resize-pane -L 1
|
|
bind > resize-pane -R 1
|
|
bind - resize-pane -D 1
|
|
bind + resize-pane -U 1
|
|
|
|
# Setup window switching via fzf
|
|
bind-key f run-shell -b ~/.local/bin/tmux-switch-pane
|
|
|
|
# bind : to command-prompt like vim
|
|
# this is the default in tmux already
|
|
bind : command-prompt
|
|
|
|
# vi-style controls for copy mode
|
|
setw -g mode-keys vi
|
|
|
|
# set windows so they dont resize to the smallest
|
|
setw -g aggressive-resize on
|
|
|
|
# use mouse on
|
|
set -g mouse on
|
|
set-option -g mouse on
|
|
|
|
set -g @open-S 'https://www.duckduckgo.com/'
|
|
set -g @open-editor-command 'emacs --no-wait'
|
|
|
|
# Init plugins
|
|
run-shell ~/.tmux/plugins/tmux-copycat/copycat.tmux
|
|
run-shell ~/.tmux/plugins/tmux-open/open.tmux
|
|
run-shell ~/.tmux/plugins/tmux-yank/yank.tmux
|
|
|
|
# Automatically renumber window numbers on closing a pane (tmux >= 1.7).
|
|
set -g renumber-windows on
|
|
|
|
# Stay in copy mode on drag end.
|
|
# (Would use `bind-key -T copy-mode-vi MouseDragEnd1Pane send-keys -X
|
|
# stop-selection` but it is a bit glitchy.)
|
|
unbind-key -T copy-mode-vi MouseDragEnd1Pane
|
|
|
|
# Search back to last prompt.
|
|
bind-key b copy-mode\; send-keys -X start-of-line\; send-keys -X search-backward "⇒"\; send-keys -X next-word
|
|
|
|
# Set `v` key to start selection like vim
|
|
bind-key -T copy-mode-vi 'v' send -X begin-selection
|
|
|
|
# Start window and pane numbering at 1, (0 is too hard to reach).
|
|
set -g base-index 1
|
|
set -g pane-base-index 1
|
|
|
|
# Needed as on tmux 1.9 and up (defaults to off).
|
|
# Added in tmux commit c7a121cfc0137c907b7bfb.
|
|
# Also need by vim plugin tmux-focus-events.vim
|
|
set -g focus-events on
|
|
|
|
# Github colors for Tmux
|
|
#https://github.com/projekt0n/github-theme-contrib/blob/main/tmux/github_light.confhttps://github.com/projekt0n/github-theme-contrib/blob/main/tmux/github_light.confhttps://github.com/projekt0n/github-theme-contrib/blob/main/tmux/github_light.conf
|
|
|
|
## set status bar
|
|
set -g status-style bg=default
|
|
setw -g window-status-current-style bg="#282a2e"
|
|
setw -g window-status-current-style fg="#81a2be"
|
|
|
|
## highlight active window
|
|
setw -g window-style 'bg=#282a2e'
|
|
setw -g window-active-style 'bg=#1d1f21'
|
|
setw -g pane-active-border-style ''
|
|
|
|
## highlight activity in status bar
|
|
setw -g window-status-activity-style fg="#8abeb7"
|
|
setw -g window-status-activity-style bg="#1d1f21"
|
|
|
|
## pane border and colors
|
|
set -g pane-active-border-style bg=default
|
|
set -g pane-active-border-style fg="#373b41"
|
|
set -g pane-border-style bg=default
|
|
set -g pane-border-style fg="#373b41"
|
|
|
|
set -g clock-mode-colour "#81a2be"
|
|
set -g clock-mode-style 24
|
|
|
|
set -g message-style bg="#8abeb7"
|
|
set -g message-style fg="#000000"
|
|
|
|
set -g message-command-style bg="#8abeb7"
|
|
set -g message-command-style fg="#000000"
|
|
|
|
# message bar or "prompt"
|
|
set -g message-style bg="#2d2d2d"
|
|
set -g message-style fg="#cc99cc"
|
|
|
|
set -g mode-style bg="#1d1f21"
|
|
set -g mode-style fg="#de935f"
|
|
|
|
# right side of status bar holds "[host name] (date time)"
|
|
set -g status-right-length 100
|
|
set -g status-right-style fg=black
|
|
set -g status-right-style bold
|
|
set -g status-right '#[fg=#f99157,bg=#2d2d2d] %H:%M |#[fg=#6699cc] %y.%m.%d '
|
|
|
|
# make background window look like white tab
|
|
set-window-option -g window-status-style bg=default
|
|
set-window-option -g window-status-style fg=white
|
|
set-window-option -g window-status-style none
|
|
set-window-option -g window-status-format '#[fg=#6699cc,bg=colour235] #I #[fg=#999999,bg=#2d2d2d] #W #[default]'
|
|
|
|
# make foreground window look like bold yellow foreground tab
|
|
set-window-option -g window-status-current-style none
|
|
set-window-option -g window-status-current-format '#[fg=#f99157,bg=#2d2d2d] #I #[fg=#cccccc,bg=#393939] #W #[default]'
|
|
|
|
# active terminal yellow border, non-active white
|
|
set -g pane-border-style bg=default
|
|
set -g pane-border-style fg="#999999"
|
|
set -g pane-active-border-style fg="#f99157"
|