1
0
Fork 0
mirror of synced 2024-11-17 15:05:35 -05:00

added support for tpm, resolves #61

This commit is contained in:
Gregory Pakosz 2020-10-10 18:56:13 +02:00
parent 2aaacfbd8f
commit d950ee3c8c
4 changed files with 118 additions and 16 deletions

1
.gitignore vendored Normal file
View file

@ -0,0 +1 @@
plugins/**

View file

@ -162,13 +162,12 @@ bind P choose-buffer # choose which buffer to paste from
# -- user defined overrides ----------------------------------------------------
if '[ -f ~/.tmux.conf.local ]' 'source ~/.tmux.conf.local'
source -q ~/.tmux.conf.local
# -- 8< ------------------------------------------------------------------------
run 'cut -c3- ~/.tmux.conf | sh -s _apply_configuration'
run -b '[ -z "#{window_active}" ] && [ -z "#{version}" ] && tmux set display-time 3000 \; display "This configuration will soon require tmux >= 2.4" \; set -u display-time || true'
# EOF
@ -1332,19 +1331,72 @@ run -b '[ -z "#{window_active}" ] && [ -z "#{version}" ] && tmux set display-tim
# setw -g clock-mode-style "$tmux_conf_theme_clock_style"
# }
#
# __apply_plugins() {
# window_active="$1"
# tmux_conf_update_plugins_on_launch="$2"
# tmux_conf_update_plugins_on_reload="$3"
#
# TMUX_PLUGIN_MANAGER_PATH=${TMUX_PLUGIN_MANAGER_PATH:-~/.tmux/plugins}
# if [ ! -d "$TMUX_PLUGIN_MANAGER_PATH/tpm" ]; then
# install_tpm=true
# tmux display 'Installing tpm and plugins...'
# git clone --depth 1 https://github.com/tmux-plugins/tpm "$TMUX_PLUGIN_MANAGER_PATH/tpm"
# elif { [ -z "$window_active" ] && _is_enabled "$tmux_conf_update_plugins_on_launch"; } || { [ -n "$window_active" ] && _is_enabled "$tmux_conf_update_plugins_on_reload"; }; then
# update_tpm=true
# tmux display 'Updating tpm and plugins...'
# (cd "$TMUX_PLUGIN_MANAGER_PATH/tpm" && git checkout -q master && git reset -q --hard HEAD && git pull -q origin master)
# fi
# if [ x"$install_tpm" = x"true" ] || [ x"$update_tpm" = x"true" ]; then
# perl -0777 -p -i -e 's/git clone --recursive/git clone --recursive --depth 1 --shallow-submodules/g
# ;s/(install_plugin "\$plugin")\n(\s+)done/\1&\n\2done\n\2wait/g' "$TMUX_PLUGIN_MANAGER_PATH/tpm/scripts/install_plugins.sh"
# perl -p -i -e 's/git submodule update --init --recursive/git submodule update --init --recursive --depth 1/g' "$TMUX_PLUGIN_MANAGER_PATH/tpm/scripts/update_plugin.sh"
# tmux set-environment -g TMUX_PLUGIN_MANAGER_PATH "$TMUX_PLUGIN_MANAGER_PATH"
# fi
# if [ x"$update_tpm" = x"true" ]; then
# "$TMUX_PLUGIN_MANAGER_PATH/tpm/bin/update_plugins" all >/dev/null 2>&1
# tmux display 'Done updating tpm and plugins...'
# elif [ x"$install_tpm" = x"true" ]; then
# "$TMUX_PLUGIN_MANAGER_PATH/tpm/bin/install_plugins" >/dev/null 2>&1
# tmux display 'Done installing tpm and plugins...'
# fi
# "$TMUX_PLUGIN_MANAGER_PATH/tpm/tpm"
# if [ -z "$window_active" ] && [ $_tmux_version -lt 204 ]; then
# tmux run -b "sleep $(expr $(tmux display -p '#{display-time}') / 500) && tmux set display-time 3000 \; display 'This configuration will soon require tmux 2.4+' \; set -u display-time"
# fi
# }
#
# _apply_plugins() {
# tmux_conf_update_plugins_on_launch=${tmux_conf_update_plugins_on_launch:-true}
# tmux_conf_update_plugins_on_reload=${tmux_conf_update_plugins_on_reload:-true}
# if [ -n "$(tmux show -gv '@plugin')" ] || [ -n "$(tmux show -gv '@tpm_plugins')" ]; then
# tmux run -b "cut -c3- ~/.tmux.conf | sh -s __apply_plugins \"$window_active\" \"$tmux_conf_update_plugins_on_launch\" \"$tmux_conf_update_plugins_on_reload\""
# elif [ -z "$window_active" ]; then
# if [ $_tmux_version -lt 204 ]; then
# tmux run -b 'tmux set display-time 3000 \; display "This configuration will soon require tmux 2.4+" \; set -u display-time'
# fi
# fi
# }
#
# _apply_configuration() {
#
# if ! command -v perl > /dev/null 2>&1; then
# tmux run -b 'tmux set display-time 3000 \; display "This configuration requires perl" \; set -u display-time'
# return
# fi
# if ! command -v sed > /dev/null 2>&1; then
# tmux run -b 'tmux set display-time 3000 \; display "This configuration requires sed" \; set -u display-time'
# return
# fi
# if ! command -v awk > /dev/null 2>&1; then
# tmux run -b 'tmux set display-time 3000 \; display "This configuration requires awk" \; set -u display-time'
# return
# window_active="$(tmux display -p '#{window_active}' 2>/dev/null || true)"
# if [ -z "$window_active" ]; then
# if ! command -v perl > /dev/null 2>&1; then
# tmux run -b 'tmux set display-time 3000 \; display "This configuration requires perl" \; set -u display-time \; run "sleep 3" \; kill-server'
# return
# fi
# if ! command -v sed > /dev/null 2>&1; then
# tmux run -b 'tmux set display-time 3000 \; display "This configuration requires sed" \; set -u display-time \; run "sleep 3" \; kill-server'
# return
# fi
# if ! command -v awk > /dev/null 2>&1; then
# tmux run -b 'tmux set display-time 3000 \; display "This configuration requires awk" \; set -u display-time \; run "sleep 3" \; kill-server'
# return
# fi
# if [ $_tmux_version -lt 203 ]; then
# tmux run -b 'tmux set display-time 3000 \; display "This configuration requires tmux 2.3+" \; set -u display-time \; run "sleep 3" \; kill-server'
# return
# fi
# fi
#
# # see https://github.com/ChrisJohnsen/tmux-MacOSX-pasteboard
@ -1374,6 +1426,8 @@ run -b '[ -z "#{window_active}" ] && [ -z "#{version}" ] && tmux set display-tim
# # shellcheck disable=SC2046
# tmux setenv -gu tmux_conf_dummy $(printenv | grep -E -o '^tmux_conf_[^=]+' | awk '{printf "; setenv -gu %s", $0}')
# wait
#
# _apply_plugins
# }
#
# _urlview() {

View file

@ -347,8 +347,39 @@ tmux_conf_copy_to_os_clipboard=false
# 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
# /!\ 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

View file

@ -10,7 +10,7 @@ Installation
Requirements:
- tmux **`>= 2.1`** (soon `>= 2.4`) running inside Linux, Mac, OpenBSD, Cygwin
- 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`
@ -109,12 +109,12 @@ Features
if available
- laptop battery status line information
- uptime status line information
- optional highlight of focused pane (tmux `>= 2.1`)
- 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 (requires `perl` or Bash >= 4.1.2)
- support for 4-digit hexadecimal Unicode characters
- [Facebook PathPicker][] integration if available
- [Urlview][] integration if available
@ -299,6 +299,22 @@ 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
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`