diff options
| -rw-r--r-- | .bash_prompt | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/.bash_prompt b/.bash_prompt index a922033..9b753b3 100644 --- a/.bash_prompt +++ b/.bash_prompt @@ -25,20 +25,27 @@ __have-gitprompt () __set-title () { - local title - local git_root=$(git root 2> /dev/null) + local title=${USER} + if __show-hostname + then + title+="@${HOSTNAME}" + fi + title+=: - if [ ${git_root} ] + local path=${PWD/~/\~} + local git_root=$(git rev-parse --show-toplevel 2> /dev/null) + + if [ -z "${git_root}" -o "${git_root}" = ~ ] then - title=$(basename ${git_root}) + title+=${path} else - local path=${PWD/~/\~} - - if __show-hostname + local project=$(basename "${git_root}") + path=$(realpath --relative-to "${git_root}" "${PWD}") + if [ "${path}" = . ] then - title="${USER}@${HOSTNAME}:${path}" + title+=${project} else - title="${USER}:${path}" + title+=${project}/${path} fi fi |
