はじめに
- Emacsならでは、という使い方はしていないですね、、、
- CLIの進化が激しくUIもよくできている(
@や/コマンド)のと、EXWM経由なので快適です - 今は Claude Code君をメインとし、比較やレビュー用にgemini-cli、 Codexを使って、単純な作業は軽快な Qwen Code が、 いくらでも並列で並べられるのって、本当にAI革命は素晴しい です(ボトルネックは自分の頭)
Alacritty + tmux + ai-cli
- 作業毎にtmuxのタブでcliを増やしていきます
- 改行に迷う(
Alt-Enter?Shift-Enter?)ことがあるので、Shift-Enterに統一してます - tmuxはChromeと同じような
Ctrl-Tabのタブを使っていて、Emacsからも移動できるようにしていますが、あまり使ってない - 他、Emacsの選択範囲をCLIに送るような工夫をしていますが、ほぼ使ってない
Alacritty
.config/alacritty/alacritty.toml
[font]
size = 8
[colors.primary]
background = "#FFFFFF"
foreground = "#000000"
[font.normal]
family = "MeiryoKe_Console"
[selection]
# save_to_clipboard = true
bindings = [
# tmuxのタブ操作に合せる
{ key = "Tab", mods = "Control", chars = "\u001b[27;5;9~" },
{ key = "Tab", mods = "Control|Shift", chars = "\u001b[27;6;9~" },
# Ctrl-^, -でフォントサイズを変更
{ key = "^", mods = "Control", action = "IncreaseFontSize" },
# Alt-wでコピー(ただしtmuxでは動作しない)
{ key = "W", mods = "Alt", action = "Copy" },
# Win-yでペースト
{ key = "Y", mods = "Super", action = "Paste" },
# 改行がAlt-EnterかShift-Enterで迷うことがあるので、Shift-Enterに統一
{ key = "Return", mods = "Shift", chars = "\u001b\r" }
]
tmux
.tmux.conf
# ステータスバーの色を灰色に設定
set -g status-style bg=colour252,fg=black
set -g base-index 1 # ウィンドウの番号を 1 から開始
setw -g pane-base-index 1 # ペインの番号を 1 から開始
set-option -g status-position top # ステータスバーをトップに配置する
set -g status-interval 1 # ステータスバー更新速度 15s(default) → 1s
set-option -g status-right ""
bind r source-file ~/.tmux.conf \; display "Reloaded!"
set -g mouse on
# unbind -T copy-mode MouseDragEnd1Pane
bind-key -n C-Tab next-window
bind-key -n C-S-Tab previous-window
bind-key -n C-BTab previous-window
unbind C-b
set-option -g prefix C-t
bind C-t send-prefix
bind C-t new-window
bind C-o select-pane -t :.+
bind-key 2 split-window -v
bind-key 3 split-window -h
bind-key C-b select-pane -L
bind-key C-n select-pane -D
bind-key C-p select-pane -U
bind-key C-f select-pane -R
bind-key k kill-pane
# resize C-t + C-Up,Down...連打がサイズ変更
Emacs
外部エディタ起動で呼ばれた時に、毎回保存を確認されないように
(server-start)
(defun my/server-save-and-edit ()
(interactive)
(save-buffer)
(server-edit))
(define-key ctl-x-map "#" #'my/server-save-and-edit)
各CLIにおける外部エディタ起動のショートカット
- Claude Code:
Ctrl-g - codex: 今ないけど
Ctrl-gになるぽい - gemini-cli:
Ctrl-x
- qwen:
Ctrl-x
CLIの切り替え
別バッファで編集しているファイル上からも Ctrl-tabで、別ウィンドウのAI(tmux)を切り替えてます。
;; ** 自分の環境でしか動かないかもなので参考までに **
(defun my-tmux-next-window ()
"Switch to the next tmux window in the current EXWM workspace's corresponding tmux session."
(interactive)
(let ((current-workspace-index exwm-workspace-current-index))
(call-process "tmux" nil 0 nil "next-window" "-t"
(number-to-string current-workspace-index))))
(defun my-tmux-previous-window ()
"Switch to the previous tmux window in target session 0."
(interactive)
(let ((current-workspace-index exwm-workspace-current-index))
(call-process "tmux" nil 0 nil "previous-window" "-t"
(number-to-string current-workspace-index))))
(global-set-key (kbd "<C-tab>") 'my-tmux-next-window)
(global-set-key (kbd "C-<iso-lefttab>") 'my-tmux-previous-window)
CLIへの送信
編集しているファイル上の 現在行 もしくは 選択範囲 のテキストをAI(tmux)に直接送信します。
フォーカスを変えず、ENTER含めていきなり実行 するのが便利かと思いつつも、全然使ってません。
;; ** 自分の環境でしか動かないかもなので参考までに **
(defun my-send-to-tmux ()
"Send the selected region or current line to tmux pane 0, followed by Enter."
(interactive)
(let* ((contents
(if (region-active-p)
(buffer-substring-no-properties (region-beginning) (region-end))
(buffer-substring-no-properties (line-beginning-position) (line-end-position))))
(escaped-contents (shell-quote-argument contents))
(tmux-send-text-command (concat "tmux send-keys -t 0 -- " escaped-contents))
(tmux-enter-command "tmux send-keys -t 0 Enter"))
(shell-command tmux-send-text-command)
(shell-command tmux-enter-command)))
(global-set-key (kbd "C-x <C-return>") 'my-send-to-tmux)
まとめ
gptel やollamaもいれてはいますが、常用するに至っていません。
そんな使い方に、興味を持った方はぜひ試してみてください ![]()
Emacs Advent Calendar 2025
21日目 ai-code-interface.el について書きたいなと思っていましたが、落としてしまったので Emacs との出会いについてのポエムになりました (@kyre)
23日目 Emacsを使う理由(7): まとめ (@howking)