diff --git a/README.md b/README.md index 0b1dafc..11126cc 100644 --- a/README.md +++ b/README.md @@ -26,6 +26,7 @@ cargo install ctrlg ### With Installer Script Do not run as root or with `sudo`, the script will ask for `sudo` if needed. + ```sh bash -c 'bash <(curl --proto "=https" --tlsv1.2 -sSf https://raw.githubusercontent.com/mrjones2014/ctrlg/master/install.bash)' ``` @@ -79,6 +80,10 @@ appear in a `tmux` floating window, and specify the window size, with `$CTRLG_TM `$CTRLG_TMUX_POPUP_ARGS`, respectively. `$CTRLG_TMUX_POPUP_ARGS` can be any window positioning or sizing arguments accepted by `tmux popup`. `$CTRLG_TMUX_POPUP_ARGS` defaults to `-w 75% -h 75%`. +You can also define a hook function to send the `cd` command to additional `tmux` panes not in the +current window. The function must return a list of `tmux` pane IDs. The hook function is +`_ctrlg_get_related_panes`. + ### Fish ```fish diff --git a/src/commands/shell/ctrlg.bash b/src/commands/shell/ctrlg.bash index b1b88fc..5463a2b 100644 --- a/src/commands/shell/ctrlg.bash +++ b/src/commands/shell/ctrlg.bash @@ -16,6 +16,12 @@ function _ctrlg_tmux_send_all_panes { tmux send-keys -t "$pane" " $1" Enter fi done + + if [[ $(type -t _ctrlg_get_related_panes) == function ]]; then + for pane in $(_ctrlg_get_related_panes); do + tmux send-keys -t "$pane" " $1" Enter + done + fi fi } diff --git a/src/commands/shell/ctrlg.fish b/src/commands/shell/ctrlg.fish index aae7aa3..da3f5e6 100644 --- a/src/commands/shell/ctrlg.fish +++ b/src/commands/shell/ctrlg.fish @@ -13,6 +13,11 @@ function _ctrlg_tmux_send_all_panes tmux send-keys -t "$pane" " $argv" Enter end end + if type _ctrlg_get_related_panes >/dev/null + for pane in (_ctrlg_get_related_panes || "") + tmux send-keys -t "$pane" " $argv" Enter + end + end end end diff --git a/src/commands/shell/ctrlg.zsh b/src/commands/shell/ctrlg.zsh index 1bf3552..3171cdd 100644 --- a/src/commands/shell/ctrlg.zsh +++ b/src/commands/shell/ctrlg.zsh @@ -15,6 +15,11 @@ function _ctrlg_tmux_send_all_panes() { tmux send-keys -t "$pane" " $1" Enter fi done + if [[ $(type -t _ctrlg_get_related_panes) == function ]]; then + for pane in $(_ctrlg_get_related_panes); do + tmux send-keys -t "$pane" " $1" Enter + done + fi fi }