Init Commit
This commit is contained in:
commit
b04f979811
225 changed files with 31653 additions and 0 deletions
1531
tmux/.config/tmux/different-layout/.tmux.conf
Normal file
1531
tmux/.config/tmux/different-layout/.tmux.conf
Normal file
File diff suppressed because it is too large
Load diff
431
tmux/.config/tmux/different-layout/.tmux.conf.local
Normal file
431
tmux/.config/tmux/different-layout/.tmux.conf.local
Normal file
|
|
@ -0,0 +1,431 @@
|
|||
# : << EOF
|
||||
# https://github.com/gpakosz/.tmux
|
||||
# (‑●‑●)> dual licensed under the WTFPL v2 license and the MIT license,
|
||||
# without any warranty.
|
||||
# Copyright 2012— Gregory Pakosz (@gpakosz).
|
||||
|
||||
|
||||
# -- navigation ----------------------------------------------------------------
|
||||
|
||||
# if you're running tmux within iTerm2
|
||||
# - and tmux is 1.9 or 1.9a
|
||||
# - and iTerm2 is configured to let option key act as +Esc
|
||||
# - and iTerm2 is configured to send [1;9A -> [1;9D for option + arrow keys
|
||||
# then uncomment the following line to make Meta + arrow keys mapping work
|
||||
#set -ga terminal-overrides "*:kUP3=\e[1;9A,*:kDN3=\e[1;9B,*:kRIT3=\e[1;9C,*:kLFT3=\e[1;9D"
|
||||
|
||||
|
||||
# -- windows & pane creation ---------------------------------------------------
|
||||
|
||||
# new window retains current path, possible values are:
|
||||
# - true
|
||||
# - false (default)
|
||||
# - disabled (do not modify new-window bindings)
|
||||
tmux_conf_new_window_retain_current_path=false
|
||||
|
||||
# new pane retains current path, possible values are:
|
||||
# - true (default)
|
||||
# - false
|
||||
# - disabled (do not modify split-window bindings)
|
||||
tmux_conf_new_pane_retain_current_path=true
|
||||
|
||||
# new pane tries to reconnect ssh sessions, possible values are:
|
||||
# - true
|
||||
# - false (default)
|
||||
# - disabled (do not modify split-window bindings)
|
||||
tmux_conf_new_pane_reconnect_ssh=false
|
||||
|
||||
# prompt for session name when creating a new session, possible values are:
|
||||
# - true
|
||||
# - false (default)
|
||||
# - disabled (do not modify new-session bindings)
|
||||
tmux_conf_new_session_prompt=false
|
||||
|
||||
|
||||
# -- display -------------------------------------------------------------------
|
||||
|
||||
# RGB 24-bit colour support (tmux >= 2.2), possible values are:
|
||||
# - true
|
||||
# - false
|
||||
# - auto (default)
|
||||
#
|
||||
# automatic detection relies on the COLORTERM environment variable being defined
|
||||
# to 'truecolor' or '24bit' or '$ tput colors' answering '16777216'
|
||||
# see https://github.com/termstandard/colors
|
||||
tmux_conf_24b_colour=auto
|
||||
|
||||
# default theme
|
||||
tmux_conf_theme_colour_1="#080808" # dark gray
|
||||
tmux_conf_theme_colour_2="#303030" # gray
|
||||
tmux_conf_theme_colour_3="#8a8a8a" # light gray
|
||||
tmux_conf_theme_colour_4="#00afff" # light blue
|
||||
tmux_conf_theme_colour_5="#ffff00" # yellow
|
||||
tmux_conf_theme_colour_6="#080808" # dark gray
|
||||
tmux_conf_theme_colour_7="#e4e4e4" # white
|
||||
tmux_conf_theme_colour_8="#080808" # dark gray
|
||||
tmux_conf_theme_colour_9="#ffff00" # yellow
|
||||
tmux_conf_theme_colour_10="#ff00af" # pink
|
||||
tmux_conf_theme_colour_11="#5fff00" # green
|
||||
tmux_conf_theme_colour_12="#8a8a8a" # light gray
|
||||
tmux_conf_theme_colour_13="#e4e4e4" # white
|
||||
tmux_conf_theme_colour_14="#080808" # dark gray
|
||||
tmux_conf_theme_colour_15="#080808" # dark gray
|
||||
tmux_conf_theme_colour_16="#d70000" # red
|
||||
tmux_conf_theme_colour_17="#e4e4e4" # white
|
||||
|
||||
# default theme (ansi)
|
||||
#tmux_conf_theme_colour_1="colour0"
|
||||
#tmux_conf_theme_colour_2="colour8"
|
||||
#tmux_conf_theme_colour_3="colour8"
|
||||
#tmux_conf_theme_colour_4="colour14"
|
||||
#tmux_conf_theme_colour_5="colour11"
|
||||
#tmux_conf_theme_colour_6="colour0"
|
||||
#tmux_conf_theme_colour_7="colour15"
|
||||
#tmux_conf_theme_colour_8="colour0"
|
||||
#tmux_conf_theme_colour_9="colour11"
|
||||
#tmux_conf_theme_colour_10="colour13"
|
||||
#tmux_conf_theme_colour_11="colour10"
|
||||
#tmux_conf_theme_colour_12="colour8"
|
||||
#tmux_conf_theme_colour_13="colour15"
|
||||
#tmux_conf_theme_colour_14="colour0"
|
||||
#tmux_conf_theme_colour_15="colour0"
|
||||
#tmux_conf_theme_colour_16="colour1"
|
||||
#tmux_conf_theme_colour_17="colour15"
|
||||
|
||||
# window style
|
||||
tmux_conf_theme_window_fg="default"
|
||||
tmux_conf_theme_window_bg="default"
|
||||
|
||||
# highlight focused pane (tmux >= 2.1), possible values are:
|
||||
# - true
|
||||
# - false (default)
|
||||
tmux_conf_theme_highlight_focused_pane=false
|
||||
|
||||
# focused pane colours:
|
||||
tmux_conf_theme_focused_pane_bg="$tmux_conf_theme_colour_2"
|
||||
|
||||
# pane border style, possible values are:
|
||||
# - thin (default)
|
||||
# - fat
|
||||
tmux_conf_theme_pane_border_style=thin
|
||||
|
||||
# pane borders colours:
|
||||
tmux_conf_theme_pane_border="$tmux_conf_theme_colour_2"
|
||||
tmux_conf_theme_pane_active_border="$tmux_conf_theme_colour_4"
|
||||
|
||||
# pane indicator colours (when you hit <prefix> + q)
|
||||
tmux_conf_theme_pane_indicator="$tmux_conf_theme_colour_4"
|
||||
tmux_conf_theme_pane_active_indicator="$tmux_conf_theme_colour_4"
|
||||
|
||||
# status line style
|
||||
tmux_conf_theme_message_fg="$tmux_conf_theme_colour_1"
|
||||
tmux_conf_theme_message_bg="$tmux_conf_theme_colour_5"
|
||||
tmux_conf_theme_message_attr="bold"
|
||||
|
||||
# status line command style (<prefix> : Escape)
|
||||
tmux_conf_theme_message_command_fg="$tmux_conf_theme_colour_5"
|
||||
tmux_conf_theme_message_command_bg="$tmux_conf_theme_colour_1"
|
||||
tmux_conf_theme_message_command_attr="bold"
|
||||
|
||||
# window modes style
|
||||
tmux_conf_theme_mode_fg="$tmux_conf_theme_colour_1"
|
||||
tmux_conf_theme_mode_bg="$tmux_conf_theme_colour_5"
|
||||
tmux_conf_theme_mode_attr="bold"
|
||||
|
||||
# status line style
|
||||
tmux_conf_theme_status_fg="$tmux_conf_theme_colour_3"
|
||||
tmux_conf_theme_status_bg="$tmux_conf_theme_colour_1"
|
||||
tmux_conf_theme_status_attr="none"
|
||||
|
||||
# terminal title
|
||||
# - built-in variables are:
|
||||
# - #{circled_window_index}
|
||||
# - #{circled_session_name}
|
||||
# - #{hostname}
|
||||
# - #{hostname_ssh}
|
||||
# - #{hostname_full}
|
||||
# - #{hostname_full_ssh}
|
||||
# - #{username}
|
||||
# - #{username_ssh}
|
||||
tmux_conf_theme_terminal_title="#h ❐ #S ● #I #W"
|
||||
|
||||
# window status style
|
||||
# - built-in variables are:
|
||||
# - #{circled_window_index}
|
||||
# - #{circled_session_name}
|
||||
# - #{hostname}
|
||||
# - #{hostname_ssh}
|
||||
# - #{hostname_full}
|
||||
# - #{hostname_full_ssh}
|
||||
# - #{username}
|
||||
# - #{username_ssh}
|
||||
tmux_conf_theme_window_status_fg="$tmux_conf_theme_colour_3"
|
||||
tmux_conf_theme_window_status_bg="$tmux_conf_theme_colour_1"
|
||||
tmux_conf_theme_window_status_attr="none"
|
||||
tmux_conf_theme_window_status_format="#I #W"
|
||||
#tmux_conf_theme_window_status_format="#{circled_window_index} #W"
|
||||
#tmux_conf_theme_window_status_format="#I #W#{?window_bell_flag,🔔,}#{?window_zoomed_flag,🔍,}"
|
||||
|
||||
# window current status style
|
||||
# - built-in variables are:
|
||||
# - #{circled_window_index}
|
||||
# - #{circled_session_name}
|
||||
# - #{hostname}
|
||||
# - #{hostname_ssh}
|
||||
# - #{hostname_full}
|
||||
# - #{hostname_full_ssh}
|
||||
# - #{username}
|
||||
# - #{username_ssh}
|
||||
tmux_conf_theme_window_status_current_fg="$tmux_conf_theme_colour_1"
|
||||
tmux_conf_theme_window_status_current_bg="$tmux_conf_theme_colour_4"
|
||||
tmux_conf_theme_window_status_current_attr="bold"
|
||||
tmux_conf_theme_window_status_current_format="#I #W"
|
||||
#tmux_conf_theme_window_status_current_format="#{circled_window_index} #W"
|
||||
#tmux_conf_theme_window_status_current_format="#I #W#{?window_zoomed_flag,🔍,}"
|
||||
|
||||
# window activity status style
|
||||
tmux_conf_theme_window_status_activity_fg="default"
|
||||
tmux_conf_theme_window_status_activity_bg="default"
|
||||
tmux_conf_theme_window_status_activity_attr="underscore"
|
||||
|
||||
# window bell status style
|
||||
tmux_conf_theme_window_status_bell_fg="$tmux_conf_theme_colour_5"
|
||||
tmux_conf_theme_window_status_bell_bg="default"
|
||||
tmux_conf_theme_window_status_bell_attr="blink,bold"
|
||||
|
||||
# window last status style
|
||||
tmux_conf_theme_window_status_last_fg="$tmux_conf_theme_colour_4"
|
||||
tmux_conf_theme_window_status_last_bg="$tmux_conf_theme_colour_2"
|
||||
tmux_conf_theme_window_status_last_attr="none"
|
||||
|
||||
# status left/right sections separators
|
||||
tmux_conf_theme_left_separator_main=""
|
||||
tmux_conf_theme_left_separator_sub="|"
|
||||
tmux_conf_theme_right_separator_main=""
|
||||
tmux_conf_theme_right_separator_sub="|"
|
||||
#tmux_conf_theme_left_separator_main='\uE0B0' # /!\ you don't need to install Powerline
|
||||
#tmux_conf_theme_left_separator_sub='\uE0B1' # you only need fonts patched with
|
||||
#tmux_conf_theme_right_separator_main='\uE0B2' # Powerline symbols or the standalone
|
||||
#tmux_conf_theme_right_separator_sub='\uE0B3' # PowerlineSymbols.otf font, see README.md
|
||||
|
||||
# status left/right content:
|
||||
# - separate main sections with "|"
|
||||
# - separate subsections with ","
|
||||
# - built-in variables are:
|
||||
# - #{battery_bar}
|
||||
# - #{battery_hbar}
|
||||
# - #{battery_percentage}
|
||||
# - #{battery_status}
|
||||
# - #{battery_vbar}
|
||||
# - #{circled_session_name}
|
||||
# - #{hostname_ssh}
|
||||
# - #{hostname}
|
||||
# - #{hostname_full}
|
||||
# - #{hostname_full_ssh}
|
||||
# - #{loadavg}
|
||||
# - #{mouse}
|
||||
# - #{pairing}
|
||||
# - #{prefix}
|
||||
# - #{root}
|
||||
# - #{synchronized}
|
||||
# - #{uptime_y}
|
||||
# - #{uptime_d} (modulo 365 when #{uptime_y} is used)
|
||||
# - #{uptime_h}
|
||||
# - #{uptime_m}
|
||||
# - #{uptime_s}
|
||||
# - #{username}
|
||||
# - #{username_ssh}
|
||||
tmux_conf_theme_status_left=" ❐ #S | ↑#{?uptime_y, #{uptime_y}y,}#{?uptime_d, #{uptime_d}d,}#{?uptime_h, #{uptime_h}h,}#{?uptime_m, #{uptime_m}m,} "
|
||||
tmux_conf_theme_status_right=" #{prefix}#{mouse}#{pairing}#{synchronized}#{?battery_status,#{battery_status},}#{?battery_bar, #{battery_bar},}#{?battery_percentage, #{battery_percentage},} , %R , %d %b | #{username}#{root} | #{hostname} "
|
||||
|
||||
# status left style
|
||||
tmux_conf_theme_status_left_fg="$tmux_conf_theme_colour_6,$tmux_conf_theme_colour_7,$tmux_conf_theme_colour_8"
|
||||
tmux_conf_theme_status_left_bg="$tmux_conf_theme_colour_9,$tmux_conf_theme_colour_10,$tmux_conf_theme_colour_11"
|
||||
tmux_conf_theme_status_left_attr="bold,none,none"
|
||||
|
||||
# status right style
|
||||
tmux_conf_theme_status_right_fg="$tmux_conf_theme_colour_12,$tmux_conf_theme_colour_13,$tmux_conf_theme_colour_14"
|
||||
tmux_conf_theme_status_right_bg="$tmux_conf_theme_colour_15,$tmux_conf_theme_colour_16,$tmux_conf_theme_colour_17"
|
||||
tmux_conf_theme_status_right_attr="none,none,bold"
|
||||
|
||||
# pairing indicator
|
||||
tmux_conf_theme_pairing="⚇" # U+2687
|
||||
tmux_conf_theme_pairing_fg="none"
|
||||
tmux_conf_theme_pairing_bg="none"
|
||||
tmux_conf_theme_pairing_attr="none"
|
||||
|
||||
# prefix indicator
|
||||
tmux_conf_theme_prefix="⌨" # U+2328
|
||||
tmux_conf_theme_prefix_fg="none"
|
||||
tmux_conf_theme_prefix_bg="none"
|
||||
tmux_conf_theme_prefix_attr="none"
|
||||
|
||||
# mouse indicator
|
||||
tmux_conf_theme_mouse="↗" # U+2197
|
||||
tmux_conf_theme_mouse_fg="none"
|
||||
tmux_conf_theme_mouse_bg="none"
|
||||
tmux_conf_theme_mouse_attr="none"
|
||||
|
||||
# root indicator
|
||||
tmux_conf_theme_root="!"
|
||||
tmux_conf_theme_root_fg="none"
|
||||
tmux_conf_theme_root_bg="none"
|
||||
tmux_conf_theme_root_attr="bold,blink"
|
||||
|
||||
# synchronized indicator
|
||||
tmux_conf_theme_synchronized="⚏" # U+268F
|
||||
tmux_conf_theme_synchronized_fg="none"
|
||||
tmux_conf_theme_synchronized_bg="none"
|
||||
tmux_conf_theme_synchronized_attr="none"
|
||||
|
||||
# battery bar symbols
|
||||
tmux_conf_battery_bar_symbol_full="◼"
|
||||
tmux_conf_battery_bar_symbol_empty="◻"
|
||||
#tmux_conf_battery_bar_symbol_full="♥"
|
||||
#tmux_conf_battery_bar_symbol_empty="·"
|
||||
|
||||
# battery bar length (in number of symbols), possible values are:
|
||||
# - auto
|
||||
# - a number, e.g. 5
|
||||
tmux_conf_battery_bar_length="auto"
|
||||
|
||||
# battery bar palette, possible values are:
|
||||
# - gradient (default)
|
||||
# - heat
|
||||
# - "colour_full_fg,colour_empty_fg,colour_bg"
|
||||
tmux_conf_battery_bar_palette="gradient"
|
||||
#tmux_conf_battery_bar_palette="#d70000,#e4e4e4,#000000" # red, white, black
|
||||
|
||||
# battery hbar palette, possible values are:
|
||||
# - gradient (default)
|
||||
# - heat
|
||||
# - "colour_low,colour_half,colour_full"
|
||||
tmux_conf_battery_hbar_palette="gradient"
|
||||
#tmux_conf_battery_hbar_palette="#d70000,#ff5f00,#5fff00" # red, orange, green
|
||||
|
||||
# battery vbar palette, possible values are:
|
||||
# - gradient (default)
|
||||
# - heat
|
||||
# - "colour_low,colour_half,colour_full"
|
||||
tmux_conf_battery_vbar_palette="gradient"
|
||||
#tmux_conf_battery_vbar_palette="#d70000,#ff5f00,#5fff00" # red, orange, green
|
||||
|
||||
# symbols used to indicate whether battery is charging or discharging
|
||||
tmux_conf_battery_status_charging="↑" # U+2191
|
||||
tmux_conf_battery_status_discharging="↓" # U+2193
|
||||
#tmux_conf_battery_status_charging="🔌" # U+1F50C
|
||||
#tmux_conf_battery_status_discharging="🔋" # U+1F50B
|
||||
|
||||
# clock style (when you hit <prefix> + t)
|
||||
# you may want to use %I:%M %p in place of %R in tmux_conf_theme_status_right
|
||||
tmux_conf_theme_clock_colour="$tmux_conf_theme_colour_4"
|
||||
tmux_conf_theme_clock_style="24"
|
||||
|
||||
|
||||
# -- clipboard -----------------------------------------------------------------
|
||||
|
||||
# in copy mode, copying selection also copies to the OS clipboard
|
||||
# - true
|
||||
# - false (default)
|
||||
# - disabled
|
||||
# on macOS, this requires installing reattach-to-user-namespace, see README.md
|
||||
# on Linux, this requires xsel or xclip
|
||||
tmux_conf_copy_to_os_clipboard=false
|
||||
|
||||
|
||||
# -- user customizations -------------------------------------------------------
|
||||
# this is the place to override or undo settings
|
||||
|
||||
# increase history size
|
||||
#set -g history-limit 10000
|
||||
|
||||
# start with mouse mode enabled
|
||||
#set -g mouse on
|
||||
|
||||
# force Vi mode
|
||||
# really you should export VISUAL or EDITOR environment variable, see manual
|
||||
#set -g status-keys vi
|
||||
#set -g mode-keys vi
|
||||
|
||||
# replace C-b by C-a instead of using both prefixes
|
||||
# set -gu prefix2
|
||||
# unbind C-a
|
||||
# unbind C-b
|
||||
# set -g prefix C-a
|
||||
# bind C-a send-prefix
|
||||
|
||||
# if you don't want Oh my tmux! to alter a binding, use #!important
|
||||
# bind v new-window -c #{pane_current_path} #!important
|
||||
|
||||
# move status line to top
|
||||
#set -g status-position top
|
||||
|
||||
|
||||
# -- tpm -----------------------------------------------------------------------
|
||||
|
||||
# while I don't use tpm myself, many people requested official support so here
|
||||
# is a seamless integration that automatically installs plugins in parallel
|
||||
|
||||
# whenever a plugin introduces a variable to be used in 'status-left' or
|
||||
# 'status-right', you can use it in 'tmux_conf_theme_status_left' and
|
||||
# 'tmux_conf_theme_status_right' variables.
|
||||
|
||||
# by default, launching tmux will update tpm and all plugins
|
||||
# - true (default)
|
||||
# - false
|
||||
tmux_conf_update_plugins_on_launch=true
|
||||
|
||||
# by default, reloading the configuration will update tpm and all plugins
|
||||
# - true (default)
|
||||
# - false
|
||||
tmux_conf_update_plugins_on_reload=true
|
||||
|
||||
# by default, reloading the configuration will uninstall tpm and plugins when no
|
||||
# plugins are enabled
|
||||
# - true (default)
|
||||
# - false
|
||||
tmux_conf_uninstall_plugins_on_reload=true
|
||||
|
||||
# /!\ the tpm bindings differ slightly from upstream:
|
||||
# - installing plugins: <prefix> + I
|
||||
# - uninstalling plugins: <prefix> + Alt + u
|
||||
# - updating plugins: <prefix> + u
|
||||
|
||||
# /!\ do not add set -g @plugin 'tmux-plugins/tpm'
|
||||
# /!\ do not add run '~/.tmux/plugins/tpm/tpm'
|
||||
|
||||
# to enable a plugin, use the 'set -g @plugin' syntax:
|
||||
# visit https://github.com/tmux-plugins for available plugins
|
||||
#set -g @plugin 'tmux-plugins/tmux-copycat'
|
||||
#set -g @plugin 'tmux-plugins/tmux-cpu'
|
||||
#set -g @plugin 'tmux-plugins/tmux-resurrect'
|
||||
#set -g @plugin 'tmux-plugins/tmux-continuum'
|
||||
#set -g @continuum-restore 'on'
|
||||
|
||||
|
||||
# -- custom variables ----------------------------------------------------------
|
||||
|
||||
# to define a custom #{foo} variable, define a POSIX shell function between the
|
||||
# '# EOF' and the '# "$@"' lines. Please note that the opening brace { character
|
||||
# must be on the same line as the function name otherwise the parse won't detect
|
||||
# it.
|
||||
#
|
||||
# then, use #{foo} in e.g. the 'tmux_conf_theme_status_left' or the
|
||||
# 'tmux_conf_theme_status_right' variables.
|
||||
|
||||
# # /!\ do not remove the following line
|
||||
# EOF
|
||||
#
|
||||
# # /!\ do not "uncomment" the functions: the leading "# " characters are needed
|
||||
#
|
||||
# weather() { # see https://github.com/chubin/wttr.in#one-line-output
|
||||
# curl -f -s -m 2 'wttr.in?format=3' || printf '\n' # /!\ make sure curl is installed
|
||||
# sleep 900 # sleep for 15 minutes, throttle network requests whatever the value of status-interval
|
||||
# }
|
||||
#
|
||||
# online() {
|
||||
# ping -c 1 1.1.1.1 >/dev/null 2>&1 && printf '✔' || printf '✘'
|
||||
# }
|
||||
#
|
||||
# "$@"
|
||||
# # /!\ do not remove the previous line
|
||||
18
tmux/.config/tmux/different-layout/LICENSE.MIT
Normal file
18
tmux/.config/tmux/different-layout/LICENSE.MIT
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
Copyright 2012— Gregory Pakosz
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
13
tmux/.config/tmux/different-layout/LICENSE.WTFPLv2
Normal file
13
tmux/.config/tmux/different-layout/LICENSE.WTFPLv2
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
|
||||
Version 2, December 2004
|
||||
|
||||
Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
|
||||
|
||||
Everyone is permitted to copy and distribute verbatim or modified
|
||||
copies of this license document, and changing it is allowed as long
|
||||
as the name is changed.
|
||||
|
||||
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. You just DO WHAT THE FUCK YOU WANT TO.
|
||||
370
tmux/.config/tmux/different-layout/README.md
Normal file
370
tmux/.config/tmux/different-layout/README.md
Normal file
|
|
@ -0,0 +1,370 @@
|
|||
.tmux
|
||||
=====
|
||||
|
||||
Self-contained, pretty and versatile `.tmux.conf` configuration file.
|
||||
|
||||

|
||||
|
||||
Installation
|
||||
------------
|
||||
|
||||
Requirements:
|
||||
|
||||
- tmux **`>= 2.3`** (soon `>= 2.4`) running inside Linux, Mac, OpenBSD, Cygwin
|
||||
or WSL
|
||||
- awk, perl and sed
|
||||
- outside of tmux, `$TERM` must be set to `xterm-256color`
|
||||
|
||||
To install, run the following from your terminal: (you may want to backup your
|
||||
existing `~/.tmux.conf` first)
|
||||
|
||||
```
|
||||
$ cd
|
||||
$ git clone https://github.com/gpakosz/.tmux.git
|
||||
$ ln -s -f .tmux/.tmux.conf
|
||||
$ cp .tmux/.tmux.conf.local .
|
||||
```
|
||||
|
||||
💡 You can clone the repository anywhere you want, provided you create the
|
||||
proper `~/.tmux.conf` symlink and you copy the `.tmux.conf.local` sample file in
|
||||
your home directory:
|
||||
|
||||
```
|
||||
$ git clone https://github.com/gpakosz/.tmux.git /path/to/oh-my-tmux
|
||||
$ ln -s -f /path/to/oh-my-tmux/.tmux.conf ~/.tmux.conf
|
||||
$ cp /path/to/oh-my-tmux/.tmux.conf.local ~/.tmux.conf.local
|
||||
```
|
||||
|
||||
Then proceed to [customize] your `~/.tmux.conf.local` copy.
|
||||
|
||||
[customize]: #configuration
|
||||
|
||||
If you're a Vim user, setting the `$EDITOR` environment variable to `vim` will
|
||||
enable and further customize the vi-style key bindings (see tmux manual).
|
||||
|
||||
If you're new to tmux, I recommend you read [tmux 2: Productive Mouse-Free
|
||||
Development][bhtmux2] by [@bphogan].
|
||||
|
||||
[bhtmux2]: https://pragprog.com/book/bhtmux2/tmux-2
|
||||
[@bphogan]: https://twitter.com/bphogan
|
||||
|
||||
Troubleshooting
|
||||
---------------
|
||||
|
||||
- **I'm running tmux `HEAD` and things don't work properly. What should I do?**
|
||||
|
||||
Please open an issue describing what doesn't work with upcoming tmux. I'll do
|
||||
my best to address it.
|
||||
|
||||
- **Status line is broken and/or gets duplicated at the bottom of the screen.
|
||||
What gives?**
|
||||
|
||||
This particularly happens on Linux when the distribution provides a version
|
||||
of glib that received Unicode 9.0 upgrades (glib `>= 2.50.1`) while providing
|
||||
a version of glibc that didn't (glibc `< 2.26`). You may also configure
|
||||
`LC_CTYPE` to use an `UTF-8` locale. Typically VTE based terminal emulators
|
||||
rely on glib's `g_unichar_iswide()` function while tmux relies on glibc's
|
||||
`wcwidth()` function. When these two functions disagree, display gets messed
|
||||
up.
|
||||
|
||||
This can also happen on macOS when using iTerm2 and "Use Unicode version 9
|
||||
character widths" is enabled in `Preferences... > Profiles > Text`
|
||||
|
||||
For that reason, the default `~/.tmux.conf.local` file stopped using Unicode
|
||||
characters for which width changed in between Unicode 8.0 and 9.0 standards,
|
||||
as well as Emojis.
|
||||
|
||||
- **I installed Powerline and/or (patched) fonts but can't see Powerline
|
||||
symbols.**
|
||||
|
||||
First, you don't need to install Powerline. You only need fonts patched with
|
||||
Powerline symbols or the standalone `PowerlineSymbols.otf` font. Then make
|
||||
sure your `~/.tmux.conf.local` copy uses the right code points for
|
||||
`tmux_conf_theme_left_separator_XXX` values.
|
||||
|
||||
- **I'm using Bash On Windows (WSL), colors and Powerline look are broken.**
|
||||
|
||||
There is currently a [bug][1681] in the new console powering Bash On Windows
|
||||
preventing text attributes (bold, underscore, ...) to combine properly with
|
||||
colors. The workaround is to search your `~/.tmux.conf.local` copy and
|
||||
replace attributes with `'none'`.
|
||||
|
||||
Also, until Window's console replaces its GDI based render with a DirectWrite
|
||||
one, Powerline symbols will be broken.
|
||||
|
||||
The alternative is to use the [Mintty terminal for WSL][wsltty].
|
||||
|
||||
[1681]: https://github.com/Microsoft/BashOnWindows/issues/1681
|
||||
[wsltty]: https://github.com/mintty/wsltty
|
||||
|
||||
Features
|
||||
--------
|
||||
|
||||
- `C-a` acts as secondary prefix, while keeping default `C-b` prefix
|
||||
- visual theme inspired by [Powerline][]
|
||||
- [maximize any pane to a new window with `<prefix> +`][maximize-pane]
|
||||
- SSH/Mosh aware username and hostname status line information
|
||||
- mouse mode toggle with `<prefix> m`
|
||||
- automatic usage of [`reattach-to-user-namespace`][reattach-to-user-namespace]
|
||||
if available
|
||||
- laptop battery status line information
|
||||
- uptime status line information
|
||||
- optional highlight of focused pane
|
||||
- configurable new windows and panes behavior (optionally retain current path)
|
||||
- SSH/Mosh aware split pane (reconnects to remote server)
|
||||
- copy to OS clipboard (needs [`reattach-to-user-namespace`][reattach-to-user-namespace]
|
||||
on macOS, `xsel` or `xclip` on Linux)
|
||||
- support for 4-digit hexadecimal Unicode characters
|
||||
- [Facebook PathPicker][] integration if available
|
||||
- [Urlview][] integration if available
|
||||
|
||||
[Powerline]: https://github.com/Lokaltog/powerline
|
||||
[maximize-pane]: http://pempek.net/articles/2013/04/14/maximizing-tmux-pane-new-window/
|
||||
[reattach-to-user-namespace]: https://github.com/ChrisJohnsen/tmux-MacOSX-pasteboard
|
||||
[Facebook PathPicker]: https://facebook.github.io/PathPicker/
|
||||
[Urlview]: https://packages.debian.org/stable/misc/urlview
|
||||
|
||||
The "maximize any pane to a new window with `<prefix> +`" feature is different
|
||||
from builtin `resize-pane -Z` as it allows you to further split a maximized
|
||||
pane. It's also more flexible by allowing you to maximize a pane to a new
|
||||
window, then change window, then go back and the pane is still in maximized
|
||||
state in its own window. You can then minimize a pane by using `<prefix> +`
|
||||
either from the source window or the maximized window.
|
||||
|
||||

|
||||
|
||||
Mouse mode allows you to set the active window, set the active pane, resize
|
||||
panes and automatically switches to copy-mode to select text.
|
||||
|
||||

|
||||
|
||||
Bindings
|
||||
--------
|
||||
|
||||
tmux may be controlled from an attached client by using a key combination of a
|
||||
prefix key, followed by a command key. This configuration uses `C-a` as a
|
||||
secondary prefix while keeping `C-b` as the default prefix. In the following
|
||||
list of key bindings:
|
||||
- `<prefix>` means you have to either hit <kbd>Ctrl</kbd> + <kbd>a</kbd> or <kbd>Ctrl</kbd> + <kbd>b</kbd>
|
||||
- `<prefix> c` means you have to hit <kbd>Ctrl</kbd> + <kbd>a</kbd> or <kbd>Ctrl</kbd> + <kbd>b</kbd> followed by <kbd>c</kbd>
|
||||
- `<prefix> C-c` means you have to hit <kbd>Ctrl</kbd> + <kbd>a</kbd> or <kbd>Ctrl</kbd> + <kbd>b</kbd> followed by <kbd>Ctrl</kbd> + <kbd>c</kbd>
|
||||
|
||||
This configuration uses the following bindings:
|
||||
|
||||
- `<prefix> e` opens `~/.tmux.conf.local` with the editor defined by the
|
||||
`$EDITOR` environment variable (defaults to `vim` when empty)
|
||||
- `<prefix> r` reloads the configuration
|
||||
- `C-l` clears both the screen and the tmux history
|
||||
|
||||
- `<prefix> C-c` creates a new session
|
||||
- `<prefix> C-f` lets you switch to another session by name
|
||||
|
||||
- `<prefix> C-h` and `<prefix> C-l` let you navigate windows (default
|
||||
`<prefix> n` and `<prefix> p` are unbound)
|
||||
- `<prefix> Tab` brings you to the last active window
|
||||
|
||||
- `<prefix> -` splits the current pane vertically
|
||||
- `<prefix> _` splits the current pane horizontally
|
||||
- `<prefix> h`, `<prefix> j`, `<prefix> k` and `<prefix> l` let you navigate
|
||||
panes ala Vim
|
||||
- `<prefix> H`, `<prefix> J`, `<prefix> K`, `<prefix> L` let you resize panes
|
||||
- `<prefix> <` and `<prefix> >` let you swap panes
|
||||
- `<prefix> +` maximizes the current pane to a new window
|
||||
|
||||
- `<prefix> m` toggles mouse mode on or off
|
||||
|
||||
- `<prefix> U` launches Urlview (if available)
|
||||
- `<prefix> F` launches Facebook PathPicker (if available)
|
||||
|
||||
- `<prefix> Enter` enters copy-mode
|
||||
- `<prefix> b` lists the paste-buffers
|
||||
- `<prefix> p` pastes from the top paste-buffer
|
||||
- `<prefix> P` lets you choose the paste-buffer to paste from
|
||||
|
||||
Additionally, `copy-mode-vi` matches [my own Vim configuration][]
|
||||
|
||||
[my own Vim configuration]: https://github.com/gpakosz/.vim.git
|
||||
|
||||
Bindings for `copy-mode-vi`:
|
||||
|
||||
- `v` begins selection / visual mode
|
||||
- `C-v` toggles between blockwise visual mode and visual mode
|
||||
- `H` jumps to the start of line
|
||||
- `L` jumps to the end of line
|
||||
- `y` copies the selection to the top paste-buffer
|
||||
- `Escape` cancels the current operation
|
||||
|
||||
Configuration
|
||||
-------------
|
||||
|
||||
While this configuration tries to bring sane default settings, you may want to
|
||||
customize it further to your needs. Instead of altering the `~/.tmux.conf` file
|
||||
and diverging from upstream, the proper way is to edit the `~/.tmux.conf.local`
|
||||
file.
|
||||
|
||||
Please refer to the sample `.tmux.conf.local` file to know more about variables
|
||||
you can adjust to alter different behaviors. Pressing `<prefix> e` will open
|
||||
`~/.tmux.conf.local` with the editor defined by the `$EDITOR` environment
|
||||
variable (defaults to `vim` when empty).
|
||||
|
||||
### Enabling the Powerline look
|
||||
|
||||
Powerline originated as a status-line plugin for Vim. Its popular eye-catching
|
||||
look is based on the use of special symbols: <img width="80" alt="Powerline Symbols" style="vertical-align: middle;" src="https://cloud.githubusercontent.com/assets/553208/10687156/1b76dda6-796b-11e5-83a1-1634337c4571.png" />
|
||||
|
||||
To make use of these symbols, there are several options:
|
||||
|
||||
- use a font that already bundles those: this is e.g. the case of the
|
||||
[2.030R-ro/1.050R-it version][source code pro] of the Source Code Pro font
|
||||
- use a [pre-patched font][powerline patched fonts]
|
||||
- use your preferred font along with the [Powerline font][powerline font] (that
|
||||
only contains the Powerline symbols): [this highly depends on your operating
|
||||
system and your terminal emulator][terminal support], for instance here's a
|
||||
screenshot of iTerm2 configured to use `PowerlineSymbols.otf`
|
||||

|
||||
|
||||
[source code pro]: https://github.com/adobe-fonts/source-code-pro/releases/tag/2.030R-ro/1.050R-it
|
||||
[powerline patched fonts]: https://github.com/powerline/fonts
|
||||
[powerline font]: https://github.com/powerline/powerline/raw/develop/font/PowerlineSymbols.otf
|
||||
[terminal support]: http://powerline.readthedocs.io/en/master/usage.html#usage-terminal-emulators
|
||||
[Powerline manual]: http://powerline.readthedocs.org/en/latest/installation.html#fonts-installation
|
||||
|
||||
Please see the [Powerline manual] for further details.
|
||||
|
||||
Then edit your `~/.tmux.conf.local` copy (with `<prefix> e`) and adjust the
|
||||
following variables:
|
||||
|
||||
```
|
||||
tmux_conf_theme_left_separator_main='\uE0B0'
|
||||
tmux_conf_theme_left_separator_sub='\uE0B1'
|
||||
tmux_conf_theme_right_separator_main='\uE0B2'
|
||||
tmux_conf_theme_right_separator_sub='\uE0B3'
|
||||
```
|
||||
### Configuring the status line
|
||||
|
||||
Contrary to the first iterations of this configuration, by now you have total
|
||||
control on the content and order of `status-left` and `status-right`.
|
||||
|
||||
Edit your `~/.tmux.conf.local` copy (`<prefix> e`) and adjust the
|
||||
`tmux_conf_theme_status_left` and `tmux_conf_theme_status_right` variables to
|
||||
your own preferences.
|
||||
|
||||
This configuration supports the following builtin variables:
|
||||
|
||||
- `#{battery_bar}`: horizontal battery charge bar
|
||||
- `#{battery_percentage}`: battery percentage
|
||||
- `#{battery_status}`: is battery charging or discharging?
|
||||
- `#{battery_vbar}`: vertical battery charge bar
|
||||
- `#{circled_session_name}`: circled session number, up to 20
|
||||
- `#{hostname}`: SSH/Mosh aware hostname information
|
||||
- `#{hostname_ssh}`: SSH/Mosh aware hostname information, blank when not
|
||||
connected to a remote server through SSH/Mosh
|
||||
- `#{loadavg}`: load average
|
||||
- `#{pairing}`: is session attached to more than one client?
|
||||
- `#{prefix}`: is prefix being depressed?
|
||||
- `#{root}`: is current user root?
|
||||
- `#{synchronized}`: are the panes synchronized?
|
||||
- `#{uptime_y}`: uptime years
|
||||
- `#{uptime_d}`: uptime days, modulo 365 when `#{uptime_y}` is used
|
||||
- `#{uptime_h}`: uptime hours
|
||||
- `#{uptime_m}`: uptime minutes
|
||||
- `#{uptime_s}`: uptime seconds
|
||||
- `#{username}`: SSH/Mosh aware username information
|
||||
- `#{username_ssh}`: SSH aware username information, blank when not connected
|
||||
to a remote server through SSH/Mosh
|
||||
|
||||
Beside custom variables mentioned above, the `tmux_conf_theme_status_left` and
|
||||
`tmux_conf_theme_status_right` variables support usual tmux syntax, e.g. using
|
||||
`#()` to call an external command that inserts weather information provided by
|
||||
[wttr.in]:
|
||||
```
|
||||
tmux_conf_theme_status_right='#{prefix}#{pairing}#{synchronized} #(curl -m 1 wttr.in?format=3 2>/dev/null; sleep 900) , %R , %d %b | #{username}#{root} | #{hostname} '
|
||||
```
|
||||
The `sleep 900` call makes sure the network request is issued at most every 15
|
||||
minutes whatever the value of `status-interval`.
|
||||
|
||||

|
||||
|
||||
[wttr.in]: https://github.com/chubin/wttr.in#one-line-output
|
||||
|
||||
💡 You can also define your own custom variables. See the sample
|
||||
`.tmux.conf.local` file for instructions.
|
||||
|
||||
Finally, remember `tmux_conf_theme_status_left` and
|
||||
`tmux_conf_theme_status_right` end up being given to tmux as `status-left` and
|
||||
`status-right` which means they're passed through `strftime()`. As such, the `%`
|
||||
character has a special meaning and needs to be escaped by doubling it, e.g.
|
||||
```
|
||||
tmux_conf_theme_status_right='#(echo foo %% bar)'
|
||||
```
|
||||
See `man 3 strftime`.
|
||||
|
||||
### Using TPM plugins
|
||||
|
||||
This configuration now comes with built-in [TPM] support:
|
||||
- use the `set -g @plugin ...` syntax to enable a plugin
|
||||
- whenever a plugin introduces a variable to be used in `status-left` or
|
||||
`status-right`, you can use it in `tmux_conf_theme_status_left` and
|
||||
`tmux_conf_theme_status_right` variables, see instructions above 👆
|
||||
- ⚠️ do not add `set -g @plugin 'tmux-plugins/tpm'`
|
||||
- ⚠️ do not add `run '~/.tmux/plugins/tpm/tpm'` to `~/.tmux.conf` or your
|
||||
- `~/.tmux.conf.local` copy ← people who are used to alter
|
||||
`.tmux.conf` to add TPM support will have to adapt their configuration
|
||||
|
||||
⚠️ The TPM bindings differ slightly from upstream:
|
||||
- installing plugins: `<prefix> + I`
|
||||
- uninstalling plugins: `<prefix> + Alt + u`
|
||||
- updating plugins: `<prefix> + u`
|
||||
|
||||
See `~/.tmux.conf.local` for instructions.
|
||||
|
||||
[TPM]: https://github.com/tmux-plugins/tpm
|
||||
|
||||
### Accessing the macOS clipboard from within tmux sessions (tmux `< 2.6`)
|
||||
|
||||
[Chris Johnsen created the `reattach-to-user-namespace`
|
||||
utility][reattach-to-user-namespace] that makes `pbcopy` and `pbpaste` work
|
||||
again within tmux.
|
||||
|
||||
To install `reattach-to-user-namespace`, use either [MacPorts][] or
|
||||
[Homebrew][]:
|
||||
|
||||
$ port install tmux-pasteboard
|
||||
|
||||
or
|
||||
|
||||
$ brew install reattach-to-user-namespace
|
||||
|
||||
Once installed, `reattach-to-usernamespace` will be automatically detected.
|
||||
|
||||
[MacPorts]: http://www.macports.org/
|
||||
[Homebrew]: http://brew.sh/
|
||||
|
||||
### Using the configuration under Cygwin within Mintty
|
||||
|
||||
**I don't recommend running this configuration with Cygwin anymore. Forking
|
||||
under Cygwin is extremely slow and this configuration issues a lot of
|
||||
`run-shell` commands under the hood. As such, you will experience high CPU
|
||||
usage. As an alternative consider using [Mintty terminal for WSL][wsltty].**
|
||||
|
||||

|
||||
|
||||
It is possible to use this configuration under Cygwin within Mintty, however
|
||||
support for Unicode symbols and emojis lacks behind Mac and Linux.
|
||||
|
||||
Particularly, Mintty's text rendering is implemented with GDI which has
|
||||
limitations:
|
||||
|
||||
- color emojis are only available through DirectWrite starting with Windows 8.1
|
||||
- display of double width symbols, like the battery discharging symbol indicator
|
||||
(U+1F50B) is buggy
|
||||
|
||||
To get Unicode symbols displayed properly, you have to use [font linking].
|
||||
Open `regedit.exe` then navigate to the registry key at
|
||||
`HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\FontLink\SystemLink`
|
||||
and add a new entry for you preferred font to link it with the Segoe UI Symbol
|
||||
font.
|
||||
|
||||

|
||||
|
||||
[font linking]: https://msdn.microsoft.com/en-us/goglobal/bb688134.aspx
|
||||
18
tmux/.config/tmux/plugins/tmux-power/.github/stale.yml
vendored
Normal file
18
tmux/.config/tmux/plugins/tmux-power/.github/stale.yml
vendored
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
# Number of days of inactivity before an issue becomes stale
|
||||
daysUntilStale: 60
|
||||
# Number of days of inactivity before a stale issue is closed
|
||||
daysUntilClose: 7
|
||||
# Issues with these labels will never be considered stale
|
||||
exemptLabels:
|
||||
- pinned
|
||||
- security
|
||||
- bug
|
||||
# Label to use when marking an issue as stale
|
||||
staleLabel: stale
|
||||
# Comment to post when marking an issue as stale. Set to `false` to disable
|
||||
markComment: >
|
||||
This issue has been automatically marked as stale because it has not had
|
||||
recent activity. It will be closed if no further activity occurs. Thank you
|
||||
for your contributions.
|
||||
# Comment to post when closing a stale issue. Set to `false` to disable
|
||||
closeComment: false
|
||||
1
tmux/.config/tmux/plugins/tmux-power/LICENSE
Normal file
1
tmux/.config/tmux/plugins/tmux-power/LICENSE
Normal file
|
|
@ -0,0 +1 @@
|
|||
https://wfxr.mit-license.org/2017
|
||||
118
tmux/.config/tmux/plugins/tmux-power/README.md
Normal file
118
tmux/.config/tmux/plugins/tmux-power/README.md
Normal file
|
|
@ -0,0 +1,118 @@
|
|||
# Tmux Powerline Theme
|
||||
|
||||
[](https://github.com/tmux-plugins/tpm)
|
||||
[](https://github.com/rothgar/awesome-tmux)
|
||||
[](https://wfxr.mit-license.org/2017)
|
||||
|
||||
Yet another powerline theme for tmux.
|
||||
|
||||
### 📥 Installation
|
||||
|
||||
**Install manually**
|
||||
|
||||
Clone the repo somewhere and source it in `.tmux.conf`:
|
||||
|
||||
```tmux
|
||||
run-shell "/path/to/tmux-power.tmux"
|
||||
```
|
||||
|
||||
*NOTE: Options should be set before sourcing.*
|
||||
|
||||
**Install using [TPM](https://github.com/tmux-plugins/tpm)**
|
||||
|
||||
```tmux
|
||||
set -g @plugin 'wfxr/tmux-power'
|
||||
```
|
||||
|
||||
### 🎨 Themes
|
||||
|
||||
**Gold**(default): `set -g @tmux_power_theme 'gold'`
|
||||

|
||||
|
||||
**Redwine**: `set -g @tmux_power_theme 'redwine'`
|
||||

|
||||
|
||||
**Moon**: `set -g @tmux_power_theme 'moon'`
|
||||

|
||||
|
||||
**Forest**: `set -g @tmux_power_theme 'forest'`
|
||||

|
||||
|
||||
**Violet**: `set -g @tmux_power_theme 'violet'`
|
||||

|
||||
|
||||
**Snow**: `set -g @tmux_power_theme 'snow'`
|
||||

|
||||
|
||||
**Coral**: `set -g @tmux_power_theme 'coral'`
|
||||

|
||||
|
||||
**Sky**: `set -g @tmux_power_theme 'sky'`
|
||||

|
||||
|
||||
**Default**: `set -g @tmux_power_theme 'default'`
|
||||
Set this theme if you want to honor the terminal colorscheme. To be used with
|
||||
something like [pywal](https://github.com/dylanaraps/pywal) for instance.
|
||||
|
||||
### ⚙ Customizing
|
||||
|
||||
You can define your favourite main color if you don't like any of above.
|
||||
|
||||
```tmux
|
||||
set -g @tmux_power_theme '#483D8B' # dark slate blue
|
||||
```
|
||||
|
||||
You can change the date and time formats using strftime:
|
||||
|
||||
```tmux
|
||||
set -g @tmux_power_date_format '%F'
|
||||
set -g @tmux_power_time_format '%T'
|
||||
```
|
||||
|
||||
You can also customize the icons:
|
||||
|
||||
```tmux
|
||||
set -g @tmux_power_date_icon ' ' # set it to a blank will disable the icon
|
||||
set -g @tmux_power_time_icon '🕘' # emoji can be used if your terminal supports
|
||||
set -g @tmux_power_user_icon 'U'
|
||||
set -g @tmux_power_session_icon 'S'
|
||||
set -g @tmux_power_upload_speed_icon '↑'
|
||||
set -g @tmux_power_download_speed_icon '↓'
|
||||
set -g @tmux_power_left_arrow_icon '<'
|
||||
set -g @tmux_power_right_arrow_icon '>'
|
||||
```
|
||||
*The default icons use glyphs from [nerd-fonts](https://github.com/ryanoasis/nerd-fonts).*
|
||||
|
||||
### 📦 Plugin support
|
||||
|
||||
**[tmux-net-speed](https://github.com/wfxr/tmux-net-speed)**
|
||||
|
||||
```tmux
|
||||
set -g @tmux_power_show_upload_speed true
|
||||
set -g @tmux_power_show_download_speed true
|
||||
```
|
||||
|
||||
**[tmux-prefix-highlight](https://github.com/tmux-plugins/tmux-prefix-highlight)**
|
||||
|
||||
```tmux
|
||||
# 'L' for left only, 'R' for right only and 'LR' for both
|
||||
set -g @tmux_power_prefix_highlight_pos 'LR'
|
||||
```
|
||||
|
||||
**[tmux-web-reachable](https://github.com/wfxr/tmux-web-reachable)**
|
||||
|
||||
```tmux
|
||||
set -g @tmux_power_show_web_reachable true
|
||||
```
|
||||
|
||||
### 🔗 Other plugins
|
||||
|
||||
You might also find these useful:
|
||||
|
||||
- [tmux-fzf-url](https://github.com/wfxr/tmux-fzf-url)
|
||||
- [tmux-net-speed](https://github.com/wfxr/tmux-net-speed)
|
||||
- [tmux-web-reachable](https://github.com/wfxr/tmux-web-reachable)
|
||||
|
||||
### 📃 License
|
||||
|
||||
[MIT](https://wfxr.mit-license.org/2017) (c) Wenxuan Zhang
|
||||
168
tmux/.config/tmux/plugins/tmux-power/tmux-power.tmux
Executable file
168
tmux/.config/tmux/plugins/tmux-power/tmux-power.tmux
Executable file
|
|
@ -0,0 +1,168 @@
|
|||
#!/usr/bin/env bash
|
||||
#===============================================================================
|
||||
# Author: Wenxuan
|
||||
# Email: wenxuangm@gmail.com
|
||||
# Created: 2018-04-05 17:37
|
||||
#===============================================================================
|
||||
|
||||
# $1: option
|
||||
# $2: default value
|
||||
tmux_get() {
|
||||
local value="$(tmux show -gqv "$1")"
|
||||
[ -n "$value" ] && echo "$value" || echo "$2"
|
||||
}
|
||||
|
||||
# $1: option
|
||||
# $2: value
|
||||
tmux_set() {
|
||||
tmux set-option -gq "$1" "$2"
|
||||
}
|
||||
|
||||
# Options
|
||||
right_arrow_icon=$(tmux_get '@tmux_power_right_arrow_icon' '')
|
||||
left_arrow_icon=$(tmux_get '@tmux_power_left_arrow_icon' '')
|
||||
upload_speed_icon=$(tmux_get '@tmux_power_upload_speed_icon' '')
|
||||
download_speed_icon=$(tmux_get '@tmux_power_download_speed_icon' '')
|
||||
session_icon="$(tmux_get '@tmux_power_session_icon' '')"
|
||||
user_icon="$(tmux_get '@tmux_power_user_icon' '')"
|
||||
time_icon="$(tmux_get '@tmux_power_time_icon' '')"
|
||||
date_icon="$(tmux_get '@tmux_power_date_icon' '')"
|
||||
show_upload_speed="$(tmux_get @tmux_power_show_upload_speed false)"
|
||||
show_download_speed="$(tmux_get @tmux_power_show_download_speed false)"
|
||||
show_web_reachable="$(tmux_get @tmux_power_show_web_reachable false)"
|
||||
prefix_highlight_pos=$(tmux_get @tmux_power_prefix_highlight_pos)
|
||||
time_format=$(tmux_get @tmux_power_time_format '%T')
|
||||
date_format=$(tmux_get @tmux_power_date_format '%F')
|
||||
# short for Theme-Colour
|
||||
TC=$(tmux_get '@tmux_power_theme' 'gold')
|
||||
case $TC in
|
||||
'gold' )
|
||||
TC='#ffb86c'
|
||||
;;
|
||||
'redwine' )
|
||||
TC='#b34a47'
|
||||
;;
|
||||
'moon' )
|
||||
TC='#00abab'
|
||||
;;
|
||||
'forest' )
|
||||
TC='#228b22'
|
||||
;;
|
||||
'violet' )
|
||||
TC='#9370db'
|
||||
;;
|
||||
'snow' )
|
||||
TC='#fffafa'
|
||||
;;
|
||||
'coral' )
|
||||
TC='#ff7f50'
|
||||
;;
|
||||
'sky' )
|
||||
TC='#87ceeb'
|
||||
;;
|
||||
'default' ) # Useful when your term changes colour dynamically (e.g. pywal)
|
||||
TC='colour3'
|
||||
;;
|
||||
esac
|
||||
|
||||
G01=#080808 #232
|
||||
G02=#121212 #233
|
||||
G03=#1c1c1c #234
|
||||
G04=#262626 #235
|
||||
G05=#303030 #236
|
||||
G06=#3a3a3a #237
|
||||
G07=#444444 #238
|
||||
G08=#4e4e4e #239
|
||||
G09=#585858 #240
|
||||
G10=#626262 #241
|
||||
G11=#6c6c6c #242
|
||||
G12=#767676 #243
|
||||
|
||||
FG="$G10"
|
||||
BG="$G04"
|
||||
|
||||
# Status options
|
||||
tmux_set status-interval 1
|
||||
tmux_set status on
|
||||
|
||||
# Basic status bar colors
|
||||
tmux_set status-fg "$FG"
|
||||
tmux_set status-bg "$BG"
|
||||
tmux_set status-attr none
|
||||
|
||||
# tmux-prefix-highlight
|
||||
tmux_set @prefix_highlight_fg "$BG"
|
||||
tmux_set @prefix_highlight_bg "$FG"
|
||||
tmux_set @prefix_highlight_show_copy_mode 'on'
|
||||
tmux_set @prefix_highlight_copy_mode_attr "fg=$TC,bg=$BG,bold"
|
||||
tmux_set @prefix_highlight_output_prefix "#[fg=$TC]#[bg=$BG]$left_arrow_icon#[bg=$TC]#[fg=$BG]"
|
||||
tmux_set @prefix_highlight_output_suffix "#[fg=$TC]#[bg=$BG]$right_arrow_icon"
|
||||
|
||||
#
|
||||
# Left side of status bar
|
||||
tmux_set status-left-bg "$G04"
|
||||
tmux_set status-left-fg "G12"
|
||||
tmux_set status-left-length 150
|
||||
user=$(whoami)
|
||||
LS="#[fg=$G04,bg=$TC,bold] $user_icon $user@#h #[fg=$TC,bg=$G06,nobold]$right_arrow_icon#[fg=$TC,bg=$G06] $session_icon #S "
|
||||
if "$show_upload_speed"; then
|
||||
LS="$LS#[fg=$G06,bg=$G05]$right_arrow_icon#[fg=$TC,bg=$G05] $upload_speed_icon #{upload_speed} #[fg=$G05,bg=$BG]$right_arrow_icon"
|
||||
else
|
||||
LS="$LS#[fg=$G06,bg=$BG]$right_arrow_icon"
|
||||
fi
|
||||
if [[ $prefix_highlight_pos == 'L' || $prefix_highlight_pos == 'LR' ]]; then
|
||||
LS="$LS#{prefix_highlight}"
|
||||
fi
|
||||
tmux_set status-left "$LS"
|
||||
|
||||
# Right side of status bar
|
||||
tmux_set status-right-bg "$G04"
|
||||
tmux_set status-right-fg "G12"
|
||||
tmux_set status-right-length 150
|
||||
RS="#[fg=$G06]$left_arrow_icon#[fg=$TC,bg=$G06] $time_icon $time_format #[fg=$TC,bg=$G06]$left_arrow_icon#[fg=$G04,bg=$TC] $date_icon $date_format "
|
||||
if "$show_download_speed"; then
|
||||
RS="#[fg=$G05,bg=$BG]$left_arrow_icon#[fg=$TC,bg=$G05] $download_speed_icon #{download_speed} $RS"
|
||||
fi
|
||||
if "$show_web_reachable"; then
|
||||
RS=" #{web_reachable_status} $RS"
|
||||
fi
|
||||
if [[ $prefix_highlight_pos == 'R' || $prefix_highlight_pos == 'LR' ]]; then
|
||||
RS="#{prefix_highlight}$RS"
|
||||
fi
|
||||
tmux_set status-right "$RS"
|
||||
|
||||
# Window status
|
||||
tmux_set window-status-format " #I:#W#F "
|
||||
tmux_set window-status-current-format "#[fg=$BG,bg=$G06]$right_arrow_icon#[fg=$TC,bold] #I:#W#F #[fg=$G06,bg=$BG,nobold]$right_arrow_icon"
|
||||
|
||||
# Window separator
|
||||
tmux_set window-status-separator ""
|
||||
|
||||
# Window status alignment
|
||||
tmux_set status-justify centre
|
||||
|
||||
# Current window status
|
||||
tmux_set window-status-current-statys "fg=$TC,bg=$BG"
|
||||
|
||||
# Pane border
|
||||
tmux_set pane-border-style "fg=$G07,bg=default"
|
||||
|
||||
# Active pane border
|
||||
tmux_set pane-active-border-style "fg=$TC,bg=$BG"
|
||||
|
||||
# Pane number indicator
|
||||
tmux_set display-panes-colour "$G07"
|
||||
tmux_set display-panes-active-colour "$TC"
|
||||
|
||||
# Clock mode
|
||||
tmux_set clock-mode-colour "$TC"
|
||||
tmux_set clock-mode-style 24
|
||||
|
||||
# Message
|
||||
tmux_set message-style "fg=$TC,bg=$BG"
|
||||
|
||||
# Command message
|
||||
tmux_set message-command-style "fg=$TC,bg=$BG"
|
||||
|
||||
# Copy mode highlight
|
||||
tmux_set mode-style "bg=$TC,fg=$FG"
|
||||
2
tmux/.config/tmux/plugins/tmux-sensible/.gitattributes
vendored
Normal file
2
tmux/.config/tmux/plugins/tmux-sensible/.gitattributes
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
# Force text files to have unix eols, so Windows/Cygwin does not break them
|
||||
*.* eol=lf
|
||||
43
tmux/.config/tmux/plugins/tmux-sensible/CHANGELOG.md
Normal file
43
tmux/.config/tmux/plugins/tmux-sensible/CHANGELOG.md
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
# Changelog
|
||||
|
||||
### master
|
||||
- remove `detach-on-destroy`
|
||||
- do not set `aggressive-resize` on iTerm terminal
|
||||
- disable `detach-on-destroy`
|
||||
|
||||
### v3.0.0, 2015-06-24
|
||||
- remove 'almost sensible' feature
|
||||
|
||||
### v2.3.0, 2015-06-24
|
||||
- update to support \*THE\* latest tmux version
|
||||
- bugfix for `prefix + R` key binding
|
||||
- fix for tmux 2.0 `default-terminal` option (thanks @kwbr)
|
||||
|
||||
### v2.2.0, 2015-02-10
|
||||
- bugfix in `key_binding_not_set`: the regex is now properly detecting key
|
||||
bindings with `-r` flag.
|
||||
- enable `aggressive-resize`
|
||||
|
||||
### v2.1.0, 2014-12-12
|
||||
- check before binding `prefix + prefix` (@m1foley)
|
||||
- enable `focus-events`
|
||||
- deprecate 'almost sensible' feature. The reason for this is to focus the
|
||||
plugin on doing just one thing.
|
||||
|
||||
### v2.0.0, 2014-10-03
|
||||
- bugfix: prevent exiting tmux if 'reattach-to-user-namespace' is not installed
|
||||
- remove all mouse-related options
|
||||
- introduce 'almost sensible' setting and options
|
||||
|
||||
### v1.1.0, 2014-08-30
|
||||
- bugfix: determine the default shell from the $SHELL env var on OS X
|
||||
- set `mode-mouse on` by default
|
||||
- do not make any decision about the prefix, just enhance it
|
||||
- update `README.md`. List options set in the plugin.
|
||||
- do *not* set `mode-mouse on` by default because some users don't like it
|
||||
- if a user changes default prefix but binds `C-b` to something else, do not
|
||||
unbind `C-b`
|
||||
|
||||
### v1.0.0, 2014-07-30
|
||||
- initial work on the plugin
|
||||
- add readme
|
||||
19
tmux/.config/tmux/plugins/tmux-sensible/LICENSE.md
Normal file
19
tmux/.config/tmux/plugins/tmux-sensible/LICENSE.md
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
Copyright (C) 2014 Bruno Sutic
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the "Software"),
|
||||
to deal in the Software without restriction, including without limitation
|
||||
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
and/or sell copies of the Software, and to permit persons to whom the
|
||||
Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included
|
||||
in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
|
||||
OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
110
tmux/.config/tmux/plugins/tmux-sensible/README.md
Normal file
110
tmux/.config/tmux/plugins/tmux-sensible/README.md
Normal file
|
|
@ -0,0 +1,110 @@
|
|||
# Tmux sensible
|
||||
|
||||
A set of tmux options that should be acceptable to everyone.
|
||||
|
||||
Inspired by [vim-sensible](https://github.com/tpope/vim-sensible).
|
||||
|
||||
Tested and working on Linux, OSX and Cygwin.
|
||||
|
||||
### Principles
|
||||
|
||||
- `tmux-sensible` options should be acceptable to **every** tmux user!<br/>
|
||||
If any of the options bothers you, please open an issue and it will probably
|
||||
be updated (or removed).
|
||||
- if you think a new option should be added, feel free to open a pull request.
|
||||
- **no overriding** of user defined settings.<br/>
|
||||
Your existing `.tmux.conf` settings are respected and they won't be changed.
|
||||
That way you can use `tmux-sensible` if you have a few specific options.
|
||||
|
||||
### Goals
|
||||
|
||||
- group standard tmux community options in one place
|
||||
- remove clutter from your `.tmux.conf`
|
||||
- educate new tmux users about basic options
|
||||
|
||||
### Options
|
||||
|
||||
# address vim mode switching delay (http://superuser.com/a/252717/65504)
|
||||
set -s escape-time 0
|
||||
|
||||
# increase scrollback buffer size
|
||||
set -g history-limit 50000
|
||||
|
||||
# tmux messages are displayed for 4 seconds
|
||||
set -g display-time 4000
|
||||
|
||||
# refresh 'status-left' and 'status-right' more often
|
||||
set -g status-interval 5
|
||||
|
||||
# set only on OS X where it's required
|
||||
set -g default-command "reattach-to-user-namespace -l $SHELL"
|
||||
|
||||
# upgrade $TERM
|
||||
set -g default-terminal "screen-256color"
|
||||
|
||||
# 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
|
||||
|
||||
### Key bindings
|
||||
|
||||
# easier and faster switching between next/prev window
|
||||
bind C-p previous-window
|
||||
bind C-n next-window
|
||||
|
||||
Above bindings enhance the default `prefix + p` and `prefix + n` bindings by
|
||||
allowing you to hold `Ctrl` and repeat `a + p`/`a + n` (if your prefix is
|
||||
`C-a`), which is a lot quicker.
|
||||
|
||||
# source .tmux.conf as suggested in `man tmux`
|
||||
bind R source-file '~/.tmux.conf'
|
||||
|
||||
"Adaptable" key bindings that build upon your `prefix` value:
|
||||
|
||||
# if prefix is 'C-a'
|
||||
bind C-a send-prefix
|
||||
bind a last-window
|
||||
|
||||
If prefix is `C-b`, above keys will be `C-b` and `b`.<br/>
|
||||
If prefix is `C-z`, above keys will be `C-z` and `z`... you get the idea.
|
||||
|
||||
### Installation with [Tmux Plugin Manager](https://github.com/tmux-plugins/tpm) (recommended)
|
||||
|
||||
Add plugin to the list of TPM plugins in `.tmux.conf`:
|
||||
|
||||
set -g @plugin 'tmux-plugins/tmux-sensible'
|
||||
|
||||
Hit `prefix + I` to fetch the plugin and source it. That's it!
|
||||
|
||||
### Manual Installation
|
||||
|
||||
Clone the repo:
|
||||
|
||||
$ git clone https://github.com/tmux-plugins/tmux-sensible ~/clone/path
|
||||
|
||||
Add this line to the bottom of `.tmux.conf`:
|
||||
|
||||
run-shell ~/clone/path/sensible.tmux
|
||||
|
||||
Reload TMUX environment with `$ tmux source-file ~/.tmux.conf`, and that's it.
|
||||
|
||||
### Other goodies
|
||||
|
||||
You might also find these useful:
|
||||
|
||||
- [copycat](https://github.com/tmux-plugins/tmux-copycat)
|
||||
improve tmux search and reduce mouse usage
|
||||
- [pain control](https://github.com/tmux-plugins/tmux-pain-control)
|
||||
useful standard bindings for controlling panes
|
||||
- [resurrect](https://github.com/tmux-plugins/tmux-resurrect)
|
||||
persists tmux environment across system restarts
|
||||
|
||||
### License
|
||||
|
||||
[MIT](LICENSE.md)
|
||||
168
tmux/.config/tmux/plugins/tmux-sensible/sensible.tmux
Executable file
168
tmux/.config/tmux/plugins/tmux-sensible/sensible.tmux
Executable file
|
|
@ -0,0 +1,168 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
|
||||
# used to match output from `tmux list-keys`
|
||||
KEY_BINDING_REGEX="bind-key[[:space:]]\+\(-r[[:space:]]\+\)\?\(-T prefix[[:space:]]\+\)\?"
|
||||
|
||||
is_osx() {
|
||||
local platform=$(uname)
|
||||
[ "$platform" == "Darwin" ]
|
||||
}
|
||||
|
||||
iterm_terminal() {
|
||||
[[ "${TERM_PROGRAM}" =~ ^iTerm || "${LC_TERMINAL}" =~ ^iTerm ]]
|
||||
}
|
||||
|
||||
command_exists() {
|
||||
local command="$1"
|
||||
type "$command" >/dev/null 2>&1
|
||||
}
|
||||
|
||||
# returns prefix key, e.g. 'C-a'
|
||||
prefix() {
|
||||
tmux show-option -gv prefix
|
||||
}
|
||||
|
||||
# if prefix is 'C-a', this function returns 'a'
|
||||
prefix_without_ctrl() {
|
||||
local prefix="$(prefix)"
|
||||
echo "$prefix" | cut -d '-' -f2
|
||||
}
|
||||
|
||||
option_value_not_changed() {
|
||||
local option="$1"
|
||||
local default_value="$2"
|
||||
local option_value=$(tmux show-option -gv "$option")
|
||||
[ "$option_value" == "$default_value" ]
|
||||
}
|
||||
|
||||
server_option_value_not_changed() {
|
||||
local option="$1"
|
||||
local default_value="$2"
|
||||
local option_value=$(tmux show-option -sv "$option")
|
||||
[ "$option_value" == "$default_value" ]
|
||||
}
|
||||
|
||||
key_binding_not_set() {
|
||||
local key="${1//\\/\\\\}"
|
||||
if $(tmux list-keys | grep -q "${KEY_BINDING_REGEX}${key}[[:space:]]"); then
|
||||
return 1
|
||||
else
|
||||
return 0
|
||||
fi
|
||||
}
|
||||
|
||||
key_binding_not_changed() {
|
||||
local key="$1"
|
||||
local default_value="$2"
|
||||
if $(tmux list-keys | grep -q "${KEY_BINDING_REGEX}${key}[[:space:]]\+${default_value}"); then
|
||||
# key still has the default binding
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
get_tmux_config() {
|
||||
local tmux_config_xdg="${XDG_CONFIG_HOME:-$HOME/.config}/tmux/tmux.conf"
|
||||
local tmux_config="$HOME/.tmux.conf"
|
||||
|
||||
if [ -f "${tmux_config_xdg}" ]; then
|
||||
echo "${tmux_config_xdg}"
|
||||
else
|
||||
echo ${tmux_config}
|
||||
fi
|
||||
}
|
||||
|
||||
main() {
|
||||
# OPTIONS
|
||||
|
||||
# address vim mode switching delay (http://superuser.com/a/252717/65504)
|
||||
if server_option_value_not_changed "escape-time" "500"; then
|
||||
tmux set-option -s escape-time 0
|
||||
fi
|
||||
|
||||
# increase scrollback buffer size
|
||||
if option_value_not_changed "history-limit" "2000"; then
|
||||
tmux set-option -g history-limit 50000
|
||||
fi
|
||||
|
||||
# tmux messages are displayed for 4 seconds
|
||||
if option_value_not_changed "display-time" "750"; then
|
||||
tmux set-option -g display-time 4000
|
||||
fi
|
||||
|
||||
# refresh 'status-left' and 'status-right' more often
|
||||
if option_value_not_changed "status-interval" "15"; then
|
||||
tmux set-option -g status-interval 5
|
||||
fi
|
||||
|
||||
# required (only) on OS X
|
||||
if is_osx && command_exists "reattach-to-user-namespace" && option_value_not_changed "default-command" ""; then
|
||||
tmux set-option -g default-command "reattach-to-user-namespace -l $SHELL"
|
||||
fi
|
||||
|
||||
# upgrade $TERM, tmux 1.9
|
||||
if option_value_not_changed "default-terminal" "screen"; then
|
||||
tmux set-option -g default-terminal "screen-256color"
|
||||
fi
|
||||
# upgrade $TERM, tmux 2.0+
|
||||
if server_option_value_not_changed "default-terminal" "screen"; then
|
||||
tmux set-option -s default-terminal "screen-256color"
|
||||
fi
|
||||
|
||||
# emacs key bindings in tmux command prompt (prefix + :) are better than
|
||||
# vi keys, even for vim users
|
||||
tmux set-option -g status-keys emacs
|
||||
|
||||
# focus events enabled for terminals that support them
|
||||
tmux set-option -g focus-events on
|
||||
|
||||
# super useful when using "grouped sessions" and multi-monitor setup
|
||||
if ! iterm_terminal; then
|
||||
tmux set-window-option -g aggressive-resize on
|
||||
fi
|
||||
|
||||
# DEFAULT KEY BINDINGS
|
||||
|
||||
local prefix="$(prefix)"
|
||||
local prefix_without_ctrl="$(prefix_without_ctrl)"
|
||||
|
||||
# if C-b is not prefix
|
||||
if [ $prefix != "C-b" ]; then
|
||||
# unbind obsolete default binding
|
||||
if key_binding_not_changed "C-b" "send-prefix"; then
|
||||
tmux unbind-key C-b
|
||||
fi
|
||||
|
||||
# pressing `prefix + prefix` sends <prefix> to the shell
|
||||
if key_binding_not_set "$prefix"; then
|
||||
tmux bind-key "$prefix" send-prefix
|
||||
fi
|
||||
fi
|
||||
|
||||
# If Ctrl-a is prefix then `Ctrl-a + a` switches between alternate windows.
|
||||
# Works for any prefix character.
|
||||
if key_binding_not_set "$prefix_without_ctrl"; then
|
||||
tmux bind-key "$prefix_without_ctrl" last-window
|
||||
fi
|
||||
|
||||
# easier switching between next/prev window
|
||||
if key_binding_not_set "C-p"; then
|
||||
tmux bind-key C-p previous-window
|
||||
fi
|
||||
if key_binding_not_set "C-n"; then
|
||||
tmux bind-key C-n next-window
|
||||
fi
|
||||
|
||||
# source `.tmux.conf` file - as suggested in `man tmux`
|
||||
if key_binding_not_set "R"; then
|
||||
local tmux_config=$(get_tmux_config)
|
||||
|
||||
tmux bind-key R run-shell " \
|
||||
tmux source-file ${tmux_config} > /dev/null; \
|
||||
tmux display-message 'Sourced ${tmux_config}!'"
|
||||
fi
|
||||
}
|
||||
main
|
||||
9
tmux/.config/tmux/plugins/tpm/.gitattributes
vendored
Normal file
9
tmux/.config/tmux/plugins/tpm/.gitattributes
vendored
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
# Force text files to have unix eols, so Windows/Cygwin does not break them
|
||||
*.* eol=lf
|
||||
|
||||
# These files are unfortunately not recognized as text files so
|
||||
# explicitly listing them here
|
||||
tpm eol=lf
|
||||
bin/* eol=lf
|
||||
bindings/* eol=lf
|
||||
tests/* eol=lf
|
||||
4
tmux/.config/tmux/plugins/tpm/.gitignore
vendored
Normal file
4
tmux/.config/tmux/plugins/tpm/.gitignore
vendored
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
**/.vagrant/
|
||||
run_tests
|
||||
tests/run_tests_in_isolation
|
||||
tests/helpers/helpers.sh
|
||||
3
tmux/.config/tmux/plugins/tpm/.gitmodules
vendored
Normal file
3
tmux/.config/tmux/plugins/tpm/.gitmodules
vendored
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
[submodule "lib/tmux-test"]
|
||||
path = lib/tmux-test
|
||||
url = https://github.com/tmux-plugins/tmux-test.git
|
||||
19
tmux/.config/tmux/plugins/tpm/.travis.yml
Normal file
19
tmux/.config/tmux/plugins/tpm/.travis.yml
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
# generic packages and tmux
|
||||
before_install:
|
||||
- sudo apt-get update
|
||||
- sudo apt-get install -y git-core expect
|
||||
- sudo apt-get install -y python-software-properties software-properties-common
|
||||
- sudo apt-get install -y libevent-dev libncurses-dev
|
||||
- git clone https://github.com/tmux/tmux.git
|
||||
- cd tmux
|
||||
- git checkout 2.0
|
||||
- sh autogen.sh
|
||||
- ./configure && make && sudo make install
|
||||
|
||||
install:
|
||||
- git fetch --unshallow --recurse-submodules || git fetch --recurse-submodules
|
||||
# manual `git clone` required for testing `tmux-test` plugin itself
|
||||
- git clone https://github.com/tmux-plugins/tmux-test lib/tmux-test; true
|
||||
- lib/tmux-test/setup
|
||||
|
||||
script: ./tests/run_tests_in_isolation
|
||||
83
tmux/.config/tmux/plugins/tpm/CHANGELOG.md
Normal file
83
tmux/.config/tmux/plugins/tpm/CHANGELOG.md
Normal file
|
|
@ -0,0 +1,83 @@
|
|||
# Changelog
|
||||
|
||||
### master
|
||||
- upgrade to new version of `tmux-test`
|
||||
- bug: when using `emacs` copy mode, Enter does not quit screen after tpm
|
||||
installation/update. Fix by making `Escape` the key for emacs mode.
|
||||
- add a doc with troubleshooting instructions
|
||||
- add `.gitattributes` file that forces linefeed characters (classic `\n`) as
|
||||
line endings - helps with misconfigured git on windows/cygwin
|
||||
- readme update: announce Cygwin support
|
||||
- un-deprecate old plugin definition syntax: `set -g @tpm_plugins`
|
||||
|
||||
### v3.0.0, 2015-08-03
|
||||
- refactor `shared_set_tpm_path_constant` function
|
||||
- move all instructions to `docs/` dir
|
||||
- add `bin/install_plugins` cli executable script
|
||||
- improved test runner function
|
||||
- switch to using [tmux-test](https://github.com/tmux-plugins/tmux-test)
|
||||
framework
|
||||
- add `bin/update_plugins` cli executable script
|
||||
- refactor test `expect` scripts, make them simpler and ensure they properly
|
||||
assert expectations
|
||||
- refactor code that sets 'TMUX_PLUGIN_MANAGER_PATH' global env var
|
||||
- stop using global variable for 'tpm path'
|
||||
- support defining plugins via `set -g @plugin` in sourced files as well
|
||||
|
||||
### v2.0.0, 2015-07-07
|
||||
- enable overriding default key bindings
|
||||
- start using `C-c` to clear screen
|
||||
- add uninstall/clean procedure and keybinding (prefix+alt+u) (@chilicuil)
|
||||
- add new `set @plugin 'repo'` plugin definition syntax (@chilicuil)
|
||||
- revert back to using `-g` flag in new plugin definition syntax
|
||||
- permit leading whitespace with new plugin definition syntax (thanks @chilicuil)
|
||||
- make sure `TMUX_PLUGIN_MANAGER_PATH` always has trailng slash
|
||||
- ensure old/deprecated plugin syntax `set -g @tpm_plugins` works alongside new
|
||||
`set -g @plugin` syntax
|
||||
|
||||
### v1.2.2, 2015-02-08
|
||||
- set GIT_TERMINAL_PROMPT=0 when doing `git clone`, `pull` or `submodule update`
|
||||
to ensure git does not prompt for username/password in any case
|
||||
|
||||
### v1.2.1, 2014-11-21
|
||||
- change the way plugin name is expanded. It now uses the http username
|
||||
and password by default, like this: `https://git::@github.com/`. This prevents
|
||||
username and password prompt (and subsequently tmux install hanging) with old
|
||||
git versions. Fixes #7.
|
||||
|
||||
### v1.2.0, 2014-11-20
|
||||
- refactor tests so they can be used on travis
|
||||
- add travis.yml, add travis badge to the readme
|
||||
|
||||
### v1.1.0, 2014-11-19
|
||||
- if the plugin is not downloaded do not source it
|
||||
- remove `PLUGINS.md`, an obsolete list of plugins
|
||||
- update readme with instructions about uninstalling plugins
|
||||
- tilde char and `$HOME` in `TMUX_SHARED_MANAGER_PATH` couldn't be used because
|
||||
they are just plain strings. Fixing the problem by manually expanding them.
|
||||
- bugfix: fragile `*.tmux` file globbing (@majutsushi)
|
||||
|
||||
### v1.0.0, 2014-08-05
|
||||
- update readme because of github organization change to
|
||||
[tmux-plugins](https://github.com/tmux-plugins)
|
||||
- update tests to pass
|
||||
- update README to suggest different first plugin
|
||||
- update list of plugins in the README
|
||||
- remove README 'about' section
|
||||
- move key binding to the main file. Delete `key_binding.sh`.
|
||||
- rename `display_message` -> `echo_message`
|
||||
- installing plugins installs just new plugins. Already installed plugins aren't
|
||||
updated.
|
||||
- add 'update plugin' binding and functionality
|
||||
- add test for updating a plugin
|
||||
|
||||
### v0.0.2, 2014-07-17
|
||||
- run all *.tmux plugin files as executables
|
||||
- fix all redirects to /dev/null
|
||||
- fix bug: TPM shared path is created before sync (cloning plugins from github
|
||||
is done)
|
||||
- add test suite running in Vagrant
|
||||
- add Tmux version check. `TPM` won't run if Tmux version is less than 1.9.
|
||||
|
||||
### v0.0.1, 2014-05-21
|
||||
- get TPM up and running
|
||||
2
tmux/.config/tmux/plugins/tpm/HOW_TO_PLUGIN.md
Normal file
2
tmux/.config/tmux/plugins/tpm/HOW_TO_PLUGIN.md
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
Instructions moved to
|
||||
[docs/how_to_create_plugin.md](docs/how_to_create_plugin.md).
|
||||
20
tmux/.config/tmux/plugins/tpm/LICENSE.md
Normal file
20
tmux/.config/tmux/plugins/tpm/LICENSE.md
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
MIT license
|
||||
Copyright (C) 2014 Bruno Sutic
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the "Software"),
|
||||
to deal in the Software without restriction, including without limitation
|
||||
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
and/or sell copies of the Software, and to permit persons to whom the
|
||||
Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included
|
||||
in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
|
||||
OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
101
tmux/.config/tmux/plugins/tpm/README.md
Normal file
101
tmux/.config/tmux/plugins/tpm/README.md
Normal file
|
|
@ -0,0 +1,101 @@
|
|||
# Tmux Plugin Manager
|
||||
|
||||
[](https://travis-ci.org/tmux-plugins/tpm)
|
||||
|
||||
Installs and loads `tmux` plugins.
|
||||
|
||||
Tested and working on Linux, OSX, and Cygwin.
|
||||
|
||||
See list of plugins [here](https://github.com/tmux-plugins/list).
|
||||
|
||||
### Installation
|
||||
|
||||
Requirements: `tmux` version 1.9 (or higher), `git`, `bash`.
|
||||
|
||||
Clone TPM:
|
||||
|
||||
```bash
|
||||
$ git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm
|
||||
```
|
||||
|
||||
Put this at the bottom of `~/.tmux.conf` (`$XDG_CONFIG_HOME/tmux/tmux.conf`
|
||||
works too):
|
||||
|
||||
```bash
|
||||
# List of plugins
|
||||
set -g @plugin 'tmux-plugins/tpm'
|
||||
set -g @plugin 'tmux-plugins/tmux-sensible'
|
||||
|
||||
# Other examples:
|
||||
# set -g @plugin 'github_username/plugin_name'
|
||||
# set -g @plugin 'github_username/plugin_name#branch'
|
||||
# set -g @plugin 'git@github.com:user/plugin'
|
||||
# set -g @plugin 'git@bitbucket.com:user/plugin'
|
||||
|
||||
# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
|
||||
run '~/.tmux/plugins/tpm/tpm'
|
||||
```
|
||||
|
||||
Reload TMUX environment so TPM is sourced:
|
||||
|
||||
```bash
|
||||
# type this in terminal if tmux is already running
|
||||
$ tmux source ~/.tmux.conf
|
||||
```
|
||||
|
||||
That's it!
|
||||
|
||||
### Installing plugins
|
||||
|
||||
1. Add new plugin to `~/.tmux.conf` with `set -g @plugin '...'`
|
||||
2. Press `prefix` + <kbd>I</kbd> (capital i, as in **I**nstall) to fetch the plugin.
|
||||
|
||||
You're good to go! The plugin was cloned to `~/.tmux/plugins/` dir and sourced.
|
||||
|
||||
### Uninstalling plugins
|
||||
|
||||
1. Remove (or comment out) plugin from the list.
|
||||
2. Press `prefix` + <kbd>alt</kbd> + <kbd>u</kbd> (lowercase u as in **u**ninstall) to remove the plugin.
|
||||
|
||||
All the plugins are installed to `~/.tmux/plugins/` so alternatively you can
|
||||
find plugin directory there and remove it.
|
||||
|
||||
### Key bindings
|
||||
|
||||
`prefix` + <kbd>I</kbd>
|
||||
- Installs new plugins from GitHub or any other git repository
|
||||
- Refreshes TMUX environment
|
||||
|
||||
`prefix` + <kbd>U</kbd>
|
||||
- updates plugin(s)
|
||||
|
||||
`prefix` + <kbd>alt</kbd> + <kbd>u</kbd>
|
||||
- remove/uninstall plugins not on the plugin list
|
||||
|
||||
### Docs
|
||||
|
||||
- [Help, tpm not working](docs/tpm_not_working.md) - problem solutions
|
||||
|
||||
More advanced features and instructions, regular users probably do not need
|
||||
this:
|
||||
|
||||
- [How to create a plugin](docs/how_to_create_plugin.md). It's easy.
|
||||
- [Managing plugins via the command line](docs/managing_plugins_via_cmd_line.md)
|
||||
- [Changing plugins install dir](docs/changing_plugins_install_dir.md)
|
||||
- [Automatic TPM installation on a new machine](docs/automatic_tpm_installation.md)
|
||||
|
||||
### Tests
|
||||
|
||||
Tests for this project run on [Travis CI](https://travis-ci.org/tmux-plugins/tpm).
|
||||
|
||||
When run locally, [vagrant](https://www.vagrantup.com/) is required.
|
||||
Run tests with:
|
||||
|
||||
```bash
|
||||
# within project directory
|
||||
$ ./run_tests
|
||||
```
|
||||
|
||||
### License
|
||||
|
||||
[MIT](LICENSE.md)
|
||||
14
tmux/.config/tmux/plugins/tpm/bin/clean_plugins
Executable file
14
tmux/.config/tmux/plugins/tpm/bin/clean_plugins
Executable file
|
|
@ -0,0 +1,14 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# Script intended for use via the command line.
|
||||
#
|
||||
# `.tmux.conf` needs to be set for TPM. Tmux has to be installed on the system,
|
||||
# but does not need to be started in order to run this script.
|
||||
|
||||
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
SCRIPTS_DIR="$CURRENT_DIR/../scripts"
|
||||
|
||||
main() {
|
||||
"$SCRIPTS_DIR/clean_plugins.sh" # has correct exit code
|
||||
}
|
||||
main
|
||||
14
tmux/.config/tmux/plugins/tpm/bin/install_plugins
Executable file
14
tmux/.config/tmux/plugins/tpm/bin/install_plugins
Executable file
|
|
@ -0,0 +1,14 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# Script intended for use via the command line.
|
||||
#
|
||||
# `.tmux.conf` needs to be set for TPM. Tmux has to be installed on the system,
|
||||
# but does not need to be started in order to run this script.
|
||||
|
||||
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
SCRIPTS_DIR="$CURRENT_DIR/../scripts"
|
||||
|
||||
main() {
|
||||
"$SCRIPTS_DIR/install_plugins.sh" # has correct exit code
|
||||
}
|
||||
main
|
||||
24
tmux/.config/tmux/plugins/tpm/bin/update_plugins
Executable file
24
tmux/.config/tmux/plugins/tpm/bin/update_plugins
Executable file
|
|
@ -0,0 +1,24 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# Script intended for use via the command line.
|
||||
#
|
||||
# `.tmux.conf` needs to be set for TPM. Tmux has to be installed on the system,
|
||||
# but does not need to be started in order to run this script.
|
||||
|
||||
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
SCRIPTS_DIR="$CURRENT_DIR/../scripts"
|
||||
PROGRAM_NAME="$0"
|
||||
|
||||
if [ $# -eq 0 ]; then
|
||||
echo "usage:"
|
||||
echo " $PROGRAM_NAME all update all plugins"
|
||||
echo " $PROGRAM_NAME tmux-foo update plugin 'tmux-foo'"
|
||||
echo " $PROGRAM_NAME tmux-bar tmux-baz update multiple plugins"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
main() {
|
||||
"$SCRIPTS_DIR/update_plugin.sh" --shell-echo "$*" # has correct exit code
|
||||
}
|
||||
main "$*"
|
||||
|
||||
19
tmux/.config/tmux/plugins/tpm/bindings/clean_plugins
Executable file
19
tmux/.config/tmux/plugins/tpm/bindings/clean_plugins
Executable file
|
|
@ -0,0 +1,19 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# Tmux key-binding script.
|
||||
# Scripts intended to be used via the command line are in `bin/` directory.
|
||||
|
||||
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
SCRIPTS_DIR="$CURRENT_DIR/../scripts"
|
||||
HELPERS_DIR="$SCRIPTS_DIR/helpers"
|
||||
|
||||
source "$HELPERS_DIR/tmux_echo_functions.sh"
|
||||
source "$HELPERS_DIR/tmux_utils.sh"
|
||||
|
||||
main() {
|
||||
reload_tmux_environment
|
||||
"$SCRIPTS_DIR/clean_plugins.sh" --tmux-echo >/dev/null 2>&1
|
||||
reload_tmux_environment
|
||||
end_message
|
||||
}
|
||||
main
|
||||
19
tmux/.config/tmux/plugins/tpm/bindings/install_plugins
Executable file
19
tmux/.config/tmux/plugins/tpm/bindings/install_plugins
Executable file
|
|
@ -0,0 +1,19 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# Tmux key-binding script.
|
||||
# Scripts intended to be used via the command line are in `bin/` directory.
|
||||
|
||||
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
SCRIPTS_DIR="$CURRENT_DIR/../scripts"
|
||||
HELPERS_DIR="$SCRIPTS_DIR/helpers"
|
||||
|
||||
source "$HELPERS_DIR/tmux_echo_functions.sh"
|
||||
source "$HELPERS_DIR/tmux_utils.sh"
|
||||
|
||||
main() {
|
||||
reload_tmux_environment
|
||||
"$SCRIPTS_DIR/install_plugins.sh" --tmux-echo >/dev/null 2>&1
|
||||
reload_tmux_environment
|
||||
end_message
|
||||
}
|
||||
main
|
||||
49
tmux/.config/tmux/plugins/tpm/bindings/update_plugins
Executable file
49
tmux/.config/tmux/plugins/tpm/bindings/update_plugins
Executable file
|
|
@ -0,0 +1,49 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# Tmux key-binding script.
|
||||
# Scripts intended to be used via the command line are in `bin/` directory.
|
||||
|
||||
# This script:
|
||||
# - shows a list of installed plugins
|
||||
# - starts a prompt to enter the name of the plugin that will be updated
|
||||
|
||||
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
SCRIPTS_DIR="$CURRENT_DIR/../scripts"
|
||||
HELPERS_DIR="$SCRIPTS_DIR/helpers"
|
||||
|
||||
source "$HELPERS_DIR/plugin_functions.sh"
|
||||
source "$HELPERS_DIR/tmux_echo_functions.sh"
|
||||
source "$HELPERS_DIR/tmux_utils.sh"
|
||||
|
||||
display_plugin_update_list() {
|
||||
local plugins="$(tpm_plugins_list_helper)"
|
||||
tmux_echo "Installed plugins:"
|
||||
tmux_echo ""
|
||||
|
||||
for plugin in $plugins; do
|
||||
# displaying only installed plugins
|
||||
if plugin_already_installed "$plugin"; then
|
||||
local plugin_name="$(plugin_name_helper "$plugin")"
|
||||
tmux_echo " $plugin_name"
|
||||
fi
|
||||
done
|
||||
|
||||
tmux_echo ""
|
||||
tmux_echo "Type plugin name to update it."
|
||||
tmux_echo ""
|
||||
tmux_echo "- \"all\" - updates all plugins"
|
||||
tmux_echo "- ENTER - cancels"
|
||||
}
|
||||
|
||||
update_plugin_prompt() {
|
||||
tmux command-prompt -p 'plugin update:' " \
|
||||
send-keys C-c; \
|
||||
run-shell '$SCRIPTS_DIR/update_plugin_prompt_handler.sh %1'"
|
||||
}
|
||||
|
||||
main() {
|
||||
reload_tmux_environment
|
||||
display_plugin_update_list
|
||||
update_plugin_prompt
|
||||
}
|
||||
main
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
# Automatic tpm installation
|
||||
|
||||
One of the first things we do on a new machine is cloning our dotfiles. Not everything comes with them though, so for example `tpm` most likely won't be installed.
|
||||
|
||||
If you want to install `tpm` and plugins automatically when tmux is started, put the following snippet in `.tmux.conf` before the final `run '~/.tmux/plugins/tpm/tpm'`:
|
||||
|
||||
```
|
||||
if "test ! -d ~/.tmux/plugins/tpm" \
|
||||
"run 'git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm && ~/.tmux/plugins/tpm/bin/install_plugins'"
|
||||
```
|
||||
|
||||
This useful tip was submitted by @acr4 and narfman0.
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
# Changing plugins install dir
|
||||
|
||||
By default, TPM installs plugins in a subfolder named `plugins/` inside
|
||||
`$XDG_CONFIG_HOME/tmux/` if a `tmux.conf` file was found at that location, or
|
||||
inside `~/.tmux/` otherwise.
|
||||
|
||||
You can change the install path by putting this in `.tmux.conf`:
|
||||
|
||||
set-environment -g TMUX_PLUGIN_MANAGER_PATH '/some/other/path/'
|
||||
|
||||
Tmux plugin manager initialization in `.tmux.conf` should also be updated:
|
||||
|
||||
# initializes TMUX plugin manager in a new path
|
||||
run /some/other/path/tpm/tpm
|
||||
|
||||
Please make sure that the `run` line is at the very bottom of `.tmux.conf`.
|
||||
108
tmux/.config/tmux/plugins/tpm/docs/how_to_create_plugin.md
Normal file
108
tmux/.config/tmux/plugins/tpm/docs/how_to_create_plugin.md
Normal file
|
|
@ -0,0 +1,108 @@
|
|||
# How to create Tmux plugins
|
||||
|
||||
Creating a new plugin is easy.
|
||||
|
||||
For demonstration purposes we'll create a simple plugin that lists all
|
||||
installed TPM plugins. Yes, a plugin that lists plugins :) We'll bind that to
|
||||
`prefix + T`.
|
||||
|
||||
The source code for this example plugin can be found
|
||||
[here](https://github.com/tmux-plugins/tmux-example-plugin).
|
||||
|
||||
### 1. create a new git project
|
||||
|
||||
TPM depends on git for downloading and updating plugins.
|
||||
|
||||
To create a new git project:
|
||||
|
||||
$ mkdir tmux_my_plugin
|
||||
$ cd tmux_my_plugin
|
||||
$ git init
|
||||
|
||||
### 2. create a `*.tmux` plugin run file
|
||||
|
||||
When it sources a plugin, TPM executes all `*.tmux` files in your plugins'
|
||||
directory. That's how plugins are run.
|
||||
|
||||
Create a plugin run file in plugin directory:
|
||||
|
||||
$ touch my_plugin.tmux
|
||||
$ chmod u+x my_plugin.tmux
|
||||
|
||||
You can have more than one `*.tmux` file, and all will get executed. However, usually
|
||||
you'll need just one.
|
||||
|
||||
### 3. create a plugin key binding
|
||||
|
||||
We want the behavior of the plugin to trigger when a user hits `prefix + T`.
|
||||
|
||||
Key `T` is chosen because:
|
||||
- it's "kind of" a mnemonic for `TPM`
|
||||
- the key is not used by Tmux natively. Tmux man page, KEY BINDINGS section
|
||||
contains a list of all the bindings Tmux uses. There's plenty of unused keys
|
||||
and we don't want to override any of Tmux default key bindings.
|
||||
|
||||
Open the plugin run file in your favorite text editor:
|
||||
|
||||
$ vim my_plugin.tmux
|
||||
# or
|
||||
$ subl my_plugin.tmux
|
||||
|
||||
Put the following content in the file:
|
||||
|
||||
#!/usr/bin/env bash
|
||||
|
||||
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
tmux bind-key T run-shell "$CURRENT_DIR/scripts/tmux_list_plugins.sh"
|
||||
|
||||
As you can see, plugin run file is a simple bash script that sets up the binding.
|
||||
|
||||
When pressed, `prefix + T` will execute another shell script:
|
||||
`tmux_list_plugins.sh`. That script should be in `scripts/` directory -
|
||||
relative to the plugin run file.
|
||||
|
||||
|
||||
### 4. listing plugins
|
||||
|
||||
Now that we have the binding, let's create a script that's invoked with
|
||||
`prefix + T`.
|
||||
|
||||
$ mkdir scripts
|
||||
$ touch scripts/tmux_list_plugins.sh
|
||||
$ chmod u+x scripts/tmux_list_plugins.sh
|
||||
|
||||
And here's the script content:
|
||||
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# fetching the directory where plugins are installed
|
||||
plugin_path="$(tmux show-env -g TMUX_PLUGIN_MANAGER_PATH | cut -f2 -d=)"
|
||||
|
||||
# listing installed plugins
|
||||
ls -1 "$plugin_path"
|
||||
|
||||
### 5. try it out
|
||||
|
||||
To see if this works, execute the plugin run file:
|
||||
|
||||
$ ./my_plugin.tmux
|
||||
|
||||
That should set up the key binding. Now hit `prefix + T` and see if it works.
|
||||
|
||||
### 6. publish the plugin
|
||||
|
||||
When everything is ready, push the plugin to an online git repository,
|
||||
preferably Github.
|
||||
|
||||
Other users can install your plugin by just adding plugin git URL to the
|
||||
`@plugin` list in their `.tmux.conf`.
|
||||
|
||||
If the plugin is on Github, your users will be able to use the shorthand of
|
||||
`github_username/repository`.
|
||||
|
||||
### Conclusion
|
||||
|
||||
Hopefully, that was easy. As you can see, it's mostly shell scripting.
|
||||
|
||||
You can use other scripting languages (ruby, python etc) but plain old shell
|
||||
is preferred because of portability.
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
# Managing plugins via the command line
|
||||
|
||||
Aside from tmux key bindings, TPM provides shell interface for managing plugins
|
||||
via scripts located in [bin/](../bin/) directory.
|
||||
|
||||
Tmux does not need to be started in order to run scripts (but it's okay if it
|
||||
is). If you [changed tpm install dir](../docs/changing_plugins_install_dir.md)
|
||||
in `.tmux.conf` that should work fine too.
|
||||
|
||||
Prerequisites:
|
||||
|
||||
- tmux installed on the system (doh)
|
||||
- `.tmux.conf` set up for TPM
|
||||
|
||||
### Installing plugins
|
||||
|
||||
As usual, plugins need to be specified in `.tmux.conf`. Run the following
|
||||
command to install plugins:
|
||||
|
||||
~/.tmux/plugins/tpm/bin/install_plugins
|
||||
|
||||
### Updating plugins
|
||||
|
||||
To update all installed plugins:
|
||||
|
||||
~/.tmux/plugins/tpm/bin/update_plugins all
|
||||
|
||||
or update a single plugin:
|
||||
|
||||
~/.tmux/plugins/tpm/bin/update_plugins tmux-sensible
|
||||
|
||||
### Removing plugins
|
||||
|
||||
To remove plugins not on the plugin list:
|
||||
|
||||
~/.tmux/plugins/tpm/bin/clean_plugins
|
||||
96
tmux/.config/tmux/plugins/tpm/docs/tpm_not_working.md
Normal file
96
tmux/.config/tmux/plugins/tpm/docs/tpm_not_working.md
Normal file
|
|
@ -0,0 +1,96 @@
|
|||
# Help, tpm not working!
|
||||
|
||||
Here's the list of issues users had with `tpm`:
|
||||
|
||||
<hr />
|
||||
|
||||
> Nothing works. `tpm` key bindings `prefix + I`, `prefix + U` not even
|
||||
defined.
|
||||
|
||||
Related [issue #22](https://github.com/tmux-plugins/tpm/issues/22)
|
||||
|
||||
- Do you have required `tmux` version to run `tpm`?<br/>
|
||||
Check `tmux` version with `$ tmux -V` command and make sure it's higher or
|
||||
equal to the required version for `tpm` as stated in the readme.
|
||||
|
||||
- ZSH tmux plugin might be causing issues.<br/>
|
||||
If you have it installed, try disabling it and see if `tpm` works then.
|
||||
|
||||
<hr />
|
||||
|
||||
> Help, I'm using custom config file with `tmux -f /path/to/my_tmux.conf`
|
||||
to start Tmux and for some reason plugins aren't loaded!?
|
||||
|
||||
Related [issue #57](https://github.com/tmux-plugins/tpm/issues/57)
|
||||
|
||||
`tpm` has a known issue when using custom config file with `-f` option.
|
||||
The solution is to use alternative plugin definition syntax. Here are the steps
|
||||
to make it work:
|
||||
|
||||
1. remove all `set -g @plugin` lines from tmux config file
|
||||
2. in the config file define the plugins in the following way:
|
||||
|
||||
# List of plugins
|
||||
set -g @tpm_plugins ' \
|
||||
tmux-plugins/tpm \
|
||||
tmux-plugins/tmux-sensible \
|
||||
tmux-plugins/tmux-resurrect \
|
||||
'
|
||||
|
||||
# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
|
||||
run '~/.tmux/plugins/tpm/tpm'
|
||||
|
||||
3. Reload TMUX environment so TPM is sourced: `$ tmux source /path/to/my_tmux.conf`
|
||||
|
||||
The plugins should now be working.
|
||||
|
||||
<hr />
|
||||
|
||||
> Weird sequence of characters show up when installing or updating plugins
|
||||
|
||||
Related: [issue #25](https://github.com/tmux-plugins/tpm/issues/25)
|
||||
|
||||
- This could be caused by [tmuxline.vim](https://github.com/edkolev/tmuxline.vim)
|
||||
plugin. Uninstall it and see if things work.
|
||||
|
||||
<hr />
|
||||
|
||||
> "failed to connect to server" error when sourcing .tmux.conf
|
||||
|
||||
Related: [issue #48](https://github.com/tmux-plugins/tpm/issues/48)
|
||||
|
||||
- Make sure `tmux source ~/.tmux.conf` command is ran from inside `tmux`.
|
||||
|
||||
<hr />
|
||||
|
||||
> tpm not working: '~/.tmux/plugins/tpm/tpm' returned 2 (Windows / Cygwin)
|
||||
|
||||
Related: [issue #81](https://github.com/tmux-plugins/tpm/issues/81)
|
||||
|
||||
This issue is most likely caused by Windows line endings. For example, if you
|
||||
have git's `core.autocrlf` option set to `true`, git will automatically convert
|
||||
all the files to Windows line endings which might cause a problem.
|
||||
|
||||
The solution is to convert all line ending to Unix newline characters. This
|
||||
command handles that for all files under `.tmux/` dir (skips `.git`
|
||||
subdirectories):
|
||||
|
||||
```bash
|
||||
find ~/.tmux -type d -name '.git*' -prune -o -type f -print0 | xargs -0 dos2unix
|
||||
```
|
||||
|
||||
<hr />
|
||||
|
||||
> '~/.tmux/plugins/tpm/tpm' returned 127 (on macOS, w/ tmux installed using brew)
|
||||
|
||||
Related: [issue #67](https://github.com/tmux-plugins/tpm/issues/67)
|
||||
|
||||
This problem is because tmux's `run-shell` command runs a shell which doesn't read from user configs, thus tmux installed in `/usr/local/bin` will not be found.
|
||||
|
||||
The solution is to insert the following line:
|
||||
|
||||
```
|
||||
set-environment -g PATH "/usr/local/bin:/bin:/usr/bin"
|
||||
```
|
||||
|
||||
before any `run-shell`/`run` commands in `~/.tmux.conf`.
|
||||
78
tmux/.config/tmux/plugins/tpm/scripts/check_tmux_version.sh
Executable file
78
tmux/.config/tmux/plugins/tpm/scripts/check_tmux_version.sh
Executable file
|
|
@ -0,0 +1,78 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
VERSION="$1"
|
||||
UNSUPPORTED_MSG="$2"
|
||||
|
||||
get_tmux_option() {
|
||||
local option=$1
|
||||
local default_value=$2
|
||||
local option_value=$(tmux show-option -gqv "$option")
|
||||
if [ -z "$option_value" ]; then
|
||||
echo "$default_value"
|
||||
else
|
||||
echo "$option_value"
|
||||
fi
|
||||
}
|
||||
|
||||
# Ensures a message is displayed for 5 seconds in tmux prompt.
|
||||
# Does not override the 'display-time' tmux option.
|
||||
display_message() {
|
||||
local message="$1"
|
||||
|
||||
# display_duration defaults to 5 seconds, if not passed as an argument
|
||||
if [ "$#" -eq 2 ]; then
|
||||
local display_duration="$2"
|
||||
else
|
||||
local display_duration="5000"
|
||||
fi
|
||||
|
||||
# saves user-set 'display-time' option
|
||||
local saved_display_time=$(get_tmux_option "display-time" "750")
|
||||
|
||||
# sets message display time to 5 seconds
|
||||
tmux set-option -gq display-time "$display_duration"
|
||||
|
||||
# displays message
|
||||
tmux display-message "$message"
|
||||
|
||||
# restores original 'display-time' value
|
||||
tmux set-option -gq display-time "$saved_display_time"
|
||||
}
|
||||
|
||||
# this is used to get "clean" integer version number. Examples:
|
||||
# `tmux 1.9` => `19`
|
||||
# `1.9a` => `19`
|
||||
get_digits_from_string() {
|
||||
local string="$1"
|
||||
local only_digits="$(echo "$string" | tr -dC '[:digit:]')"
|
||||
echo "$only_digits"
|
||||
}
|
||||
|
||||
tmux_version_int() {
|
||||
local tmux_version_string=$(tmux -V)
|
||||
echo "$(get_digits_from_string "$tmux_version_string")"
|
||||
}
|
||||
|
||||
unsupported_version_message() {
|
||||
if [ -n "$UNSUPPORTED_MSG" ]; then
|
||||
echo "$UNSUPPORTED_MSG"
|
||||
else
|
||||
echo "Error, Tmux version unsupported! Please install Tmux version $VERSION or greater!"
|
||||
fi
|
||||
}
|
||||
|
||||
exit_if_unsupported_version() {
|
||||
local current_version="$1"
|
||||
local supported_version="$2"
|
||||
if [ "$current_version" -lt "$supported_version" ]; then
|
||||
display_message "$(unsupported_version_message)"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
main() {
|
||||
local supported_version_int="$(get_digits_from_string "$VERSION")"
|
||||
local current_version_int="$(tmux_version_int)"
|
||||
exit_if_unsupported_version "$current_version_int" "$supported_version_int"
|
||||
}
|
||||
main
|
||||
41
tmux/.config/tmux/plugins/tpm/scripts/clean_plugins.sh
Executable file
41
tmux/.config/tmux/plugins/tpm/scripts/clean_plugins.sh
Executable file
|
|
@ -0,0 +1,41 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
HELPERS_DIR="$CURRENT_DIR/helpers"
|
||||
|
||||
source "$HELPERS_DIR/plugin_functions.sh"
|
||||
source "$HELPERS_DIR/utility.sh"
|
||||
|
||||
if [ "$1" == "--tmux-echo" ]; then # tmux-specific echo functions
|
||||
source "$HELPERS_DIR/tmux_echo_functions.sh"
|
||||
else # shell output functions
|
||||
source "$HELPERS_DIR/shell_echo_functions.sh"
|
||||
fi
|
||||
|
||||
clean_plugins() {
|
||||
local plugins plugin plugin_directory
|
||||
plugins="$(tpm_plugins_list_helper)"
|
||||
|
||||
for plugin_directory in "$(tpm_path)"/*; do
|
||||
[ -d "${plugin_directory}" ] || continue
|
||||
plugin="$(plugin_name_helper "${plugin_directory}")"
|
||||
case "${plugins}" in
|
||||
*"${plugin}"*) : ;;
|
||||
*)
|
||||
[ "${plugin}" = "tpm" ] && continue
|
||||
echo_ok "Removing \"$plugin\""
|
||||
rm -rf "${plugin_directory}" >/dev/null 2>&1
|
||||
[ -d "${plugin_directory}" ] &&
|
||||
echo_err " \"$plugin\" clean fail" ||
|
||||
echo_ok " \"$plugin\" clean success"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
main() {
|
||||
ensure_tpm_path_exists
|
||||
clean_plugins
|
||||
exit_value_helper
|
||||
}
|
||||
main
|
||||
|
|
@ -0,0 +1,104 @@
|
|||
# using @tpm_plugins is now deprecated in favor of using @plugin syntax
|
||||
tpm_plugins_variable_name="@tpm_plugins"
|
||||
|
||||
# manually expanding tilde char or `$HOME` variable.
|
||||
_manual_expansion() {
|
||||
local path="$1"
|
||||
local expanded_tilde="${path/#\~/$HOME}"
|
||||
echo "${expanded_tilde/#\$HOME/$HOME}"
|
||||
}
|
||||
|
||||
_tpm_path() {
|
||||
local string_path="$(tmux start-server\; show-environment -g TMUX_PLUGIN_MANAGER_PATH | cut -f2 -d=)/"
|
||||
_manual_expansion "$string_path"
|
||||
}
|
||||
|
||||
_CACHED_TPM_PATH="$(_tpm_path)"
|
||||
|
||||
# Get the absolute path to the users configuration file of TMux.
|
||||
# This includes a prioritized search on different locations.
|
||||
#
|
||||
_get_user_tmux_conf() {
|
||||
# Define the different possible locations.
|
||||
xdg_location="${XDG_CONFIG_HOME:-$HOME/.config}/tmux/tmux.conf"
|
||||
default_location="$HOME/.tmux.conf"
|
||||
|
||||
# Search for the correct configuration file by priority.
|
||||
if [ -f "$xdg_location" ]; then
|
||||
echo "$xdg_location"
|
||||
|
||||
else
|
||||
echo "$default_location"
|
||||
fi
|
||||
}
|
||||
|
||||
_tmux_conf_contents() {
|
||||
user_config=$(_get_user_tmux_conf)
|
||||
cat /etc/tmux.conf "$user_config" 2>/dev/null
|
||||
if [ "$1" == "full" ]; then # also output content from sourced files
|
||||
local file
|
||||
for file in $(_sourced_files); do
|
||||
cat $(_manual_expansion "$file") 2>/dev/null
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
# return files sourced from tmux config files
|
||||
_sourced_files() {
|
||||
_tmux_conf_contents |
|
||||
sed -E -n -e "s/^[[:space:]]*source(-file)?[[:space:]]+(-q+[[:space:]]+)?['\"]?([^'\"]+)['\"]?/\3/p"
|
||||
}
|
||||
|
||||
# Want to be able to abort in certain cases
|
||||
trap "exit 1" TERM
|
||||
export TOP_PID=$$
|
||||
|
||||
_fatal_error_abort() {
|
||||
echo >&2 "Aborting."
|
||||
kill -s TERM $TOP_PID
|
||||
}
|
||||
|
||||
# PUBLIC FUNCTIONS BELOW
|
||||
|
||||
tpm_path() {
|
||||
if [ "$_CACHED_TPM_PATH" == "/" ]; then
|
||||
echo >&2 "FATAL: Tmux Plugin Manager not configured in tmux.conf"
|
||||
_fatal_error_abort
|
||||
fi
|
||||
echo "$_CACHED_TPM_PATH"
|
||||
}
|
||||
|
||||
tpm_plugins_list_helper() {
|
||||
# lists plugins from @tpm_plugins option
|
||||
echo "$(tmux start-server\; show-option -gqv "$tpm_plugins_variable_name")"
|
||||
|
||||
# read set -g @plugin "tmux-plugins/tmux-example-plugin" entries
|
||||
_tmux_conf_contents "full" |
|
||||
awk '/^[ \t]*set(-option)? +-g +@plugin/ { gsub(/'\''/,""); gsub(/'\"'/,""); print $4 }'
|
||||
}
|
||||
|
||||
# Allowed plugin name formats:
|
||||
# 1. "git://github.com/user/plugin_name.git"
|
||||
# 2. "user/plugin_name"
|
||||
plugin_name_helper() {
|
||||
local plugin="$1"
|
||||
# get only the part after the last slash, e.g. "plugin_name.git"
|
||||
local plugin_basename="$(basename "$plugin")"
|
||||
# remove ".git" extension (if it exists) to get only "plugin_name"
|
||||
local plugin_name="${plugin_basename%.git}"
|
||||
echo "$plugin_name"
|
||||
}
|
||||
|
||||
plugin_path_helper() {
|
||||
local plugin="$1"
|
||||
local plugin_name="$(plugin_name_helper "$plugin")"
|
||||
echo "$(tpm_path)${plugin_name}/"
|
||||
}
|
||||
|
||||
plugin_already_installed() {
|
||||
local plugin="$1"
|
||||
local plugin_path="$(plugin_path_helper "$plugin")"
|
||||
[ -d "$plugin_path" ] &&
|
||||
cd "$plugin_path" &&
|
||||
git remote >/dev/null 2>&1
|
||||
}
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
echo_ok() {
|
||||
echo "$*"
|
||||
}
|
||||
|
||||
echo_err() {
|
||||
fail_helper "$*"
|
||||
}
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
_has_emacs_mode_keys() {
|
||||
$(tmux show -gw mode-keys | grep -q emacs)
|
||||
}
|
||||
|
||||
tmux_echo() {
|
||||
local message="$1"
|
||||
tmux run-shell "echo '$message'"
|
||||
}
|
||||
|
||||
echo_ok() {
|
||||
tmux_echo "$*"
|
||||
}
|
||||
|
||||
echo_err() {
|
||||
tmux_echo "$*"
|
||||
}
|
||||
|
||||
end_message() {
|
||||
if _has_emacs_mode_keys; then
|
||||
local continue_key="ESCAPE"
|
||||
else
|
||||
local continue_key="ENTER"
|
||||
fi
|
||||
tmux_echo ""
|
||||
tmux_echo "TMUX environment reloaded."
|
||||
tmux_echo ""
|
||||
tmux_echo "Done, press $continue_key to continue."
|
||||
}
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
HELPERS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
source "$HELPERS_DIR/plugin_functions.sh"
|
||||
|
||||
reload_tmux_environment() {
|
||||
tmux source-file $(_get_user_tmux_conf) >/dev/null 2>&1
|
||||
}
|
||||
17
tmux/.config/tmux/plugins/tpm/scripts/helpers/utility.sh
Normal file
17
tmux/.config/tmux/plugins/tpm/scripts/helpers/utility.sh
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
ensure_tpm_path_exists() {
|
||||
mkdir -p "$(tpm_path)"
|
||||
}
|
||||
|
||||
fail_helper() {
|
||||
local message="$1"
|
||||
echo "$message" >&2
|
||||
FAIL="true"
|
||||
}
|
||||
|
||||
exit_value_helper() {
|
||||
if [ "$FAIL" == "true" ]; then
|
||||
exit 1
|
||||
else
|
||||
exit 0
|
||||
fi
|
||||
}
|
||||
75
tmux/.config/tmux/plugins/tpm/scripts/install_plugins.sh
Executable file
75
tmux/.config/tmux/plugins/tpm/scripts/install_plugins.sh
Executable file
|
|
@ -0,0 +1,75 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
HELPERS_DIR="$CURRENT_DIR/helpers"
|
||||
|
||||
source "$HELPERS_DIR/plugin_functions.sh"
|
||||
source "$HELPERS_DIR/utility.sh"
|
||||
|
||||
if [ "$1" == "--tmux-echo" ]; then # tmux-specific echo functions
|
||||
source "$HELPERS_DIR/tmux_echo_functions.sh"
|
||||
else # shell output functions
|
||||
source "$HELPERS_DIR/shell_echo_functions.sh"
|
||||
fi
|
||||
|
||||
clone() {
|
||||
local plugin="$1"
|
||||
local branch="$2"
|
||||
if [ -n "$branch" ]; then
|
||||
cd "$(tpm_path)" &&
|
||||
GIT_TERMINAL_PROMPT=0 git clone -b "$branch" --single-branch --recursive "$plugin" >/dev/null 2>&1
|
||||
else
|
||||
cd "$(tpm_path)" &&
|
||||
GIT_TERMINAL_PROMPT=0 git clone --single-branch --recursive "$plugin" >/dev/null 2>&1
|
||||
fi
|
||||
}
|
||||
|
||||
# tries cloning:
|
||||
# 1. plugin name directly - works if it's a valid git url
|
||||
# 2. expands the plugin name to point to a github repo and tries cloning again
|
||||
clone_plugin() {
|
||||
local plugin="$1"
|
||||
local branch="$2"
|
||||
clone "$plugin" "$branch" ||
|
||||
clone "https://git::@github.com/$plugin" "$branch"
|
||||
}
|
||||
|
||||
# clone plugin and produce output
|
||||
install_plugin() {
|
||||
local plugin="$1"
|
||||
local branch="$2"
|
||||
local plugin_name="$(plugin_name_helper "$plugin")"
|
||||
|
||||
if plugin_already_installed "$plugin"; then
|
||||
echo_ok "Already installed \"$plugin_name\""
|
||||
else
|
||||
echo_ok "Installing \"$plugin_name\""
|
||||
clone_plugin "$plugin" "$branch" &&
|
||||
echo_ok " \"$plugin_name\" download success" ||
|
||||
echo_err " \"$plugin_name\" download fail"
|
||||
fi
|
||||
}
|
||||
|
||||
install_plugins() {
|
||||
local plugins="$(tpm_plugins_list_helper)"
|
||||
for plugin in $plugins; do
|
||||
IFS='#' read -ra plugin <<< "$plugin"
|
||||
install_plugin "${plugin[0]}" "${plugin[1]}"
|
||||
done
|
||||
}
|
||||
|
||||
verify_tpm_path_permissions() {
|
||||
local path="$(tpm_path)"
|
||||
# check the write permission flag for all users to ensure
|
||||
# that we have proper access
|
||||
[ -w "$path" ] ||
|
||||
echo_err "$path is not writable!"
|
||||
}
|
||||
|
||||
main() {
|
||||
ensure_tpm_path_exists
|
||||
verify_tpm_path_permissions
|
||||
install_plugins
|
||||
exit_value_helper
|
||||
}
|
||||
main
|
||||
42
tmux/.config/tmux/plugins/tpm/scripts/source_plugins.sh
Executable file
42
tmux/.config/tmux/plugins/tpm/scripts/source_plugins.sh
Executable file
|
|
@ -0,0 +1,42 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
HELPERS_DIR="$CURRENT_DIR/helpers"
|
||||
|
||||
source "$HELPERS_DIR/plugin_functions.sh"
|
||||
|
||||
plugin_dir_exists() {
|
||||
[ -d "$1" ]
|
||||
}
|
||||
|
||||
# Runs all *.tmux files from the plugin directory.
|
||||
# Files are ran as executables.
|
||||
# No errors if the plugin dir does not exist.
|
||||
silently_source_all_tmux_files() {
|
||||
local plugin_path="$1"
|
||||
local plugin_tmux_files="$plugin_path*.tmux"
|
||||
if plugin_dir_exists "$plugin_path"; then
|
||||
for tmux_file in $plugin_tmux_files; do
|
||||
# if the glob didn't find any files this will be the
|
||||
# unexpanded glob which obviously doesn't exist
|
||||
[ -f "$tmux_file" ] || continue
|
||||
# runs *.tmux file as an executable
|
||||
$tmux_file >/dev/null 2>&1
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
source_plugins() {
|
||||
local plugin plugin_path
|
||||
local plugins="$(tpm_plugins_list_helper)"
|
||||
for plugin in $plugins; do
|
||||
IFS='#' read -ra plugin <<< "$plugin"
|
||||
plugin_path="$(plugin_path_helper "${plugin[0]}")"
|
||||
silently_source_all_tmux_files "$plugin_path"
|
||||
done
|
||||
}
|
||||
|
||||
main() {
|
||||
source_plugins
|
||||
}
|
||||
main
|
||||
73
tmux/.config/tmux/plugins/tpm/scripts/update_plugin.sh
Executable file
73
tmux/.config/tmux/plugins/tpm/scripts/update_plugin.sh
Executable file
|
|
@ -0,0 +1,73 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# this script handles core logic of updating plugins
|
||||
|
||||
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
HELPERS_DIR="$CURRENT_DIR/helpers"
|
||||
|
||||
source "$HELPERS_DIR/plugin_functions.sh"
|
||||
source "$HELPERS_DIR/utility.sh"
|
||||
|
||||
if [ "$1" == "--tmux-echo" ]; then # tmux-specific echo functions
|
||||
source "$HELPERS_DIR/tmux_echo_functions.sh"
|
||||
else # shell output functions
|
||||
source "$HELPERS_DIR/shell_echo_functions.sh"
|
||||
fi
|
||||
|
||||
# from now on ignore first script argument
|
||||
shift
|
||||
|
||||
pull_changes() {
|
||||
local plugin="$1"
|
||||
local plugin_path="$(plugin_path_helper "$plugin")"
|
||||
cd "$plugin_path" &&
|
||||
GIT_TERMINAL_PROMPT=0 git pull &&
|
||||
GIT_TERMINAL_PROMPT=0 git submodule update --init --recursive
|
||||
}
|
||||
|
||||
update() {
|
||||
local plugin="$1"
|
||||
$(pull_changes "$plugin" > /dev/null 2>&1) &&
|
||||
echo_ok " \"$plugin\" update success" ||
|
||||
echo_err " \"$plugin\" update fail"
|
||||
}
|
||||
|
||||
update_all() {
|
||||
echo_ok "Updating all plugins!"
|
||||
echo_ok ""
|
||||
local plugins="$(tpm_plugins_list_helper)"
|
||||
for plugin in $plugins; do
|
||||
IFS='#' read -ra plugin <<< "$plugin"
|
||||
local plugin_name="$(plugin_name_helper "${plugin[0]}")"
|
||||
# updating only installed plugins
|
||||
if plugin_already_installed "$plugin_name"; then
|
||||
update "$plugin_name" &
|
||||
fi
|
||||
done
|
||||
wait
|
||||
}
|
||||
|
||||
update_plugins() {
|
||||
local plugins="$*"
|
||||
for plugin in $plugins; do
|
||||
IFS='#' read -ra plugin <<< "$plugin"
|
||||
local plugin_name="$(plugin_name_helper "${plugin[0]}")"
|
||||
if plugin_already_installed "$plugin_name"; then
|
||||
update "$plugin_name" &
|
||||
else
|
||||
echo_err "$plugin_name not installed!" &
|
||||
fi
|
||||
done
|
||||
wait
|
||||
}
|
||||
|
||||
main() {
|
||||
ensure_tpm_path_exists
|
||||
if [ "$1" == "all" ]; then
|
||||
update_all
|
||||
else
|
||||
update_plugins "$*"
|
||||
fi
|
||||
exit_value_helper
|
||||
}
|
||||
main "$*"
|
||||
18
tmux/.config/tmux/plugins/tpm/scripts/update_plugin_prompt_handler.sh
Executable file
18
tmux/.config/tmux/plugins/tpm/scripts/update_plugin_prompt_handler.sh
Executable file
|
|
@ -0,0 +1,18 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
HELPERS_DIR="$CURRENT_DIR/helpers"
|
||||
|
||||
if [ $# -eq 0 ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
source "$HELPERS_DIR/tmux_echo_functions.sh"
|
||||
source "$HELPERS_DIR/tmux_utils.sh"
|
||||
|
||||
main() {
|
||||
"$CURRENT_DIR/update_plugin.sh" --tmux-echo "$*"
|
||||
reload_tmux_environment
|
||||
end_message
|
||||
}
|
||||
main "$*"
|
||||
13
tmux/.config/tmux/plugins/tpm/scripts/variables.sh
Normal file
13
tmux/.config/tmux/plugins/tpm/scripts/variables.sh
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
install_key_option="@tpm-install"
|
||||
default_install_key="I"
|
||||
|
||||
update_key_option="@tpm-update"
|
||||
default_update_key="U"
|
||||
|
||||
clean_key_option="@tpm-clean"
|
||||
default_clean_key="M-u"
|
||||
|
||||
SUPPORTED_TMUX_VERSION="1.9"
|
||||
|
||||
DEFAULT_TPM_ENV_VAR_NAME="TMUX_PLUGIN_MANAGER_PATH"
|
||||
DEFAULT_TPM_PATH="$HOME/.tmux/plugins/"
|
||||
36
tmux/.config/tmux/plugins/tpm/tests/expect_failed_plugin_download
Executable file
36
tmux/.config/tmux/plugins/tpm/tests/expect_failed_plugin_download
Executable file
|
|
@ -0,0 +1,36 @@
|
|||
#!/usr/bin/env expect
|
||||
|
||||
# disables script output
|
||||
log_user 0
|
||||
|
||||
spawn tmux
|
||||
|
||||
# Waiting for tmux to attach. If this is not done, next command, `send` will
|
||||
# not work properly.
|
||||
sleep 1
|
||||
|
||||
# this is tmux prefix + I
|
||||
send "I"
|
||||
|
||||
# cloning might take a while
|
||||
set timeout 20
|
||||
|
||||
expect_after {
|
||||
timeout { exit 1 }
|
||||
}
|
||||
|
||||
expect {
|
||||
"Installing \"non-existing-plugin\""
|
||||
}
|
||||
|
||||
expect {
|
||||
"\"non-existing-plugin\" download fail"
|
||||
}
|
||||
|
||||
expect {
|
||||
"Done, press ENTER to continue" {
|
||||
exit 0
|
||||
}
|
||||
}
|
||||
|
||||
exit 1
|
||||
35
tmux/.config/tmux/plugins/tpm/tests/expect_successful_clean_plugins
Executable file
35
tmux/.config/tmux/plugins/tpm/tests/expect_successful_clean_plugins
Executable file
|
|
@ -0,0 +1,35 @@
|
|||
#!/usr/bin/env expect
|
||||
|
||||
# disables script output
|
||||
log_user 0
|
||||
|
||||
spawn tmux
|
||||
|
||||
# Waiting for tmux to attach. If this is not done, next command, `send` will
|
||||
# not work properly.
|
||||
sleep 1
|
||||
|
||||
# this is tmux prefix + alt + u
|
||||
send "u"
|
||||
|
||||
set timeout 5
|
||||
|
||||
expect_after {
|
||||
timeout { exit 1 }
|
||||
}
|
||||
|
||||
expect {
|
||||
"Removing \"tmux-example-plugin\""
|
||||
}
|
||||
|
||||
expect {
|
||||
"\"tmux-example-plugin\" clean success"
|
||||
}
|
||||
|
||||
expect {
|
||||
"Done, press ENTER to continue." {
|
||||
exit 0
|
||||
}
|
||||
}
|
||||
|
||||
exit 1
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
#!/usr/bin/env expect
|
||||
|
||||
# disables script output
|
||||
log_user 0
|
||||
|
||||
spawn tmux
|
||||
|
||||
# Waiting for tmux to attach. If this is not done, next command, `send` will
|
||||
# not work properly.
|
||||
sleep 1
|
||||
|
||||
# this is tmux prefix + I
|
||||
send "I"
|
||||
|
||||
# cloning might take a while
|
||||
set timeout 15
|
||||
|
||||
expect_after {
|
||||
timeout { exit 1 }
|
||||
}
|
||||
|
||||
expect {
|
||||
"Installing \"tmux-example-plugin\""
|
||||
}
|
||||
|
||||
expect {
|
||||
"\"tmux-example-plugin\" download success"
|
||||
}
|
||||
|
||||
expect {
|
||||
"Installing \"tmux-copycat\""
|
||||
}
|
||||
|
||||
expect {
|
||||
"\"tmux-copycat\" download success"
|
||||
}
|
||||
|
||||
expect {
|
||||
"Done, press ENTER to continue." {
|
||||
exit 0
|
||||
}
|
||||
}
|
||||
|
||||
exit 1
|
||||
50
tmux/.config/tmux/plugins/tpm/tests/expect_successful_plugin_download
Executable file
50
tmux/.config/tmux/plugins/tpm/tests/expect_successful_plugin_download
Executable file
|
|
@ -0,0 +1,50 @@
|
|||
#!/usr/bin/env expect
|
||||
|
||||
# disables script output
|
||||
log_user 0
|
||||
|
||||
spawn tmux
|
||||
|
||||
# Waiting for tmux to attach. If this is not done, next command, `send` will
|
||||
# not work properly.
|
||||
sleep 1
|
||||
|
||||
# this is tmux prefix + I
|
||||
send "I"
|
||||
|
||||
# cloning might take a while
|
||||
set timeout 15
|
||||
|
||||
expect_after {
|
||||
timeout { exit 1 }
|
||||
}
|
||||
|
||||
expect {
|
||||
"Installing \"tmux-example-plugin\""
|
||||
}
|
||||
|
||||
expect {
|
||||
"\"tmux-example-plugin\" download success"
|
||||
}
|
||||
|
||||
expect {
|
||||
"Done, press ENTER to continue" {
|
||||
send "
"
|
||||
}
|
||||
}
|
||||
|
||||
sleep 1
|
||||
# this is tmux prefix + I
|
||||
send "I"
|
||||
|
||||
expect {
|
||||
"Already installed \"tmux-example-plugin\""
|
||||
}
|
||||
|
||||
expect {
|
||||
"Done, press ENTER to continue" {
|
||||
exit 0
|
||||
}
|
||||
}
|
||||
|
||||
exit 1
|
||||
|
|
@ -0,0 +1,55 @@
|
|||
#!/usr/bin/env expect
|
||||
|
||||
# disables script output
|
||||
log_user 0
|
||||
|
||||
spawn tmux
|
||||
|
||||
# Waiting for tmux to attach. If this is not done, next command, `send` will
|
||||
# not work properly.
|
||||
sleep 1
|
||||
|
||||
# this is tmux prefix + U
|
||||
send "U"
|
||||
|
||||
set timeout 15
|
||||
|
||||
expect_after {
|
||||
timeout { exit 1 }
|
||||
}
|
||||
|
||||
expect {
|
||||
"Installed plugins"
|
||||
}
|
||||
|
||||
expect {
|
||||
"tmux-example-plugin"
|
||||
}
|
||||
|
||||
expect {
|
||||
"\"all\" - updates all plugins"
|
||||
}
|
||||
|
||||
expect {
|
||||
"ENTER - cancels"
|
||||
}
|
||||
|
||||
# wait for tmux to display prompt before sending characters
|
||||
sleep 1
|
||||
send "tmux-example-plugin\r"
|
||||
|
||||
expect {
|
||||
"Updating \"tmux-example-plugin\""
|
||||
}
|
||||
|
||||
expect {
|
||||
"\"tmux-example-plugin\" update success"
|
||||
}
|
||||
|
||||
expect {
|
||||
"Done, press ENTER to continue." {
|
||||
exit 0
|
||||
}
|
||||
}
|
||||
|
||||
exit 1
|
||||
59
tmux/.config/tmux/plugins/tpm/tests/expect_successful_update_of_all_plugins
Executable file
59
tmux/.config/tmux/plugins/tpm/tests/expect_successful_update_of_all_plugins
Executable file
|
|
@ -0,0 +1,59 @@
|
|||
#!/usr/bin/env expect
|
||||
|
||||
# disables script output
|
||||
log_user 0
|
||||
|
||||
spawn tmux
|
||||
|
||||
# Waiting for tmux to attach. If this is not done, next command, `send` will
|
||||
# not work properly.
|
||||
sleep 1
|
||||
|
||||
# this is tmux prefix + U
|
||||
send "U"
|
||||
|
||||
set timeout 5
|
||||
|
||||
expect_after {
|
||||
timeout { exit 1 }
|
||||
}
|
||||
|
||||
expect {
|
||||
"Installed plugins"
|
||||
}
|
||||
|
||||
expect {
|
||||
"tmux-example-plugin"
|
||||
}
|
||||
|
||||
expect {
|
||||
"\"all\" - updates all plugins"
|
||||
}
|
||||
|
||||
expect {
|
||||
"ENTER - cancels"
|
||||
}
|
||||
|
||||
# wait for tmux to display prompt before sending characters
|
||||
sleep 1
|
||||
send "all\r"
|
||||
|
||||
expect {
|
||||
"Updating all plugins!"
|
||||
}
|
||||
|
||||
expect {
|
||||
"Updating \"tmux-example-plugin\""
|
||||
}
|
||||
|
||||
expect {
|
||||
"\"tmux-example-plugin\" update success"
|
||||
}
|
||||
|
||||
expect {
|
||||
"Done, press ENTER to continue." {
|
||||
exit 0
|
||||
}
|
||||
}
|
||||
|
||||
exit 1
|
||||
13
tmux/.config/tmux/plugins/tpm/tests/helpers/tpm.sh
Normal file
13
tmux/.config/tmux/plugins/tpm/tests/helpers/tpm.sh
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
check_dir_exists_helper() {
|
||||
[ -d "$1" ]
|
||||
}
|
||||
|
||||
# runs the scripts and asserts it has the correct output and exit code
|
||||
script_run_helper() {
|
||||
local script="$1"
|
||||
local expected_output="$2"
|
||||
local expected_exit_code="${3:-0}"
|
||||
$script 2>&1 |
|
||||
grep "$expected_output" >/dev/null 2>&1 && # grep -q flag quits the script early
|
||||
[ "${PIPESTATUS[0]}" -eq "$expected_exit_code" ]
|
||||
}
|
||||
67
tmux/.config/tmux/plugins/tpm/tests/test_plugin_clean.sh
Executable file
67
tmux/.config/tmux/plugins/tpm/tests/test_plugin_clean.sh
Executable file
|
|
@ -0,0 +1,67 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
TPM_DIR="$PWD"
|
||||
PLUGINS_DIR="$HOME/.tmux/plugins"
|
||||
|
||||
source "$CURRENT_DIR/helpers/helpers.sh"
|
||||
source "$CURRENT_DIR/helpers/tpm.sh"
|
||||
|
||||
manually_install_the_plugin() {
|
||||
rm -rf "$PLUGINS_DIR"
|
||||
mkdir -p "$PLUGINS_DIR"
|
||||
cd "$PLUGINS_DIR"
|
||||
git clone --quiet https://github.com/tmux-plugins/tmux-example-plugin
|
||||
}
|
||||
|
||||
# TMUX KEY-BINDING TESTS
|
||||
|
||||
test_plugin_uninstallation_via_tmux_key_binding() {
|
||||
set_tmux_conf_helper <<- HERE
|
||||
set -g mode-keys vi
|
||||
run-shell "$TPM_DIR/tpm"
|
||||
HERE
|
||||
|
||||
manually_install_the_plugin
|
||||
|
||||
"$CURRENT_DIR/expect_successful_clean_plugins" ||
|
||||
fail_helper "[key-binding] clean fails"
|
||||
|
||||
teardown_helper
|
||||
}
|
||||
|
||||
# SCRIPT TESTS
|
||||
|
||||
test_plugin_uninstallation_via_script() {
|
||||
set_tmux_conf_helper <<- HERE
|
||||
set -g mode-keys vi
|
||||
run-shell "$TPM_DIR/tpm"
|
||||
HERE
|
||||
|
||||
manually_install_the_plugin
|
||||
|
||||
script_run_helper "$TPM_DIR/bin/clean_plugins" '"tmux-example-plugin" clean success' ||
|
||||
fail_helper "[script] plugin cleaning fails"
|
||||
|
||||
teardown_helper
|
||||
}
|
||||
|
||||
test_unsuccessful_plugin_uninstallation_via_script() {
|
||||
set_tmux_conf_helper <<- HERE
|
||||
set -g mode-keys vi
|
||||
run-shell "$TPM_DIR/tpm"
|
||||
HERE
|
||||
|
||||
manually_install_the_plugin
|
||||
chmod 000 "$PLUGINS_DIR/tmux-example-plugin" # disable directory deletion
|
||||
|
||||
local expected_exit_code=1
|
||||
script_run_helper "$TPM_DIR/bin/clean_plugins" '"tmux-example-plugin" clean fail' "$expected_exit_code" ||
|
||||
fail_helper "[script] unsuccessful plugin cleaning doesn't fail"
|
||||
|
||||
chmod 755 "$PLUGINS_DIR/tmux-example-plugin" # enable directory deletion
|
||||
|
||||
teardown_helper
|
||||
}
|
||||
|
||||
run_tests
|
||||
284
tmux/.config/tmux/plugins/tpm/tests/test_plugin_installation.sh
Executable file
284
tmux/.config/tmux/plugins/tpm/tests/test_plugin_installation.sh
Executable file
|
|
@ -0,0 +1,284 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
PLUGINS_DIR="$HOME/.tmux/plugins"
|
||||
TPM_DIR="$PWD"
|
||||
|
||||
CUSTOM_PLUGINS_DIR="$HOME/foo/plugins"
|
||||
ADDITIONAL_CONFIG_FILE_1="$HOME/.tmux/additional_config_file_1"
|
||||
ADDITIONAL_CONFIG_FILE_2="$HOME/.tmux/additional_config_file_2"
|
||||
|
||||
source "$CURRENT_DIR/helpers/helpers.sh"
|
||||
source "$CURRENT_DIR/helpers/tpm.sh"
|
||||
|
||||
# TMUX KEY-BINDING TESTS
|
||||
|
||||
test_plugin_installation_via_tmux_key_binding() {
|
||||
set_tmux_conf_helper <<- HERE
|
||||
set -g mode-keys vi
|
||||
set -g @plugin "tmux-plugins/tmux-example-plugin"
|
||||
run-shell "$TPM_DIR/tpm"
|
||||
HERE
|
||||
|
||||
"$CURRENT_DIR/expect_successful_plugin_download" ||
|
||||
fail_helper "[key-binding] plugin installation fails"
|
||||
|
||||
check_dir_exists_helper "$PLUGINS_DIR/tmux-example-plugin/" ||
|
||||
fail_helper "[key-binding] plugin download fails"
|
||||
|
||||
teardown_helper
|
||||
}
|
||||
|
||||
test_plugin_installation_via_tmux_key_binding_set_option() {
|
||||
set_tmux_conf_helper <<- HERE
|
||||
set -g mode-keys vi
|
||||
set-option -g @plugin "tmux-plugins/tmux-example-plugin"
|
||||
run-shell "$TPM_DIR/tpm"
|
||||
HERE
|
||||
|
||||
"$CURRENT_DIR/expect_successful_plugin_download" ||
|
||||
fail_helper "[key-binding][set-option] plugin installation fails"
|
||||
|
||||
check_dir_exists_helper "$PLUGINS_DIR/tmux-example-plugin/" ||
|
||||
fail_helper "[key-binding][set-option] plugin download fails"
|
||||
|
||||
teardown_helper
|
||||
}
|
||||
|
||||
test_plugin_installation_custom_dir_via_tmux_key_binding() {
|
||||
set_tmux_conf_helper <<- HERE
|
||||
set -g mode-keys vi
|
||||
set-environment -g TMUX_PLUGIN_MANAGER_PATH '$CUSTOM_PLUGINS_DIR'
|
||||
|
||||
set -g @plugin "tmux-plugins/tmux-example-plugin"
|
||||
run-shell "$TPM_DIR/tpm"
|
||||
HERE
|
||||
|
||||
"$CURRENT_DIR/expect_successful_plugin_download" ||
|
||||
fail_helper "[key-binding][custom dir] plugin installation fails"
|
||||
|
||||
check_dir_exists_helper "$CUSTOM_PLUGINS_DIR/tmux-example-plugin/" ||
|
||||
fail_helper "[key-binding][custom dir] plugin download fails"
|
||||
|
||||
teardown_helper
|
||||
rm -rf "$CUSTOM_PLUGINS_DIR"
|
||||
}
|
||||
|
||||
test_non_existing_plugin_installation_via_tmux_key_binding() {
|
||||
set_tmux_conf_helper <<- HERE
|
||||
set -g mode-keys vi
|
||||
set -g @plugin "tmux-plugins/non-existing-plugin"
|
||||
run-shell "$TPM_DIR/tpm"
|
||||
HERE
|
||||
|
||||
"$CURRENT_DIR/expect_failed_plugin_download" ||
|
||||
fail_helper "[key-binding] non existing plugin installation doesn't fail"
|
||||
|
||||
teardown_helper
|
||||
}
|
||||
|
||||
test_multiple_plugins_installation_via_tmux_key_binding() {
|
||||
set_tmux_conf_helper <<- HERE
|
||||
set -g mode-keys vi
|
||||
set -g @plugin "tmux-plugins/tmux-example-plugin"
|
||||
\ \ set -g @plugin 'tmux-plugins/tmux-copycat'
|
||||
run-shell "$TPM_DIR/tpm"
|
||||
HERE
|
||||
|
||||
"$CURRENT_DIR/expect_successful_multiple_plugins_download" ||
|
||||
fail_helper "[key-binding] multiple plugins installation fails"
|
||||
|
||||
check_dir_exists_helper "$PLUGINS_DIR/tmux-example-plugin/" ||
|
||||
fail_helper "[key-binding] plugin download fails (tmux-example-plugin)"
|
||||
|
||||
check_dir_exists_helper "$PLUGINS_DIR/tmux-copycat/" ||
|
||||
fail_helper "[key-binding] plugin download fails (tmux-copycat)"
|
||||
|
||||
teardown_helper
|
||||
}
|
||||
|
||||
test_plugins_installation_from_sourced_file_via_tmux_key_binding() {
|
||||
set_tmux_conf_helper <<- HERE
|
||||
set -g mode-keys vi
|
||||
source '$ADDITIONAL_CONFIG_FILE_1'
|
||||
set -g @plugin 'tmux-plugins/tmux-example-plugin'
|
||||
run-shell "$TPM_DIR/tpm"
|
||||
HERE
|
||||
|
||||
mkdir ~/.tmux
|
||||
echo "set -g @plugin 'tmux-plugins/tmux-copycat'" > "$ADDITIONAL_CONFIG_FILE_1"
|
||||
|
||||
"$CURRENT_DIR/expect_successful_multiple_plugins_download" ||
|
||||
fail_helper "[key-binding][sourced file] plugins installation fails"
|
||||
|
||||
check_dir_exists_helper "$PLUGINS_DIR/tmux-example-plugin/" ||
|
||||
fail_helper "[key-binding][sourced file] plugin download fails (tmux-example-plugin)"
|
||||
|
||||
check_dir_exists_helper "$PLUGINS_DIR/tmux-copycat/" ||
|
||||
fail_helper "[key-binding][sourced file] plugin download fails (tmux-copycat)"
|
||||
|
||||
teardown_helper
|
||||
}
|
||||
|
||||
test_plugins_installation_from_multiple_sourced_files_via_tmux_key_binding() {
|
||||
set_tmux_conf_helper <<- HERE
|
||||
set -g mode-keys vi
|
||||
\ \ source '$ADDITIONAL_CONFIG_FILE_1'
|
||||
source-file '$ADDITIONAL_CONFIG_FILE_2'
|
||||
run-shell "$TPM_DIR/tpm"
|
||||
HERE
|
||||
|
||||
mkdir ~/.tmux
|
||||
echo "set -g @plugin 'tmux-plugins/tmux-example-plugin'" > "$ADDITIONAL_CONFIG_FILE_1"
|
||||
echo " set -g @plugin 'tmux-plugins/tmux-copycat'" > "$ADDITIONAL_CONFIG_FILE_2"
|
||||
|
||||
"$CURRENT_DIR/expect_successful_multiple_plugins_download" ||
|
||||
fail_helper "[key-binding][multiple sourced files] plugins installation fails"
|
||||
|
||||
check_dir_exists_helper "$PLUGINS_DIR/tmux-example-plugin/" ||
|
||||
fail_helper "[key-binding][multiple sourced files] plugin download fails (tmux-example-plugin)"
|
||||
|
||||
check_dir_exists_helper "$PLUGINS_DIR/tmux-copycat/" ||
|
||||
fail_helper "[key-binding][multiple sourced files] plugin download fails (tmux-copycat)"
|
||||
|
||||
teardown_helper
|
||||
}
|
||||
|
||||
# SCRIPT TESTS
|
||||
|
||||
test_plugin_installation_via_script() {
|
||||
set_tmux_conf_helper <<- HERE
|
||||
set -g mode-keys vi
|
||||
set -g @plugin "tmux-plugins/tmux-example-plugin"
|
||||
run-shell "$TPM_DIR/tpm"
|
||||
HERE
|
||||
|
||||
script_run_helper "$TPM_DIR/bin/install_plugins" '"tmux-example-plugin" download success' ||
|
||||
fail_helper "[script] plugin installation fails"
|
||||
|
||||
check_dir_exists_helper "$PLUGINS_DIR/tmux-example-plugin/" ||
|
||||
fail_helper "[script] plugin download fails"
|
||||
|
||||
script_run_helper "$TPM_DIR/bin/install_plugins" 'Already installed "tmux-example-plugin"' ||
|
||||
fail_helper "[script] plugin already installed message fail"
|
||||
|
||||
teardown_helper
|
||||
}
|
||||
|
||||
test_plugin_installation_custom_dir_via_script() {
|
||||
set_tmux_conf_helper <<- HERE
|
||||
set -g mode-keys vi
|
||||
set-environment -g TMUX_PLUGIN_MANAGER_PATH '$CUSTOM_PLUGINS_DIR'
|
||||
|
||||
set -g @plugin "tmux-plugins/tmux-example-plugin"
|
||||
run-shell "$TPM_DIR/tpm"
|
||||
HERE
|
||||
|
||||
script_run_helper "$TPM_DIR/bin/install_plugins" '"tmux-example-plugin" download success' ||
|
||||
fail_helper "[script][custom dir] plugin installation fails"
|
||||
|
||||
check_dir_exists_helper "$CUSTOM_PLUGINS_DIR/tmux-example-plugin/" ||
|
||||
fail_helper "[script][custom dir] plugin download fails"
|
||||
|
||||
script_run_helper "$TPM_DIR/bin/install_plugins" 'Already installed "tmux-example-plugin"' ||
|
||||
fail_helper "[script][custom dir] plugin already installed message fail"
|
||||
|
||||
teardown_helper
|
||||
rm -rf "$CUSTOM_PLUGINS_DIR"
|
||||
}
|
||||
|
||||
test_non_existing_plugin_installation_via_script() {
|
||||
set_tmux_conf_helper <<- HERE
|
||||
set -g mode-keys vi
|
||||
set -g @plugin "tmux-plugins/non-existing-plugin"
|
||||
run-shell "$TPM_DIR/tpm"
|
||||
HERE
|
||||
|
||||
local expected_exit_code=1
|
||||
script_run_helper "$TPM_DIR/bin/install_plugins" '"non-existing-plugin" download fail' "$expected_exit_code" ||
|
||||
fail_helper "[script] non existing plugin installation doesn't fail"
|
||||
|
||||
teardown_helper
|
||||
}
|
||||
|
||||
test_multiple_plugins_installation_via_script() {
|
||||
set_tmux_conf_helper <<- HERE
|
||||
set -g mode-keys vi
|
||||
set -g @plugin "tmux-plugins/tmux-example-plugin"
|
||||
\ \ set -g @plugin 'tmux-plugins/tmux-copycat'
|
||||
run-shell "$TPM_DIR/tpm"
|
||||
HERE
|
||||
|
||||
script_run_helper "$TPM_DIR/bin/install_plugins" '"tmux-example-plugin" download success' ||
|
||||
fail_helper "[script] multiple plugins installation fails"
|
||||
|
||||
check_dir_exists_helper "$PLUGINS_DIR/tmux-example-plugin/" ||
|
||||
fail_helper "[script] plugin download fails (tmux-example-plugin)"
|
||||
|
||||
check_dir_exists_helper "$PLUGINS_DIR/tmux-copycat/" ||
|
||||
fail_helper "[script] plugin download fails (tmux-copycat)"
|
||||
|
||||
script_run_helper "$TPM_DIR/bin/install_plugins" 'Already installed "tmux-copycat"' ||
|
||||
fail_helper "[script] multiple plugins already installed message fail"
|
||||
|
||||
teardown_helper
|
||||
}
|
||||
|
||||
test_plugins_installation_from_sourced_file_via_script() {
|
||||
set_tmux_conf_helper <<- HERE
|
||||
set -g mode-keys vi
|
||||
source '$ADDITIONAL_CONFIG_FILE_1'
|
||||
set -g @plugin 'tmux-plugins/tmux-example-plugin'
|
||||
run-shell "$TPM_DIR/tpm"
|
||||
HERE
|
||||
|
||||
mkdir ~/.tmux
|
||||
echo "set -g @plugin 'tmux-plugins/tmux-copycat'" > "$ADDITIONAL_CONFIG_FILE_1"
|
||||
|
||||
script_run_helper "$TPM_DIR/bin/install_plugins" '"tmux-copycat" download success' ||
|
||||
fail_helper "[script][sourced file] plugins installation fails"
|
||||
|
||||
check_dir_exists_helper "$PLUGINS_DIR/tmux-example-plugin/" ||
|
||||
fail_helper "[script][sourced file] plugin download fails (tmux-example-plugin)"
|
||||
|
||||
check_dir_exists_helper "$PLUGINS_DIR/tmux-copycat/" ||
|
||||
fail_helper "[script][sourced file] plugin download fails (tmux-copycat)"
|
||||
|
||||
script_run_helper "$TPM_DIR/bin/install_plugins" 'Already installed "tmux-copycat"' ||
|
||||
fail_helper "[script][sourced file] plugins already installed message fail"
|
||||
|
||||
teardown_helper
|
||||
}
|
||||
|
||||
test_plugins_installation_from_multiple_sourced_files_via_script() {
|
||||
set_tmux_conf_helper <<- HERE
|
||||
set -g mode-keys vi
|
||||
\ \ source '$ADDITIONAL_CONFIG_FILE_1'
|
||||
source-file '$ADDITIONAL_CONFIG_FILE_2'
|
||||
set -g @plugin 'tmux-plugins/tmux-example-plugin'
|
||||
run-shell "$TPM_DIR/tpm"
|
||||
HERE
|
||||
|
||||
mkdir ~/.tmux
|
||||
echo " set -g @plugin 'tmux-plugins/tmux-copycat'" > "$ADDITIONAL_CONFIG_FILE_1"
|
||||
echo "set -g @plugin 'tmux-plugins/tmux-sensible'" > "$ADDITIONAL_CONFIG_FILE_2"
|
||||
|
||||
script_run_helper "$TPM_DIR/bin/install_plugins" '"tmux-sensible" download success' ||
|
||||
fail_helper "[script][multiple sourced files] plugins installation fails"
|
||||
|
||||
check_dir_exists_helper "$PLUGINS_DIR/tmux-example-plugin/" ||
|
||||
fail_helper "[script][multiple sourced files] plugin download fails (tmux-example-plugin)"
|
||||
|
||||
check_dir_exists_helper "$PLUGINS_DIR/tmux-copycat/" ||
|
||||
fail_helper "[script][multiple sourced files] plugin download fails (tmux-copycat)"
|
||||
|
||||
check_dir_exists_helper "$PLUGINS_DIR/tmux-sensible/" ||
|
||||
fail_helper "[script][multiple sourced files] plugin download fails (tmux-sensible)"
|
||||
|
||||
script_run_helper "$TPM_DIR/bin/install_plugins" 'Already installed "tmux-sensible"' ||
|
||||
fail_helper "[script][multiple sourced files] plugins already installed message fail"
|
||||
|
||||
teardown_helper
|
||||
}
|
||||
|
||||
run_tests
|
||||
100
tmux/.config/tmux/plugins/tpm/tests/test_plugin_installation_legacy.sh
Executable file
100
tmux/.config/tmux/plugins/tpm/tests/test_plugin_installation_legacy.sh
Executable file
|
|
@ -0,0 +1,100 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
PLUGINS_DIR="$HOME/.tmux/plugins"
|
||||
TPM_DIR="$PWD"
|
||||
|
||||
source "$CURRENT_DIR/helpers/helpers.sh"
|
||||
source "$CURRENT_DIR/helpers/tpm.sh"
|
||||
|
||||
# TMUX KEY-BINDING TESTS
|
||||
|
||||
test_plugin_installation_via_tmux_key_binding() {
|
||||
set_tmux_conf_helper <<- HERE
|
||||
set -g mode-keys vi
|
||||
set -g @tpm_plugins "tmux-plugins/tmux-example-plugin"
|
||||
run-shell "$TPM_DIR/tpm"
|
||||
HERE
|
||||
|
||||
# opens tmux and test it with `expect`
|
||||
$CURRENT_DIR/expect_successful_plugin_download ||
|
||||
fail_helper "[key-binding] plugin installation fails"
|
||||
|
||||
# check plugin dir exists after download
|
||||
check_dir_exists_helper "$PLUGINS_DIR/tmux-example-plugin/" ||
|
||||
fail_helper "[key-binding] plugin download fails"
|
||||
|
||||
teardown_helper
|
||||
}
|
||||
|
||||
test_legacy_and_new_syntax_for_plugin_installation_work_via_tmux_key_binding() {
|
||||
set_tmux_conf_helper <<- HERE
|
||||
set -g mode-keys vi
|
||||
set -g @tpm_plugins " \
|
||||
tmux-plugins/tmux-example-plugin \
|
||||
"
|
||||
set -g @plugin 'tmux-plugins/tmux-copycat'
|
||||
run-shell "$TPM_DIR/tpm"
|
||||
HERE
|
||||
|
||||
# opens tmux and test it with `expect`
|
||||
"$CURRENT_DIR"/expect_successful_multiple_plugins_download ||
|
||||
fail_helper "[key-binding] multiple plugins installation fails"
|
||||
|
||||
# check plugin dir exists after download
|
||||
check_dir_exists_helper "$PLUGINS_DIR/tmux-example-plugin/" ||
|
||||
fail_helper "[key-binding] plugin download fails (tmux-example-plugin)"
|
||||
|
||||
check_dir_exists_helper "$PLUGINS_DIR/tmux-copycat/" ||
|
||||
fail_helper "[key-binding] plugin download fails (tmux-copycat)"
|
||||
|
||||
teardown_helper
|
||||
}
|
||||
|
||||
# SCRIPT TESTS
|
||||
|
||||
test_plugin_installation_via_script() {
|
||||
set_tmux_conf_helper <<- HERE
|
||||
set -g mode-keys vi
|
||||
set -g @tpm_plugins "tmux-plugins/tmux-example-plugin"
|
||||
run-shell "$TPM_DIR/tpm"
|
||||
HERE
|
||||
|
||||
script_run_helper "$TPM_DIR/bin/install_plugins" '"tmux-example-plugin" download success' ||
|
||||
fail_helper "[script] plugin installation fails"
|
||||
|
||||
check_dir_exists_helper "$PLUGINS_DIR/tmux-example-plugin/" ||
|
||||
fail_helper "[script] plugin download fails"
|
||||
|
||||
script_run_helper "$TPM_DIR/bin/install_plugins" 'Already installed "tmux-example-plugin"' ||
|
||||
fail_helper "[script] plugin already installed message fail"
|
||||
|
||||
teardown_helper
|
||||
}
|
||||
|
||||
test_legacy_and_new_syntax_for_plugin_installation_work_via_script() {
|
||||
set_tmux_conf_helper <<- HERE
|
||||
set -g mode-keys vi
|
||||
set -g @tpm_plugins " \
|
||||
tmux-plugins/tmux-example-plugin \
|
||||
"
|
||||
set -g @plugin 'tmux-plugins/tmux-copycat'
|
||||
run-shell "$TPM_DIR/tpm"
|
||||
HERE
|
||||
|
||||
script_run_helper "$TPM_DIR/bin/install_plugins" '"tmux-example-plugin" download success' ||
|
||||
fail_helper "[script] multiple plugin installation fails"
|
||||
|
||||
check_dir_exists_helper "$PLUGINS_DIR/tmux-example-plugin/" ||
|
||||
fail_helper "[script] plugin download fails (tmux-example-plugin)"
|
||||
|
||||
check_dir_exists_helper "$PLUGINS_DIR/tmux-copycat/" ||
|
||||
fail_helper "[script] plugin download fails (tmux-copycat)"
|
||||
|
||||
script_run_helper "$TPM_DIR/bin/install_plugins" 'Already installed "tmux-copycat"' ||
|
||||
fail_helper "[script] multiple plugins already installed message fail"
|
||||
|
||||
teardown_helper
|
||||
}
|
||||
|
||||
run_tests
|
||||
78
tmux/.config/tmux/plugins/tpm/tests/test_plugin_sourcing.sh
Executable file
78
tmux/.config/tmux/plugins/tpm/tests/test_plugin_sourcing.sh
Executable file
|
|
@ -0,0 +1,78 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
TPM_DIR="$PWD"
|
||||
PLUGINS_DIR="$HOME/.tmux/plugins"
|
||||
|
||||
CUSTOM_PLUGINS_DIR="$HOME/foo/plugins"
|
||||
|
||||
source "$CURRENT_DIR/helpers/helpers.sh"
|
||||
source "$CURRENT_DIR/helpers/tpm.sh"
|
||||
|
||||
check_binding_defined() {
|
||||
local binding="$1"
|
||||
tmux list-keys | grep -q "$binding"
|
||||
}
|
||||
|
||||
create_test_plugin_helper() {
|
||||
local plugin_path="$PLUGINS_DIR/tmux_test_plugin/"
|
||||
rm -rf "$plugin_path"
|
||||
mkdir -p "$plugin_path"
|
||||
|
||||
while read line; do
|
||||
echo "$line" >> "$plugin_path/test_plugin.tmux"
|
||||
done
|
||||
chmod +x "$plugin_path/test_plugin.tmux"
|
||||
}
|
||||
|
||||
check_tpm_path() {
|
||||
local correct_tpm_path="$1"
|
||||
local tpm_path="$(tmux start-server\; show-environment -g TMUX_PLUGIN_MANAGER_PATH | cut -f2 -d=)"
|
||||
[ "$correct_tpm_path" == "$tpm_path" ]
|
||||
}
|
||||
|
||||
test_plugin_sourcing() {
|
||||
set_tmux_conf_helper <<- HERE
|
||||
set -g mode-keys vi
|
||||
set -g @plugin "doesnt_matter/tmux_test_plugin"
|
||||
run-shell "$TPM_DIR/tpm"
|
||||
HERE
|
||||
|
||||
# manually creates a local tmux plugin
|
||||
create_test_plugin_helper <<- HERE
|
||||
tmux bind-key R run-shell foo_command
|
||||
HERE
|
||||
|
||||
tmux new-session -d # tmux starts detached
|
||||
check_binding_defined "R run-shell foo_command" ||
|
||||
fail_helper "Plugin sourcing fails"
|
||||
|
||||
teardown_helper
|
||||
}
|
||||
|
||||
test_default_tpm_path() {
|
||||
set_tmux_conf_helper <<- HERE
|
||||
set -g mode-keys vi
|
||||
run-shell "$TPM_DIR/tpm"
|
||||
HERE
|
||||
|
||||
check_tpm_path "${PLUGINS_DIR}/" ||
|
||||
fail_helper "Default TPM path not correct"
|
||||
|
||||
teardown_helper
|
||||
}
|
||||
|
||||
test_custom_tpm_path() {
|
||||
set_tmux_conf_helper <<- HERE
|
||||
set -g mode-keys vi
|
||||
set-environment -g TMUX_PLUGIN_MANAGER_PATH '$CUSTOM_PLUGINS_DIR'
|
||||
run-shell "$TPM_DIR/tpm"
|
||||
HERE
|
||||
|
||||
check_tpm_path "$CUSTOM_PLUGINS_DIR" ||
|
||||
fail_helper "Custom TPM path not correct"
|
||||
|
||||
teardown_helper
|
||||
}
|
||||
|
||||
run_tests
|
||||
60
tmux/.config/tmux/plugins/tpm/tests/test_plugin_update.sh
Executable file
60
tmux/.config/tmux/plugins/tpm/tests/test_plugin_update.sh
Executable file
|
|
@ -0,0 +1,60 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
TPM_DIR="$PWD"
|
||||
PLUGINS_DIR="$HOME/.tmux/plugins"
|
||||
|
||||
source "$CURRENT_DIR/helpers/helpers.sh"
|
||||
source "$CURRENT_DIR/helpers/tpm.sh"
|
||||
|
||||
manually_install_the_plugin() {
|
||||
mkdir -p "$PLUGINS_DIR"
|
||||
cd "$PLUGINS_DIR"
|
||||
git clone --quiet https://github.com/tmux-plugins/tmux-example-plugin
|
||||
}
|
||||
|
||||
# TMUX KEY-BINDING TESTS
|
||||
|
||||
test_plugin_update_via_tmux_key_binding() {
|
||||
set_tmux_conf_helper <<- HERE
|
||||
set -g mode-keys vi
|
||||
set -g @plugin "tmux-plugins/tmux-example-plugin"
|
||||
run-shell "$TPM_DIR/tpm"
|
||||
HERE
|
||||
|
||||
manually_install_the_plugin
|
||||
|
||||
"$CURRENT_DIR/expect_successful_update_of_all_plugins" ||
|
||||
fail_helper "[key-binding] 'update all plugins' fails"
|
||||
|
||||
"$CURRENT_DIR/expect_successful_update_of_a_single_plugin" ||
|
||||
fail_helper "[key-binding] 'update single plugin' fails"
|
||||
|
||||
teardown_helper
|
||||
}
|
||||
|
||||
# SCRIPT TESTS
|
||||
|
||||
test_plugin_update_via_script() {
|
||||
set_tmux_conf_helper <<- HERE
|
||||
set -g mode-keys vi
|
||||
set -g @plugin "tmux-plugins/tmux-example-plugin"
|
||||
run-shell "$TPM_DIR/tpm"
|
||||
HERE
|
||||
|
||||
manually_install_the_plugin
|
||||
|
||||
local expected_exit_code=1
|
||||
script_run_helper "$TPM_DIR/bin/update_plugins" 'usage' "$expected_exit_code" ||
|
||||
fail_helper "[script] running update plugins without args should fail"
|
||||
|
||||
script_run_helper "$TPM_DIR/bin/update_plugins tmux-example-plugin" '"tmux-example-plugin" update success' ||
|
||||
fail_helper "[script] plugin update fails"
|
||||
|
||||
script_run_helper "$TPM_DIR/bin/update_plugins all" '"tmux-example-plugin" update success' ||
|
||||
fail_helper "[script] update all plugins fails"
|
||||
|
||||
teardown_helper
|
||||
}
|
||||
|
||||
run_tests
|
||||
81
tmux/.config/tmux/plugins/tpm/tpm
Executable file
81
tmux/.config/tmux/plugins/tpm/tpm
Executable file
|
|
@ -0,0 +1,81 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
BINDINGS_DIR="$CURRENT_DIR/bindings"
|
||||
SCRIPTS_DIR="$CURRENT_DIR/scripts"
|
||||
|
||||
source "$SCRIPTS_DIR/variables.sh"
|
||||
|
||||
get_tmux_option() {
|
||||
local option="$1"
|
||||
local default_value="$2"
|
||||
local option_value="$(tmux show-option -gqv "$option")"
|
||||
if [ -z "$option_value" ]; then
|
||||
echo "$default_value"
|
||||
else
|
||||
echo "$option_value"
|
||||
fi
|
||||
}
|
||||
|
||||
tpm_path_set() {
|
||||
tmux show-environment -g "$DEFAULT_TPM_ENV_VAR_NAME" >/dev/null 2>&1
|
||||
}
|
||||
|
||||
# Check if configuration file exists at an XDG-compatible location, if so use
|
||||
# that directory for TMUX_PLUGIN_MANAGER_PATH. Otherwise use $DEFAULT_TPM_PATH.
|
||||
set_default_tpm_path() {
|
||||
local xdg_tmux_path="${XDG_CONFIG_HOME:-$HOME/.config}/tmux"
|
||||
local tpm_path="$DEFAULT_TPM_PATH"
|
||||
|
||||
if [ -f "$xdg_tmux_path/tmux.conf" ]; then
|
||||
tpm_path="$xdg_tmux_path/plugins/"
|
||||
fi
|
||||
|
||||
tmux set-environment -g "$DEFAULT_TPM_ENV_VAR_NAME" "$tpm_path"
|
||||
}
|
||||
|
||||
# Ensures TMUX_PLUGIN_MANAGER_PATH global env variable is set.
|
||||
#
|
||||
# Put this in `.tmux.conf` to override the default:
|
||||
# `set-environment -g TMUX_PLUGIN_MANAGER_PATH "/some/other/path/"`
|
||||
set_tpm_path() {
|
||||
if ! tpm_path_set; then
|
||||
set_default_tpm_path
|
||||
fi
|
||||
}
|
||||
|
||||
# 1. Fetches plugin names from `@plugin` variables
|
||||
# 2. Creates full plugin path
|
||||
# 3. Sources all *.tmux files from each of the plugin directories
|
||||
# - no errors raised if directory does not exist
|
||||
# Files are sourced as tmux config files, not as shell scripts!
|
||||
source_plugins() {
|
||||
"$SCRIPTS_DIR/source_plugins.sh" >/dev/null 2>&1
|
||||
}
|
||||
|
||||
# prefix + I - downloads TPM plugins and reloads TMUX environment
|
||||
# prefix + U - updates a plugin (or all of them) and reloads TMUX environment
|
||||
# prefix + alt + u - remove unused TPM plugins and reloads TMUX environment
|
||||
set_tpm_key_bindings() {
|
||||
local install_key="$(get_tmux_option "$install_key_option" "$default_install_key")"
|
||||
tmux bind-key "$install_key" run-shell "$BINDINGS_DIR/install_plugins"
|
||||
|
||||
local update_key="$(get_tmux_option "$update_key_option" "$default_update_key")"
|
||||
tmux bind-key "$update_key" run-shell "$BINDINGS_DIR/update_plugins"
|
||||
|
||||
local clean_key="$(get_tmux_option "$clean_key_option" "$default_clean_key")"
|
||||
tmux bind-key "$clean_key" run-shell "$BINDINGS_DIR/clean_plugins"
|
||||
}
|
||||
|
||||
supported_tmux_version_ok() {
|
||||
"$SCRIPTS_DIR/check_tmux_version.sh" "$SUPPORTED_TMUX_VERSION"
|
||||
}
|
||||
|
||||
main() {
|
||||
if supported_tmux_version_ok; then
|
||||
set_tpm_path
|
||||
set_tpm_key_bindings
|
||||
source_plugins
|
||||
fi
|
||||
}
|
||||
main
|
||||
1
tmux/.config/tmux/plugins/vim-tmux-navigator/.gitignore
vendored
Normal file
1
tmux/.config/tmux/plugins/vim-tmux-navigator/.gitignore
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
doc/tags
|
||||
21
tmux/.config/tmux/plugins/vim-tmux-navigator/License.md
Normal file
21
tmux/.config/tmux/plugins/vim-tmux-navigator/License.md
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2017 Chris Toomey
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
461
tmux/.config/tmux/plugins/vim-tmux-navigator/README.md
Normal file
461
tmux/.config/tmux/plugins/vim-tmux-navigator/README.md
Normal file
|
|
@ -0,0 +1,461 @@
|
|||
Vim Tmux Navigator
|
||||
==================
|
||||
|
||||
This plugin is a repackaging of [Mislav Marohnić's](https://mislav.net/) tmux-navigator
|
||||
configuration described in [this gist][]. When combined with a set of tmux
|
||||
key bindings, the plugin will allow you to navigate seamlessly between
|
||||
vim and tmux splits using a consistent set of hotkeys.
|
||||
|
||||
**NOTE**: This requires tmux v1.8 or higher.
|
||||
|
||||
Usage
|
||||
-----
|
||||
|
||||
This plugin provides the following mappings which allow you to move between
|
||||
Vim panes and tmux splits seamlessly.
|
||||
|
||||
- `<ctrl-h>` => Left
|
||||
- `<ctrl-j>` => Down
|
||||
- `<ctrl-k>` => Up
|
||||
- `<ctrl-l>` => Right
|
||||
- `<ctrl-\>` => Previous split
|
||||
|
||||
**Note** - you don't need to use your tmux `prefix` key sequence before using
|
||||
the mappings.
|
||||
|
||||
If you want to use alternate key mappings, see the [configuration section
|
||||
below][].
|
||||
|
||||
Installation
|
||||
------------
|
||||
|
||||
### Vim
|
||||
|
||||
If you don't have a preferred installation method, I recommend using [Vundle][].
|
||||
Assuming you have Vundle installed and configured, the following steps will
|
||||
install the plugin:
|
||||
|
||||
Add the following line to your `~/.vimrc` file
|
||||
|
||||
``` vim
|
||||
Plugin 'christoomey/vim-tmux-navigator'
|
||||
```
|
||||
|
||||
Then run
|
||||
|
||||
```
|
||||
:PluginInstall
|
||||
```
|
||||
|
||||
If you are using Vim 8+, you don't need any plugin manager. Simply clone this repository inside `~/.vim/pack/plugin/start/` directory and restart Vim.
|
||||
|
||||
```
|
||||
git clone git@github.com:christoomey/vim-tmux-navigator.git ~/.vim/pack/plugins/start/vim-tmux-navigator
|
||||
```
|
||||
|
||||
### lazy.nvim
|
||||
|
||||
If you are using [lazy.nvim](https://github.com/folke/lazy.nvim). Add the following plugin to your configuration.
|
||||
|
||||
```lua
|
||||
{
|
||||
"christoomey/vim-tmux-navigator",
|
||||
cmd = {
|
||||
"TmuxNavigateLeft",
|
||||
"TmuxNavigateDown",
|
||||
"TmuxNavigateUp",
|
||||
"TmuxNavigateRight",
|
||||
"TmuxNavigatePrevious",
|
||||
},
|
||||
keys = {
|
||||
{ "<c-h>", "<cmd><C-U>TmuxNavigateLeft<cr>" },
|
||||
{ "<c-j>", "<cmd><C-U>TmuxNavigateDown<cr>" },
|
||||
{ "<c-k>", "<cmd><C-U>TmuxNavigateUp<cr>" },
|
||||
{ "<c-l>", "<cmd><C-U>TmuxNavigateRight<cr>" },
|
||||
{ "<c-\\>", "<cmd><C-U>TmuxNavigatePrevious<cr>" },
|
||||
},
|
||||
}
|
||||
```
|
||||
|
||||
Then, restart Neovim and lazy.nvim will automatically install the plugin and configure the keybindings.
|
||||
|
||||
### tmux
|
||||
|
||||
To configure the tmux side of this customization there are two options:
|
||||
|
||||
#### Add a snippet
|
||||
|
||||
Add the following to your `~/.tmux.conf` file:
|
||||
|
||||
``` tmux
|
||||
# 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|l?n?vim?x?|fzf)(diff)?$'"
|
||||
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'
|
||||
tmux_version='$(tmux -V | sed -En "s/^tmux ([0-9]+(.[0-9]+)?).*/\1/p")'
|
||||
if-shell -b '[ "$(echo "$tmux_version < 3.0" | bc)" = 1 ]' \
|
||||
"bind-key -n 'C-\\' if-shell \"$is_vim\" 'send-keys C-\\' 'select-pane -l'"
|
||||
if-shell -b '[ "$(echo "$tmux_version >= 3.0" | bc)" = 1 ]' \
|
||||
"bind-key -n 'C-\\' if-shell \"$is_vim\" 'send-keys C-\\\\' 'select-pane -l'"
|
||||
|
||||
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
|
||||
bind-key -T copy-mode-vi 'C-\' select-pane -l
|
||||
```
|
||||
|
||||
#### TPM
|
||||
|
||||
If you'd prefer, you can use the Tmux Plugin Manager ([TPM][]) instead of
|
||||
copying the snippet.
|
||||
When using TPM, add the following lines to your ~/.tmux.conf:
|
||||
|
||||
``` tmux
|
||||
set -g @plugin 'christoomey/vim-tmux-navigator'
|
||||
run '~/.tmux/plugins/tpm/tpm'
|
||||
```
|
||||
|
||||
Thanks to Christopher Sexton who provided the updated tmux configuration in
|
||||
[this blog post][].
|
||||
|
||||
Configuration
|
||||
-------------
|
||||
|
||||
### Custom Key Bindings
|
||||
|
||||
If you don't want the plugin to create any mappings, you can use the five
|
||||
provided functions to define your own custom maps. You will need to define
|
||||
custom mappings in your `~/.vimrc` as well as update the bindings in tmux to
|
||||
match.
|
||||
|
||||
#### Vim
|
||||
|
||||
Add the following to your `~/.vimrc` to define your custom maps:
|
||||
|
||||
``` vim
|
||||
let g:tmux_navigator_no_mappings = 1
|
||||
|
||||
noremap <silent> {Left-Mapping} :<C-U>TmuxNavigateLeft<cr>
|
||||
noremap <silent> {Down-Mapping} :<C-U>TmuxNavigateDown<cr>
|
||||
noremap <silent> {Up-Mapping} :<C-U>TmuxNavigateUp<cr>
|
||||
noremap <silent> {Right-Mapping} :<C-U>TmuxNavigateRight<cr>
|
||||
noremap <silent> {Previous-Mapping} :<C-U>TmuxNavigatePrevious<cr>
|
||||
```
|
||||
|
||||
*Note* Each instance of `{Left-Mapping}` or `{Down-Mapping}` must be replaced
|
||||
in the above code with the desired mapping. Ie, the mapping for `<ctrl-h>` =>
|
||||
Left would be created with `noremap <silent> <c-h> :<C-U>TmuxNavigateLeft<cr>`.
|
||||
|
||||
##### Autosave on leave
|
||||
|
||||
You can configure the plugin to write the current buffer, or all buffers, when
|
||||
navigating from Vim to tmux. This functionality is exposed via the
|
||||
`g:tmux_navigator_save_on_switch` variable, which can have either of the
|
||||
following values:
|
||||
|
||||
Value | Behavior
|
||||
------ | ------
|
||||
1 | `:update` (write the current buffer, but only if changed)
|
||||
2 | `:wall` (write all buffers)
|
||||
|
||||
To enable this, add the following (with the desired value) to your ~/.vimrc:
|
||||
|
||||
```vim
|
||||
" Write all buffers before navigating from Vim to tmux pane
|
||||
let g:tmux_navigator_save_on_switch = 2
|
||||
```
|
||||
|
||||
##### Disable While Zoomed
|
||||
|
||||
By default, if you zoom the tmux pane running Vim and then attempt to navigate
|
||||
"past" the edge of the Vim session, tmux will unzoom the pane. This is the
|
||||
default tmux behavior, but may be confusing if you've become accustomed to
|
||||
navigation "wrapping" around the sides due to this plugin.
|
||||
|
||||
We provide an option, `g:tmux_navigator_disable_when_zoomed`, which can be used
|
||||
to disable this unzooming behavior, keeping all navigation within Vim until the
|
||||
tmux pane is explicitly unzoomed.
|
||||
|
||||
To disable navigation when zoomed, add the following to your ~/.vimrc:
|
||||
|
||||
```vim
|
||||
" Disable tmux navigator when zooming the Vim pane
|
||||
let g:tmux_navigator_disable_when_zoomed = 1
|
||||
```
|
||||
|
||||
##### Preserve Zoom
|
||||
|
||||
As noted above, navigating from a Vim pane to another tmux pane normally causes
|
||||
the window to be unzoomed. Some users may prefer the behavior of tmux's `-Z`
|
||||
option to `select-pane`, which keeps the window zoomed if it was zoomed. To
|
||||
enable this behavior, set the `g:tmux_navigator_preserve_zoom` option to `1`:
|
||||
|
||||
```vim
|
||||
" If the tmux window is zoomed, keep it zoomed when moving from Vim to another pane
|
||||
let g:tmux_navigator_preserve_zoom = 1
|
||||
```
|
||||
|
||||
Naturally, if `g:tmux_navigator_disable_when_zoomed` is enabled, this option
|
||||
will have no effect.
|
||||
|
||||
#### Tmux
|
||||
|
||||
Alter each of the five lines of the tmux configuration listed above to use your
|
||||
custom mappings. **Note** each line contains two references to the desired
|
||||
mapping.
|
||||
|
||||
### Additional Customization
|
||||
|
||||
#### Ignoring programs that use Ctrl+hjkl movement
|
||||
|
||||
In interactive programs such as FZF, Ctrl+hjkl can be used instead of the arrow keys to move the selection up and down. If vim-tmux-navigator is getting in your way trying to change the active window instead, you can make it be ignored and work as if this plugin were not enabled. Just modify the `is_vim` variable(that you have either on the snipped you pasted on `~/.tmux.conf` or on the `vim-tmux-navigator.tmux` file). For example, to add the program `foobar`:
|
||||
|
||||
```diff
|
||||
- is_vim="ps -o state= -o comm= -t '#{pane_tty}' | grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|l?n?vim?x?|fzf)(diff)?$'"
|
||||
+ is_vim="ps -o state= -o comm= -t '#{pane_tty}' | grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|l?n?vim?x?|fzf|foobar)(diff)?$'"
|
||||
```
|
||||
|
||||
#### Restoring Clear Screen (C-l)
|
||||
|
||||
The default key bindings include `<Ctrl-l>` which is the readline key binding
|
||||
for clearing the screen. The following binding can be added to your `~/.tmux.conf` file to provide an alternate mapping to `clear-screen`.
|
||||
|
||||
``` tmux
|
||||
bind C-l send-keys 'C-l'
|
||||
```
|
||||
|
||||
With this enabled you can use `<prefix> C-l` to clear the screen.
|
||||
|
||||
Thanks to [Brian Hogan][] for the tip on how to re-map the clear screen binding.
|
||||
|
||||
#### Restoring SIGQUIT (C-\\)
|
||||
|
||||
The default key bindings also include `<Ctrl-\>` which is the default method of
|
||||
sending SIGQUIT to a foreground process. Similar to "Clear Screen" above, a key
|
||||
binding can be created to replicate SIGQUIT in the prefix table.
|
||||
|
||||
``` tmux
|
||||
bind C-\\ send-keys 'C-\'
|
||||
```
|
||||
|
||||
Alternatively, you can exclude the previous pane key binding from your `~/.tmux.conf`. If using TPM, the following line can be used to unbind the previous pane binding set by the plugin.
|
||||
|
||||
``` tmux
|
||||
unbind -n C-\\
|
||||
```
|
||||
|
||||
#### Disable Wrapping
|
||||
|
||||
By default, if you try to move past the edge of the screen, tmux/vim will
|
||||
"wrap" around to the opposite side. To disable this, you'll need to
|
||||
configure both tmux and vim:
|
||||
|
||||
For vim, you only need to enable this option:
|
||||
```vim
|
||||
let g:tmux_navigator_no_wrap = 1
|
||||
```
|
||||
|
||||
Tmux doesn't have an option, so whatever key bindings you have need to be set
|
||||
to conditionally wrap based on position on screen:
|
||||
|
||||
```tmux
|
||||
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-h' if-shell "$is_vim" { send-keys C-h } { if-shell -F '#{pane_at_left}' {} { select-pane -L } }
|
||||
bind-key -n 'C-j' if-shell "$is_vim" { send-keys C-j } { if-shell -F '#{pane_at_bottom}' {} { select-pane -D } }
|
||||
bind-key -n 'C-k' if-shell "$is_vim" { send-keys C-k } { if-shell -F '#{pane_at_top}' {} { select-pane -U } }
|
||||
bind-key -n 'C-l' if-shell "$is_vim" { send-keys C-l } { if-shell -F '#{pane_at_right}' {} { select-pane -R } }
|
||||
|
||||
bind-key -T copy-mode-vi 'C-h' if-shell -F '#{pane_at_left}' {} { select-pane -L }
|
||||
bind-key -T copy-mode-vi 'C-j' if-shell -F '#{pane_at_bottom}' {} { select-pane -D }
|
||||
bind-key -T copy-mode-vi 'C-k' if-shell -F '#{pane_at_top}' {} { select-pane -U }
|
||||
bind-key -T copy-mode-vi 'C-l' if-shell -F '#{pane_at_right}' {} { select-pane -R }
|
||||
```
|
||||
|
||||
#### Nesting
|
||||
If you like to nest your tmux sessions, this plugin is not going to work
|
||||
properly. It probably never will, as it would require detecting when Tmux would
|
||||
wrap from one outermost pane to another and propagating that to the outer
|
||||
session.
|
||||
|
||||
By default this plugin works on the outermost tmux session and the vim
|
||||
sessions it contains, but you can customize the behaviour by adding more
|
||||
commands to the expression used by the grep command.
|
||||
|
||||
When nesting tmux sessions via ssh or mosh, you could extend it to look like
|
||||
`'(^|\/)g?(view|vim|ssh|mosh?)(diff)?$'`, which makes this plugin work within
|
||||
the innermost tmux session and the vim sessions within that one. This works
|
||||
better than the default behaviour if you use the outer Tmux sessions as relays
|
||||
to different hosts and have all instances of vim on remote hosts.
|
||||
|
||||
Similarly, if you like to nest tmux locally, add `|tmux` to the expression.
|
||||
|
||||
This behaviour means that you can't leave the innermost session with Ctrl-hjkl
|
||||
directly. These following fallback mappings can be targeted to the right Tmux
|
||||
session by escaping the prefix (Tmux' `send-prefix` command).
|
||||
|
||||
``` tmux
|
||||
bind -r C-h run "tmux select-pane -L"
|
||||
bind -r C-j run "tmux select-pane -D"
|
||||
bind -r C-k run "tmux select-pane -U"
|
||||
bind -r C-l run "tmux select-pane -R"
|
||||
bind -r C-\ run "tmux select-pane -l"
|
||||
```
|
||||
|
||||
Another workaround is to configure tmux on the outer machine to send keys to
|
||||
the inner tmux session:
|
||||
|
||||
```
|
||||
bind-key -n 'M-h' 'send-keys c-h'
|
||||
bind-key -n 'M-j' 'send-keys c-j'
|
||||
bind-key -n 'M-k' 'send-keys c-k'
|
||||
bind-key -n 'M-l' 'send-keys c-l'
|
||||
```
|
||||
|
||||
Here we bind "meta" key (aka "alt" or "option" key) combinations for each of
|
||||
the four directions and send those along to the innermost session via
|
||||
`send-keys`. You use the normal `C-h,j,k,l` while in the outermost session and
|
||||
the alternative bindings to navigate the innermost session. Note that if you
|
||||
use the example above on a Mac, you may need to configure your terminal app to
|
||||
get the option key to work like a normal meta key. Consult your terminal app's
|
||||
manual for details.
|
||||
|
||||
A third possible solution is to manually prevent the outermost tmux session
|
||||
from intercepting the navigation keystrokes by disabling the prefix table:
|
||||
|
||||
```
|
||||
set -g pane-active-border-style 'fg=#000000,bg=#ffff00'
|
||||
bind -T root F12 \
|
||||
set prefix None \;\
|
||||
set key-table off \;\
|
||||
if -F '#{pane_in_mode}' 'send-keys -X cancel' \;\
|
||||
set -g pane-active-border-style 'fg=#000000,bg=#00ff00'
|
||||
refresh-client -S \;\
|
||||
|
||||
bind -T off F12 \
|
||||
set -u prefix \;\
|
||||
set -u key-table \;\
|
||||
set -g pane-active-border-style 'fg=#000000,bg=#ffff00'
|
||||
refresh-client -S
|
||||
```
|
||||
|
||||
This code, added to the machine running the outermost tmux session, toggles the
|
||||
outermost prefix table on and off with the `F12` key. When off, the active
|
||||
pane's border changes to green to indicate that the inner session receives
|
||||
navigation keystrokes. When toggled back on, the border returns to yellow and
|
||||
normal operation resumes and the outermost responds to the nav keystrokes.
|
||||
|
||||
The code example above also toggles the prefix key (ctrl-b by default) for the
|
||||
outer session so that same prefix can be temporarily used on the inner session
|
||||
instead of having to use a different prefix (ctrl-a by default) which you may
|
||||
find convenient. If not, simply remove the lines that set/unset the prefix key
|
||||
from the code example above.
|
||||
|
||||
|
||||
Troubleshooting
|
||||
---------------
|
||||
|
||||
### Vim -> Tmux doesn't work!
|
||||
|
||||
This is likely due to conflicting key mappings in your `~/.vimrc`. You can use
|
||||
the following search pattern to find conflicting mappings
|
||||
`\v(nore)?map\s+\<c-[hjkl]\>`. Any matching lines should be deleted or
|
||||
altered to avoid conflicting with the mappings from the plugin.
|
||||
|
||||
Another option is that the pattern matching included in the `.tmux.conf` is
|
||||
not recognizing that Vim is active. To check that tmux is properly recognizing
|
||||
Vim, use the provided Vim command `:TmuxNavigatorProcessList`. The output of
|
||||
that command should be a list like:
|
||||
|
||||
```
|
||||
Ss -zsh
|
||||
S+ vim
|
||||
S+ tmux
|
||||
```
|
||||
|
||||
If you encounter a different output please [open an issue][] with as much info
|
||||
about your OS, Vim version, and tmux version as possible.
|
||||
|
||||
[open an issue]: https://github.com/christoomey/vim-tmux-navigator/issues/new
|
||||
|
||||
### Tmux Can't Tell if Vim Is Active
|
||||
|
||||
This functionality requires tmux version 1.8 or higher. You can check your
|
||||
version to confirm with this shell command:
|
||||
|
||||
``` bash
|
||||
tmux -V # should return 'tmux 1.8'
|
||||
```
|
||||
|
||||
### Switching out of Vim Is Slow
|
||||
|
||||
If you find that navigation within Vim (from split to split) is fine, but Vim
|
||||
to a non-Vim tmux pane is delayed, it might be due to a slow shell startup.
|
||||
Consider moving code from your shell's non-interactive rc file (e.g.,
|
||||
`~/.zshenv`) into the interactive startup file (e.g., `~/.zshrc`) as Vim only
|
||||
sources the non-interactive config.
|
||||
|
||||
### It doesn't work in Vim's `terminal` mode
|
||||
|
||||
Terminal mode is currently unsupported as adding this plugin's mappings there
|
||||
causes conflict with movement mappings for FZF (it also uses terminal mode).
|
||||
There's a conversation about this in https://github.com/christoomey/vim-tmux-navigator/pull/172
|
||||
|
||||
### It Doesn't Work in tmate
|
||||
|
||||
[tmate][] is a tmux fork that aids in setting up remote pair programming
|
||||
sessions. It is designed to run alongside tmux without issue, but occasionally
|
||||
there are hiccups. Specifically, if the versions of tmux and tmate don't match,
|
||||
you can have issues. See [this
|
||||
issue](https://github.com/christoomey/vim-tmux-navigator/issues/27) for more
|
||||
detail.
|
||||
|
||||
[tmate]: http://tmate.io/
|
||||
|
||||
### Switching between host panes doesn't work when docker is running
|
||||
|
||||
Images built from minimalist OSes may not have the `ps` command or have a
|
||||
simpler version of the command that is not compatible with this plugin.
|
||||
Try installing the `procps` package using the appropriate package manager
|
||||
command. For Alpine, you would do `apk add procps`.
|
||||
|
||||
If this doesn't solve your problem, you can also try the following:
|
||||
|
||||
Replace the `is_vim` variable in your `~/.tmux.conf` file with:
|
||||
```tmux
|
||||
if-shell '[ -f /.dockerenv ]' \
|
||||
"is_vim=\"ps -o state=,comm= -t '#{pane_tty}' \
|
||||
| grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|l?n?vim?x?)(diff)?$'\""
|
||||
# Filter out docker instances of nvim from the host system to prevent
|
||||
# host from thinking nvim is running in a pseudoterminal when its not.
|
||||
"is_vim=\"ps -o state=,comm=,cgroup= -t '#{pane_tty}' \
|
||||
| grep -ivE '^.+ +.+ +.+\\/docker\\/.+$' \
|
||||
| grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|l?n?vim?x?)(diff)? +'\""
|
||||
```
|
||||
|
||||
Details: The output of the ps command on the host system includes processes
|
||||
running within containers, but containers have their own instances of
|
||||
/dev/pts/\*. vim-tmux-navigator relies on /dev/pts/\* to determine if vim is
|
||||
running, so if vim is running in say /dev/pts/<N> in a container and there is a
|
||||
tmux pane (not running vim) in /dev/pts/<N> on the host system, then without
|
||||
the patch above vim-tmux-navigator will think vim is running when its not.
|
||||
|
||||
### It Still Doesn't Work!!!
|
||||
|
||||
The tmux configuration uses an inlined grep pattern match to help determine if
|
||||
the current pane is running Vim. If you run into any issues with the navigation
|
||||
not happening as expected, you can try using [Mislav's original external
|
||||
script][] which has a more robust check.
|
||||
|
||||
[Brian Hogan]: https://twitter.com/bphogan
|
||||
[Mislav's original external script]: https://github.com/mislav/dotfiles/blob/master/bin/tmux-vim-select-pane
|
||||
[Vundle]: https://github.com/gmarik/vundle
|
||||
[TPM]: https://github.com/tmux-plugins/tpm
|
||||
[configuration section below]: #custom-key-bindings
|
||||
[this blog post]: http://www.codeography.com/2013/06/19/navigating-vim-and-tmux-splits
|
||||
[this gist]: https://gist.github.com/mislav/5189704
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
*tmux-navigator.txt* Plugin to allow seamless navigation between tmux and vim
|
||||
|
||||
==============================================================================
|
||||
CONTENTS *tmux-navigator-contents*
|
||||
|
||||
|
||||
==============================================================================
|
||||
INTRODUCTION *tmux-navigator*
|
||||
|
||||
Vim-tmux-navigator is a little plugin which enables seamless navigation
|
||||
between tmux panes and vim splits. This plugin is a repackaging of Mislav
|
||||
Marohinc's tmux=navigator configuration. When combined with a set of tmux key
|
||||
bindings, the plugin will allow you to navigate seamlessly between vim and
|
||||
tmux splits using a consistent set of hotkeys.
|
||||
|
||||
NOTE: This requires tmux v1.8 or higher.
|
||||
|
||||
==============================================================================
|
||||
CONFIGURATION *tmux-navigator-configuration*
|
||||
|
||||
* Activate autoupdate on exit
|
||||
let g:tmux_navigator_save_on_switch = 1
|
||||
|
||||
* Disable vim->tmux navigation when the Vim pane is zoomed in tmux
|
||||
let g:tmux_navigator_disable_when_zoomed = 1
|
||||
|
||||
* If the Vim pane is zoomed, stay zoomed when moving to another tmux pane
|
||||
let g:tmux_navigator_preserve_zoom = 1
|
||||
|
||||
* Custom Key Bindings
|
||||
let g:tmux_navigator_no_mappings = 1
|
||||
|
||||
noremap <silent> {Left-mapping} :<C-U>TmuxNavigateLeft<cr>
|
||||
noremap <silent> {Down-Mapping} :<C-U>TmuxNavigateDown<cr>
|
||||
noremap <silent> {Up-Mapping} :<C-U>TmuxNavigateUp<cr>
|
||||
noremap <silent> {Right-Mapping} :<C-U>TmuxNavigateRight<cr>
|
||||
noremap <silent> {Previous-Mapping} :<C-U><C-U>TmuxNavigatePrevious<cr>
|
||||
|
||||
vim:tw=78:ts=8:ft=help:norl:
|
||||
42
tmux/.config/tmux/plugins/vim-tmux-navigator/pattern-check
Normal file
42
tmux/.config/tmux/plugins/vim-tmux-navigator/pattern-check
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
#!/usr/bin/env bash
|
||||
#
|
||||
# Collection of various test strings that could be the output of the tmux
|
||||
# 'pane_current_comamnd' message. Included as regression test for updates to
|
||||
# the inline grep pattern used in the `.tmux.conf` configuration
|
||||
|
||||
set -e
|
||||
|
||||
RED=$(tput setaf 1)
|
||||
GREEN=$(tput setaf 2)
|
||||
YELLOW=$(tput setaf 3)
|
||||
NORMAL=$(tput sgr0)
|
||||
|
||||
vim_pattern='(^|\/)g?(view|l?n?vim?x?|fzf)(diff)?$'
|
||||
match_tests=(vim Vim VIM vimdiff lvim /usr/local/bin/vim vi gvim view gview nvim vimx fzf)
|
||||
no_match_tests=( /Users/christoomey/.vim/thing /usr/local/bin/start-vim )
|
||||
|
||||
display_matches() {
|
||||
for process_name in "$@"; do
|
||||
printf "%s %s\n" "$(matches_vim_pattern $process_name)" "$process_name"
|
||||
done
|
||||
}
|
||||
|
||||
matches_vim_pattern() {
|
||||
if echo "$1" | grep -iqE "$vim_pattern"; then
|
||||
echo "${GREEN}match${NORMAL}"
|
||||
else
|
||||
echo "${RED}fail${NORMAL}"
|
||||
fi
|
||||
}
|
||||
|
||||
main() {
|
||||
echo "Testing against pattern: ${YELLOW}$vim_pattern${NORMAL}\n"
|
||||
|
||||
echo "These should all ${GREEN}match${NORMAL}\n----------------------"
|
||||
display_matches "${match_tests[@]}"
|
||||
|
||||
echo "\nThese should all ${RED}fail${NORMAL}\n---------------------"
|
||||
display_matches "${no_match_tests[@]}"
|
||||
}
|
||||
|
||||
main
|
||||
|
|
@ -0,0 +1,140 @@
|
|||
" Maps <C-h/j/k/l> to switch vim splits in the given direction. If there are
|
||||
" no more windows in that direction, forwards the operation to tmux.
|
||||
" Additionally, <C-\> toggles between last active vim splits/tmux panes.
|
||||
|
||||
if exists("g:loaded_tmux_navigator") || &cp || v:version < 700
|
||||
finish
|
||||
endif
|
||||
let g:loaded_tmux_navigator = 1
|
||||
|
||||
function! s:VimNavigate(direction)
|
||||
try
|
||||
execute 'wincmd ' . a:direction
|
||||
catch
|
||||
echohl ErrorMsg | echo 'E11: Invalid in command-line window; <CR> executes, CTRL-C quits: wincmd k' | echohl None
|
||||
endtry
|
||||
endfunction
|
||||
|
||||
if !get(g:, 'tmux_navigator_no_mappings', 0)
|
||||
noremap <silent> <c-h> :<C-U>TmuxNavigateLeft<cr>
|
||||
noremap <silent> <c-j> :<C-U>TmuxNavigateDown<cr>
|
||||
noremap <silent> <c-k> :<C-U>TmuxNavigateUp<cr>
|
||||
noremap <silent> <c-l> :<C-U>TmuxNavigateRight<cr>
|
||||
noremap <silent> <c-\> :<C-U>TmuxNavigatePrevious<cr>
|
||||
endif
|
||||
|
||||
if empty($TMUX)
|
||||
command! TmuxNavigateLeft call s:VimNavigate('h')
|
||||
command! TmuxNavigateDown call s:VimNavigate('j')
|
||||
command! TmuxNavigateUp call s:VimNavigate('k')
|
||||
command! TmuxNavigateRight call s:VimNavigate('l')
|
||||
command! TmuxNavigatePrevious call s:VimNavigate('p')
|
||||
finish
|
||||
endif
|
||||
|
||||
command! TmuxNavigateLeft call s:TmuxAwareNavigate('h')
|
||||
command! TmuxNavigateDown call s:TmuxAwareNavigate('j')
|
||||
command! TmuxNavigateUp call s:TmuxAwareNavigate('k')
|
||||
command! TmuxNavigateRight call s:TmuxAwareNavigate('l')
|
||||
command! TmuxNavigatePrevious call s:TmuxAwareNavigate('p')
|
||||
|
||||
if !exists("g:tmux_navigator_save_on_switch")
|
||||
let g:tmux_navigator_save_on_switch = 0
|
||||
endif
|
||||
|
||||
if !exists("g:tmux_navigator_disable_when_zoomed")
|
||||
let g:tmux_navigator_disable_when_zoomed = 0
|
||||
endif
|
||||
|
||||
if !exists("g:tmux_navigator_preserve_zoom")
|
||||
let g:tmux_navigator_preserve_zoom = 0
|
||||
endif
|
||||
|
||||
if !exists("g:tmux_navigator_no_wrap")
|
||||
let g:tmux_navigator_no_wrap = 0
|
||||
endif
|
||||
|
||||
let s:pane_position_from_direction = {'h': 'left', 'j': 'bottom', 'k': 'top', 'l': 'right'}
|
||||
|
||||
function! s:TmuxOrTmateExecutable()
|
||||
return (match($TMUX, 'tmate') != -1 ? 'tmate' : 'tmux')
|
||||
endfunction
|
||||
|
||||
function! s:TmuxVimPaneIsZoomed()
|
||||
return s:TmuxCommand("display-message -p '#{window_zoomed_flag}'") == 1
|
||||
endfunction
|
||||
|
||||
function! s:TmuxSocket()
|
||||
" The socket path is the first value in the comma-separated list of $TMUX.
|
||||
return split($TMUX, ',')[0]
|
||||
endfunction
|
||||
|
||||
function! s:TmuxCommand(args)
|
||||
let cmd = s:TmuxOrTmateExecutable() . ' -S ' . s:TmuxSocket() . ' ' . a:args
|
||||
let l:x=&shellcmdflag
|
||||
let &shellcmdflag='-c'
|
||||
let retval=system(cmd)
|
||||
let &shellcmdflag=l:x
|
||||
return retval
|
||||
endfunction
|
||||
|
||||
function! s:TmuxNavigatorProcessList()
|
||||
echo s:TmuxCommand("run-shell 'ps -o state= -o comm= -t ''''#{pane_tty}'''''")
|
||||
endfunction
|
||||
command! TmuxNavigatorProcessList call s:TmuxNavigatorProcessList()
|
||||
|
||||
let s:tmux_is_last_pane = 0
|
||||
augroup tmux_navigator
|
||||
au!
|
||||
autocmd WinEnter * let s:tmux_is_last_pane = 0
|
||||
augroup END
|
||||
|
||||
function! s:NeedsVitalityRedraw()
|
||||
return exists('g:loaded_vitality') && v:version < 704 && !has("patch481")
|
||||
endfunction
|
||||
|
||||
function! s:ShouldForwardNavigationBackToTmux(tmux_last_pane, at_tab_page_edge)
|
||||
if g:tmux_navigator_disable_when_zoomed && s:TmuxVimPaneIsZoomed()
|
||||
return 0
|
||||
endif
|
||||
return a:tmux_last_pane || a:at_tab_page_edge
|
||||
endfunction
|
||||
|
||||
function! s:TmuxAwareNavigate(direction)
|
||||
let nr = winnr()
|
||||
let tmux_last_pane = (a:direction == 'p' && s:tmux_is_last_pane)
|
||||
if !tmux_last_pane
|
||||
call s:VimNavigate(a:direction)
|
||||
endif
|
||||
let at_tab_page_edge = (nr == winnr())
|
||||
" Forward the switch panes command to tmux if:
|
||||
" a) we're toggling between the last tmux pane;
|
||||
" b) we tried switching windows in vim but it didn't have effect.
|
||||
if s:ShouldForwardNavigationBackToTmux(tmux_last_pane, at_tab_page_edge)
|
||||
if g:tmux_navigator_save_on_switch == 1
|
||||
try
|
||||
update " save the active buffer. See :help update
|
||||
catch /^Vim\%((\a\+)\)\=:E32/ " catches the no file name error
|
||||
endtry
|
||||
elseif g:tmux_navigator_save_on_switch == 2
|
||||
try
|
||||
wall " save all the buffers. See :help wall
|
||||
catch /^Vim\%((\a\+)\)\=:E141/ " catches the no file name error
|
||||
endtry
|
||||
endif
|
||||
let args = 'select-pane -t ' . shellescape($TMUX_PANE) . ' -' . tr(a:direction, 'phjkl', 'lLDUR')
|
||||
if g:tmux_navigator_preserve_zoom == 1
|
||||
let l:args .= ' -Z'
|
||||
endif
|
||||
if g:tmux_navigator_no_wrap == 1
|
||||
let args = 'if -F "#{pane_at_' . s:pane_position_from_direction[a:direction] . '}" "" "' . args . '"'
|
||||
endif
|
||||
silent call s:TmuxCommand(args)
|
||||
if s:NeedsVitalityRedraw()
|
||||
redraw!
|
||||
endif
|
||||
let s:tmux_is_last_pane = 1
|
||||
else
|
||||
let s:tmux_is_last_pane = 0
|
||||
endif
|
||||
endfunction
|
||||
25
tmux/.config/tmux/plugins/vim-tmux-navigator/vim-tmux-navigator.tmux
Executable file
25
tmux/.config/tmux/plugins/vim-tmux-navigator/vim-tmux-navigator.tmux
Executable file
|
|
@ -0,0 +1,25 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
version_pat='s/^tmux[^0-9]*([.0-9]+).*/\1/p'
|
||||
|
||||
is_vim="ps -o state= -o comm= -t '#{pane_tty}' \
|
||||
| grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|l?n?vim?x?|fzf)(diff)?$'"
|
||||
tmux bind-key -n C-h if-shell "$is_vim" "send-keys C-h" "select-pane -L"
|
||||
tmux bind-key -n C-j if-shell "$is_vim" "send-keys C-j" "select-pane -D"
|
||||
tmux bind-key -n C-k if-shell "$is_vim" "send-keys C-k" "select-pane -U"
|
||||
tmux bind-key -n C-l if-shell "$is_vim" "send-keys C-l" "select-pane -R"
|
||||
tmux_version="$(tmux -V | sed -En "$version_pat")"
|
||||
tmux setenv -g tmux_version "$tmux_version"
|
||||
|
||||
#echo "{'version' : '${tmux_version}', 'sed_pat' : '${version_pat}' }" > ~/.tmux_version.json
|
||||
|
||||
tmux if-shell -b '[ "$(echo "$tmux_version < 3.0" | bc)" = 1 ]' \
|
||||
"bind-key -n 'C-\\' if-shell \"$is_vim\" 'send-keys C-\\' 'select-pane -l'"
|
||||
tmux if-shell -b '[ "$(echo "$tmux_version >= 3.0" | bc)" = 1 ]' \
|
||||
"bind-key -n 'C-\\' if-shell \"$is_vim\" 'send-keys C-\\\\' 'select-pane -l'"
|
||||
|
||||
tmux bind-key -T copy-mode-vi C-h select-pane -L
|
||||
tmux bind-key -T copy-mode-vi C-j select-pane -D
|
||||
tmux bind-key -T copy-mode-vi C-k select-pane -U
|
||||
tmux bind-key -T copy-mode-vi C-l select-pane -R
|
||||
tmux bind-key -T copy-mode-vi C-\\ select-pane -l
|
||||
67
tmux/.config/tmux/tmux.conf
Normal file
67
tmux/.config/tmux/tmux.conf
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
set -g @plugin 'tmux-plugins/tpm'
|
||||
set -g @plugin 'tmux-plugins/tmux-sensible'
|
||||
set -g @plugin 'christoomey/vim-tmux-navigator'
|
||||
|
||||
set -g @plugin 'pschmitt/tmux-ssh-split'
|
||||
# Other examples:
|
||||
# set -g @plugin 'github_username/plugin_name'
|
||||
# set -g @plugin 'github_username/plugin_name#branch'
|
||||
# set -g @plugin 'git@github.com:user/plugin'
|
||||
# set -g @plugin 'git@bitbucket.com:user/plugin'
|
||||
#set -g @plugin "arcticicestudio/nord-tmux"
|
||||
#set -g default-terminal "st-256color"
|
||||
#set -g @plugin 'wfxr/tmux-power'
|
||||
#set -g @tmux_power_theme 'default'
|
||||
#set -g status-style fg=white,bg=black
|
||||
|
||||
# ----------------------
|
||||
# Status Bar
|
||||
# -----------------------
|
||||
set-option -g status on # turn the status bar on
|
||||
set -g status-interval 5 # set update frequencey (default 15 seconds)
|
||||
set -g status-justify centre # center window list for clarity
|
||||
# set-option -g status-position top # position the status bar at top of screen
|
||||
|
||||
# visual notification of activity in other windows
|
||||
|
||||
# set color for status bar
|
||||
#set-option -g status-bg color8 #base02
|
||||
set -g status-style bg=default
|
||||
set-option -g status-fg color3 #yellow
|
||||
|
||||
# set window list colors - red for active and cyan for inactive
|
||||
|
||||
# show host name and IP address on left side of status bar
|
||||
set -g status-left-length 85
|
||||
|
||||
# show session name, window & pane number, date and time on right side of
|
||||
# status bar
|
||||
set -g status-right-length 60
|
||||
set -g status-right "#[fg=blue]#S #I:#P #[fg=yellow]: %d %b %Y #[fg=green]: %l:%M %p : #(date -u | awk '{print $4}') :"
|
||||
set -g status-right "#[fg=blue]#(tmux-cpu --no-color)"
|
||||
|
||||
# mouse mode (commented lines for old versions of tmux)
|
||||
# setw -g mode-mouse on
|
||||
# set -g mouse-resize-pane on
|
||||
# set -g mouse-select-pane on
|
||||
# set -g mouse-select-window on
|
||||
# key bindings
|
||||
|
||||
# divider color
|
||||
set -g default-terminal "xterm-256color"
|
||||
|
||||
unbind r
|
||||
bind r source-file /home/moo/.config/tmux/tmux.conf
|
||||
|
||||
#act like vim
|
||||
setw -g mode-keys vi
|
||||
bind-key h select-pane -L
|
||||
bind-key j select-pane -D
|
||||
bind-key k select-pane -U
|
||||
bind-key l select-pane -R
|
||||
|
||||
bind-key -n C-S-Left swap-window -t -1
|
||||
bind-key -n C-S-Right swap-window -t +1
|
||||
|
||||
# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
|
||||
run '~/.config/tmux/plugins/tpm/tpm'
|
||||
Loading…
Add table
Add a link
Reference in a new issue