Skip to content

Instantly share code, notes, and snippets.

@a3f
Last active July 11, 2023 13:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save a3f/52781ef85c6920ef8e27e1a9f7b6277a to your computer and use it in GitHub Desktop.
Save a3f/52781ef85c6920ef8e27e1a9f7b6277a to your computer and use it in GitHub Desktop.
#!/bin/bash
add=1
while getopts "dur" o; do
case "${o}" in
d|u|r)
add=0
;;
*)
echo "Usage: $0 [-dur] [USER]" 1>&2;
exit 1;
;;
esac
done
shift $((OPTIND-1))
user=$1
chown -R $USER:ptxdevel /tmp/tmux-$UID/
chown -R $USER:ptxdevel /tmp/tmux-$UID/default
if [ $add -eq 0 ]; then
if [ -n "$user" ]; then
tmux server-access -d "$user";
fi
chmod -R -070 /tmp/tmux-$UID/
else
if [ -n "$user" ]; then
tmux server-access -a "$user";
fi
chmod -R +070 /tmp/tmux-$UID/
echo "ssh -tt $HOSTNAME -- tmux -S /tmp/tmux-$UID/default attach"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment