make zsh clipboard system-wide, improve emacs_open (add focus on startup)
This commit is contained in:
parent
0c40ac63fa
commit
e8bbb6964a
@ -1 +1 @@
|
||||
Subproject commit f0067856bffe9ae3255e842c637e675330a68acf
|
||||
Subproject commit 4c68b4f2ae2ca0ff178fceeda0ea0dc340c218a3
|
@ -1,12 +1,12 @@
|
||||
alias e='emacs_open'
|
||||
alias emacs='_emacs -c -n '
|
||||
is_osx && alias emacs='cocoa_emacs'
|
||||
alias terminal_emacs='_emacs -t'
|
||||
alias ec='_emacs -n '
|
||||
export GLOBAL_EMACS=""
|
||||
is_ssh && emacs="terminal_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 {
|
||||
@ -46,21 +46,26 @@ function existing_emacs {
|
||||
}
|
||||
|
||||
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//'
|
||||
}
|
||||
|
||||
function emacs_open {
|
||||
local server_file="$(get_running_emacs_instances | head -n1)"
|
||||
if [ -z $server_file ]; then
|
||||
_emacs -c -n "$@"
|
||||
return
|
||||
if ! emacs_daemon_exists; then
|
||||
emacs
|
||||
fi
|
||||
local server_file="$(emacs_get_running_instances | head -n1)"
|
||||
emacs_make_frame_if_none_exists $server_file
|
||||
[ ! -z "$@" ] && emacsclient "$@" -n --server-file="$server_file"
|
||||
focus_emacs
|
||||
}
|
||||
|
||||
# Make emacs the default editor.
|
||||
|
48
dotfiles/lib/zsh/system-wide-clipboard.zsh
Normal file
48
dotfiles/lib/zsh/system-wide-clipboard.zsh
Normal 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
|
@ -15,7 +15,8 @@
|
||||
<dict>
|
||||
<key>CFBundleTypeExtensions</key>
|
||||
<array>
|
||||
<string>*</string>
|
||||
<string>*</string>
|
||||
<string>org</string>
|
||||
</array>
|
||||
<key>CFBundleTypeName</key>
|
||||
<string>Automator workflow file</string>
|
||||
|
Loading…
Reference in New Issue
Block a user