Emacs cocoa WIP.

This commit is contained in:
2014-10-21 11:00:04 -07:00
parent af417d6c15
commit 355d851507
5 changed files with 65 additions and 7 deletions

View File

@@ -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

View File

@@ -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