irongit

Hygo AI custom shell.

HygoShell/setup.sh
43 lines1.1 KBBourne Again Shell (bash)
1CURRENT_DIR=$(pwd)
2cd ~/.hygo
3HYGOSHELL_UPDATE=$(git pull)
4if [[ "$HYGOSHELL_UPDATE" == *"Already"* ]]; then
5 echo -e "\n\e[38;5;214mHygoShell is up to date.\e[0m\n"
6else
7 echo -e "\n\e[38;5;214mHygoShell updating.\e[0m\n"
8fi
9cd $CURRENT_DIR
10
11# Function to get the current Git branch
12get_git_branch() {
13 git branch 2>/dev/null | grep '*' | sed 's/* //'
14}
15
16git_branch_str() {
17 git_branch=$(get_git_branch)
18 if [ -n "$git_branch" ]; then
19 echo "($git_branch)"
20 fi
21}
22
23update_prompt() {
24 local git_branch=$(get_git_branch)
25 if [ -n "$git_branch" ]; then
26 PROMPT="%F{214}%n@%m %F{white}%~ %F{51}($git_branch)$NEWLINE%F{214}%#%k%f "
27 else
28 PROMPT="%F{214}%n@%m %F{white}%~$NEWLINE%F{214}%#%k%f "
29 fi
30}
31
32# Set up zsh prompt
33if [ -n "$ZSH_VERSION" ]; then
34 NEWLINE=$'\n'
35 autoload -Uz add-zsh-hook
36 add-zsh-hook precmd update_prompt
37 update_prompt
38fi
39
40# Set up bash prompt
41if [ -n "$BASH_VERSION" ]; then
42 PS1='\[\e[38;5;214m\]\u@\h \w$(git_branch=$(get_git_branch); if [ -n "$git_branch" ]; then echo " \[\e[37m\]($git_branch\[\e[0m\])"; fi)\n\$\[\e[0m\] '
43fi