From 762f7a7aa582d2efa301d12778d6e98cd4e5681b Mon Sep 17 00:00:00 2001 From: Dominik Ritter Date: Sun, 22 Mar 2015 17:13:48 +0100 Subject: [PATCH 1/4] Better installation instructions. --- README.md | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 5fc09a94..2fbb1103 100644 --- a/README.md +++ b/README.md @@ -41,19 +41,15 @@ here](https://powerline.readthedocs.org/en/latest/installation/linux.html#fonts- You can also find the raw font files [in this Github repository](https://github.com/powerline/fonts). -To install this theme, drop the `.zsh-theme` file into your `.oh-my-zsh/themes` -directory. A better form of installation is to clone this repository and then -create a symlink in your 'themes' directory: +To install this theme, drop the `.zsh-theme` file into your `.oh-my-zsh/custom/themes` +directory: - $ git clone https://github.com/bhilburn/powerlevel9k.git powerlevel9k.git - $ ln -s powerlevel9k.git/powerlevel9k.zsh-theme ~/.oh-my-zsh/themes/powerlevel9k.zsh-theme - -Note that *you cannot clone this repository into your `~/.oh-my-zsh/themes/` directory*. -Oh-My-Zsh does not traverse subdirectories for themes, and will not find your theme. + $ cd ~/.oh-my-zsh/custom/themes + $ git clone https://github.com/bhilburn/powerlevel9k.git powerlevel9k You then need to select it in your `~/.zshrc`: - ZSH_THEME="powerlevel9k" + ZSH_THEME="powerlevel9k/powerlevel9k" If you do not want to display the `user@host` string, you should also put this in your `~/.zshrc`: From d3125e8b6fe90d0c8dd28bcc1d8a2d64d49d8e4e Mon Sep 17 00:00:00 2001 From: Dominik Ritter Date: Sun, 22 Mar 2015 20:10:09 +0100 Subject: [PATCH 2/4] All elements can now be on each side. For better customization, you can add an array of elements in your zshrc: POWERLEVEL9K_LEFT_PROMPT_ELEMENTS POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS --- README.md | 8 ++++++++ powerlevel9k.zsh-theme | 44 +++++++++++++++++++++++++----------------- 2 files changed, 34 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 5fc09a94..62707906 100644 --- a/README.md +++ b/README.md @@ -60,6 +60,14 @@ in your `~/.zshrc`: export DEFAULT_USER= +### Customization + +You can choose, which segments are shown on each side. Just add the following variables to +your `~/.zshrc`: + + POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(context dir git) + POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(status history time) + ### Bugs / Contact If you have any requests or bug reports, please use the tracker in this Github diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 21bb9b40..51eaab5f 100644 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -91,7 +91,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 - left_prompt_segment black default "%(!.%{%F{yellow}%}.)$USER@%m" + $1_prompt_segment black default "%(!.%{%F{yellow}%}.)$USER@%m" fi } @@ -102,9 +102,9 @@ prompt_git() { if $(git rev-parse --is-inside-work-tree >/dev/null 2>&1); then dirty=$(parse_git_dirty) if [[ -n $dirty ]]; then - left_prompt_segment yellow black + $1_prompt_segment yellow black else - left_prompt_segment green black + $1_prompt_segment green black fi echo -n "${vcs_info_msg_0_}" @@ -162,7 +162,7 @@ function +vi-git-tagname() { # Dir: current working directory prompt_dir() { - left_prompt_segment blue black '%~' + $1_prompt_segment blue black '%~' } # Virtualenv: current working virtualenv @@ -171,7 +171,7 @@ prompt_dir() { prompt_virtualenv() { local virtualenv_path="$VIRTUAL_ENV" if [[ -n $virtualenv_path && -n $VIRTUAL_ENV_DISABLE_PROMPT ]]; then - left_prompt_segment blue black "(`basename $virtualenv_path`)" + $1_prompt_segment blue black "(`basename $virtualenv_path`)" fi } @@ -184,13 +184,13 @@ prompt_status() { [[ $UID -eq 0 ]] && symbols+="%{%F{yellow}%}⚡" [[ $(jobs -l | wc -l) -gt 0 ]] && symbols+="%{%F{cyan}%}⚙" - [[ -n "$symbols" ]] && left_prompt_segment black default "$symbols" + [[ -n "$symbols" ]] && $1_prompt_segment black default "$symbols" } # Right Status: (return code, root status, background jobs) # This creates a status segment for the *right* prompt. Exact same thing as # above - just other side. -rprompt_status() { +prompt_longstatus() { local symbols bg symbols=() @@ -205,17 +205,17 @@ rprompt_status() { [[ $UID -eq 0 ]] && symbols+="%{%F{yellow}%}⚡" [[ $(jobs -l | wc -l) -gt 0 ]] && symbols+="%{%F{cyan}%}⚙" - [[ -n "$symbols" ]] && right_prompt_segment $bg default "$symbols" + [[ -n "$symbols" ]] && $1_prompt_segment $bg default "$symbols" } # System time prompt_time() { - right_prompt_segment white black '%D{%H:%M:%S} ' + $1_prompt_segment white black '%D{%H:%M:%S} ' } # Command number (in local history) prompt_history() { - right_prompt_segment "244" black '%h' + $1_prompt_segment "244" black '%h' } # Ruby Version Manager information @@ -229,20 +229,28 @@ prompt_rvm() { # Main prompt build_left_prompt() { - #prompt_virtualenv - prompt_context - prompt_dir - prompt_git - #prompt_rvm + if (( ${#POWERLEVEL9K_LEFT_PROMPT_ELEMENTS} == 0 )); then + POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(context dir git) + fi + + for element in $POWERLEVEL9K_LEFT_PROMPT_ELEMENTS; do + prompt_$element "left" + done + left_prompt_end } # Right prompt build_right_prompt() { RETVAL=$? - rprompt_status - prompt_history - prompt_time + + if (( ${#POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS} == 0 )); then + POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(longstatus history time) + fi + + for element in $POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS; do + prompt_$element "right" + done } # Create the prompts From db9b607b0e3691bfa07b9c875186d1f10d78e9e9 Mon Sep 17 00:00:00 2001 From: Dominik Ritter Date: Sun, 22 Mar 2015 20:15:33 +0100 Subject: [PATCH 3/4] rvm-prompt is now customizable too.. --- powerlevel9k.zsh-theme | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 51eaab5f..02a9d875 100644 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -223,7 +223,7 @@ prompt_rvm() { local rvm_prompt rvm_prompt=`rvm-prompt` if [ "$rvm_prompt" != "" ]; then - left_prompt_segment "240" white "$rvm_prompt " + $1_prompt_segment "240" white "$rvm_prompt " fi } From 4a9886c25b338fcb7db511c0d2698a73516e69ca Mon Sep 17 00:00:00 2001 From: Ben Hilburn Date: Sun, 22 Mar 2015 12:55:27 -0700 Subject: [PATCH 4/4] Minor cleanup of whitespace and README --- README.md | 5 +++-- powerlevel9k.zsh-theme | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index e034f9ca..4a9f4c45 100644 --- a/README.md +++ b/README.md @@ -58,8 +58,9 @@ in your `~/.zshrc`: ### Customization -You can choose, which segments are shown on each side. Just add the following variables to -your `~/.zshrc`: +You can choose which segments are shown on each side. Just add the following variables to +your `~/.zshrc`. The below also shows the default settings if you don't define +your own. POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(context dir git) POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(status history time) diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 02a9d875..954454a2 100644 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -5,7 +5,7 @@ # # This theme was inspired by agnoster's Theme: # https://gist.github.com/3712874 -# +# # The `vcs_info` hooks in this file are from Tom Upton: # https://github.com/tupton/dotfiles/blob/master/zsh/zshrc # @@ -236,7 +236,7 @@ build_left_prompt() { for element in $POWERLEVEL9K_LEFT_PROMPT_ELEMENTS; do prompt_$element "left" done - + left_prompt_end }