summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.bashprompt38
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