dotfiles

🎜 Clone'em, tweak'em, stick'em in your $HOME 🎝
git clone https://git.kevinlegouguec.net/dotfiles
Log | Files | Refs | README

commit 5ac43c1b2a921fd2745f0d9945279f14c240ae89
parent ce9b3d4d27268e5123535f348ea3f0f8f553f972
Author: KΓ©vin Le Gouguec <kevin.legouguec@gmail.com>
Date:   Tue, 27 Apr 2021 22:52:25 +0200

Tweak window title for terminal emulators

Diffstat:
M.bash_prompt | 25++++++++++++++++---------
1 file changed, 16 insertions(+), 9 deletions(-)

diff --git 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