27 lines
682 B
Bash
Raw Normal View History

alias emacs='cemacs'
alias cemacs='_emacs -c -n'
alias temacs='_emacs -t'
alias ec='_emacs -n '
function _emacs {
2014-10-28 02:48:51 -07:00
local server_name="$(_current_dot_directory)"
2014-10-27 13:28:27 +00:00
if ! _emacs_daemon_exists "$server_name"; then
echo "Starting emacs with server name '$server_name'"
\emacs --daemon="$server_name"
fi
emacsclient $* --server-file=$server_name
}
2014-10-27 13:28:27 +00:00
function _emacs_daemon_exists {
! test -z "$(ps aux | grep -v grep | grep -i "emacs.*--daemon=.*$1$")"
}
function _dot_directory {
echo $1 | sed "s:/:.:g"
}
2014-10-28 02:48:51 -07:00
function _current_dot_directory {
local directory="$(git rev-parse --show-toplevel 2> /dev/null || pwd)"
_dot_directory $directory
}