make zsh clipboard system-wide, improve emacs_open (add focus on startup)

This commit is contained in:
Ivan Malison 2014-11-18 16:41:30 -08:00
parent 0c40ac63fa
commit e8bbb6964a
4 changed files with 64 additions and 10 deletions

@ -1 +1 @@
Subproject commit f0067856bffe9ae3255e842c637e675330a68acf Subproject commit 4c68b4f2ae2ca0ff178fceeda0ea0dc340c218a3

View File

@ -1,12 +1,12 @@
alias e='emacs_open'
alias emacs='_emacs -c -n ' alias emacs='_emacs -c -n '
is_osx && alias emacs='cocoa_emacs' is_osx && alias emacs='cocoa_emacs'
alias terminal_emacs='_emacs -t' alias terminal_emacs='_emacs -t'
alias ec='_emacs -n '
export GLOBAL_EMACS="" export GLOBAL_EMACS=""
is_ssh && emacs="terminal_emacs" is_ssh && emacs="terminal_emacs"
function cocoa_emacs { function cocoa_emacs {
reattach-to-user-namespace zsh -c "source ~/.zshrc && _emacs -c -n" reattach-to-user-namespace zsh -c 'source ~/.zshrc && _emacs -c -n "$@"'
} }
function _emacs { function _emacs {
@ -46,21 +46,26 @@ function existing_emacs {
} }
function emacs_make_frame_if_none_exists { function emacs_make_frame_if_none_exists {
emacsclient -e '(make-frame-if-none-exists)' --server-file=$1 emacsclient -e '(make-frame-if-none-exists-and-focus)' --server-file=$1
focus_emacs
} }
function get_running_emacs_instances { function focus_emacs {
osascript -e 'tell application "Emacs" to activate'
}
function emacs_get_running_instances {
pgrep -i emacs | xargs ps -o command -p | egrep -o " --daemon=(.*)" | awk -F= '{print $2}' | sed 's/\^J3,4\^J//' pgrep -i emacs | xargs ps -o command -p | egrep -o " --daemon=(.*)" | awk -F= '{print $2}' | sed 's/\^J3,4\^J//'
} }
function emacs_open { function emacs_open {
local server_file="$(get_running_emacs_instances | head -n1)" if ! emacs_daemon_exists; then
if [ -z $server_file ]; then emacs
_emacs -c -n "$@"
return
fi fi
local server_file="$(emacs_get_running_instances | head -n1)"
emacs_make_frame_if_none_exists $server_file emacs_make_frame_if_none_exists $server_file
[ ! -z "$@" ] && emacsclient "$@" -n --server-file="$server_file" [ ! -z "$@" ] && emacsclient "$@" -n --server-file="$server_file"
focus_emacs
} }
# Make emacs the default editor. # Make emacs the default editor.

View File

@ -0,0 +1,48 @@
pb-kill-line () {
zle kill-line
echo -n $CUTBUFFER | clipboard
}
pb-kill-whole-line () {
zle kill-whole-line
echo -n $CUTBUFFER | clipboard
}
pb-backward-kill-word () {
zle backward-kill-word
echo -n $CUTBUFFER | clipboard
}
pb-kill-word () {
zle kill-word
echo -n $CUTBUFFER | clipboard
}
pb-kill-buffer () {
zle kill-buffer
echo -n $CUTBUFFER | clipboard
}
pb-copy-region-as-kill-deactivate-mark () {
zle copy-region-as-kill
zle set-mark-command -n -1
echo -n $CUTBUFFER | clipboard
}
pb-yank () {
CUTBUFFER=$(pbpaste)
zle yank
}
zle -N pb-kill-line
zle -N pb-kill-whole-line
zle -N pb-backward-kill-word
zle -N pb-kill-word
zle -N pb-kill-buffer
zle -N pb-copy-region-as-kill-deactivate-mark
zle -N pb-yank
bindkey '^K' pb-kill-line
bindkey '^U' pb-kill-whole-line
bindkey '\ew' pb-copy-region-as-kill-deactivate-mark
bindkey '\eW' pb-copy-region-as-kill-deactivate-mark

View File

@ -15,7 +15,8 @@
<dict> <dict>
<key>CFBundleTypeExtensions</key> <key>CFBundleTypeExtensions</key>
<array> <array>
<string>*</string> <string>*</string>
<string>org</string>
</array> </array>
<key>CFBundleTypeName</key> <key>CFBundleTypeName</key>
<string>Automator workflow file</string> <string>Automator workflow file</string>