Created
January 9, 2026 05:29
-
-
Save mtskf/704b8be594c6d7f054decac65effca82 to your computer and use it in GitHub Desktop.
zshrc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # ============================================================================== | |
| # 🔧 基本設定 (最初に読み込む必要あり) | |
| # ============================================================================== | |
| # PATHの重複を防ぐ | |
| typeset -U path cdpath fpath manpath | |
| # 言語設定 | |
| export LANG=en_US.UTF-8 | |
| # デフォルトエディタ | |
| export EDITOR=antigravity | |
| export VISUAL=antigravity | |
| # ============================================================================== | |
| # 📦 パッケージマネージャ & ランタイム環境 | |
| # ============================================================================== | |
| # Homebrew | |
| eval "$(/opt/homebrew/bin/brew shellenv)" | |
| # Nodenv (Node.jsバージョン管理) | |
| # eval "$(nodenv init - zsh)" | |
| # Volta (Node.jsバージョン管理) | |
| export PATH="$HOME/.volta/bin:$PATH" | |
| # Rbenv (Rubyバージョン管理) | |
| eval "$(rbenv init - zsh)" | |
| # NPM | |
| export npm_config_ignore_scripts=true | |
| # Yarn | |
| export PATH="$PATH:$HOME/.yarn/bin" | |
| # GEM / Cocoapods | |
| export GEM_HOME=$HOME/.gem | |
| export PATH=$GEM_HOME/bin:$PATH | |
| # pnpm | |
| export PNPM_HOME="$HOME/Library/pnpm" | |
| case ":$PATH:" in | |
| *":$PNPM_HOME:"*) ;; | |
| *) export PATH="$PNPM_HOME:$PATH" ;; | |
| esac | |
| # ============================================================================== | |
| # 🛠️ ツール | |
| # ============================================================================== | |
| # Starship (プロンプトカスタマイズ) | |
| eval "$(starship init zsh)" | |
| # Jump (ディレクトリ移動) | |
| eval "$(jump shell)" | |
| # Antigravity | |
| export PATH="$HOME/.antigravity/antigravity/bin:$PATH" | |
| # ============================================================================== | |
| # ⌨️ 補完 | |
| # ============================================================================== | |
| # 補完の初期化 (起動高速化のため1日1回だけ再構築) | |
| autoload -Uz compinit | |
| if [[ -n ~/.zcompdump(#qN.mh+24) ]]; then | |
| compinit | |
| else | |
| compinit -C | |
| fi | |
| # 小文字入力で大文字もマッチ | |
| zstyle ':completion:*' matcher-list 'm:{[:lower:]}={[:upper:]}' | |
| # カラー有効化 | |
| autoload -Uz colors && colors | |
| # ============================================================================== | |
| # 📜 履歴 | |
| # ============================================================================== | |
| HISTFILE=$HOME/.zsh_history | |
| HISTSIZE=1000000 | |
| SAVEHIST=1000000 | |
| setopt SHARE_HISTORY # セッション間で履歴を共有 | |
| setopt HIST_IGNORE_ALL_DUPS # 古い重複エントリを削除 | |
| setopt HIST_IGNORE_DUPS # 連続する重複を記録しない | |
| setopt HIST_FIND_NO_DUPS # 検索時に重複を表示しない | |
| setopt HIST_IGNORE_SPACE # スペースで始まるコマンドは記録しない | |
| setopt HIST_REDUCE_BLANKS # 余分な空白を削除 | |
| setopt APPEND_HISTORY # 履歴ファイルに追記 | |
| setopt INC_APPEND_HISTORY # 終了時ではなく即座に書き込み | |
| setopt HIST_EXPIRE_DUPS_FIRST # 重複を先に削除 | |
| setopt HIST_SAVE_NO_DUPS # 重複をファイルに書き込まない | |
| setopt HIST_VERIFY # 履歴から実行前にコマンドを表示 | |
| setopt HIST_EXPAND # 補完時に履歴を展開 | |
| # 矢印キーで履歴検索 | |
| autoload history-search-end | |
| zle -N history-beginning-search-backward-end history-search-end | |
| zle -N history-beginning-search-forward-end history-search-end | |
| LISTMAX=1000 | |
| WORDCHARS="$WORDCHARS|:" | |
| # ============================================================================== | |
| # ⚙️ シェルオプション | |
| # ============================================================================== | |
| # 表示 | |
| setopt print_eight_bit # 日本語ファイル名を正しく表示 | |
| setopt nolistbeep # 補完時のビープ音を無効化 | |
| # 補完の挙動 | |
| setopt AUTO_MENU # Tabで補完候補を順次選択 | |
| setopt AUTO_LIST # 曖昧な補完で候補をリスト表示 | |
| setopt AUTO_PARAM_KEYS # 変数名を補完 | |
| setopt AUTO_PARAM_SLASH # ディレクトリ補完時に末尾に/を追加 | |
| setopt LIST_PACKED # 補完候補を詰めて表示 | |
| setopt COMPLETE_IN_WORD # カーソル位置で補完 | |
| setopt ALWAYS_LAST_PROMPT # 補完時にプロンプト位置を維持 | |
| unsetopt AUTO_REMOVE_SLASH # 末尾の/を削除しない | |
| unsetopt COMPLETE_ALIASES # エイリアスを展開してから補完 | |
| # ディレクトリ移動 | |
| setopt auto_cd # ディレクトリ名だけでcd | |
| setopt AUTO_PUSHD # cdでディレクトリスタックに追加 | |
| setopt PUSHD_IGNORE_DUPS # 重複を除いてスタックに追加 | |
| setopt AUTO_NAME_DIRS # ~$varでディレクトリにアクセス | |
| setopt CDABLE_VARS # 変数名でcd | |
| setopt MARK_DIRS # グロブでディレクトリに/を付加 | |
| DIRSTACKSIZE=100 | |
| # グロブ / パターンマッチ | |
| unsetopt GLOB_DOTS # ドットファイルは明示的に指定 | |
| # その他 | |
| setopt PROMPT_SUBST # プロンプトで変数展開 | |
| setopt CORRECT # コマンドのスペル訂正 | |
| unsetopt CORRECT_ALL # 引数のスペル訂正はしない | |
| unsetopt IGNORE_EOF # ^Dでログアウトしない | |
| # キーバインド | |
| bindkey '^K' kill-line # Ctrl+K: カーソル後を削除 | |
| bindkey '^[[1;2D' backward-char # Shift+Left: 左に移動 | |
| bindkey '^[[1;2C' forward-char # Shift+Right: 右に移動 | |
| bindkey -d # Reset: 全キーバインドを削除 | |
| bindkey -e # Emacs: Emacsモードを設定 | |
| # ============================================================================== | |
| # 🚀 エイリアス | |
| # ============================================================================== | |
| # 安全対策 | |
| alias rm='rm -i' | |
| alias cp='cp -i' | |
| alias mv='mv -i' | |
| alias mkdir='mkdir -p' | |
| # ls (色付き) | |
| alias ls='ls -G' | |
| alias ll='ls -lh' | |
| alias la='ls -lAh' | |
| # ナビゲーション | |
| alias ..='cd ../' | |
| alias ...='cd ../..' | |
| alias ....='cd ../../..' | |
| alias o="open" | |
| # macOS | |
| alias ios="open -a Simulator" | |
| alias hosts="sudo antigravity /etc/hosts" | |
| alias hostsapply="dscacheutil -flushcache" | |
| alias restartFinder="sudo killall Finder && open /System/Library/CoreServices/Finder.app" | |
| alias findin='mdfind -onlyin ./' | |
| alias lock='pmset displaysleepnow' | |
| # ネットワーク | |
| alias myip='curl -s ifconfig.me' | |
| alias ports='lsof -i -P -n | grep LISTEN' | |
| # 開発 | |
| alias now='vercel' | |
| alias python="python3" | |
| # 個人用 | |
| alias foam="code ~/Documents/Private/Foam" | |
| alias ep='noglob ep' # Edge Protocol Generator | |
| alias note='code ~/Library/Mobile\ Documents/iCloud~md~obsidian/Documents/M' | |
| # ============================================================================== | |
| # 🔨 関数 | |
| # ============================================================================== | |
| # Homebrew: アップデート・アップグレード・クリーンアップを一括実行 | |
| brewupdate() { | |
| brew update | |
| brew upgrade | |
| brew cleanup | |
| brew doctor | |
| } | |
| # Git: リモートの全ブランチを追跡してプル | |
| pullall() { | |
| for remote in $(git branch -r); do | |
| git branch --track "${remote#origin/}" "$remote" 2>/dev/null | |
| done | |
| git fetch --all | |
| git pull --all | |
| } | |
| # Finderの最前面ウィンドウのディレクトリに移動 | |
| cdf() { | |
| local target | |
| target=$(osascript -e 'tell application "Finder" to if (count of Finder windows) > 0 then get POSIX path of (target of front Finder window as text)') | |
| if [[ -n "$target" ]]; then | |
| cd "$target" && pwd | |
| else | |
| echo 'Finderウィンドウが見つかりません' >&2 | |
| fi | |
| } | |
| # Antigravity: 引数がなければカレントディレクトリを開く | |
| a() { | |
| if [ $# -eq 0 ]; then | |
| antigravity . | |
| else | |
| antigravity "$@" | |
| fi | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment