Compare commits
3 Commits
7dd5e99734
...
815c19fde8
Author | SHA1 | Date |
---|---|---|
Pavle Portic | 815c19fde8 | |
Pavle Portic | 1f1390148a | |
Pavle Portic | 4a6c728dcb |
|
@ -135,41 +135,6 @@ prompt_git() {
|
|||
fi
|
||||
}
|
||||
|
||||
prompt_hg() {
|
||||
local rev status
|
||||
if $(hg id >/dev/null 2>&1); then
|
||||
if $(hg prompt >/dev/null 2>&1); then
|
||||
if [[ $(hg prompt "{status|unknown}") = "?" ]]; then
|
||||
# if files are not added
|
||||
prompt_segment red white
|
||||
st='±'
|
||||
elif [[ -n $(hg prompt "{status|modified}") ]]; then
|
||||
# if any modification
|
||||
prompt_segment yellow black
|
||||
st='±'
|
||||
else
|
||||
# if working copy is clean
|
||||
prompt_segment green black
|
||||
fi
|
||||
echo -n $(hg prompt "☿ {rev}@{branch}") $st
|
||||
else
|
||||
st=""
|
||||
rev=$(hg id -n 2>/dev/null | sed 's/[^-0-9]//g')
|
||||
branch=$(hg id -b 2>/dev/null)
|
||||
if `hg st | grep -q "^\?"`; then
|
||||
prompt_segment red black
|
||||
st='±'
|
||||
elif `hg st | grep -q "^[MA]"`; then
|
||||
prompt_segment yellow black
|
||||
st='±'
|
||||
else
|
||||
prompt_segment green black
|
||||
fi
|
||||
echo -n "☿ $rev@$branch" $st
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
# Dir: current working directory
|
||||
prompt_dir() {
|
||||
if [[ -w "$PWD" ]]; then
|
||||
|
@ -187,6 +152,17 @@ prompt_virtualenv() {
|
|||
fi
|
||||
}
|
||||
|
||||
# Terraform: current terraform workspace
|
||||
prompt_tf() {
|
||||
# dont show 'default' workspace in home dir
|
||||
[[ "$PWD" == ~ ]] && return
|
||||
# check if in terraform dir
|
||||
if [ -d .terraform ]; then
|
||||
workspace=$(terraform workspace show 2> /dev/null) || return
|
||||
prompt_segment magenta black "[${workspace}]"
|
||||
fi
|
||||
}
|
||||
|
||||
# Status:
|
||||
# - was there an error
|
||||
# - am I root
|
||||
|
@ -203,6 +179,10 @@ prompt_status() {
|
|||
#[[ -n "$symbols" ]] && prompt_segment "$symbols"
|
||||
}
|
||||
|
||||
prompt_time() {
|
||||
prompt_segment background default $(date "+%H:%M:%S")
|
||||
}
|
||||
|
||||
## Main prompt
|
||||
build_prompt() {
|
||||
#RETVAL=$?
|
||||
|
@ -210,8 +190,8 @@ build_prompt() {
|
|||
prompt_virtualenv
|
||||
prompt_context
|
||||
prompt_dir
|
||||
prompt_tf
|
||||
prompt_git
|
||||
prompt_hg
|
||||
prompt_end
|
||||
}
|
||||
|
||||
|
@ -220,6 +200,7 @@ build_rprompt() {
|
|||
RETVAL=$?
|
||||
prompt_status
|
||||
prompt_endr
|
||||
prompt_time
|
||||
}
|
||||
|
||||
PROMPT='%{%f%b%k%}$(build_prompt) '
|
||||
|
|
Loading…
Reference in New Issue