Skip to content
This repository has been archived by the owner on Apr 6, 2023. It is now read-only.

Commit

Permalink
Merge pull request #84 from mrjones2014/matjones/83-extra-windows-hook
Browse files Browse the repository at this point in the history
add hook to send cd command to additional panes
  • Loading branch information
mrjones2014 authored Mar 29, 2022
2 parents 09136df + 3758235 commit 5d5a14c
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 0 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)'
```
Expand Down Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions src/commands/shell/ctrlg.bash
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
5 changes: 5 additions & 0 deletions src/commands/shell/ctrlg.fish
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
5 changes: 5 additions & 0 deletions src/commands/shell/ctrlg.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down

0 comments on commit 5d5a14c

Please sign in to comment.