Skip to content

Commit

Permalink
fix: ps1 erroring when not in a git repo
Browse files Browse the repository at this point in the history
  • Loading branch information
pmqueiroz committed Jan 4, 2024
1 parent e6fce23 commit 69ab204
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion dots/sources.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,14 @@ function format_time_diff {
echo "${hours}h${minutes}m${seconds}s"
}

function branch_format {
branch_name=$(git branch --show-current 2> /dev/null)

if [ $? -eq 0 ]; then
git_style $branch_name
fi
}

function __before_command {
if [[ $BASH_COMMAND != *"__after_command"* && $BASH_COMMAND != *"_zoxide_hook"* ]]; then
first_command=$(date +%s)
Expand Down Expand Up @@ -68,7 +76,7 @@ function __after_command {
formatted_time=
fi

PS1+="$DEFAULT_PS1 \$(git_style $(git branch --show-current)) $ran_time"
PS1+="$DEFAULT_PS1 \$(branch_format) $ran_time"
}

trap '__before_command' DEBUG
Expand Down

0 comments on commit 69ab204

Please sign in to comment.