Created
June 7, 2010 17:25
-
-
Save iki/428944 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
N="${1:-projectx}" | |
I="${2:-0}" | |
echo "=== Opening terminal multiplexer server [$N] session [$I]" | |
G="tmux-$N" # group name | |
D="/var/lib/tmux/sockets/$N" | |
S="$D/.shared" | |
DP=2770 # set group id = any created file will have the same group as the directory | |
SP=660 | |
[ -d "$D" ] || { sudo mkdir -p "$D" && sudo chmod "$DP" "$D" && sudo chown "root:$G" "$D" || exit $?; } | |
if [ ! -e "$S" ] || ! tmux -S "$S" has-session -t "$I"; then | |
tmux -S "$S" new-session -d -s "$I" && chmod "$SP" "$S" && sudo chown root "$S" || exit $? | |
# change owner to root, so tmux can't shrink permissions to 600 later | |
fi | |
# P=$D/$USER" | |
# run ln -fT "$S" "$P" # use hardlinked private socket, because tmux will reset its permissions to 600 | |
# (does not help actually, all hardlinks have the same permissions) | |
# http://comments.gmane.org/gmane.comp.terminal-emulators.tmux.user/557 | |
tmux -S "$S" attach-session -t "$I" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment