summaryrefslogtreecommitdiff
path: root/plugins/zsh-navigation-tools/doc/znt-tmux.zsh
diff options
context:
space:
mode:
authorPhilipp Schmitt <pschmitt@users.noreply.github.com>2021-12-24 18:09:01 +0100
committerGitHub <noreply@github.com>2021-12-24 18:09:01 +0100
commit068feca15d09dce6747d0fb6cab2027b938e82bd (patch)
treef3603a06b14c7d51ea59bf745d811319207c7e17 /plugins/zsh-navigation-tools/doc/znt-tmux.zsh
parent4f90849425b4f40778e2fdb5281a1bae4117a7c2 (diff)
downloadzsh-068feca15d09dce6747d0fb6cab2027b938e82bd.tar.gz
zsh-068feca15d09dce6747d0fb6cab2027b938e82bd.tar.bz2
zsh-068feca15d09dce6747d0fb6cab2027b938e82bd.zip
feat(zsh-navigation-tools)!: update to zdharma-continuum fork (#10402)
BREAKING CHANGE: the `zsh-navigation-tools` plugin now bundles the version from the zdharma-continuum project, which republished the projects that psprint deleted (we don't yet know yet why). In theory this change doesn't break anything, but be aware of the change and that the upstream repository now lives somewhere else. Source: https://github.com/zdharma-continuum/zsh-navigation-tools/commit/67b24e1
Diffstat (limited to 'plugins/zsh-navigation-tools/doc/znt-tmux.zsh')
-rwxr-xr-xplugins/zsh-navigation-tools/doc/znt-tmux.zsh50
1 files changed, 50 insertions, 0 deletions
diff --git a/plugins/zsh-navigation-tools/doc/znt-tmux.zsh b/plugins/zsh-navigation-tools/doc/znt-tmux.zsh
new file mode 100755
index 000000000..309c11a0b
--- /dev/null
+++ b/plugins/zsh-navigation-tools/doc/znt-tmux.zsh
@@ -0,0 +1,50 @@
+#!/usr/bin/env zsh
+
+# Copyright (c) 2016, Zsolt Lengyel
+# Modifications copyright (c) 2016, Sebastian Gniazdowski
+
+#
+# This script opens a new, temporary tmux pane and runs n-history. When
+# a selection is made, the result (history entry) is pasted back into
+# original tmux pane, and the temporary pane is closed. This allows to
+# use local history on remote machines.
+#
+# To use, put this line to your ~/.tmux.conf. The tool is invoked with:
+# Ctrl+b h
+#
+# bind h run-shell -b "$ZNT_REPO_DIR/doc/znt-tmux.zsh"
+#
+
+# get and save the current active tmux pane id
+active_pane=$(tmux display -p -F ':#{session_id}:#I:#P:#{pane_active}:#{window_active}:#{session_attached}' )
+a_active_pane=("${(@s/:/)active_pane}")
+
+active_session=${a_active_pane[2]//$}
+active_window=$a_active_pane[3]
+active_pane=$a_active_pane[4]
+
+# set variables for upcoming window
+tmux setenv -t $active_session:$active_window.$active_pane "ZNT_TMUX_MODE" 1
+tmux setenv -t $active_session:$active_window.$active_pane "ZNT_TMUX_ORIGIN_SESSION" "$active_session"
+tmux setenv -t $active_session:$active_window.$active_pane "ZNT_TMUX_ORIGIN_WINDOW" "$active_window"
+tmux setenv -t $active_session:$active_window.$active_pane "ZNT_TMUX_ORIGIN_PANE" "$active_pane"
+
+# create a new window in the active session and call it znt-hist
+tmux new-window -t $active_session: -n znt-hist
+
+# unset the variables, so only above single window has them
+tmux setenv -u -t $active_session:$active_window.$active_pane "ZNT_TMUX_MODE"
+tmux setenv -u -t $active_session:$active_window.$active_pane "ZNT_TMUX_ORIGIN_SESSION"
+tmux setenv -u -t $active_session:$active_window.$active_pane "ZNT_TMUX_ORIGIN_WINDOW"
+tmux setenv -u -t $active_session:$active_window.$active_pane "ZNT_TMUX_ORIGIN_PANE"
+
+# znt's session id
+znt_active_pane=$(tmux display -p -F ':#{session_id}:#I:#P:#{pane_active}:#{window_active}:#{session_attached}' )
+znt_a_active_pane=("${(@s/:/)znt_active_pane}")
+
+znt_active_session=${znt_a_active_pane[2]//$}
+znt_active_window=$znt_a_active_pane[3]
+znt_active_pane=$znt_a_active_pane[4]
+
+# call znt
+tmux send -t "$znt_active_session:$znt_active_window.$znt_active_pane" n-history ENTER