Skip to content

Instantly share code, notes, and snippets.

@ssh0
Last active June 29, 2016 09:48
Show Gist options
  • Save ssh0/34738ab37b6b64f28cba to your computer and use it in GitHub Desktop.
Save ssh0/34738ab37b6b64f28cba to your computer and use it in GitHub Desktop.
[tmux] 端末起動時に自動で新規セッションを作成 or 既存セッションにアタッチ ref: http://qiita.com/ssh0/items/a9956a74bff8254a606a
if [[ ! -n $TMUX && $- == *l* ]]; then
# get the IDs
ID="`tmux list-sessions`"
if [[ -z "$ID" ]]; then
tmux new-session
fi
create_new_session="Create New Session"
ID="$ID\n${create_new_session}:"
ID="`echo $ID | $PERCOL | cut -d: -f1`"
if [[ "$ID" = "${create_new_session}" ]]; then
tmux new-session
elif [[ -n "$ID" ]]; then
tmux attach-session -t "$ID"
else
: # Start terminal normally
fi
fi
main: 3 windows (created Wed Jan 27 11:49:33 2016) [88x34] (attached)
1: 1 windows (created Wed Jan 27 17:59:17 2016) [213x54]
$ echo $-
569XZghiklms
$ echo $-
569XZghikms
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment