Commit 18f6c720 authored by Dom Sekotill's avatar Dom Sekotill
Browse files

Fix tmux session starting & quiting

parent f8996c92
Loading
Loading
Loading
Loading

.tmux/child-instance.conf

deleted100644 → 0
+0 −4
Original line number Diff line number Diff line
# Start new session and switch to it
link-window -s General:0 -t 0

# vim:ft=tmux

.tmux/new-session.sh

deleted100755 → 0
+0 −9
Original line number Diff line number Diff line
#!/bin/sh
# set up a new session by sourcing child-instance.conf from a high-numbered 
# window (this allows window 0 to exit so that it can be replaced by 
# child-instance.conf)
case "$__NEW_SESSION_SOURCE__" in
	'') tmux new-window -t 99 "__NEW_SESSION_SOURCE__=yes '$0'" ;;
	yes) tmux source ~/.tmux/child-instance.conf ;;
esac
#exec ~/.tmux/motd-shell.sh
+2 −2
Original line number Diff line number Diff line
@@ -4,11 +4,11 @@ bind c new-window '~/.tmux/motd-shell.sh'

# "S": new session with prompt and child-instance.conf settings
unbind S
bind S command-prompt -p "Session name:" "new-session -ds '%%' ~/.tmux/new-session.sh"
bind S command-prompt -p "Session name:" "run-shell -b 'exec ~/.tmux/session.sh new %%'"

# "Q": quit session with confirmation
unbind Q
bind Q confirm-before kill-session
bind Q confirm-before -p "Kill session? (y/n)" "run-shell -b 'exec ~/.tmux/session.sh quit'"

# "A": rename current window
unbind A

.tmux/session.sh

0 → 100755
+24 −0
Original line number Diff line number Diff line
#!/bin/sh
set -eu

new_session()
{
	tmux new-session -ds "$1"
	tmux link-window -dk -s General:0 -t "$1":0
	tmux switch-client -t "$1"
}

quit_session()
{
	local session=`tmux list-clients -F '#{client_session}'`
	tmux switch-client -n
	tmux kill-session -t "$session"
}

action=$1
shift
case $action in
	new) new_session "$@" ;;
	quit) quit_session "$@" ;;
	*) exit 2 ;;
esac