bin/split_man

22 lines
547 B
Plaintext
Raw Normal View History

2023-07-20 06:21:29 +02:00
#!/usr/bin/env bash
# Check if gum is available
if ! test -x "$(command -v gum)"; then
echo "Missing dependency: gum"
echo "See https://github.com/charmbracelet/gum"
exit 1
fi
CMD=$(gum input --placeholder="command")
if [[ -n "$BYOBU_BACKEND" && "$BYOBU_BACKEND" = "tmux" ]]; then
byobu-tmux split-window -h man "$CMD"
elif [[ -n "$TMUX" ]]; then
tmux split-window -h man "$CMD"
elif [[ -n "$ZELLIJ" ]]; then
zellij action new-pane -- man "$CMD"
else
echo "No byobu, tmux, or Zellij sessions detected"
exit 1
fi