add
This commit is contained in:
139
scripts/claude-zsh-functions.sh
Normal file
139
scripts/claude-zsh-functions.sh
Normal file
@ -0,0 +1,139 @@
|
||||
#!/bin/zsh
|
||||
# Claude Code用のzsh関数集
|
||||
|
||||
# 拡張ヘルプ関数
|
||||
function claude-help() {
|
||||
local script_path="${0:a:h}/claude-help.sh"
|
||||
|
||||
# スクリプトが見つからない場合のフォールバック
|
||||
if [[ ! -f "$script_path" ]]; then
|
||||
script_path="$HOME/git/claude/scripts/claude-help.sh"
|
||||
fi
|
||||
|
||||
if [[ -f "$script_path" ]]; then
|
||||
bash "$script_path" "$@"
|
||||
else
|
||||
echo "Error: claude-help.sh not found"
|
||||
echo "Expected location: $script_path"
|
||||
fi
|
||||
}
|
||||
|
||||
# クイックリファレンス(従来の関数を改良)
|
||||
function claude-readme() {
|
||||
# カラー定義
|
||||
local BLUE='\033[0;34m'
|
||||
local GREEN='\033[0;32m'
|
||||
local YELLOW='\033[1;33m'
|
||||
local NC='\033[0m'
|
||||
|
||||
echo -e "${GREEN}Claude Code クイックリファレンス${NC}"
|
||||
echo -e "${BLUE}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
|
||||
echo '
|
||||
ショートカット:
|
||||
^A/^E ・・・行頭/行末に移動
|
||||
^B/^F ・・・1文字前/後に移動
|
||||
^W ・・・単語削除(高速)
|
||||
^J ・・・改行(Enter代替)
|
||||
|
||||
Claude特有:
|
||||
ESC×1 ・・・入力を全消去
|
||||
ESC×2 ・・・前のメッセージに戻る
|
||||
\ + Enter ・・・複数行入力
|
||||
|
||||
よく使うコマンド:
|
||||
claude --resume ・・・セッション復元
|
||||
claude --dangerously-skip-permissions ・・・許可スキップ
|
||||
think / think hard / ultrathink ・・・思考モード
|
||||
'
|
||||
echo -e "${YELLOW}詳細は 'claude-help' で確認${NC}"
|
||||
}
|
||||
|
||||
# Claude Codeセッションの管理
|
||||
function claude-session() {
|
||||
case "$1" in
|
||||
"save")
|
||||
# 現在のセッションIDを保存
|
||||
echo "Session saved (use 'claude --resume' to restore)"
|
||||
;;
|
||||
"list")
|
||||
# 利用可能なセッションをリスト
|
||||
ls -la ~/.claude/sessions/ 2>/dev/null || echo "No sessions found"
|
||||
;;
|
||||
*)
|
||||
echo "Usage: claude-session [save|list]"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
# Claude Code用の安全チェック付き実行
|
||||
function claude-safe() {
|
||||
local hooks_dir="$HOME/git/claude/scripts"
|
||||
|
||||
# 安全チェックスクリプトを設定
|
||||
export CLAUDE_BEFORE_BASH="$hooks_dir/claude-arch-safety-check.sh"
|
||||
|
||||
# Claude Codeを起動
|
||||
claude "$@"
|
||||
|
||||
# 環境変数をクリア
|
||||
unset CLAUDE_BEFORE_BASH
|
||||
}
|
||||
|
||||
# プロジェクト固有のCLAUDE.mdを編集
|
||||
function claude-edit-config() {
|
||||
local config_file="CLAUDE.md"
|
||||
|
||||
if [[ ! -f "$config_file" ]]; then
|
||||
echo "Creating new CLAUDE.md..."
|
||||
cat > "$config_file" << 'EOF'
|
||||
# CLAUDE.md
|
||||
|
||||
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
|
||||
|
||||
## Project Overview
|
||||
[プロジェクトの概要をここに記載]
|
||||
|
||||
## Commands
|
||||
[よく使うコマンドをここに記載]
|
||||
|
||||
## Architecture
|
||||
[アーキテクチャの説明をここに記載]
|
||||
EOF
|
||||
fi
|
||||
|
||||
${EDITOR:-vim} "$config_file"
|
||||
}
|
||||
|
||||
# Claude Codeのドキュメントを開く
|
||||
function claude-docs() {
|
||||
local topic="${1:-overview}"
|
||||
local base_url="https://docs.anthropic.com/en/docs/claude-code"
|
||||
|
||||
case "$topic" in
|
||||
"shortcuts"|"keys")
|
||||
open "$base_url/interactive-mode" 2>/dev/null || xdg-open "$base_url/interactive-mode"
|
||||
;;
|
||||
"settings")
|
||||
open "$base_url/settings" 2>/dev/null || xdg-open "$base_url/settings"
|
||||
;;
|
||||
"memory")
|
||||
open "$base_url/memory" 2>/dev/null || xdg-open "$base_url/memory"
|
||||
;;
|
||||
*)
|
||||
open "$base_url/$topic" 2>/dev/null || xdg-open "$base_url/$topic"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
# エイリアス定義
|
||||
alias ch='claude-help'
|
||||
alias cr='claude-readme'
|
||||
alias cs='claude-safe'
|
||||
alias ce='claude-edit-config'
|
||||
alias cd-docs='claude-docs'
|
||||
|
||||
# 初回実行時のメッセージ
|
||||
if [[ -z "$CLAUDE_ZSH_LOADED" ]]; then
|
||||
export CLAUDE_ZSH_LOADED=1
|
||||
echo "Claude Code helper functions loaded. Type 'claude-help' for more info."
|
||||
fi
|
Reference in New Issue
Block a user