forked from colonelpanic/dotfiles
emacs cocoa stuff, set-path launch agent, as_user function.
This commit is contained in:
parent
355d851507
commit
4d707d59e3
@ -1 +1 @@
|
|||||||
Subproject commit ad458bced3a0cd204671c8e88c3f0f1e445eaf33
|
Subproject commit 3a01d4be1d0c953cd1c4f293e8d0b32b543a2131
|
@ -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"
|
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"
|
hash brew 2>/dev/null && add_to_front_of_path "$(brew --prefix coreutils)/libexec/gnubin"
|
||||||
add_to_front_of_path "/usr/local/bin"
|
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
|
for filename in ~/.lib/shellrc/*; do
|
||||||
source $filename
|
source $filename
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
alias emacs="emacsclient -t"
|
alias emacs="emacsclient -c -n"
|
||||||
alias xemacs="\emacs --daemon > /dev/null 2&> /dev/null; emacsclient -c &"
|
alias temacs="emacsclient -t"
|
||||||
|
alias cemacs="emacsclient -c -n"
|
||||||
alias tmux="tmux -2"
|
alias tmux="tmux -2"
|
||||||
alias reload_tmux_conf="tmux source-file .tmux.conf"
|
alias reload_tmux_conf="tmux source-file .tmux.conf"
|
||||||
alias tmux_cb_to_remote_cb='tmux saveb - | linux_nc_paste_to_remote_clipboard'
|
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
|
export TERM=xterm-256color
|
||||||
fi
|
fi
|
||||||
# Make emacs the default editor.
|
# Make emacs the default editor.
|
||||||
export EDITOR="emacsclient"
|
export EDITOR="emacsclient -cn"
|
||||||
export ALTERNATE_EDITOR=""
|
export ALTERNATE_EDITOR=""
|
||||||
export VISUAL="emacsclient"
|
export VISUAL="emacsclient"
|
||||||
|
|
||||||
|
@ -265,3 +265,31 @@ EOF
|
|||||||
function dirty_talk() {
|
function dirty_talk() {
|
||||||
while true; do talk_dirty_to_me | tee >(cat) | say; done
|
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
|
||||||
|
}
|
||||||
|
@ -3,14 +3,14 @@
|
|||||||
<plist version="1.0">
|
<plist version="1.0">
|
||||||
<dict>
|
<dict>
|
||||||
<key>Label</key>
|
<key>Label</key>
|
||||||
<string>set-path</string>
|
<string>com.example.hello</string>
|
||||||
<key>ProgramArguments</key>
|
<key>ProgramArguments</key>
|
||||||
<array>
|
<array>
|
||||||
<string>zsh</string>
|
<string>zsh</string>
|
||||||
<string>-c</string>
|
<string>-c</string>
|
||||||
<string>'source ~/.zshrc; launchctl setenv PATH $PATH'</string>
|
<string>source ~/.zshrc && echo password | sudo -Sv && as_current_user /bin/launchctl setenv PATH $PATH</string>
|
||||||
</array>
|
</array>
|
||||||
<key>KeepAlive</key>
|
<key>RunAtLoad</key>
|
||||||
<true/>
|
<true/>
|
||||||
</dict>
|
</dict>
|
||||||
</plist>
|
</plist>
|
||||||
|
17
tasks/osx.py
17
tasks/osx.py
@ -64,15 +64,18 @@ def brew_install(ctx):
|
|||||||
|
|
||||||
@ctask
|
@ctask
|
||||||
def setup_cocoa_emacs(ctx):
|
def setup_cocoa_emacs(ctx):
|
||||||
if not os.path.exists('/Applications/emacs'):
|
if not os.path.exists('/Applications/Emacs.app'):
|
||||||
ctx.run('ln -s $(brew --prefix emacs) /Applications/emacs', hide=True)
|
ctx.run('ln -s $(brew --prefix emacs)/Emacs.app /Applications/Emacs.app', hide=True)
|
||||||
|
|
||||||
launch_agent_dir = os.path.expanduser('~/Library/LaunchAgents/')
|
launch_agent_dir = os.path.expanduser('~/Library/LaunchAgents/')
|
||||||
filename = 'set-path.plist'
|
filename = 'set-path.plist'
|
||||||
util.ensure_path_exists(launch_agent_dir)
|
|
||||||
ctx.run('cp {0} {1}'.format(
|
source = os.path.join(util.RESOURCES_DIRECTORY, filename)
|
||||||
os.path.join(util.RESOURCES_DIRECTORY, filename),
|
destination = os.path.join(launch_agent_dir, filename)
|
||||||
os.path.join(launch_agent_dir, filename)
|
|
||||||
))
|
if os.path.exists(source) and not os.path.exists(destination):
|
||||||
|
util.ensure_path_exists(launch_agent_dir)
|
||||||
|
ctx.run('ln -s {0} {1}'.format(source, destination))
|
||||||
|
|
||||||
|
|
||||||
@ctask
|
@ctask
|
||||||
|
Loading…
Reference in New Issue
Block a user