From 9903090ebf6e1f16e4dba62ae15a7127a82fcae7 Mon Sep 17 00:00:00 2001 From: Ross Patterson Date: Sat, 15 Jul 2023 13:35:47 -0700 Subject: [PATCH] feat(tpm): Convert to a TPM plugin --- README.md | 15 ++++++++++++++- active-row.conf | 14 +++++++------- nested.tmux | 4 ++++ 3 files changed, 25 insertions(+), 8 deletions(-) create mode 100755 nested.tmux diff --git a/README.md b/README.md index 41d8b3b..761d152 100644 --- a/README.md +++ b/README.md @@ -8,12 +8,25 @@ This is a simple tmux configuration enabling to have arbitrarily many nested tmu # Quick start +The easiest and recommended way to install is as a [TPM +plugin](https://github.com/tmux-plugins/tpm#installation). Add this line to your +`~/.tmux.conf`: + +```tmux +set -g @plugin 'aleclearmind/nested-tmux' +``` + +Hit prefix + I to fetch the plugin and source it. + +Alternatively, install and use directly without TPM: + ``` mkdir ~/.tmux.conf.d/ cd ~/.tmux.conf.d/ git clone https://github.com/aleclearmind/nested-tmux.git mv ~/.tmux.conf ~/.tmux.conf.backup -echo "source ~/.tmux.conf.d/nested-tmux/active-row.conf" > ~/.tmux.conf +echo 'TPM_PLUGIN_DIR="~/.tmux.conf.d/nested-tmux"' > ~/.tmux.conf +echo 'source "$TPM_PLUGIN_DIR/active-row.conf"' >> ~/.tmux.conf tmux ``` diff --git a/active-row.conf b/active-row.conf index ac89b0c..1121cd4 100644 --- a/active-row.conf +++ b/active-row.conf @@ -28,7 +28,7 @@ set -g prefix C-a bind C-c new-window # Create a new nested tmux (Ctrl + A, Ctrl + s) -bind C-s new-window ~/.tmux.conf.d/nested-tmux/new-tmux \; \ +bind C-s new-window "$TPM_PLUGIN_DIR/new-tmux" \; \ rename-window '' \; \ command-prompt -I "#W" "rename-window -- '%%'" @@ -59,17 +59,17 @@ bind -n C-t new-window bind -n M-up send-keys M-F12 # Switch to outer tmux (Alt + Down) -bind -n M-down source-file ~/.tmux.conf.d/nested-tmux/inactive-row.conf \; \ - run-shell 'tmux -L $TMUX_PARENT source-file ~/.tmux.conf.d/nested-tmux/active-row.conf' \; \ +bind -n M-down source-file "$TPM_PLUGIN_DIR/inactive-row.conf" \; \ + run-shell 'tmux -L $TMUX_PARENT source-file "$TPM_PLUGIN_DIR/active-row.conf"' \; \ run-shell 'tmux -L $TMUX_PARENT set -g window-status-current-style bg=$active_window_bg' # Handler for becoming active (Alt + F12, don't use directly) -bind -n M-F12 run-shell 'tmux -L $TMUX_PARENT source-file ~/.tmux.conf.d/nested-tmux/inactive-row.conf' \; \ - source-file ~/.tmux.conf.d/nested-tmux/active-row.conf \; \ +bind -n M-F12 run-shell 'tmux -L $TMUX_PARENT source-file "$TPM_PLUGIN_DIR/inactive-row.conf"' \; \ + source-file "$TPM_PLUGIN_DIR/active-row.conf" \; \ set -g window-status-current-style bg=$active_window_bg # Handler for closed window: enable outer terminal -set-hook -g client-detached "run-shell 'tmux -L $TMUX_PARENT source-file ~/.tmux.conf.d/nested-tmux/active-row.conf && tmux -L $TMUX_PARENT set -g window-status-current-style bg=$active_window_bg'" +set-hook -g client-detached "run-shell 'tmux -L $TMUX_PARENT source-file $TPM_PLUGIN_DIR/active-row.conf && tmux -L $TMUX_PARENT set -g window-status-current-style bg=$active_window_bg'" # # Appearance @@ -84,4 +84,4 @@ setw -g window-status-current-style bg=$active_window_bg if-shell 'test -z "$TMUX_PARENT"' 'bind -n M-down send-keys ""' '' # When a new session is created unbind the parent -if-shell 'test -z "$TMUX_PARENT"' '' 'run-shell "tmux -L $TMUX_PARENT source-file ~/.tmux.conf.d/nested-tmux/inactive-row.conf"' +if-shell 'test -z "$TMUX_PARENT"' '' 'run-shell "tmux -L $TMUX_PARENT source-file $TPM_PLUGIN_DIR/inactive-row.conf"' diff --git a/nested.tmux b/nested.tmux new file mode 100755 index 0000000..9ed2d6d --- /dev/null +++ b/nested.tmux @@ -0,0 +1,4 @@ +#!/usr/bin/env bash + +export TPM_PLUGIN_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +tmux source-file "${TPM_PLUGIN_DIR}/active-row.conf"