牌語備忘録 -pygo

あくまでもメモです。なるべくオフィシャルの情報を参照してください。

牌語備忘録 -pygo

Emacs-app と iTerm2 と Zsh を便利に使うためのメモ

※追記20130622:修正
※追記20130629:oh-my-zsh 抜けてた

(Emacs24.3, Zsh5.0.2, MacOSX10.8)

MacPortsEmacs-app をインストール前提で

Emacs

init.el
;; server start for emacs-client
(require 'server)
(unless (server-running-p)
  (server-start))
  (defun iterm()
    (interactive)
    (shell-command "open -a iTerm ")
    )

  (defun show-in-iterm-for-mac()
    (interactive)
    (shell-command (concat "open -a iTerm " default-directory))
    )

  (global-set-key (kbd "s-t") 'iterm)
  (global-set-key (kbd "s-T") 'show-in-iterm-for-mac)

iTerm2

Preferences/Profiles/keys

Left option key acts as: Esc

Zsh

zshrc

上記リンクに iTermからEmac.appを開くを追加

## Invoke the ``dired'' of current working directory in Emacs buffer.
function dired () {
  emacsclient -e "(dired \"$PWD\")"
  open "/Applications/MacPorts/Emacs.app"
}
 
## Chdir to the ``default-directory'' of currently opened in Emacs buffer.
function cde () {
    EMACS_CWD=`emacsclient -e "
     (expand-file-name
      (with-current-buffer
          (nth 1
               (assoc 'buffer-list
                      (nth 1 (nth 1 (current-frame-configuration)))))
        default-directory))" | sed 's/^"\(.*\)"$/\1/'`
 
    echo "chdir to $EMACS_CWD"
    cd "$EMACS_CWD"
}
  • iTerm2 から リードオンリーで Emacs.app を開きたい場合
## read_only_emacsclient
function roe () {
    emacsclient -e "(find-file-read-only \"$1\")"
    open "/Applications/MacPorts/Emacs.app"
}
  • emacsclient

Emacs.app 使う場合

if [ "$EMACS" != t ];then
    alias e="open -a Emacs.app"
    alias emacsclient="/Applications/MacPorts/Emacs.app/Contents/MacOS/bin/emacsclient"
    alias ecli="/Applications/MacPorts/Emacs.app/Contents/MacOS/bin/emacsclient -nw"
fi

Check

  1. emacs.app を起動
  2. iTerm2 で zsh 起動
  3. zsh で コマンド「dired」「cde」打って動作するか確認

とりあえずこんな感じかな