Skip to content

Instantly share code, notes, and snippets.

@joech4n
Last active December 24, 2021 02:19
Show Gist options
  • Save joech4n/a5b9a0e717a8f0fea48054a3781ddefe to your computer and use it in GitHub Desktop.
Save joech4n/a5b9a0e717a8f0fea48054a3781ddefe to your computer and use it in GitHub Desktop.
Dungeon Crawl Stone Soup (DCSS) Auto-Login tmux Script
#!/usr/bin/env bash
source ~/.crawl.secret # Get $USERNAME and $PASSWORD
# Example
# $ cat .crawl.secret
# USERNAME=myusername
# PASSWORD=mypassword
# name of tmux session
export SESSION="crawl"
# if session already running, attach it.
tmux has-session -t $SESSION 2> /dev/null
if [ $? -eq 0 ]; then
echo "Session $SESSION already exists. Attaching."
else
# else create it, and detach it to work on it a bit
tmux new-session -d -s $SESSION
tmux new-window -t $SESSION:1 -k -n "crawl" "$SHELL"
fi
# if not already connected, connect and login
if ! netstat -at |grep crawl.akrasiac.org |grep ESTABLISHED ; then
tmux send-keys -t $SESSION:1 "ssh -i ~/.ssh/id_rsa.cao [email protected]" Enter
sleep 1
tmux send-keys -t $SESSION:1 "l"
sleep 1
tmux send-keys -t $SESSION:1 "$USERNAME" Enter
sleep 1
tmux send-keys -t $SESSION:1 "$PASSWORD" Enter
tmux send-keys -t $SESSION:1 "p"
fi
tmux select-window -t $SESSION:1
tmux attach -dt $SESSION
#!/usr/bin/env bash
source ~/.nethack.secret # Get $USERNAME and $PASSWORD
# Example
# $ cat .crawl.secret
# USERNAME=myusername
# PASSWORD=mypassword
# name of tmux session
export SESSION="nethack"
# if session already running, attach it.
tmux has-session -t $SESSION 2> /dev/null
if [ $? -eq 0 ]; then
echo "Session $SESSION already exists. Attaching."
else
# else create it, and detach it to work on it a bit
tmux new-session -d -s $SESSION
tmux new-window -t $SESSION:1 -k -n "crawl" "$SHELL"
fi
# if not already connected, connect and login
if ! netstat -at |grep alt.org |grep ESTABLISHED ; then
tmux send-keys -t $SESSION:1 "ssh [email protected]" Enter
sleep 1
tmux send-keys -t $SESSION:1 "l"
sleep 1
tmux send-keys -t $SESSION:1 "$USERNAME" Enter
sleep 1
tmux send-keys -t $SESSION:1 "$PASSWORD" Enter
tmux send-keys -t $SESSION:1 "1"
tmux send-keys -t $SESSION:1 "p"
fi
tmux select-window -t $SESSION:1
tmux attach -dt $SESSION
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment