Noriyo Akita's Today I Learned

# Ghostty 導入メモ

Table of Contents

インストール

全人類 Ghostty やってる、やってないのお前だけ…と言われた気がしたので(幻聴)

brew install --cask ghostty

Powerlevel10k with instant prompt の警告

[WARNING]: Console output during zsh initialization detected.
When using Powerlevel10k with instant prompt, console output during zsh
initialization may indicate issues.
You can:
- Recommended: Change ~/.zshrc so that it does not perform console I/O
after the instant prompt preamble. See the link below for details.
* You will not see this error message again.
* Zsh will start quickly and prompt will update smoothly.
- Suppress this warning either by running p10k configure or by manually
defining the following parameter:
typeset -g POWERLEVEL9K_INSTANT_PROMPT=quiet
* You will not see this error message again.
* Zsh will start quickly but prompt will jump down after initialization.
- Disable instant prompt either by running p10k configure or by manually
defining the following parameter:
typeset -g POWERLEVEL9K_INSTANT_PROMPT=off
* You will not see this error message again.
* Zsh will start slowly.
- Do nothing.
* You will see this error message every time you start zsh.
* Zsh will start quickly but prompt will jump down after initialization.
For details, see:
https://github.com/romkatv/powerlevel10k/blob/master/README.md#instant-prompt
-- console output produced during zsh initialization follows --

instant promptを off に

~/.zshrc
typeset -g POWERLEVEL9K_INSTANT_PROMPT=off

quiet にしても警告が消えなかったので仕方なく

iTerm2連携を条件分岐に

~/.zshrc
if [[ "$TERM_PROGRAM" == "iTerm.app" ]]; then
source ~/.iterm2_shell_integration.zsh
iterm2_print_user_vars
fi

なんか Claude Code がこんなことを言ってきたのでとりあえず設定した

問題は65-66行目のiTerm2連携:
source ~/.iterm2_shell_integration.zsh
iterm2_print_user_vars
これがinstant promptの後に読み込まれてコンソール出力してるから、Powerlevel10kが怒ってるの。Ghosttyを使ってるのに、iTerm2のintegrationも読み込まれちゃってる状態ね。
修正案:iTerm2の部分を、iTerm2使用時のみ読み込むように条件分岐する:
# iTerm2連携 (iTerm2使用時のみ)
if [[ "$TERM_PROGRAM" == "iTerm.app" ]]; then
source ~/.iterm2_shell_integration.zsh
iterm2_print_user_vars
fi
これで:
- iTerm2 → iTerm2連携が有効
- Ghostty → iTerm2連携はスキップ(警告消える)
- 他のターミナル → 同様にスキップ

on Claude Code

ctrl + J で改行

通常のシェルだとできるのだがなぜか Claude Code 上だとできなかったので config に書いた。shift + enter でもできるようにしている

command = /bin/zsh -l -i
shell-integration = zsh
# Config generated by Ghostty Config
window-inherit-working-directory = true
window-save-state = always
background-opacity = 0.8
# break line on shift + enter / ctrl + j
keybind = shift+enter=text:\x1b\r
keybind = ctrl+j=text:\x1b\r
theme = Dracula
font-feature = -liga
font-family = "Source Han Code JP"
# Trims trailing whitespace on data that is copied to the clipboard.
# This does not affect data sent to the clipboard via `clipboard-write`.
clipboard-trim-trailing-spaces = true

file explorer

yazi を入れることにした。ft も悪くないが、ファイルを実際に vi で開くことができるのが違う 開きさえすれば行番号付きのファイルパスをヤンクすることができるので

" leader is \
" 相対パス:行番号 をコピー (例: src/main.py:42)
nnoremap <leader>cf :let @+ = expand("%") . ":" . line(".")<CR>
" ビジュアルモードで選択範囲のパスと行番号をコピー (例: path/to/file:10-15)
xnoremap <leader>cf :<C-u>let @+ = expand("%") . ":" . line("'<") . "-" . line("'>")<CR>
" 絶対パス:行番号 をコピー (例: /home/user/src/main.py:42)
nnoremap <leader>cF :let @+ = expand("%:p") . ":" . line(".")<CR>
" Copy a file name only
nnoremap <leader>cn :let @+ = expand("%:t") . ":" . line(".")<CR>
My avatar

Thanks for reading my blog post! Feel free to check out my other posts or contact me via the social links in the footer.


More Posts