Last active
September 25, 2026 23:15
-
-
Save amane-katagiri/cb3a9b3785fbf50752587676b8e61a04 to your computer and use it in GitHub Desktop.
clausonaのプロファイルをディレクトリごとに自動で切り替えるためのbash/fish向けコマンド集
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
| function __ai_profile | |
| set -l dir $PWD | |
| while true | |
| if test -f "$dir/.ai-profile" | |
| string trim < "$dir/.ai-profile" | |
| return 0 | |
| end | |
| if test "$dir" = "/" | |
| return 1 | |
| end | |
| set dir (dirname "$dir") | |
| end | |
| end | |
| function claude | |
| set -l profile (__ai_profile) | |
| if test -n "$profile" | |
| command clausona run "claude:$profile" $argv | |
| else | |
| command claude $argv | |
| end | |
| end | |
| function codex | |
| set -l profile (__ai_profile) | |
| if test -n "$profile" | |
| command clausona run "codex:$profile" $argv | |
| else | |
| command codex $argv | |
| end | |
| end | |
| function aip | |
| if test (count $argv) -eq 0 | |
| set -l profile (__ai_profile) | |
| if test -n "$profile" | |
| echo "$profile" | |
| else | |
| echo "No .ai-profile" | |
| end | |
| return | |
| end | |
| echo $argv[1] > .ai-profile | |
| echo "AI profile: $argv[1]" | |
| end |
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
| __ai_profile() { | |
| local dir="$PWD" | |
| while true; do | |
| if [[ -f "$dir/.ai-profile" ]]; then | |
| tr -d '[:space:]' < "$dir/.ai-profile" | |
| return 0 | |
| fi | |
| [[ "$dir" == "/" ]] && return 1 | |
| dir="$(dirname "$dir")" | |
| done | |
| } | |
| claude() { | |
| local profile | |
| profile="$(__ai_profile)" | |
| if [[ -n "$profile" ]]; then | |
| command clausona run "claude:$profile" "$@" | |
| else | |
| command claude "$@" | |
| fi | |
| } | |
| codex() { | |
| local profile | |
| profile="$(__ai_profile)" | |
| if [[ -n "$profile" ]]; then | |
| command clausona run "codex:$profile" "$@" | |
| else | |
| command codex "$@" | |
| fi | |
| } | |
| aip() { | |
| if [[ $# -eq 0 ]]; then | |
| local profile | |
| profile="$(__ai_profile)" | |
| if [[ -n "$profile" ]]; then | |
| echo "$profile" | |
| else | |
| echo "No .ai-profile" | |
| fi | |
| return | |
| fi | |
| printf '%s\n' "$1" > .ai-profile | |
| echo "AI profile: $1" | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment