diff --git a/README.md b/README.md index d345203..363e490 100644 --- a/README.md +++ b/README.md @@ -26,9 +26,9 @@ in a git repository on a server, at branch "myb": `1r [user@server:~/liquidprompt] myb ± ` -A liquid prompt displaying everything may look like this: +A liquid prompt displaying everything (a rare event!) may look like this: -`⌁24% ⌂42% 3d/2&/1z [user@server:~/ … /code/liquidprompt]↥ master(+10/-5,3)* 125 ± ` +`code ⌁24% ⌂42% 3d/2&/1z [user@server:~/ … /code/liquidprompt]↥ master(+10/-5,3)*+ 125 ± ` It displays: @@ -48,9 +48,9 @@ any; terminal multiplexer (screen or tmux); * the current user, in bold yellow if it is root, in light white if it is not the same as the login user; -* a blue @ if the connection has X11 support; -* the current host, if you are connected via an SSH or telnet connection, with -different colors for each case; +* a green @ if the connection has X11 support, a yellow one if not; +* the current host, if you are connected via a telnet connection (in bold red) +or SSH (either a blue hostname or differents colors for different hosts); * a green colon if the user has write permissions on the current directory, a red one if he has not; * the current directory in bold, shortened if it takes too much space, while @@ -58,7 +58,7 @@ preserving the first two directories; * the current Python virtual environment, if any; * an up arrow if an HTTP proxy is in use; * the name of the current branch if you are in a version control repository -(git, mercurial, subversion or fossil), in green if everything is up +(git, mercurial, subversion, bazaar or fossil), in green if everything is up to date, in red if there is changes, in yellow if there is pending commits to push; * the number of added/deleted lines (git) or files (fossil), if @@ -138,6 +138,7 @@ building: * `LP_ENABLE_VCS_ROOT`, if you want to show VCS informations with root account * `LP_ENABLE_TITLE`, if you want to use the prompt as your terminal window's title * `LP_ENABLE_SCREEN_TITLE`, if you want to use the prompt as your screen window's title +* `LP_ENABLE_SSH_COLORS`, if you want different colors for hosts you SSH in Note that if required commands are not installed, enabling the corresponding feature will have no effect. diff --git a/liquidprompt b/liquidprompt index 0785fc5..a152884 100755 --- a/liquidprompt +++ b/liquidprompt @@ -216,6 +216,7 @@ _lp_source_config() LP_ENABLE_VCS_ROOT=${LP_ENABLE_VCS_ROOT:-0} LP_ENABLE_TITLE=${LP_ENABLE_TITLE:-0} LP_ENABLE_SCREEN_TITLE=${LP_ENABLE_SCREEN_TITLE:-0} + LP_ENABLE_SSH_COLORS=${LP_ENABLE_SSH_COLORS:-0} LP_DISABLED_VCS_PATH=${LP_DISABLED_VCS_PATH:-""} LP_MARK_BATTERY=${LP_MARK_BATTERY:-"⌁"} @@ -384,7 +385,20 @@ lcl) fi ;; ssh) - LP_HOST="${LP_HOST}${LP_COLOR_SSH}${_LP_HOST_SYMBOL}${NO_COL}" + # If we want a different color for each host + if [[ "$LP_ENABLE_SSH_COLORS" ]]; then + # compute the hash of the hostname + # and get the corresponding number in [1-6] (red,green,yellow,blue,purple or cyan) + # FIXME check portability of cksum and add more formats (bold? 256 colors?) + hash=$(( 1 + $(hostname | cksum | cut -d " " -f 1) % 6 )) + color=${_LP_OPEN_ESC}$(ti_setaf $hash)${_LP_CLOSE_ESC} + LP_HOST="${LP_HOST}${color}${_LP_HOST_SYMBOL}${NO_COL}" + unset hash + unset color + else + # the same color for all hosts + LP_HOST="${LP_HOST}${LP_COLOR_SSH}${_LP_HOST_SYMBOL}${NO_COL}" + fi ;; tel) LP_HOST="${LP_HOST}${LP_COLOR_TELNET}${_LP_HOST_SYMBOL}${NO_COL}" diff --git a/liquidpromptrc-dist b/liquidpromptrc-dist index 731d2ce..32b11dc 100644 --- a/liquidpromptrc-dist +++ b/liquidpromptrc-dist @@ -100,6 +100,9 @@ LP_ENABLE_TITLE=0 # Enable Title for screen and byobu LP_ENABLE_SCREEN_TITLE=0 +# Use differents colors for differents hosts you SSH in +LP_ENABLE_SSH_COLORS=0 + # Specify a list of complete and colon (":") separated paths in which, all vcs # will be disabled LP_DISABLED_VCS_PATH=""