forked from colonelpanic/dotfiles
emacs cocoa stuff, set-path launch agent, as_user function.
This commit is contained in:
Submodule dotfiles/emacs.d updated: ad458bced3...3a01d4be1d
@@ -1,17 +0,0 @@
|
||||
tell application "Terminal"
|
||||
try
|
||||
-- we look for <= 2 because Emacs --daemon seems to always have an entry in visibile-frame-list even if there isn't
|
||||
set frameVisible to do shell script "/Applications/Emacs.app/Contents/MacOS/bin/emacsclient -e '(<= 2 (length (visible-frame-list)))'"
|
||||
if frameVisible is not "t" then
|
||||
-- there is a not a visible frame, launch one
|
||||
do shell script "/Applications/Emacs.app/Contents/MacOS/bin/emacsclient -c -n"
|
||||
end if
|
||||
on error
|
||||
-- daemon is not running, start the daemon and open a frame
|
||||
do shell script "/Applications/Emacs.app/Contents/MacOS/Emacs --daemon"
|
||||
do shell script "/Applications/Emacs.app/Contents/MacOS/bin/emacsclient -c -n"
|
||||
end try
|
||||
end tell
|
||||
|
||||
-- bring the visible frame to the front
|
||||
tell application "Emacs" to activate
|
@@ -9,6 +9,7 @@ function add_to_back_of_path {
|
||||
add_to_back_of_path "$HOME/.local/lib/python2.6/site-packages"
|
||||
hash brew 2>/dev/null && add_to_front_of_path "$(brew --prefix coreutils)/libexec/gnubin"
|
||||
add_to_front_of_path "/usr/local/bin"
|
||||
hash brew 2>/dev/null && add_to_front_of_path "$(brew --prefix emacs)/libexec/gnubin"
|
||||
|
||||
for filename in ~/.lib/shellrc/*; do
|
||||
source $filename
|
||||
|
@@ -1,5 +1,6 @@
|
||||
alias emacs="emacsclient -t"
|
||||
alias xemacs="\emacs --daemon > /dev/null 2&> /dev/null; emacsclient -c &"
|
||||
alias emacs="emacsclient -c -n"
|
||||
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'
|
||||
|
@@ -4,7 +4,7 @@ elif infocmp xterm-256color >/dev/null 2>&1; then
|
||||
export TERM=xterm-256color
|
||||
fi
|
||||
# Make emacs the default editor.
|
||||
export EDITOR="emacsclient"
|
||||
export EDITOR="emacsclient -cn"
|
||||
export ALTERNATE_EDITOR=""
|
||||
export VISUAL="emacsclient"
|
||||
|
||||
|
@@ -265,3 +265,31 @@ EOF
|
||||
function dirty_talk() {
|
||||
while true; do talk_dirty_to_me | tee >(cat) | say; done
|
||||
}
|
||||
|
||||
function as_user {
|
||||
local user="$1"
|
||||
local user_pid=$(ps -axj | awk "/^$user / {print \$2;exit}")
|
||||
local command="sudo /bin/launchctl bsexec $user_pid sudo -u '$user' $2"
|
||||
echo "Running:"
|
||||
echo "$command"
|
||||
eval $command
|
||||
}
|
||||
|
||||
function as_current_user {
|
||||
as_user "$(whoami)" "$*"
|
||||
}
|
||||
|
||||
function reload_user_agent {
|
||||
as_current_user /bin/launchctl unload "$1"
|
||||
as_current_user /bin/launchctl load "$1"
|
||||
}
|
||||
|
||||
|
||||
function reload_root_agent {
|
||||
as_user 'root' "/bin/launchctl unload '$1'"
|
||||
as_user 'root' "/bin/launchctl load '$1'"
|
||||
}
|
||||
|
||||
function ec {
|
||||
emacsclient -n $1 > /dev/null
|
||||
}
|
||||
|
Reference in New Issue
Block a user