diff options
| author | Kévin Le Gouguec <kevin.legouguec@gmail.com> | 2016-11-07 19:14:21 +0100 |
|---|---|---|
| committer | Kévin Le Gouguec <kevin.legouguec@gmail.com> | 2016-11-08 07:45:21 +0100 |
| commit | 71ec4e32028745af05c533d5a4d4b4dc687b4505 (patch) | |
| tree | 71feee5b7a5621ea24efce30caa2015299b88315 | |
| parent | ee4a279a639b9a3c543c0a72583a03a4395302b0 (diff) | |
| download | dotfiles-71ec4e32028745af05c533d5a4d4b4dc687b4505.tar.xz | |
Add "automatic" setting for hostname display
This will show the hostname when logged in over SSH.
| -rw-r--r-- | .bashprompt | 38 |
1 files changed, 33 insertions, 5 deletions
diff --git a/.bashprompt b/.bashprompt index 49869fb..5fd4d01 100644 --- a/.bashprompt +++ b/.bashprompt @@ -1,13 +1,41 @@ +# Environment variables: +# +# PS1_SHOWHOSTNAME +# 'auto' (default): Only show hostname over SSH +# 'yes': Always show hostname +# anything else: Never show hostname + + +__show-hostname () +{ + case "${PS1_SHOWHOSTNAME}" in + (''|auto) + [ "${SSH_CONNECTION}" ] + return $?;; + (yes) + return 0;; + (*) + return 1;; + esac +} + __set-title () { local title - local path=$(git root 2> /dev/null) + local git_root=$(git root 2> /dev/null) - if [ ${path} ] + if [ ${git_root} ] then - title=$(basename ${path}) + title=$(basename ${git_root}) else - title="${USER}:${PWD/~/\~}" + local path=${PWD/~/\~} + + if __show-hostname + then + title="${USER}@${HOSTNAME}:${path}" + else + title="${USER}:${path}" + fi fi echo -ne "\033]2;${title}\007" @@ -85,7 +113,7 @@ __set-prompt () PS1+=$(__fontify '\u' green) - if [ ${PS1_SHOWHOSTNAME} ] + if __show-hostname then PS1+=$(__fontify '@\H' dim green) fi |
