Compare commits

...

3 Commits

Author SHA1 Message Date
Pavle Portic 815c19fde8
Add terraform prompt 2020-11-14 16:44:56 +01:00
Pavle Portic 1f1390148a
Remove mercurial prompt 2020-11-14 16:44:48 +01:00
Pavle Portic 4a6c728dcb
Add current time to prompt 2020-05-21 14:05:03 +02:00
1 changed files with 17 additions and 36 deletions

View File

@ -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) '