From b32765b9c52ed07a1f0bac2b91c876ff84f32cd8 Mon Sep 17 00:00:00 2001 From: Ivan Malison Date: Mon, 27 Oct 2014 01:55:02 -0700 Subject: [PATCH] Run an instance of emacs per directory. --- dotfiles/lib/shellrc/aliases.sh | 3 --- dotfiles/lib/shellrc/emacs.sh | 12 ++++++++++++ 2 files changed, 12 insertions(+), 3 deletions(-) create mode 100644 dotfiles/lib/shellrc/emacs.sh diff --git a/dotfiles/lib/shellrc/aliases.sh b/dotfiles/lib/shellrc/aliases.sh index a48f7c67..98a1afa5 100644 --- a/dotfiles/lib/shellrc/aliases.sh +++ b/dotfiles/lib/shellrc/aliases.sh @@ -1,6 +1,3 @@ -alias emacs="emacsclient -c -n --server-filename=$(pwd)" -alias temacs="emacsclient -t" -alias cemacs="emacsclient -c -n" alias tmux="tmux -2" alias reload_tmux_conf="tmux source-file .tmux.conf" alias tmux_cb_to_remote_cb='tmux saveb - | linux_nc_paste_to_remote_clipboard' diff --git a/dotfiles/lib/shellrc/emacs.sh b/dotfiles/lib/shellrc/emacs.sh new file mode 100644 index 00000000..0eee1867 --- /dev/null +++ b/dotfiles/lib/shellrc/emacs.sh @@ -0,0 +1,12 @@ +alias emacs='_emacs -c' +alias cemacs'_emacs -c' +alias temacs'_emacs -t' + +function _emacs { + test -z "$(ps aux | grep -v grep | grep -i "\emacs -nw --daemon=.*`dotted_directory`")" && \emacs --daemon="$(dotted_directory)" + emacsclient $* -n --server-file="$(dotted_directory)" +} + +function dotted_directory { + pwd | sed "s:/:.:g" +}