Skip to content

Commit b5b348f

Browse files
committed
Fix install.sh
1 parent 5ca700b commit b5b348f

2 files changed

Lines changed: 39 additions & 0 deletions

File tree

install.sh

100644100755
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,14 @@ for file in $DOTFILES; do
4343
done
4444

4545
echo "✅ すべてのシンボリックリンクを作成しました!"
46+
47+
# `git-prompt.sh`が環境になければインストール
48+
GIT_PROMPT_INSTALL_SCRIPT="$DOTFILES_DIR/install_git-prompt.sh"
49+
50+
if [ -f "$GIT_PROMPT_INSTALL_SCRIPT" ]; then
51+
echo "Running install_git-prompt.sh ..."
52+
source "$GIT_PROMPT_INSTALL_SCRIPT"
53+
else
54+
echo "Error: install_git-prompt.sh が見つかりません"
55+
exit 1
56+
fi

install_git-prompt.sh

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Git prompt (__git_ps1) のロード(自動ダウンロード対応)
2+
if ! command -v git >/dev/null 2>&1; then
3+
echo "Git がインストールされていません"
4+
else
5+
# Git の git-prompt.sh の場所候補
6+
GIT_PROMPT_FILES=(
7+
"/usr/share/git/completion/git-prompt.sh"
8+
"/usr/share/git-core/contrib/completion/git-prompt.sh"
9+
"$HOME/.git-prompt.sh"
10+
)
11+
12+
__git_ps1_loaded=false
13+
14+
for f in "${GIT_PROMPT_FILES[@]}"; do
15+
if [ -f "$f" ]; then
16+
source "$f"
17+
__git_ps1_loaded=true
18+
break
19+
fi
20+
done
21+
22+
# なければ自動でダウンロード
23+
if [ "$__git_ps1_loaded" = false ]; then
24+
echo "git-prompt.sh が見つからないためダウンロードします..."
25+
curl -fsSL https://raw.githubusercontent.com/git/git/master/contrib/completion/git-prompt.sh -o ~/.git-prompt.sh
26+
source ~/.git-prompt.sh
27+
fi
28+
fi

0 commit comments

Comments
 (0)