Skip to content

Instantly share code, notes, and snippets.

@darthsuogles
Created March 11, 2018 16:35
Show Gist options
  • Select an option

  • Save darthsuogles/d4bb6c46c840c225e478a7836a2d55b1 to your computer and use it in GitHub Desktop.

Select an option

Save darthsuogles/d4bb6c46c840c225e478a7836a2d55b1 to your computer and use it in GitHub Desktop.
SSH tmux session with emacs
#!/bin/bash
set -eux
function help {
echo "Please source this script instread of running it"
}
# https://www.emacswiki.org/emacs/EmacsdInitScript
function init_emacs {
export ALTERNATE_EDITOR=""
emacs --daemon='dev'
alias emacs='emacsclient -s dev'
}
function init_tmux {
tmux new -d -s 'dev'
}
# Check if we already have a running emacs daemon
daemon_pid="$(ps aux | grep -v grep | grep -Ei 'emacs --daemon' | awk '{print $2}')"
[[ -n "${daemon_pid}" ]] || init_emacs
tmux ls || init_tmux
# Connect to the launched session
tmux -2CC at -t 'dev'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment