bash prompt: add short_path function

This commit is contained in:
masterzu 2019-01-16 12:45:35 +01:00
parent 85aacbd0c4
commit b3e1617742
1 changed files with 9 additions and 1 deletions

View File

@ -8,6 +8,8 @@
# python virtualenv
# +
# xterm dynamic title http://www.faqs.org/docs/Linux-mini/Xterm-Title.html#s2
# +
# path minimizer https://superuser.com/a/271223
#
# define PROMPT_COMMAND to prompt_func
########################################################################
@ -56,6 +58,11 @@ function _my_parse_git_branch {
# echo "DEBUG[branch:$branch|remote:$remote|state:$state]"
}
function short_path {
# print first two letters of the path + last dir
echo $(dirname $1 | sed -e "s;$HOME;~;" | sed -e "s;\(/[^/]\{1,2\}\)[^/]*;\1;g")/$(basename $1)
}
function prompt_func() {
previous_return_value=$?;
@ -90,7 +97,8 @@ function prompt_func() {
# prompt="${prompt} $(date +%X)"
# PWD
prompt="${prompt} \w"
# prompt="${prompt} \w"
prompt="${prompt} $(short_path $PWD)"
# if test $previous_return_value -eq 0
# then