diff --git a/install.sh b/install.sh old mode 100644 new mode 100755 index 49d38c7..e824dc3 --- a/install.sh +++ b/install.sh @@ -43,3 +43,14 @@ for file in $DOTFILES; do done echo "✅ すべてのシンボリックリンクを作成しました!" + +# `git-prompt.sh`が環境になければインストール +GIT_PROMPT_INSTALL_SCRIPT="$DOTFILES_DIR/install_git-prompt.sh" + +if [ -f "$GIT_PROMPT_INSTALL_SCRIPT" ]; then + echo "Running install_git-prompt.sh ..." + source "$GIT_PROMPT_INSTALL_SCRIPT" +else + echo "Error: install_git-prompt.sh が見つかりません" + exit 1 +fi \ No newline at end of file diff --git a/install_git-prompt.sh b/install_git-prompt.sh new file mode 100755 index 0000000..941c673 --- /dev/null +++ b/install_git-prompt.sh @@ -0,0 +1,30 @@ +#!/usr/bin/env zsh + +# Git prompt (__git_ps1) のロード(自動ダウンロード対応) +if ! command -v git >/dev/null 2>&1; then + echo "Git がインストールされていません" +else + # Git の git-prompt.sh の場所候補 + GIT_PROMPT_FILES=( + "/usr/share/git/completion/git-prompt.sh" + "/usr/share/git-core/contrib/completion/git-prompt.sh" + "$HOME/.git-prompt.sh" + ) + + __git_ps1_loaded=false + + for f in "${GIT_PROMPT_FILES[@]}"; do + if [ -f "$f" ]; then + source "$f" + __git_ps1_loaded=true + break + fi + done + + # なければ自動でダウンロード + if [ "$__git_ps1_loaded" = false ]; then + echo "git-prompt.sh が見つからないためダウンロードします..." + curl -fsSL https://raw.githubusercontent.com/git/git/master/contrib/completion/git-prompt.sh -o ~/.git-prompt.sh + source ~/.git-prompt.sh + fi +fi