diff options
-rw-r--r-- | README.md | 50 | ||||
-rw-r--r-- | powerlevel9k.zsh-theme | 79 |
2 files changed, 96 insertions, 33 deletions
@@ -22,6 +22,9 @@ information. * Shows system time in right-prompt * Indicates background jobs with a gear * Will conditionally display the `user@host` string +* Plenty of other segments you can enable if you want them (e.g., ruby, AWS) +* Can be used as a single or double-lined prompt (see screenshots below) +* Several built-in color configurations to choose from **If you would like an OMZ theme that provides most of the same features but doesn't require Powerline fonts, check out the sister font, @@ -47,25 +50,26 @@ To install this theme, clone this repository into your Oh-My-Zsh `custom/themes` directory. $ cd ~/.oh-my-zsh/custom - $ mkdir themes # if it doesn't already exist - $ git clone https://github.com/bhilburn/powerlevel9k.git powerlevel9k + $ git clone https://github.com/bhilburn/powerlevel9k.git themes/powerlevel9k You then need to select this theme in your `~/.zshrc`: ZSH_THEME="powerlevel9k/powerlevel9k" -### Customization +### Segment Customization -You can choose which segments are shown on each side. The segments that are +Customizing your prompt is easy! Select the segments you want to have displayed, +and then assign them to either the left or right prompt. The segments that are currently available are: -* **context** - Your username and host. +* **aws** - The current AWS profile, if active (more info below) +* **context** - Your username and host (more info below) * **dir** - Your current working directory. -* **vcs** - Information about this `git` or `hg` repository (if you are in one). +* **history** - The command number for the current line. * **rbenv** - Ruby environment information (if one is active). * **status** - The return code of the previous command, and status of background jobs. -* **history** - The command number for the current line. * **time** - System time. +* **vcs** - Information about this `git` or `hg` repository (if you are in one). To specify which segments you want, just add the following variables to your `~/.zshrc`. If you don't customize this, the below configuration is the default: @@ -78,7 +82,16 @@ If you want to show the current changeset in a `git` or `hg` repository, enable POWERLEVEL9K_SHOW_CHANGESET=true -#### Conditional 'context' +#### The AWS Profile Segment + +If you would like to display the [current AWS +profile](http://docs.aws.amazon.com/cli/latest/userguide/installing.html), add +the `aws` segment to one of the prompts, and define `AWS_DEFAULT_PROFILE` in +your `~/.zshrc`: + + export AWS_DEFAULT_PROFILE=<profile_name> + +#### The 'context' Segment The `context` segment (user@host string) is conditional. This lets you enable it, but only display it if you are not your normal user or on a remote host (basically, only print it @@ -89,6 +102,27 @@ elements (it is by default), and define a `DEFAULT_USER` in your `~/.zshrc`: export DEFAULT_USER=<your username> +<<<<<<< HEAD +### Styling + +You can configure the look and feel of your prompt easily with some built-in +options. + +#### Double-Lined Prompt + +By default, `powerlevel9k` is a single-lined prompt. If you would like to have +the segments display on one line, and print the command prompt below it, simply +define `POWERLEVEL9K_PROMPT_ON_NEWLINE` in your `~/.zshrc`: + + export POWERLEVEL9K_PROMPT_ON_NEWLINE=true + +#### Light Color Theme + +If you prefer to use "light" colors, simply set `POWERLEVEL9K_COLOR_SCHEME` +to `light` in your `~/.zshrc`, and you're all set! + + POWERLEVEL9K_COLOR_SCHEME='light' + #### Solarized colors If you want your terminal colors not so bright, you may want to use an alternate diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 870c503e..55056bf1 100644 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -29,7 +29,22 @@ VCS_UNSTAGED_ICON='●' VCS_STAGED_ICON='✚' ################################################################ -# vcs_info settings for git +# color scheme +################################################################ + +local DEFAULT_COLOR DEFAULT_COLOR_INVERTED DEFAULT_COLOR_DARK +if [[ $POWERLEVEL9K_COLOR_SCHEME == "light" ]]; then + DEFAULT_COLOR=white + DEFAULT_COLOR_INVERTED=black + DEFAULT_COLOR_DARK="252" +else + DEFAULT_COLOR=black + DEFAULT_COLOR_INVERTED=white + DEFAULT_COLOR_DARK="236" +fi + +################################################################ +# VCS Information Settings ################################################################ setopt prompt_subst @@ -39,17 +54,17 @@ local VCS_WORKDIR_DIRTY=false local VCS_CHANGESET_PREFIX='' if [ $POWERLEVEL9K_SHOW_CHANGESET ]; then # Just display the first 12 characters of our changeset-ID. - VCS_CHANGESET_PREFIX='%12.12i@' + VCS_CHANGESET_PREFIX="%F{$DEFAULT_COLOR_DARK}%12.12i@%f" fi zstyle ':vcs_info:*' enable git hg zstyle ':vcs_info:*' check-for-changes true -zstyle ':vcs_info:*' formats " $VCS_CHANGESET_PREFIX%b%c%u%m" +zstyle ':vcs_info:*' formats " $VCS_CHANGESET_PREFIX%F{$DEFAULT_COLOR}%b%c%u%m%f" zstyle ':vcs_info:*' actionformats " %b %F{red}| %a%f" -zstyle ':vcs_info:*' stagedstr " %F{black}$VCS_STAGED_ICON%f" -zstyle ':vcs_info:*' unstagedstr " %F{black}$VCS_UNSTAGED_ICON%f" +zstyle ':vcs_info:*' stagedstr " %F{$DEFAULT_COLOR}$VCS_STAGED_ICON%f" +zstyle ':vcs_info:*' unstagedstr " %F{$DEFAULT_COLOR}$VCS_UNSTAGED_ICON%f" zstyle ':vcs_info:git*+set-message:*' hooks git-untracked git-aheadbehind git-remotebranch git-tagname @@ -120,7 +135,7 @@ right_prompt_segment() { # Note that if $DEFAULT_USER is not set, this prompt segment will always print prompt_context() { if [[ "$USER" != "$DEFAULT_USER" || -n "$SSH_CLIENT" ]]; then - $1_prompt_segment black default "%(!.%{%F{yellow}%}.)$USER@%m" + $1_prompt_segment $DEFAULT_COLOR "011" "%(!.%{%F{yellow}%}.)$USER@%m" fi } @@ -130,19 +145,19 @@ prompt_vcs() { if [[ -n $vcs_prompt ]]; then if ( $VCS_WORKDIR_DIRTY ); then - $1_prompt_segment yellow black + $1_prompt_segment yellow $DEFAULT_COLOR else - $1_prompt_segment green black + $1_prompt_segment green $DEFAULT_COLOR fi - echo -n "$vcs_prompt" + echo -n "%F{$DEFAULT_COLOR}%f$vcs_prompt" fi } function +vi-git-untracked() { if [[ $(git rev-parse --is-inside-work-tree 2> /dev/null) == 'true' && \ $(git ls-files --others --exclude-standard | sed q | wc -l | tr -d ' ') != 0 ]]; then - hook_com[unstaged]+=" %F{black}?%f" + hook_com[unstaged]+=" %F{$DEFAULT_COLOR}?%f" fi } @@ -155,12 +170,12 @@ function +vi-git-aheadbehind() { # for git prior to 1.7 # ahead=$(git rev-list origin/${branch_name}..HEAD | wc -l) ahead=$(git rev-list ${branch_name}@{upstream}..HEAD 2>/dev/null | wc -l | tr -d ' ') - (( $ahead )) && gitstatus+=( " %F{black}↑${ahead}%f" ) + (( $ahead )) && gitstatus+=( " %F{$DEFAULT_COLOR}↑${ahead}%f" ) # for git prior to 1.7 # behind=$(git rev-list HEAD..origin/${branch_name} | wc -l) behind=$(git rev-list HEAD..${branch_name}@{upstream} 2>/dev/null | wc -l | tr -d ' ') - (( $behind )) && gitstatus+=( " %F{black}↓${behind}%f" ) + (( $behind )) && gitstatus+=( " %F{$DEFAULT_COLOR}↓${behind}%f" ) hook_com[misc]+=${(j::)gitstatus} } @@ -172,12 +187,12 @@ function +vi-git-remotebranch() { remote=${$(git rev-parse --verify HEAD@{upstream} --symbolic-full-name 2>/dev/null)/refs\/(remotes|heads)\/} branch_name=${$(git symbolic-ref --short HEAD 2>/dev/null)} - hook_com[branch]="%F{black}${hook_com[branch]}%f" + hook_com[branch]="%F{$DEFAULT_COLOR}${hook_com[branch]}%f" # Always show the remote #if [[ -n ${remote} ]] ; then # Only show the remote if it differs from the local if [[ -n ${remote} && ${remote#*/} != ${branch_name} ]] ; then - hook_com[branch]+="%F{black}→%f%F{black}${remote}%f" + hook_com[branch]+="%F{$DEFAULT_COLOR}→%f%F{$DEFAULT_COLOR}${remote}%f" fi } @@ -185,7 +200,7 @@ function +vi-git-tagname() { local tag tag=$(git describe --tags --exact-match HEAD 2>/dev/null) - [[ -n ${tag} ]] && hook_com[branch]=" %F{black}${tag}%f" + [[ -n ${tag} ]] && hook_com[branch]=" %F{$DEFAULT_COLOR}${tag}%f" } function +vi-vcs-detect-changes() { @@ -198,16 +213,16 @@ function +vi-vcs-detect-changes() { # Dir: current working directory prompt_dir() { - $1_prompt_segment blue black '%~' + $1_prompt_segment blue $DEFAULT_COLOR '%~' } # Virtualenv: current working virtualenv # More information on virtualenv (Python): -# https://virtualenv.pypa.io/en/latest/virtualenv.html +# https://virtualenv.pypa.io/en/latest/ prompt_virtualenv() { local virtualenv_path="$VIRTUAL_ENV" if [[ -n $virtualenv_path && -n $VIRTUAL_ENV_DISABLE_PROMPT ]]; then - $1_prompt_segment blue black "(`basename $virtualenv_path`)" + $1_prompt_segment blue $DEFAULT_COLOR "(`basename $virtualenv_path`)" fi } @@ -220,7 +235,7 @@ prompt_status() { [[ $UID -eq 0 ]] && symbols+="%{%F{yellow}%}⚡" [[ $(jobs -l | wc -l) -gt 0 ]] && symbols+="%{%F{cyan}%}⚙" - [[ -n "$symbols" ]] && $1_prompt_segment black default "$symbols" + [[ -n "$symbols" ]] && $1_prompt_segment $DEFAULT_COLOR default "$symbols" } # Right Status: (return code, root status, background jobs) @@ -241,17 +256,17 @@ prompt_longstatus() { [[ $UID -eq 0 ]] && symbols+="%{%F{yellow}%}⚡" [[ $(jobs -l | wc -l) -gt 0 ]] && symbols+="%{%F{cyan}%}⚙" - [[ -n "$symbols" ]] && $1_prompt_segment $bg default "$symbols" + [[ -n "$symbols" ]] && $1_prompt_segment $bg $DEFAULT_COLOR "$symbols" } # System time prompt_time() { - $1_prompt_segment white black '%D{%H:%M:%S} ' + $1_prompt_segment $DEFAULT_COLOR_INVERTED $DEFAULT_COLOR '%D{%H:%M:%S} ' } # Command number (in local history) prompt_history() { - $1_prompt_segment "244" black '%h' + $1_prompt_segment "244" $DEFAULT_COLOR '%h' } # Ruby Version Manager information @@ -259,14 +274,23 @@ prompt_rvm() { local rvm_prompt rvm_prompt=`rvm-prompt` if [ "$rvm_prompt" != "" ]; then - $1_prompt_segment "240" white "$rvm_prompt " + $1_prompt_segment "240" $DEFAULT_COLOR "$rvm_prompt " fi } # rbenv information prompt_rbenv() { if [[ -n "$RBENV_VERSION" ]]; then - $1_prompt_segment red black "$RBENV_VERSION" + $1_prompt_segment red $DEFAULT_COLOR "$RBENV_VERSION" + fi +} + +# AWS Profile +prompt_aws() { + local aws_profile=$AWS_DEFAULT_PROFILE + if [[ -n $aws_profile ]]; + then + $1_prompt_segment red white "AWS: $aws_profile" fi } @@ -304,5 +328,10 @@ precmd() { vcs_info_hookadd set-message vcs-detect-changes } -PROMPT='%{%f%b%k%}$(build_left_prompt) ' +if [ $POWERLEVEL9K_PROMPT_ON_NEWLINE ] ; then + PROMPT='╭─%{%f%b%k%}$(build_left_prompt) +╰─ ' +else + PROMPT='%{%f%b%k%}$(build_left_prompt) ' +fi RPROMPT='%{%f%b%k%}$(build_right_prompt)%{$reset_color%}' |