summary refs log tree commit diff stats
path: root/zsh/zshrc
diff options
context:
space:
mode:
Diffstat (limited to 'zsh/zshrc')
-rwxr-xr-xzsh/zshrc24
1 files changed, 24 insertions, 0 deletions
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