Skip to content

Instantly share code, notes, and snippets.

@dom111
Last active December 3, 2018 10:22
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dom111/cc0e7d98b3f50e071b1e9e94ab2e8d6b to your computer and use it in GitHub Desktop.
Save dom111/cc0e7d98b3f50e071b1e9e94ab2e8d6b to your computer and use it in GitHub Desktop.
# a version of __git_ps1 that should show the current branch quickly without many git commands
function __git_ps1() {
local path="$(git rev-parse --show-toplevel)/.git";
local branch="$(cat ${P}HEAD | sed -re 's/.+\///g')";
if [[ -d "$path/rebase-merge/" ]]; then
if [[ -f "$path/rebase-merge/interactive" ]]; then
B="$branch|MERGING-i";
else
B="$branch|MERGING-m";
fi
else
if [ -d "$path/rebase-apply" ]; then
if [ -f "$path/rebase-apply/rebasing" ]; then
B="$branch|REBASE"
elif [ -f "$path/rebase-apply/applying" ]; then
B="$branch|AM"
else
B="$branch|AM/REBASE"
fi
elif [ -f "$path/MERGE_HEAD" ]; then
B="$branch|MERGING"
elif [ -f "$path/CHERRY_PICK_HEAD" ]; then
B="$branch|CHERRY-PICKING"
elif [ -f "$path/REVERT_HEAD" ]; then
B="$branch|REVERTING"
elif [ -f "$path/BISECT_LOG" ]; then
B="$branch|BISECTING"
fi
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment