0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Day12:fish_prompt の理解とプロンプトカスタマイズ入門

0
Posted at

本日の学習(Day12)

🎯 今日のテーマ

fish_prompt の仕組みを理解する


✅ 学んだこと

  • プロンプトは fish_prompt 関数で定義されている
  • 関数を書き換えることで表示を変更できる
  • 色は set_color で制御する
  • プロンプトは「ただの文字列」ではなく処理の結果

🧠 fish_prompt を確認する

現在の定義を見る:

functions fish_prompt

👉 関数として定義されているのが分かる。

つまり、

プロンプト = プログラム


🔎 超シンプルなプロンプトを作る

試しに作ってみる:

function fish_prompt
    set_color green
    echo -n (whoami)' > '
end

👉 ユーザー名だけのシンプル表示になる。


🎨 色を変える

例:

set_color blue

主な色:

  • red
  • green
  • yellow
  • blue
  • magenta
  • cyan
  • normal(リセット)

🚀 カレントディレクトリを表示する

function fish_prompt
    set_color cyan
    echo -n (prompt_pwd)' > '
end

prompt_pwd は fish の便利関数。


📌 なぜ fish のプロンプトは分かりやすい?

  • 最初から色付き
  • エラー表示が赤
  • Git 状態も統合可能

設計思想:

視認性 = 生産性


💡 今日の気づき

  • fish はUI設計が徹底している
  • プロンプトはカスタマイズ前提
  • 自分仕様にする余地が大きい

⚠️ ハマりポイント

❌ echo に -n を付け忘れる(改行される)
❌ set_color normal を忘れて色が残る


🔥 今日レベルアップしたこと

  • fish_prompt の正体を理解した
  • 自作プロンプトを作れるようになった
  • シェルが「カスタム可能な環境」に変わった

明日への布石

次回:

  • Git 情報をプロンプトに表示する
  • exit status(直前コマンドの結果)を表示
  • 実用的プロンプト設計

👉 ここから“見た目だけじゃない”プロンプトになります。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?