more helpers for git and tmux flow
This commit is contained in:
parent
cc79b2a6b2
commit
8ae9c6ecda
6 changed files with 123 additions and 18 deletions
34
common/general/shell/tmux_helpers.sh
Normal file
34
common/general/shell/tmux_helpers.sh
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
tmux_window () {
|
||||
cmd=${1:-}
|
||||
case "${cmd}" in
|
||||
rename)
|
||||
if [ -z "${2:-}" ]; then
|
||||
tmux setw automatic-rename
|
||||
else
|
||||
tmux rename-window "$2"
|
||||
fi
|
||||
;;
|
||||
get)
|
||||
printf '%s' "$(tmux display-message -p '#W')"
|
||||
;;
|
||||
status)
|
||||
out="$(tmux show-window-options automatic-rename 2>/dev/null || true)"
|
||||
if printf '%s' "$out" | grep -q 'automatic-rename on'; then
|
||||
printf 'auto'
|
||||
elif printf '%s' "$out" | grep -q 'automatic-rename off'; then
|
||||
printf 'manual'
|
||||
else
|
||||
# If tmux returns nothing (option not set), default to auto
|
||||
if [ -z "$out" ]; then
|
||||
printf 'auto'
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
printf 'Usage: tmux_window {rename [NAME]|get|status}\n' >&2
|
||||
return 2
|
||||
;;
|
||||
esac
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue