forked from colonelpanic/dotfiles
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"
|
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 invoke import ctask
|
||||||
|
|
||||||
from .util import RESOURCES_DIRECTORY, command_exists
|
from . import util
|
||||||
|
|
||||||
|
|
||||||
@ctask(default=True)
|
@ctask(default=True)
|
||||||
@ -11,6 +11,7 @@ def all(ctx):
|
|||||||
get_brew(ctx)
|
get_brew(ctx)
|
||||||
brew_install(ctx)
|
brew_install(ctx)
|
||||||
brew_cask(ctx)
|
brew_cask(ctx)
|
||||||
|
setup_cocoa_emacs(ctx)
|
||||||
osx_config(ctx)
|
osx_config(ctx)
|
||||||
|
|
||||||
|
|
||||||
@ -33,11 +34,15 @@ SHOULD_INSTALL = (
|
|||||||
MISC = ("file-formula", "less", "openssh --with-brewed-openssl",
|
MISC = ("file-formula", "less", "openssh --with-brewed-openssl",
|
||||||
"perl518", "rsync", "svn", "unzip", "docker", "boot2docker", "pandoc",
|
"perl518", "rsync", "svn", "unzip", "docker", "boot2docker", "pandoc",
|
||||||
"mercurial")
|
"mercurial")
|
||||||
|
|
||||||
CASKS = ('alfred', 'caffeine', 'flux', 'google-chrome', 'iterm2', 'spotify', 'vlc', 'virtualbox', 'xquartz')
|
CASKS = ('alfred', 'caffeine', 'flux', 'google-chrome', 'iterm2', 'spotify', 'vlc', 'virtualbox', 'xquartz')
|
||||||
|
|
||||||
|
|
||||||
@ctask
|
@ctask
|
||||||
def osx_config(ctx):
|
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
|
@ctask
|
||||||
def brew_cask(ctx):
|
def brew_cask(ctx):
|
||||||
@ -45,9 +50,10 @@ def brew_cask(ctx):
|
|||||||
for cask in CASKS:
|
for cask in CASKS:
|
||||||
ctx.run('brew cask install {0}'.format(cask))
|
ctx.run('brew cask install {0}'.format(cask))
|
||||||
|
|
||||||
|
|
||||||
@ctask
|
@ctask
|
||||||
def get_brew(ctx):
|
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)"')
|
ctx.run('ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"')
|
||||||
|
|
||||||
@ctask
|
@ctask
|
||||||
@ -55,9 +61,18 @@ def brew_install(ctx):
|
|||||||
for package_name in ESSENTIAL + BASICS + SHOULD_INSTALL + MISC:
|
for package_name in ESSENTIAL + BASICS + SHOULD_INSTALL + MISC:
|
||||||
ctx.run('brew install {0}'.format(package_name))
|
ctx.run('brew install {0}'.format(package_name))
|
||||||
|
|
||||||
|
|
||||||
@ctask
|
@ctask
|
||||||
def setup_emacs(ctx):
|
def setup_cocoa_emacs(ctx):
|
||||||
ctx.run('ln -s $(brew --prefix emacs) /Applications/emacs')
|
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
|
@ctask
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import errno
|
||||||
import os
|
import os
|
||||||
|
|
||||||
from invoke import run
|
from invoke import run
|
||||||
@ -10,3 +11,11 @@ RESOURCES_DIRECTORY = os.path.join(REPO_DIRECTORY, 'resources')
|
|||||||
|
|
||||||
def command_exists(command, run=run):
|
def command_exists(command, run=run):
|
||||||
return run("hash {0}".format(command), warn=True, hide=True).exited == 0
|
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