From 1002a482d3e8098386f73e40d3dfbaa955f389b2 Mon Sep 17 00:00:00 2001 From: Buddy Sandidge Date: Mon, 19 Nov 2012 13:17:57 -0800 Subject: [PATCH] Add support for changing hostname color --- bash/functions | 13 +++++++++++++ bash/prompt | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/bash/functions b/bash/functions index c382937..bc243e7 100644 --- a/bash/functions +++ b/bash/functions @@ -49,3 +49,16 @@ function get-bitrate { echo `exiftool -AudioBitrate "$1" | awk '{print $4}'`": $1" } +function _hostname-color { + case `whoami` in + 'bsandidge') echo $blue;; + 'buddy') echo $blue;; + 'root') echo $bred;; + *) echo $purple;; + esac +} + +function _hostname-show { + hostname -s | tr '[A-Z]' '[a-z]' +} + diff --git a/bash/prompt b/bash/prompt index 4a45e65..b44395c 100644 --- a/bash/prompt +++ b/bash/prompt @@ -1,7 +1,7 @@ #!/usr/bin/env bash # display hostname -PS1="\[$blue\]«\h»" +PS1="\[$(_hostname-color)\]«"'$(_hostname-show)'"»" # display separator PS1="$PS1\[$yellow\]⚡" # display current path