Emacs cocoa WIP.
This commit is contained in:
parent
af417d6c15
commit
355d851507
17
dotfiles/lib/cocoa-emacs.scpt
Normal file
17
dotfiles/lib/cocoa-emacs.scpt
Normal file
@ -0,0 +1,17 @@
|
||||
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
|
@ -1,2 +1,3 @@
|
||||
dircolors_file="$HOME/.dircolors"
|
||||
test -r $dircolors_files && eval "$(dircolors $dircolors_file)"
|
||||
|
||||
[ ! -z "$SHELL" ] && test -r $dircolors_files && eval "$(dircolors $dircolors_file)"
|
||||
|
16
resources/set-path.plist
Normal file
16
resources/set-path.plist
Normal file
@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>Label</key>
|
||||
<string>set-path</string>
|
||||
<key>ProgramArguments</key>
|
||||
<array>
|
||||
<string>zsh</string>
|
||||
<string>-c</string>
|
||||
<string>'source ~/.zshrc; launchctl setenv PATH $PATH'</string>
|
||||
</array>
|
||||
<key>KeepAlive</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</plist>
|
27
tasks/osx.py
27
tasks/osx.py
@ -2,7 +2,7 @@ import os
|
||||
|
||||
from invoke import ctask
|
||||
|
||||
from .util import RESOURCES_DIRECTORY, command_exists
|
||||
from . import util
|
||||
|
||||
|
||||
@ctask(default=True)
|
||||
@ -11,6 +11,7 @@ def all(ctx):
|
||||
get_brew(ctx)
|
||||
brew_install(ctx)
|
||||
brew_cask(ctx)
|
||||
setup_cocoa_emacs(ctx)
|
||||
osx_config(ctx)
|
||||
|
||||
|
||||
@ -33,11 +34,15 @@ SHOULD_INSTALL = (
|
||||
MISC = ("file-formula", "less", "openssh --with-brewed-openssl",
|
||||
"perl518", "rsync", "svn", "unzip", "docker", "boot2docker", "pandoc",
|
||||
"mercurial")
|
||||
|
||||
CASKS = ('alfred', 'caffeine', 'flux', 'google-chrome', 'iterm2', 'spotify', 'vlc', 'virtualbox', 'xquartz')
|
||||
|
||||
|
||||
@ctask
|
||||
def osx_config(ctx):
|
||||
ctx.run('source {0}; osx_config'.format(os.path.join(RESOURCES_DIRECTORY, 'osx.sh')))
|
||||
ctx.run('source {0}; osx_config'.format(
|
||||
os.path.join(util.RESOURCES_DIRECTORY, 'osx.sh')
|
||||
))
|
||||
|
||||
|
||||
@ctask
|
||||
def brew_cask(ctx):
|
||||
@ -45,9 +50,10 @@ def brew_cask(ctx):
|
||||
for cask in CASKS:
|
||||
ctx.run('brew cask install {0}'.format(cask))
|
||||
|
||||
|
||||
@ctask
|
||||
def get_brew(ctx):
|
||||
if not command_exists('brew'):
|
||||
if not util.command_exists('brew'):
|
||||
ctx.run('ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"')
|
||||
|
||||
@ctask
|
||||
@ -55,9 +61,18 @@ def brew_install(ctx):
|
||||
for package_name in ESSENTIAL + BASICS + SHOULD_INSTALL + MISC:
|
||||
ctx.run('brew install {0}'.format(package_name))
|
||||
|
||||
|
||||
@ctask
|
||||
def setup_emacs(ctx):
|
||||
ctx.run('ln -s $(brew --prefix emacs) /Applications/emacs')
|
||||
def setup_cocoa_emacs(ctx):
|
||||
if not os.path.exists('/Applications/emacs'):
|
||||
ctx.run('ln -s $(brew --prefix emacs) /Applications/emacs', hide=True)
|
||||
launch_agent_dir = os.path.expanduser('~/Library/LaunchAgents/')
|
||||
filename = 'set-path.plist'
|
||||
util.ensure_path_exists(launch_agent_dir)
|
||||
ctx.run('cp {0} {1}'.format(
|
||||
os.path.join(util.RESOURCES_DIRECTORY, filename),
|
||||
os.path.join(launch_agent_dir, filename)
|
||||
))
|
||||
|
||||
|
||||
@ctask
|
||||
|
@ -1,3 +1,4 @@
|
||||
import errno
|
||||
import os
|
||||
|
||||
from invoke import run
|
||||
@ -10,3 +11,11 @@ RESOURCES_DIRECTORY = os.path.join(REPO_DIRECTORY, 'resources')
|
||||
|
||||
def command_exists(command, run=run):
|
||||
return run("hash {0}".format(command), warn=True, hide=True).exited == 0
|
||||
|
||||
|
||||
def ensure_path_exists(path):
|
||||
try:
|
||||
os.makedirs(path)
|
||||
except OSError as exception:
|
||||
if exception.errno != errno.EEXIST:
|
||||
raise
|
||||
|
Loading…
Reference in New Issue
Block a user