From 1fd8816784ea51df2c1a990d3273fca8cc923038 Mon Sep 17 00:00:00 2001 From: Fernando Schauenburg Date: Tue, 19 Jul 2016 12:22:27 +0200 Subject: [PATCH] [bash] add user & host to prompt string The color of the user and host changes when the session takes place over SSH. This makes it easier to identify to which machine a terminal is connected. --- bash_profile | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/bash_profile b/bash_profile index 6daed1c..36ea6c8 100644 --- a/bash_profile +++ b/bash_profile @@ -133,14 +133,9 @@ do_solarize_shell() { fi # Customize the prompt - if [ "$BACKGROUND" = "light" ]; then - prompt_color="\[\033[0;36m\]" # cyan - else - prompt_color="\[\033[0;34m\]" # blue - fi - git_prompt='$(__git_ps1 "%s ")' - export PS1="\n[${prompt_color}\w\[\033[0m\]]\n${git_prompt}\$ "; - export PS2=". "; + [ -n "$SSH_CLIENT" ] && __c="0;33" || __c="0;36" + export PS1="\n[\[\033[${__c}m\]\u@\h \[\033[0;34m\]\w\[\033[0m\]]\n$(__git_ps1 '%s ')\$ " + export PS2=". " # Customize colors for `ls` command ls_colors="$HOME/.dircolors/solarized-$BACKGROUND"