From 4cac4e8b64f52a05837f1f40af9fba355370d5ee Mon Sep 17 00:00:00 2001 From: Alan Pearce Date: Tue, 8 Oct 2013 17:07:23 +0100 Subject: Add ec and et commands to launch emacsclient in a terminal and GUI respectively --- zsh/zshrc | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'zsh/zshrc') diff --git a/zsh/zshrc b/zsh/zshrc index 672ed7c..6fd0362 100755 --- a/zsh/zshrc +++ b/zsh/zshrc @@ -310,6 +310,8 @@ alias wprop='xprop |awk '\'' /^WM_NAME/{sub(/.* =/, "title:"); print} /^WM_WINDOW_ROLE/{sub(/.* =/, "role:"); print}'\''' +alias et="emacsclient -t" + alias -g ...='../..' #Suffix aliases @@ -374,6 +376,28 @@ smart_compile () { fi } +emacs_change_focus () { + emacsclient -n -e "(select-frame-set-input-focus (selected-frame))" > /dev/null +} + +ec () { + local visibleFrames + visibleFrames=`emacsclient -e '(length (visible-frame-list))'` + if [[ $? -ne 0 ]]; then + print "Daemon not running" + return 1 + fi + + if [[ $visibleFrames -eq 1 ]]; then + emacsclient -n -c "$@" && emacs_change_focus + else + emacs_change_focus + if [[ $# -gt 0 ]]; then + emacsclient -n "$@" + fi + fi +} + _FASD_DATA="$HOME/.zsh/fasd-data" autoload -U fasd source ~/.zsh/cache/fasd-init-zsh -- cgit 1.4.1