1
0
Fork 0
mirror of https://github.com/romkatv/powerlevel10k.git synced 2024-12-19 05:51:57 +00:00

Add syntax highlighting to examples in README

This commit is contained in:
Dominik Ritter 2016-11-29 23:24:15 +01:00
parent 51e1aa1b16
commit 11b8545fe2

View file

@ -76,10 +76,10 @@ variables to your `~/.zshrc`.
So if you wanted to set these variables manually, you would put the following in So if you wanted to set these variables manually, you would put the following in
your `~/.zshrc`: your `~/.zshrc`:
```zsh
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(context dir rbenv vcs) POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(context dir rbenv vcs)
POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(status history time) POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(status history time)
```
#### Available Prompt Segments #### Available Prompt Segments
The segments that are currently available are: The segments that are currently available are:
@ -198,28 +198,28 @@ The `custom_...` segment allows you to turn the output of a custom command into
a prompt segment. As an example, if you wanted to create a custom segment to a prompt segment. As an example, if you wanted to create a custom segment to
display your WiFi signal strength, you might define a custom segment called display your WiFi signal strength, you might define a custom segment called
`custom_wifi_signal` like this: `custom_wifi_signal` like this:
```zsh
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(context time battery dir vcs virtualenv custom_wifi_signal) POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(context time battery dir vcs virtualenv custom_wifi_signal)
POWERLEVEL9K_CUSTOM_WIFI_SIGNAL="echo signal: \$(nmcli device wifi | grep yes | awk '{print \$8}')" POWERLEVEL9K_CUSTOM_WIFI_SIGNAL="echo signal: \$(nmcli device wifi | grep yes | awk '{print \$8}')"
POWERLEVEL9K_CUSTOM_WIFI_SIGNAL_BACKGROUND="blue" POWERLEVEL9K_CUSTOM_WIFI_SIGNAL_BACKGROUND="blue"
POWERLEVEL9K_CUSTOM_WIFI_SIGNAL_FOREGROUND="yellow" POWERLEVEL9K_CUSTOM_WIFI_SIGNAL_FOREGROUND="yellow"
```
If you prefer, you can also define the function in your `.zshrc` rather than If you prefer, you can also define the function in your `.zshrc` rather than
putting it in-line with the variable export, as shown above. Just don't forget putting it in-line with the variable export, as shown above. Just don't forget
to invoke your function from your segment! Example code that achieves the same to invoke your function from your segment! Example code that achieves the same
result as the above: result as the above:
```zsh
zsh_wifi_signal(){
local signal=$(nmcli device wifi | grep yes | awk '{print $8}')
local color='%F{yellow}'
[[ $signal -gt 75 ]] && color='%F{green}'
[[ $signal -lt 50 ]] && color='%F{red}'
echo -n "%{$color%}\uf230 $signal%{%f%}" # \uf230 is 
}
zsh_wifi_signal(){ POWERLEVEL9K_CUSTOM_WIFI_SIGNAL="zsh_wifi_signal"
local signal=$(nmcli device wifi | grep yes | awk '{print $8}') POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(context time battery dir vcs virtualenv custom_wifi_signal)
local color='%F{yellow}' ```
[[ $signal -gt 75 ]] && color='%F{green}'
[[ $signal -lt 50 ]] && color='%F{red}'
echo -n "%{$color%}\uf230 $signal%{%f%}" # \uf230 is 
}
POWERLEVEL9K_CUSTOM_WIFI_SIGNAL="zsh_wifi_signal"
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(context time battery dir vcs virtualenv custom_wifi_signal)
The command, above, gives you the wireless signal segment shown below: The command, above, gives you the wireless signal segment shown below:
![signal](http://i.imgur.com/hviMATC.png) ![signal](http://i.imgur.com/hviMATC.png)
@ -253,11 +253,11 @@ Powerline" fonts, there are additional glyphs, as well:
| None | None | ![](https://cloud.githubusercontent.com/assets/1544760/12183452/40f79286-b58f-11e5-9b8c-ed1343a07b08.png) | Outside of your home folder | | None | None | ![](https://cloud.githubusercontent.com/assets/1544760/12183452/40f79286-b58f-11e5-9b8c-ed1343a07b08.png) | Outside of your home folder |
To turn off these icons you could set these variables to an empty string. To turn off these icons you could set these variables to an empty string.
```zsh
POWERLEVEL9K_HOME_ICON='' POWERLEVEL9K_HOME_ICON=''
POWERLEVEL9K_HOME_SUB_ICON='' POWERLEVEL9K_HOME_SUB_ICON=''
POWERLEVEL9K_FOLDER_ICON='' POWERLEVEL9K_FOLDER_ICON=''
```
You can limit the output to a certain length by truncating long paths. You can limit the output to a certain length by truncating long paths.
Customizations available are: Customizations available are:
@ -269,11 +269,11 @@ Customizations available are:
For example, if you wanted the truncation behavior of the `fish` shell, which For example, if you wanted the truncation behavior of the `fish` shell, which
truncates `/usr/share/plasma` to `/u/s/plasma`, you would use the following: truncates `/usr/share/plasma` to `/u/s/plasma`, you would use the following:
```zsh
POWERLEVEL9K_SHORTEN_DIR_LENGTH=1 POWERLEVEL9K_SHORTEN_DIR_LENGTH=1
POWERLEVEL9K_SHORTEN_DELIMITER="" POWERLEVEL9K_SHORTEN_DELIMITER=""
POWERLEVEL9K_SHORTEN_STRATEGY="truncate_from_right" POWERLEVEL9K_SHORTEN_STRATEGY="truncate_from_right"
```
In each case you have to specify the length you want to shorten the directory In each case you have to specify the length you want to shorten the directory
to. So in some cases `POWERLEVEL9K_SHORTEN_DIR_LENGTH` means characters, in to. So in some cases `POWERLEVEL9K_SHORTEN_DIR_LENGTH` means characters, in
others whole directories. others whole directories.
@ -343,16 +343,16 @@ See [Unit Test Ratios](#unit-test-ratios), below.
|`POWERLEVEL9K_TIME_FORMAT`|`'H:M:S'`|ZSH time format to use in this segment.| |`POWERLEVEL9K_TIME_FORMAT`|`'H:M:S'`|ZSH time format to use in this segment.|
As an example, if you wanted a reversed time format, you would use this: As an example, if you wanted a reversed time format, you would use this:
```zsh
# Reversed time format # Reversed time format
POWERLEVEL9K_TIME_FORMAT='%D{%S:%M:%H}' POWERLEVEL9K_TIME_FORMAT='%D{%S:%M:%H}'
```
If you are using an "Awesome Powerline Font", you can add a time symbol to this If you are using an "Awesome Powerline Font", you can add a time symbol to this
segment, as well: segment, as well:
```zsh
# 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}"
```
##### 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