Skip to content

Instantly share code, notes, and snippets.

@twlz0ne
Created October 18, 2013 06:57
Show Gist options
  • Save twlz0ne/7037510 to your computer and use it in GitHub Desktop.
Save twlz0ne/7037510 to your computer and use it in GitHub Desktop.
Emacs(emacsformacosx) startup script
-- @brief emacs startup script
-- @author gongqijian
-- @date 2013/04/28
--
-- Usage:
--
-- 把 applescript 转换成 bundle,跟配置文件 _emacs.d 放在同一个目录下:
-- .
-- |- runemacs.app
-- |- _emacs.d
--
-- 获得 _emacs.d 完整路径
set scptpath to POSIX path of (path to me) as Unicode text
set emacs_d to do shell script "echo $(dirname " & scptpath & ")/_emacs.d"
-- 检查 ~/.emacs.d 是否存在
set fileexists to do shell script "echo $(if [ -e ~/.emacs.d ];
then echo 'yep';
else echo 'nop'; fi)"
-- 把 /your/path/_emacs.d 链接到 ~/.emacs.d
if fileexists = "nop" then
do shell script "ln -s " & emacs_d & " ~/.emacs.d"
else
set target_d to do shell script "echo $(readlink ~/.emacs.d)"
if not target_d = emacs_d then
do shell script "export dtime=`date +%Y-%m-%d_%H-%M-%S`;
mv ~/.emacs.d ~/.emacs.d-$dtime;
ln -s " & emacs_d & " ~/.emacs.d"
end if
end if
-- 检测系统版本
set emacs_bin to do shell script "echo $(if [[ `sw_vers -productVersion` == 10.6* ]];
then echo 'Emacs-10.4';
else echo 'Emacs-10.7'; fi)"
-- 启动 Emacs
do shell script "export PATH=/usr/local/git/bin:${PATH};
export MYEMACSDIR=" & emacs_d & ";
/Applications/Emacs.app/Contents/MacOS/" & emacs_bin & " -l ${MYEMACSDIR}/_emacs.mac"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment