Differents colors for differents hosts you SSH in
Adds the LP_ENABLE_SSH_COLORS option to use a numeric hash of the hostname as the displayed color.
This commit is contained in:
parent
3d711323d5
commit
0ee5944f79
13
README.md
13
README.md
@ -26,9 +26,9 @@ in a git repository on a server, at branch "myb":
|
|||||||
|
|
||||||
`1r [user@server:~/liquidprompt] 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:
|
It displays:
|
||||||
|
|
||||||
@ -48,9 +48,9 @@ any;
|
|||||||
terminal multiplexer (screen or tmux);
|
terminal multiplexer (screen or tmux);
|
||||||
* the current user, in bold yellow if it is root, in light white if it is not
|
* the current user, in bold yellow if it is root, in light white if it is not
|
||||||
the same as the login user;
|
the same as the login user;
|
||||||
* a blue @ if the connection has X11 support;
|
* a green @ if the connection has X11 support, a yellow one if not;
|
||||||
* the current host, if you are connected via an SSH or telnet connection, with
|
* the current host, if you are connected via a telnet connection (in bold red)
|
||||||
different colors for each case;
|
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 green colon if the user has write permissions on the current directory,
|
||||||
a red one if he has not;
|
a red one if he has not;
|
||||||
* the current directory in bold, shortened if it takes too much space, while
|
* 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;
|
* the current Python virtual environment, if any;
|
||||||
* an up arrow if an HTTP proxy is in use;
|
* an up arrow if an HTTP proxy is in use;
|
||||||
* the name of the current branch if you are in a version control repository
|
* 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
|
to date, in red if there is changes, in yellow if there is pending
|
||||||
commits to push;
|
commits to push;
|
||||||
* the number of added/deleted lines (git) or files (fossil), if
|
* 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_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_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_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
|
Note that if required commands are not installed, enabling the
|
||||||
corresponding feature will have no effect.
|
corresponding feature will have no effect.
|
||||||
|
16
liquidprompt
16
liquidprompt
@ -216,6 +216,7 @@ _lp_source_config()
|
|||||||
LP_ENABLE_VCS_ROOT=${LP_ENABLE_VCS_ROOT:-0}
|
LP_ENABLE_VCS_ROOT=${LP_ENABLE_VCS_ROOT:-0}
|
||||||
LP_ENABLE_TITLE=${LP_ENABLE_TITLE:-0}
|
LP_ENABLE_TITLE=${LP_ENABLE_TITLE:-0}
|
||||||
LP_ENABLE_SCREEN_TITLE=${LP_ENABLE_SCREEN_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_DISABLED_VCS_PATH=${LP_DISABLED_VCS_PATH:-""}
|
||||||
|
|
||||||
LP_MARK_BATTERY=${LP_MARK_BATTERY:-"⌁"}
|
LP_MARK_BATTERY=${LP_MARK_BATTERY:-"⌁"}
|
||||||
@ -384,7 +385,20 @@ lcl)
|
|||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
ssh)
|
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)
|
tel)
|
||||||
LP_HOST="${LP_HOST}${LP_COLOR_TELNET}${_LP_HOST_SYMBOL}${NO_COL}"
|
LP_HOST="${LP_HOST}${LP_COLOR_TELNET}${_LP_HOST_SYMBOL}${NO_COL}"
|
||||||
|
@ -100,6 +100,9 @@ LP_ENABLE_TITLE=0
|
|||||||
# Enable Title for screen and byobu
|
# Enable Title for screen and byobu
|
||||||
LP_ENABLE_SCREEN_TITLE=0
|
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
|
# Specify a list of complete and colon (":") separated paths in which, all vcs
|
||||||
# will be disabled
|
# will be disabled
|
||||||
LP_DISABLED_VCS_PATH=""
|
LP_DISABLED_VCS_PATH=""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user