mirror of
https://github.com/romkatv/powerlevel10k.git
synced 2024-11-11 00:00:06 +00:00
host and user segments
This commit is contained in:
parent
37174ea911
commit
59e64c9051
3 changed files with 109 additions and 1 deletions
|
@ -18,6 +18,11 @@ A new script `debug/font-issues.zsh` was added, so that problems with your font
|
||||||
|
|
||||||
The `ram` segment now shows the available ram instead of free.
|
The `ram` segment now shows the available ram instead of free.
|
||||||
|
|
||||||
|
### Add new segments `host` and `user`
|
||||||
|
|
||||||
|
The user and host segments allow you to have different icons and colors for both the user and host segments
|
||||||
|
depending on their state.
|
||||||
|
|
||||||
## v0.6.0
|
## v0.6.0
|
||||||
|
|
||||||
- Fixed a bug where the tag display was broken on detached HEADs.
|
- Fixed a bug where the tag display was broken on detached HEADs.
|
||||||
|
|
48
README.md
48
README.md
|
@ -92,6 +92,7 @@ The segments that are currently available are:
|
||||||
* `dir_writable` - Displays a lock icon, if you do not have write permissions on the current folder.
|
* `dir_writable` - Displays a lock icon, if you do not have write permissions on the current folder.
|
||||||
* [`disk_usage`](#disk_usage) - Disk usage of your current partition.
|
* [`disk_usage`](#disk_usage) - Disk usage of your current partition.
|
||||||
* `history` - The command number for the current line.
|
* `history` - The command number for the current line.
|
||||||
|
* [`host`](#host) - Your current host name
|
||||||
* [`ip`](#ip) - Shows the current IP address.
|
* [`ip`](#ip) - Shows the current IP address.
|
||||||
* [`public_ip`](#public_ip) - Shows your public IP address.
|
* [`public_ip`](#public_ip) - Shows your public IP address.
|
||||||
* `load` - Your machine's load averages.
|
* `load` - Your machine's load averages.
|
||||||
|
@ -101,6 +102,7 @@ The segments that are currently available are:
|
||||||
* [`status`](#status) - The return code of the previous command.
|
* [`status`](#status) - The return code of the previous command.
|
||||||
* `swap` - Prints the current swap size.
|
* `swap` - Prints the current swap size.
|
||||||
* [`time`](#time) - System time.
|
* [`time`](#time) - System time.
|
||||||
|
* [`user`](#user) - Your current username
|
||||||
* [`vi_mode`](#vi_mode)- Your prompt's Vi editing mode (NORMAL|INSERT).
|
* [`vi_mode`](#vi_mode)- Your prompt's Vi editing mode (NORMAL|INSERT).
|
||||||
* `ssh` - Indicates whether or not you are in an SSH session.
|
* `ssh` - Indicates whether or not you are in an SSH session.
|
||||||
|
|
||||||
|
@ -354,6 +356,35 @@ The `disk_usage` segment will show the usage level of the partition that your cu
|
||||||
|POWERLEVEL9K_DISK_USAGE_WARNING_LEVEL|90|The usage level that triggers a warning state.|
|
|POWERLEVEL9K_DISK_USAGE_WARNING_LEVEL|90|The usage level that triggers a warning state.|
|
||||||
|POWERLEVEL9K_DISK_USAGE_CRITICAL_LEVEL|95|The usage level that triggers a critical state.|
|
|POWERLEVEL9K_DISK_USAGE_CRITICAL_LEVEL|95|The usage level that triggers a critical state.|
|
||||||
|
|
||||||
|
##### host
|
||||||
|
|
||||||
|
The `host` segment (host string) will print the hostname. You can customize the `host` segment.
|
||||||
|
For example, you can make it to print the full hostname by setting
|
||||||
|
```
|
||||||
|
POWERLEVEL9K_HOST_TEMPLATE="`hostname -f`"
|
||||||
|
```
|
||||||
|
|
||||||
|
You can also modify the COLOURS for the two states - LOCAL and REMOTE, by setting
|
||||||
|
```
|
||||||
|
POWERLEVEL9K_HOST_LOCAL_BACKGROUND="green"
|
||||||
|
POWERLEVEL9K_HOST_LOCAL_FOREGROUND="white"
|
||||||
|
POWERLEVEL9K_HOST_REMOTE_BACKGROUND="red"
|
||||||
|
POWERLEVEL9K_HOST_REMOTE_FOREGROUND="yellow"
|
||||||
|
```
|
||||||
|
|
||||||
|
Currently, LOCAL hosts will show the host icon and remote hosts will show the SSH icon. You can override them by setting
|
||||||
|
```
|
||||||
|
POWERLEVEL9K_HOST_ICON="\uF109 " #
|
||||||
|
POWERLEVEL9K_SSH_ICON="\uF489 " #
|
||||||
|
```
|
||||||
|
|
||||||
|
You can set the `POWERLEVEL9K_HOST_TEMPLATE` variable to change how the hostname is displayed.
|
||||||
|
See (ZSH Manual)[http://zsh.sourceforge.net/Doc/Release/Prompt-Expansion.html#Login-information]
|
||||||
|
for details. The default is set to %m which will show the hostname up to the first ‘.’
|
||||||
|
You can set it to %{N}m where N is an integer to show that many segments of system
|
||||||
|
hostname. Setting N to a negative integer will show that many segments from the
|
||||||
|
end of the hostname.
|
||||||
|
|
||||||
##### ip
|
##### ip
|
||||||
|
|
||||||
This segment tries to examine all currently used network interfaces and prints
|
This segment tries to examine all currently used network interfaces and prints
|
||||||
|
@ -436,6 +467,23 @@ segment, as well:
|
||||||
# Output time, date, and a symbol from the "Awesome Powerline Font" set
|
# Output time, date, and a symbol from the "Awesome Powerline Font" set
|
||||||
POWERLEVEL9K_TIME_FORMAT="%D{%H:%M:%S \uE868 %d.%m.%y}"
|
POWERLEVEL9K_TIME_FORMAT="%D{%H:%M:%S \uE868 %d.%m.%y}"
|
||||||
```
|
```
|
||||||
|
##### user
|
||||||
|
|
||||||
|
The `user` segment (user string) will print the username. You can customize the `user` segment.
|
||||||
|
For example, you can modify the COLOURS for the two states - DEFAULT and ROOT, by setting
|
||||||
|
```
|
||||||
|
POWERLEVEL9K_USER_DEFAULT_BACKGROUND="green"
|
||||||
|
POWERLEVEL9K_USER_DEFAULT_FOREGROUND="white"
|
||||||
|
POWERLEVEL9K_USER_ROOT_BACKGROUND="red"
|
||||||
|
POWERLEVEL9K_USER_ROOT_FOREGROUND="yellow"
|
||||||
|
```
|
||||||
|
|
||||||
|
You can also override the icons by setting
|
||||||
|
```
|
||||||
|
POWERLEVEL9K_USER_ICON="\uF415" #
|
||||||
|
POWERLEVEL9K_ROOT_ICON="#"
|
||||||
|
```
|
||||||
|
|
||||||
##### vcs
|
##### vcs
|
||||||
|
|
||||||
By default, the `vcs` segment will provide quite a bit of information. Further
|
By default, the `vcs` segment will provide quite a bit of information. Further
|
||||||
|
|
|
@ -567,6 +567,61 @@ prompt_context() {
|
||||||
"$1_prompt_segment" "${0}_${current_state}" "$2" "$DEFAULT_COLOR" "${context_states[$current_state]}" "${content}"
|
"$1_prompt_segment" "${0}_${current_state}" "$2" "$DEFAULT_COLOR" "${context_states[$current_state]}" "${content}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
################################################################
|
||||||
|
# User: user (who am I)
|
||||||
|
# Note that if $DEFAULT_USER is not set, this prompt segment will always print
|
||||||
|
set_default POWERLEVEL9K_USER_TEMPLATE "%n"
|
||||||
|
prompt_user() {
|
||||||
|
local current_state="DEFAULT"
|
||||||
|
typeset -AH user_state
|
||||||
|
if [[ "$POWERLEVEL9K_ALWAYS_SHOW_CONTEXT" == true ]] || [[ "$USER" != "$DEFAULT_USER" ]] || [[ -n "$SSH_CLIENT" || -n "$SSH_TTY" ]]; then
|
||||||
|
if [[ $(print -P "%#") == '#' ]]; then
|
||||||
|
user_state=(
|
||||||
|
"STATE" "ROOT"
|
||||||
|
"CONTENT" "${POWERLEVEL9K_USER_TEMPLATE}"
|
||||||
|
"BACKGROUND_COLOR" "${DEFAULT_COLOR}"
|
||||||
|
"FOREGROUND_COLOR" "yellow"
|
||||||
|
"VISUAL_IDENTIFIER" "ROOT_ICON"
|
||||||
|
)
|
||||||
|
elif [[ "$POWERLEVEL9K_ALWAYS_SHOW_USER" == true ]]; then
|
||||||
|
user_state=(
|
||||||
|
"STATE" "DEFAULT"
|
||||||
|
"CONTENT" "$USER"
|
||||||
|
"BACKGROUND_COLOR" "${DEFAULT_COLOR}"
|
||||||
|
"FOREGROUND_COLOR" "011"
|
||||||
|
"VISUAL_IDENTIFIER" "USER_ICON"
|
||||||
|
)
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
"$1_prompt_segment" "${0}_${user_state[STATE]}" "$2" "${user_state[BACKGROUND_COLOR]}" "${user_state[FOREGROUND_COLOR]}" "${user_state[CONTENT]}" "${user_state[VISUAL_IDENTIFIER]}"
|
||||||
|
}
|
||||||
|
|
||||||
|
################################################################
|
||||||
|
# Host: machine (where am I)
|
||||||
|
set_default POWERLEVEL9K_HOST_TEMPLATE "%m"
|
||||||
|
prompt_host() {
|
||||||
|
local current_state="LOCAL"
|
||||||
|
typeset -AH host_state
|
||||||
|
if [[ -n "$SSH_CLIENT" ]] || [[ -n "$SSH_TTY" ]]; then
|
||||||
|
host_state=(
|
||||||
|
"STATE" "REMOTE"
|
||||||
|
"CONTENT" "${POWERLEVEL9K_HOST_TEMPLATE}"
|
||||||
|
"BACKGROUND_COLOR" "${DEFAULT_COLOR}"
|
||||||
|
"FOREGROUND_COLOR" "yellow"
|
||||||
|
"VISUAL_IDENTIFIER" "SSH_ICON"
|
||||||
|
)
|
||||||
|
else
|
||||||
|
host_state=(
|
||||||
|
"STATE" "LOCAL"
|
||||||
|
"CONTENT" "${POWERLEVEL9K_HOST_TEMPLATE}"
|
||||||
|
"BACKGROUND_COLOR" "${DEFAULT_COLOR}"
|
||||||
|
"FOREGROUND_COLOR" "011"
|
||||||
|
"VISUAL_IDENTIFIER" "HOST_ICON"
|
||||||
|
)
|
||||||
|
fi
|
||||||
|
"$1_prompt_segment" "$0_${host_state[STATE]}" "$2" "${host_state[BACKGROUND_COLOR]}" "${host_state[FOREGROUND_COLOR]}" "${host_state[CONTENT]}" "${host_state[VISUAL_IDENTIFIER]}"
|
||||||
|
}
|
||||||
|
|
||||||
# The 'custom` prompt provides a way for users to invoke commands and display
|
# The 'custom` prompt provides a way for users to invoke commands and display
|
||||||
# the output in a segment.
|
# the output in a segment.
|
||||||
prompt_custom() {
|
prompt_custom() {
|
||||||
|
|
Loading…
Reference in a new issue