Improve mercurial prompt
This commit is contained in:
parent
3ee22a4ebc
commit
24a7aeb8bb
@ -18,6 +18,12 @@ alias hgca='hg commit --amend'
|
||||
# list unresolved files (since hg does not list unmerged files in the status command)
|
||||
alias hgun='hg resolve --list'
|
||||
|
||||
# Configuration
|
||||
|
||||
# Comment this line if you don't want to show if the branch is dirty or not.
|
||||
# This can save a lot of time of very large repositories.
|
||||
SHOW_DIRTY_BRANCH=1
|
||||
|
||||
function hg_get_dir() {
|
||||
# Defines path as current directory
|
||||
local current_dir=$PWD
|
||||
@ -38,13 +44,23 @@ function in_hg() {
|
||||
fi
|
||||
}
|
||||
|
||||
function hg_get_branch_id() {
|
||||
local hg_id_tip=`hg log -T "{node|short}" -l 1 -b .`
|
||||
local hg_id=`hg id -i -r .`
|
||||
|
||||
if [[ $hg_id != $hg_id_tip ]]; then
|
||||
echo "@${hg_id}"
|
||||
fi
|
||||
}
|
||||
|
||||
function hg_get_branch_name() {
|
||||
local hg_dir=$(hg_get_dir)
|
||||
if [[ $hg_dir != "" ]]; then
|
||||
local hg_id=$(hg_get_branch_id)
|
||||
if [[ -f "${hg_dir}/branch" ]]; then
|
||||
echo $(<"${hg_dir}/branch")
|
||||
echo $(<"${hg_dir}/branch")$hg_id
|
||||
else
|
||||
echo "default"
|
||||
echo "default${hg_id}"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
@ -52,10 +68,11 @@ function hg_get_branch_name() {
|
||||
function hg_prompt_info {
|
||||
local branch=$(hg_get_branch_name)
|
||||
if [[ $branch != "" ]]; then
|
||||
echo "$ZSH_PROMPT_BASE_COLOR$ZSH_THEME_HG_PROMPT_PREFIX\
|
||||
$ZSH_THEME_REPO_NAME_COLOR${display}$ZSH_PROMPT_BASE_COLOR\
|
||||
$ZSH_PROMPT_BASE_COLOR$(hg_dirty)$ZSH_THEME_HG_PROMPT_SUFFIX\
|
||||
$ZSH_PROMPT_BASE_COLOR"
|
||||
if [[ $SHOW_DIRTY_BRANCH == 1 ]]; then
|
||||
branch="${branch}$(hg_dirty)"
|
||||
fi
|
||||
echo "$ZSH_THEME_HG_PROMPT_PREFIX${branch}$ZSH_THEME_HG_PROMPT_SUFFIX"
|
||||
fi
|
||||
}
|
||||
|
||||
function hg_dirty_choose {
|
||||
|
Loading…
Reference in New Issue
Block a user