0. はじめに
これは TRAMP を emacs (Meadow) で使用する際のメモである。
設定以外は以下のリファレンスそのままなので、詳細はそちらを参照する事。
1. 使用環境
OS | Windows Xp |
emacs | Meadow 2.10 → Meadow 3.00 |
TRAMP | TRAMP Ver. 2.0.39 → Meadow 3.00 同梱版 |
ssh | plink Ver. 0.58 |
2. ソースの入手
以下のサイトからソース (tramp-2.0.39.tar.gz) をダウンロード。
http://savannah.gnu.org/projects/tramp/3. インストール
下記のリファレンスそのままなので省略。
TRAMP User Manual: Installation4. 設定
4.1 Meadow 2
make して出来た source/ を適当な場所 (以下の例では ~/.emacs.d/tramp) に置いて
~/ .emacs に以下の行を追記する。
("Meadow をインストールしたディレクトリ"/site-source/) 以下ならデフォルトでパスが
通っているのでパスの記述は不要になる。
なお、以下の設定では plink.exe がパスの通った場所にあることを前提にしている。
(add-to-list 'load-path "~/.emacs.d/tramp/source/") (require 'tramp) (setq tramp-default-method "plink") (setq tramp-completion-without-shell-p t) (setq tramp-shell-prompt-pattern "^[ $]+") (setq tramp-debug-buffer t) (nconc (cadr (assq 'tramp-login-args (assoc "ssh" tramp-methods))) '("/bin/sh" "-i")) (setcdr (assq 'tramp-remote-sh (assoc "ssh" tramp-methods)) '("/bin/sh -i")) (modify-coding-system-alist 'process "plink" 'euc-jp-unix) |
4.2 Meadow 3
Meadow 3.00 以降は default で tramp がインストールされているので
いくつかの設定は不要となっている。
現在の筆者の設定は以下。
(setq-default tramp-default-method "plink") (setq-default tramp-completion-without-shell-p t) (setq-default tramp-shell-prompt-pattern "^[ $]+") (setq-default tramp-debug-buffer t) (modify-coding-system-alist 'process "plink" 'euc-jp-unix) |
5. 基本的な使い方
C-x C-f 後、以下のように入力する。
/User@Host:Path
ssh のログインパスワードを入力後、色々な処理が行われ、ファイルを編集可能になる。
直接ログインしてからファイルを編集する場合と比べると処理速度は非常に遅いので
回線の速度が遅いと実用には耐えられない可能性が高い。
6. マルチホップを使う
ex: ユーザ "foo" がサーバ "www" にログイン後、ユーザ "hoge" に sudo してファイルを編集する。
6.1 emacs + ssh
C-x C-f 後、以下のように入力する。
ssh のログインパスワードと sudu のパスワードを入力後、ファイルを編集可能になる。
6.2 Meadow + plink
以下の設定を追加する。
(add-to-list 'tramp-multi-connection-function-alist '("sshp" tramp-multi-connect-rlogin "plink -ssh -t %h -l %u /bin/sh%n")) |
C-x C-f 後、以下のように入力する。
ssh のログインパスワードと sudo のパスワードを入力後、ファイルを編集可能になる。
7. リファレンス
http://www.gnu.org/software/tramp/TRAMP User Manual: Configuration