Powerlevel9k is a theme for ZSH which uses Powerline Fonts. It can be used with vanilla ZSH or ZSH frameworks such as Oh-My-Zsh, Prezto, Antigen, and many others.
Get more out of your terminal. Be a badass. Impress everyone in 'Screenshot Your Desktop' threads. Use powerlevel9k.
You can check out some other users' configurations in our wiki: Show Off Your Config.
There are a number of Powerline ZSH themes available, now. The developers of this theme focus on four primary goals:
- Give users a great out-of-the-box configuration with no additional configuration required.
- Make customization easy for users who do want to tweak their prompt.
- Provide useful segments that you can enable to make your prompt even more effective and helpful. We have prompt segments for everything from unit test coverage to your AWS instance.
- Optimize the code for execution speed as much as possible. A snappy terminal is a happy terminal.
Powerlevel9k can be used to create both very useful and beautiful terminal environments:
Be sure to also check out the Wiki!
There are two installation steps to go from a vanilla terminal to a PL9k terminal. Once you are done, you can optionally customize your prompt.
No configuration is necessary post-installation if you like the default settings, but there are plenty of segment customization options available if you are interested.
Be sure to check out the wiki page on the additional prompt customization options, including color and icon settings: Stylizing Your Prompt
Customizing your prompt is easy! Select the segments you want to have displayed,
and then assign them to either the left or right prompt by adding the following
variables to your ~/.zshrc
.
Variable | Default Value | Description |
---|---|---|
P9K_LEFT_PROMPT_ELEMENTS |
(context dir vcs) |
Segment list for left prompt |
P9K_RIGHT_PROMPT_ELEMENTS |
(status root_indicator background_jobs history time) |
Segment list for right prompt |
The table above shows the default values, so if you wanted to set these
variables manually, you would put the following in
your ~/.zshrc
:
P9K_LEFT_PROMPT_ELEMENTS=(context dir vcs)
P9K_RIGHT_PROMPT_ELEMENTS=(status root_indicator background_jobs history time)
The segments that are currently available are:
System Status Segments:
background_jobs
- Indicator for background jobs.battery
- Current battery status.context
- Your username and host, conditionalized based on $USER and SSH status.date
- System date.dir
- Your current working directory.dir_writable
- Displays a lock icon, if you do not have write permissions on the current folder.disk_usage
- Disk usage of your current partition.history
- The command number for the current line.host
- Your current host nameip
- Shows the current IP address.vpn_ip
- Shows the current VPN IP address.public_ip
- Shows your public IP address.load
- Your machine's load averages.os_icon
- Display a nice little icon, depending on your operating system.ram
- Show free RAM.root_indicator
- An indicator if the user has superuser status.status
- The return code of the previous command.swap
- Prints the current swap size.time
- System time.user
- Your current usernamevi_mode
- Your prompt's Vi editing mode (NORMAL|INSERT).ssh
- Indicates whether or not you are in an SSH session.
Development Environment Segments:
gitstatus
- Information about thisgit
repository (if you are in one).vcs
- Information about thisgit
orhg
repository (if you are in one).
Language Segments:
- GoLang Segments:
go_version
- Show the current GO version.
- Javascript / Node.js Segments:
node_version
- Show the version number of the installed Node.js.nodeenv
- nodeenv prompt for displaying node version and environment name.nvm
- Show the version of Node that is currently active, if it differs from the version used by NVM
- PHP Segments:
php_version
- Show the current PHP version.laravel_version
- Show the current Laravel version.symfony2_tests
- Show a ratio of test classes vs code classes for Symfony2.symfony2_version
- Show the current Symfony2 version, if you are in a Symfony2-Project dir.
- Python Segments:
virtualenv
- Your Python VirtualEnv.anaconda
- Your active Anaconda environment.pyenv
- Your active python version as reported by the first word ofpyenv version
. Note that the segment is not displayed if that word is system i.e. the segment is inactive if you are using system python.
- Ruby Segments:
chruby
- Ruby environment information usingchruby
(if one is active).rbenv
- Ruby environment information usingrbenv
(if one is active).rspec_stats
- Show a ratio of test classes vs code classes for RSpec.rvm
- Ruby environment information using$GEM_HOME
and$MY_RUBY_HOME
(if one is active).
- Rust Segments:
rust_version
- Display the current rust version and logo.
- Swift Segments:
swift_version
- Show the version number of the installed Swift.
- Java Segments:
java_version
- Show the current Java version.
- Haskell Segments:
stack_project
- Show if you are in a Haskell Stack project directory.
Cloud Segments:
- AWS Segments:
aws
- The current AWS profile, if active.aws_eb_env
- The current Elastic Beanstalk Environment.
docker_machine
- The current Docker Machine.kubecontext
- The current context of yourkubectl
configuration.dropbox
- Indicates Dropbox directory and syncing status usingdropbox-cli
Other:
custom_command
- Create a custom segment to display the output of an arbitrary command.command_execution_time
- Display the time the current command took to execute.todo
- Shows the number of tasks in your todo.txt tasks file.detect_virt
- Virtualization detection with systemdnewline
- Continues the prompt on a new line.openfoam
- Shows the currently sourced OpenFOAM environment.vagrant
- Detects if you are in a folder with a running VM.
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
display your WiFi signal strength, you might define a custom segment called
custom_wifi_signal
like this:
P9K_LEFT_PROMPT_ELEMENTS=(context time battery dir vcs virtualenv custom_wifi_signal)
P9K_CUSTOM_WIFI_SIGNAL="echo signal: \$(nmcli device wifi | grep yes | awk '{print \$8}')"
P9K_CUSTOM_WIFI_SIGNAL_BACKGROUND="blue"
P9K_CUSTOM_WIFI_SIGNAL_FOREGROUND="yellow"
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
to invoke your function from your segment! Example code that achieves the same
result as the above:
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
}
P9K_CUSTOM_WIFI_SIGNAL="zsh_wifi_signal"
P9K_LEFT_PROMPT_ELEMENTS=(context time battery dir vcs virtualenv custom_wifi_signal)
The command, above, gives you the wireless signal segment shown below:
You can define as many custom segments as you wish. If you think you have a segment that others would find useful, please consider upstreaming it to the main theme distribution so that everyone can use it!
You can disable P9k and return to a very basic prompt at any time simply by calling:
$ prompt_powerlevel9k_teardown
You can then re-enable it by calling:
$ prompt_powerlevel9k_setup
Want to just get a quick start? Check out the Show Off Your Config portion of the wiki to get going.
The Wiki also has a ton of other useful information!
Project: MIT
Logo: CC-BY-SA. Source repository: https://github.com/bhilburn/powerlevel9k-logo