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?

Day08:universal variable と永続設定

0
Posted at

本日の学習(Day08)

🎯 今日のテーマ

universal variable(-U)と永続設定の仕組みを理解する


✅ 学んだこと

  • set -U は universal variable(全セッション共通)
  • 一度設定すると次回起動時も保持される
  • ~/.config/fish/config.fish が設定ファイル
  • fish は自動保存設計になっている
  • bash のように export を毎回書く必要がない

🧠 universal variable とは?

例:

set -U EDITOR nvim

これで:

  • 新しいターミナルを開いても有効
  • 再起動しても有効

👉 設定が「自動で永続化」される。


🔎 通常変数との違い

種類 オプション 有効範囲
ローカル なし 現在のスコープ
グローバル -g 現在のセッション
エクスポート -x 子プロセスへ渡す
ユニバーサル -U 全セッション共有

🚀 実際に確認してみる

set -U TESTVAR hello

新しいターミナルで:

echo $TESTVAR

👉 hello が表示される。


📌 config.fish の役割

場所:

~/.config/fish/config.fish

ここに書いた内容は起動時に実行される。

例:

fish_add_path ~/.local/bin
abbr gs 'git status'

👉 自分専用環境が完成していく。


💡 今日の気づき

  • fish は「設定も自動管理」
  • bash より明確なスコープ設計
  • -U は想像以上に便利

⚠️ ハマりポイント

❌ 何でも -U にする
→ 意図せず全セッションに影響

❌ -x と -U を混同する

  • -x = export
  • -U = 永続共有
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?