From d01d718bd6da4446d528262192e78fcfa6a9ebed Mon Sep 17 00:00:00 2001 From: Dominik Ritter Date: Wed, 27 May 2015 21:03:02 +0200 Subject: [PATCH 01/12] Modified code to work with prezto. --- powerlevel9k.zsh-theme | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index d1e927c8..b7157f75 100644 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -423,17 +423,29 @@ build_right_prompt() { done } -precmd() { +prompt_powerlevel9k_precmd() { vcs_info # Add a static hook to examine staged/unstaged changes. vcs_info_hookadd set-message vcs-detect-changes } -if [[ "$POWERLEVEL9K_PROMPT_ON_NEWLINE" == true ]]; 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%}' +powerlevel9k_init() { + setopt LOCAL_OPTIONS + unsetopt XTRACE KSH_ARRAYS + prompt_opts=(cr percent subst) + + autoload -Uz add-zsh-hook + + add-zsh-hook precmd prompt_powerlevel9k_precmd + + if [[ "$POWERLEVEL9K_PROMPT_ON_NEWLINE" == true ]]; 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%}" +} + +powerlevel9k_init "$@" From 77024543f2fd6afd013a2fc340c9315ad360eeb5 Mon Sep 17 00:00:00 2001 From: Dominik Ritter Date: Thu, 28 May 2015 00:36:40 +0200 Subject: [PATCH 02/12] Added documentation. --- README.md | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 2c3f2a2d..d2f7be39 100644 --- a/README.md +++ b/README.md @@ -56,7 +56,9 @@ emulator the Powerline font you want to use. #### Install Powerlevel9k -To install this theme, clone this repository into your Oh-My-Zsh `custom/themes` +##### Within Oh-my-ZSH + +To install this theme, clone this repository into your [Oh-my-Zsh](https://github.com/robbyrussell/oh-my-zsh) `custom/themes` directory. $ cd ~/.oh-my-zsh/custom @@ -66,6 +68,19 @@ You then need to select this theme in your `~/.zshrc`: ZSH_THEME="powerlevel9k/powerlevel9k" +##### With Prezto + +To install this theme, clone this repository into your [Prezto](https://github.com/sorin-ionescu/prezto) `prompt/external` +directory. + + $ cd ~.zprezto/modules/prompt/external + $ git clone https://github.com/bhilburn/powerlevel9k.git + $ ln -s powerlevel9k/powerlevel9k.zsh-theme ../functions/prompt_powerlevel9k_setup + +You then need to select this theme in your `~/.zpreztorc`: + + zstyle ':prezto:module:prompt' theme 'powerlevel9k' + ### Segment Customization Customizing your prompt is easy! Select the segments you want to have displayed, From 6f22892fb77dd8021aee262848bcc301d4ff44f9 Mon Sep 17 00:00:00 2001 From: Dominik Ritter Date: Fri, 29 May 2015 23:56:31 +0200 Subject: [PATCH 03/12] Variable scoping. --- powerlevel9k.zsh-theme | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index b7157f75..3016f443 100644 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -46,7 +46,7 @@ # The `CURRENT_BG` variable is used to remember what the last BG color used was # when building the left-hand prompt. Because the RPROMPT is created from # right-left but reads the opposite, this isn't necessary for the other side. -CURRENT_BG='NONE' +local CURRENT_BG='NONE' # These characters require the Powerline fonts to work properly. If see boxes or # bizarre characters below, your fonts are not correctly installed. From eb5b9f7c1b4d848aa1e5292dc8d39905ff884b23 Mon Sep 17 00:00:00 2001 From: Dominik Ritter Date: Sat, 30 May 2015 00:00:05 +0200 Subject: [PATCH 04/12] Better compatibility with prezto. --- powerlevel9k.zsh-theme | 118 +++++++++++++++++++++-------------------- 1 file changed, 61 insertions(+), 57 deletions(-) diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 3016f443..8536f0cc 100644 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -60,7 +60,7 @@ VCS_STAGED_ICON='✚' ################################################################ local DEFAULT_COLOR DEFAULT_COLOR_INVERTED DEFAULT_COLOR_DARK -if [[ $POWERLEVEL9K_COLOR_SCHEME == "light" ]]; then +if [[ "$POWERLEVEL9K_COLOR_SCHEME" == "light" ]]; then DEFAULT_COLOR=white DEFAULT_COLOR_INVERTED=black DEFAULT_COLOR_DARK="252" @@ -82,8 +82,8 @@ local VCS_CHANGESET_PREFIX='' if [[ "$POWERLEVEL9K_SHOW_CHANGESET" == true ]]; then # Default: Just display the first 12 characters of our changeset-ID. local VCS_CHANGESET_HASH_LENGTH=12 - if [[ -n $POWERLEVEL9K_CHANGESET_HASH_LENGTH ]]; then - VCS_CHANGESET_HASH_LENGTH=$POWERLEVEL9K_CHANGESET_HASH_LENGTH + if [[ -n "$POWERLEVEL9K_CHANGESET_HASH_LENGTH" ]]; then + VCS_CHANGESET_HASH_LENGTH="$POWERLEVEL9K_CHANGESET_HASH_LENGTH" fi VCS_CHANGESET_PREFIX="%F{$DEFAULT_COLOR_DARK}%0.$VCS_CHANGESET_HASH_LENGTH""i@%f" @@ -125,27 +125,27 @@ fi # Begin a left prompt segment # Takes two arguments, background and foreground. Both can be omitted, # rendering default background/foreground. -left_prompt_segment() { +function left_prompt_segment { local bg fg - [[ -n $1 ]] && bg="%K{$1}" || bg="%k" - [[ -n $2 ]] && fg="%F{$2}" || fg="%f" - if [[ $CURRENT_BG != 'NONE' && $1 != $CURRENT_BG ]]; then - echo -n "%{$bg%F{$CURRENT_BG}%}$LEFT_SEGMENT_SEPARATOR%{$fg%} " + [[ -n "$1" ]] && bg="%K{$1}" || bg="%k" + [[ -n "$2" ]] && fg="%F{$2}" || fg="%f" + if [[ "$CURRENT_BG" != 'NONE' && "$1" != "$CURRENT_BG" ]]; then + echo -n "$bg%F{$CURRENT_BG}$LEFT_SEGMENT_SEPARATOR$fg " else - echo -n "%{$bg%}%{$fg%} " + echo -n "$bg$fg " fi - CURRENT_BG=$1 - [[ -n $3 ]] && echo -n $3 + CURRENT_BG="$1" + [[ -n "$3" ]] && echo -n "$3" } # End the left prompt, closing any open segments -left_prompt_end() { - if [[ -n $CURRENT_BG ]]; then - echo -n " %{%k%F{$CURRENT_BG}%}$LEFT_SEGMENT_SEPARATOR" +function left_prompt_end { + if [[ -n "$CURRENT_BG" ]]; then + echo -n " %k%F{$CURRENT_BG}$LEFT_SEGMENT_SEPARATOR" else - echo -n " %{%k%}" + echo -n "%k" fi - echo -n "%{%f%}" + echo -n "%f" CURRENT_BG='' } @@ -153,12 +153,12 @@ left_prompt_end() { # Takes two arguments, background and foreground. Both can be omitted, # rendering default background/foreground. No ending for the right prompt # segment is needed (unlike the left prompt, above). -right_prompt_segment() { +function right_prompt_segment { local bg fg - [[ -n $1 ]] && bg="%K{$1}" || bg="%k" - [[ -n $2 ]] && fg="%F{$2}" || fg="%f" + [[ -n "$1" ]] && bg="%K{$1}" || bg="%k" + [[ -n "$2" ]] && fg="%F{$2}" || fg="%f" echo -n " %f%F{$1}$RIGHT_SEGMENT_SEPARATOR%f%{$bg%}%{$fg%} " - [[ -n $3 ]] && echo -n $3 + [[ -n "$3" ]] && echo -n "$3" } ################################################################ @@ -167,11 +167,11 @@ right_prompt_segment() { prompt_vcs() { local vcs_prompt="${vcs_info_msg_0_}" - if [[ -n $vcs_prompt ]]; then + if [[ -n "$vcs_prompt" ]]; then if [[ "$VCS_WORKDIR_DIRTY" == true ]]; then - $1_prompt_segment yellow $DEFAULT_COLOR + $1_prompt_segment "yellow" "$DEFAULT_COLOR" else - $1_prompt_segment green $DEFAULT_COLOR + $1_prompt_segment "green" "$DEFAULT_COLOR" fi echo -n "%F{$DEFAULT_COLOR}%f$vcs_prompt" @@ -224,7 +224,7 @@ function +vi-git-tagname() { local tag tag=$(git describe --tags --exact-match HEAD 2>/dev/null) - [[ -n ${tag} ]] && hook_com[branch]=" %F{$DEFAULT_COLOR}${tag}%f" + [[ -n "${tag}" ]] && hook_com[branch]=" %F{$DEFAULT_COLOR}${tag}%f" } # Show count of stashed changes @@ -251,7 +251,7 @@ function +vi-hg-bookmarks() { } function +vi-vcs-detect-changes() { - if [[ -n ${hook_com[staged]} ]] || [[ -n ${hook_com[unstaged]} ]]; then + if [[ -n "${hook_com[staged]}" ]] || [[ -n "${hook_com[unstaged]}" ]]; then VCS_WORKDIR_DIRTY=true else VCS_WORKDIR_DIRTY=false @@ -264,8 +264,8 @@ function +vi-vcs-detect-changes() { # AWS Profile prompt_aws() { - local aws_profile=$AWS_DEFAULT_PROFILE - if [[ -n $aws_profile ]]; + local aws_profile="$AWS_DEFAULT_PROFILE" + if [[ -n "$aws_profile" ]]; then $1_prompt_segment red white "AWS: $aws_profile" fi @@ -275,18 +275,18 @@ prompt_aws() { # 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 $DEFAULT_COLOR "011" "%(!.%{%F{yellow}%}.)$USER@%m" + $1_prompt_segment "$DEFAULT_COLOR" "011" "%(!.%F{yellow}.)$USER@%m" fi } # Dir: current working directory prompt_dir() { - $1_prompt_segment blue $DEFAULT_COLOR '%~' + $1_prompt_segment "blue" "$DEFAULT_COLOR" '%~' } # Command number (in local history) prompt_history() { - $1_prompt_segment "244" $DEFAULT_COLOR '%h' + $1_prompt_segment "244" "$DEFAULT_COLOR" '%h' } # Right Status: (return code, root status, background jobs) @@ -296,24 +296,24 @@ prompt_longstatus() { local symbols bg symbols=() - if [[ $RETVAL -ne 0 ]]; then - symbols+="%{%F{"226"}%}%? ↵" + if [[ "$RETVAL" -ne 0 ]]; then + symbols+="%F{226}%? ↵" bg="009" else - symbols+="%{%F{"046"}%}✓" + symbols+="%F{046}✓" bg="008" fi - [[ $UID -eq 0 ]] && symbols+="%{%F{yellow}%}⚡" - [[ $(jobs -l | wc -l) -gt 0 ]] && symbols+="%{%F{cyan}%}⚙" + [[ "$UID" -eq 0 ]] && symbols+="%F{yellow}⚡" + [[ $(jobs -l | wc -l) -gt 0 ]] && symbols+="%F{cyan}⚙" - [[ -n "$symbols" ]] && $1_prompt_segment $bg $DEFAULT_COLOR "$symbols" + [[ -n "$symbols" ]] && $1_prompt_segment "$bg" "$DEFAULT_COLOR" "$symbols" } # rbenv information prompt_rbenv() { if [[ -n "$RBENV_VERSION" ]]; then - $1_prompt_segment red $DEFAULT_COLOR "$RBENV_VERSION" + $1_prompt_segment "red" "$DEFAULT_COLOR" "$RBENV_VERSION" fi } @@ -323,7 +323,7 @@ prompt_rspec_stats() { local code_amount=$(ls -1 app/**/*.rb | wc -l) local tests_amount=$(ls -1 spec/**/*.rb | wc -l) - build_test_stats $1 $code_amount $tests_amount "RSpec" + build_test_stats "$1" "$code_amount" "$tests_amount" "RSpec" fi } @@ -332,7 +332,7 @@ prompt_rvm() { local rvm_prompt rvm_prompt=`rvm-prompt` if [ "$rvm_prompt" != "" ]; then - $1_prompt_segment "240" $DEFAULT_COLOR "$rvm_prompt " + $1_prompt_segment "240" "$DEFAULT_COLOR" "$rvm_prompt " fi } @@ -341,11 +341,11 @@ prompt_rvm() { prompt_status() { local symbols symbols=() - [[ $RETVAL -ne 0 ]] && symbols+="%{%F{red}%}✘" - [[ $UID -eq 0 ]] && symbols+="%{%F{yellow}%}⚡" + [[ "$RETVAL" -ne 0 ]] && symbols+="%{%F{red}%}✘" + [[ "$UID" -eq 0 ]] && symbols+="%{%F{yellow}%}⚡" [[ $(jobs -l | wc -l) -gt 0 ]] && symbols+="%{%F{cyan}%}⚙" - [[ -n "$symbols" ]] && $1_prompt_segment $DEFAULT_COLOR default "$symbols" + [[ -n "$symbols" ]] && $1_prompt_segment "$DEFAULT_COLOR" "default" "$symbols" } # Symfony2-PHPUnit test ratio @@ -354,33 +354,33 @@ prompt_symfony2_tests() { local code_amount=$(ls -1 src/**/*.php | grep -v Tests | wc -l) local tests_amount=$(ls -1 src/**/*.php | grep Tests | wc -l) - build_test_stats $1 $code_amount $tests_amount "SF2-Tests" + build_test_stats "$1" "$code_amount" "$tests_amount" "SF2-Tests" fi } # Show a ratio of tests vs code build_test_stats() { - local code_amount=$2 - local tests_amount=$3+0.00001 - local headline=$4 + local code_amount="$2" + local tests_amount="$3"+0.00001 + local headline="$4" # Set float precision to 2 digits: typeset -F 2 ratio local ratio=$(( (tests_amount/code_amount) * 100 )) - [[ ratio -ge 0.75 ]] && $1_prompt_segment cyan $DEFAULT_COLOR "$headline: $ratio%%" - [[ ratio -ge 0.5 && ratio -lt 0.75 ]] && $1_prompt_segment yellow $DEFAULT_COLOR "$headline: $ratio%%" - [[ ratio -lt 0.5 ]] && $1_prompt_segment red $DEFAULT_COLOR "$headline: $ratio%%" + [[ ratio -ge 0.75 ]] && $1_prompt_segment "cyan" "$DEFAULT_COLOR" "$headline: $ratio%%" + [[ ratio -ge 0.5 && ratio -lt 0.75 ]] && $1_prompt_segment "yellow" "$DEFAULT_COLOR" "$headline: $ratio%%" + [[ ratio -lt 0.5 ]] && $1_prompt_segment "red" "$DEFAULT_COLOR" "$headline: $ratio%%" } # System time prompt_time() { - local time_format='%D{%H:%M:%S}' - if [[ -n $POWERLEVEL9K_TIME_FORMAT ]]; then - time_format=$POWERLEVEL9K_TIME_FORMAT + local time_format="%D{%H:%M:%S}" + if [[ -n "$POWERLEVEL9K_TIME_FORMAT" ]]; then + time_format="$POWERLEVEL9K_TIME_FORMAT" fi - $1_prompt_segment $DEFAULT_COLOR_INVERTED $DEFAULT_COLOR "$time_format " + $1_prompt_segment "$DEFAULT_COLOR_INVERTED" "$DEFAULT_COLOR" "$time_format " } # Virtualenv: current working virtualenv @@ -388,8 +388,8 @@ prompt_time() { # 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 $DEFAULT_COLOR "(`basename $virtualenv_path`)" + if [[ -n "$virtualenv_path" && -n "$VIRTUAL_ENV_DISABLE_PROMPT" ]]; then + $1_prompt_segment "blue" "$DEFAULT_COLOR" "(`basename $virtualenv_path`)" fi } @@ -399,7 +399,7 @@ prompt_virtualenv() { # Main prompt build_left_prompt() { - if [[ ${#POWERLEVEL9K_LEFT_PROMPT_ELEMENTS} == 0 ]]; then + if [[ "${#POWERLEVEL9K_LEFT_PROMPT_ELEMENTS}" == 0 ]]; then POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(context dir rbenv vcs) fi @@ -414,7 +414,7 @@ build_left_prompt() { build_right_prompt() { RETVAL=$? - if [[ ${#POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS} == 0 ]]; then + if [[ "${#POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS}" == 0 ]]; then POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(longstatus history time) fi @@ -435,6 +435,10 @@ powerlevel9k_init() { unsetopt XTRACE KSH_ARRAYS prompt_opts=(cr percent subst) + # initialize colors + autoload -U colors && colors + + # initialize VCS autoload -Uz add-zsh-hook add-zsh-hook precmd prompt_powerlevel9k_precmd From 4ad6080d319696dc241791bb5ca3f70db42a135e Mon Sep 17 00:00:00 2001 From: Dominik Ritter Date: Wed, 10 Jun 2015 02:31:36 +0200 Subject: [PATCH 05/12] Added a testing environment in form of a virtual machine. --- .gitignore | 1 + test-vm/README.md | 25 ++++++++++++++ test-vm/Vagrantfile | 82 ++++++++++++++++++++++++++++++++++++++++++++ test-vm/antigen.sh | 27 +++++++++++++++ test-vm/bootstrap.sh | 9 +++++ test-vm/omz.sh | 30 ++++++++++++++++ test-vm/plain.sh | 7 ++++ test-vm/prezto.sh | 27 +++++++++++++++ 8 files changed, 208 insertions(+) create mode 100644 .gitignore create mode 100644 test-vm/README.md create mode 100644 test-vm/Vagrantfile create mode 100644 test-vm/antigen.sh create mode 100644 test-vm/bootstrap.sh create mode 100644 test-vm/omz.sh create mode 100644 test-vm/plain.sh create mode 100644 test-vm/prezto.sh diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..8f6423fa --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +test-vm/.vagrant diff --git a/test-vm/README.md b/test-vm/README.md new file mode 100644 index 00000000..9f0861e9 --- /dev/null +++ b/test-vm/README.md @@ -0,0 +1,25 @@ +# Test-VM for powerlevel9k + +In this virtual machine you will find a recent ubuntu with preinstalled ZSH, oh-my-zsh, antigen, prezto and - of course - powerlevel9k. The main use-case is to test the powerlevel9k theme. + +## Installation + +In order to run this virtual machine, you need [vagrant](https://www.vagrantup.com/) and [VirtualBox](http://www.virtualbox.org/). + +## Running + +`vagrant` is a quite easy to use command line tool to configure a virtual machine. To fire the machine up, just run `vagrant up`. At the first run, it will install a whole ubuntu. With `vagrant ssh` you can log in into the machine. + +## Testing + +Once you have SSH'd into the machine, you'll see a plain ZSH. To test the other frameworks, you just have to switch to one of the following users: + + * `vagrant-antigen` + * `vagrant-prezto` + * `vagrant-omz` + +To switch use `sudo -i -H -u `. `-i` stands for "simulate initial login", `-H` sets the "$HOME" variable to the directory of the user , `-u` for the username. + +All users have `vagrant` as password and are in the /etc/sudoers. + +The regular `vagrant` user has a plain ZSH with the powerlevel9k theme. diff --git a/test-vm/Vagrantfile b/test-vm/Vagrantfile new file mode 100644 index 00000000..a526b54b --- /dev/null +++ b/test-vm/Vagrantfile @@ -0,0 +1,82 @@ +# -*- mode: ruby -*- +# vi: set ft=ruby : + +# All Vagrant configuration is done below. The "2" in Vagrant.configure +# configures the configuration version (we support older styles for +# backwards compatibility). Please don't change it unless you know what +# you're doing. +Vagrant.configure(2) do |config| + # The most common configuration options are documented and commented below. + # For a complete reference, please see the online documentation at + # https://docs.vagrantup.com. + + # Every Vagrant development environment requires a box. You can search for + # boxes at https://atlas.hashicorp.com/search. + config.vm.box = "ubuntu/precise64" + + # Bootstrap +# config.vm.provision :shell, path: "bootstrap.sh", privileged: false +# config.vm.provision :shell, path: "plain.sh" +# config.vm.provision :shell, path: "antigen.sh" +# config.vm.provision :shell, path: "prezto.sh" + config.vm.provision :shell, path: "omz.sh" + + # Disable automatic box update checking. If you disable this, then + # boxes will only be checked for updates when the user runs + # `vagrant box outdated`. This is not recommended. + # config.vm.box_check_update = false + + # Create a forwarded port mapping which allows access to a specific port + # within the machine from a port on the host machine. In the example below, + # accessing "localhost:8080" will access port 80 on the guest machine. + # config.vm.network "forwarded_port", guest: 80, host: 8080 + + # Create a private network, which allows host-only access to the machine + # using a specific IP. + # config.vm.network "private_network", ip: "192.168.33.10" + + # Create a public network, which generally matched to bridged network. + # Bridged networks make the machine appear as another physical device on + # your network. + # config.vm.network "public_network" + + # Share an additional folder to the guest VM. The first argument is + # the path on the host to the actual folder. The second argument is + # the path on the guest to mount the folder. And the optional third + # argument is a set of non-required options. + # config.vm.synced_folder "../data", "/vagrant_data" + + # Provider-specific configuration so you can fine-tune various + # backing providers for Vagrant. These expose provider-specific options. + # Example for VirtualBox: + + config.vm.provider "virtualbox" do |vb| + + # Change name to "powerlevel9k" + vb.name = "powerlevel9k" + + # Display the VirtualBox GUI when booting the machine + #vb.gui = true + + # Customize the amount of memory on the VM: + vb.memory = "256" + end + # + # View the documentation for the provider you are using for more + # information on available options. + + # Define a Vagrant Push strategy for pushing to Atlas. Other push strategies + # such as FTP and Heroku are also available. See the documentation at + # https://docs.vagrantup.com/v2/push/atlas.html for more information. + # config.push.define "atlas" do |push| + # push.app = "YOUR_ATLAS_USERNAME/YOUR_APPLICATION_NAME" + # end + + # Enable provisioning with a shell script. Additional provisioners such as + # Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the + # documentation for more information about their specific syntax and use. + # config.vm.provision "shell", inline: <<-SHELL + # sudo apt-get update + # sudo apt-get install -y apache2 + # SHELL +end diff --git a/test-vm/antigen.sh b/test-vm/antigen.sh new file mode 100644 index 00000000..1ad71af4 --- /dev/null +++ b/test-vm/antigen.sh @@ -0,0 +1,27 @@ +#!/usr/bin/zsh +# We need to run this script in ZSH, so that switching user works! +NEW_USER=vagrant-antigen +# Create User +PASSWORD='$6$OgLg9v2Z$Db38Jr9inZG7y8BzL8kqFK23fF5jZ7FU1oiIBLFjNYR9XVX03fwQayMgA6Rm1rzLbXaf.gkZaTWhB9pv5XLq11' +sudo useradd -p $PASSWORD -g vagrant -s $(which zsh) -m $NEW_USER +echo "$NEW_USER ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers.d/$NEW_USER +chmod 440 /etc/sudoers.d/$NEW_USER + +( + # Change User (See http://unix.stackexchange.com/questions/86778/why-cant-we-execute-a-list-of-commands-as-different-user-without-sudo) + USERNAME=$NEW_USER + #UID=$(id -u $NEW_USER) + #EUID=$(id -u $NEW_USER) + HOME=/home/$NEW_USER + + echo " +source ~/antigen/antigen.zsh\n +antigen theme bhilburn/powerlevel9k powerlevel9k\n +antigen apply +" > ~/.zshrc + + # install antigen + mkdir ~/antigen + curl -qL https://raw.githubusercontent.com/zsh-users/antigen/master/antigen.zsh > ~/antigen/antigen.zsh + source ~/antigen/antigen.zsh +) diff --git a/test-vm/bootstrap.sh b/test-vm/bootstrap.sh new file mode 100644 index 00000000..9651c4eb --- /dev/null +++ b/test-vm/bootstrap.sh @@ -0,0 +1,9 @@ +#!/bin/sh + +#sudo apt-get update + +sudo apt-get install -y curl +sudo apt-get install -y git + +sudo apt-get install -y zsh +sudo chsh -s $(which zsh) vagrant diff --git a/test-vm/omz.sh b/test-vm/omz.sh new file mode 100644 index 00000000..aeb5f897 --- /dev/null +++ b/test-vm/omz.sh @@ -0,0 +1,30 @@ +#!/usr/bin/zsh +# We need to run this script in ZSH, so that switching user works! +NEW_USER=vagrant-omz +# Create User +PASSWORD='$6$OgLg9v2Z$Db38Jr9inZG7y8BzL8kqFK23fF5jZ7FU1oiIBLFjNYR9XVX03fwQayMgA6Rm1rzLbXaf.gkZaTWhB9pv5XLq11' +sudo useradd -p $PASSWORD -g vagrant -s $(which zsh) -m $NEW_USER +echo "$NEW_USER ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers.d/$NEW_USER +chmod 440 /etc/sudoers.d/$NEW_USER + +( + # Change User (See http://unix.stackexchange.com/questions/86778/why-cant-we-execute-a-list-of-commands-as-different-user-without-sudo) + USERNAME=$NEW_USER + #UID=$(id -u $NEW_USER) + #EUID=$(id -u $NEW_USER) + HOME=/home/$NEW_USER + + curl -L https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh | sh + + cd ~/.oh-my-zsh/custom + git clone https://github.com/bhilburn/powerlevel9k.git themes/powerlevel9k + + echo ' +export ZSH=$HOME/.oh-my-zsh +plugins=(git bundler osx rake ruby) +ZSH_THEME="powerlevel9k/powerlevel9k" + +source $ZSH/oh-my-zsh.sh +' > ~/.zshrc + +) diff --git a/test-vm/plain.sh b/test-vm/plain.sh new file mode 100644 index 00000000..e2fa6a86 --- /dev/null +++ b/test-vm/plain.sh @@ -0,0 +1,7 @@ +#!/usr/bin/zsh + +git clone https://github.com/bhilburn/powerlevel9k.git + +echo " +source powerlevel9k/powerlevel9k.zsh-theme\n +" > ~/.zshrc diff --git a/test-vm/prezto.sh b/test-vm/prezto.sh new file mode 100644 index 00000000..dda885fd --- /dev/null +++ b/test-vm/prezto.sh @@ -0,0 +1,27 @@ +#!/usr/bin/zsh +# We need to run this script in ZSH, so that switching user works! +NEW_USER=vagrant-prezto +# Create User +PASSWORD='$6$OgLg9v2Z$Db38Jr9inZG7y8BzL8kqFK23fF5jZ7FU1oiIBLFjNYR9XVX03fwQayMgA6Rm1rzLbXaf.gkZaTWhB9pv5XLq11' +sudo useradd -p $PASSWORD -g vagrant -s $(which zsh) -m $NEW_USER +echo "$NEW_USER ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers.d/$NEW_USER +chmod 440 /etc/sudoers.d/$NEW_USER + +( + # Change User (See http://unix.stackexchange.com/questions/86778/why-cant-we-execute-a-list-of-commands-as-different-user-without-sudo) + USERNAME=$NEW_USER + #UID=$(id -u $NEW_USER) + #EUID=$(id -u $NEW_USER) + HOME=/home/$NEW_USER + + git clone --recursive https://github.com/sorin-ionescu/prezto.git "${ZDOTDIR:-$HOME}/.zprezto" + + setopt EXTENDED_GLOB + for rcfile in "${ZDOTDIR:-$HOME}"/.zprezto/runcoms/^README.md(.N); do + ln -s "$rcfile" "${ZDOTDIR:-$HOME}/.${rcfile:t}" + done + + git clone https://github.com/bhilburn/powerlevel9k.git ~/powerlevel9k + ln -s ~/powerlevel9k/powerlevel9k.zsh-theme ~/.zprezto/modules/prompt/functions/prompt_powerlevel9k_setup + sed -i "s/theme\ 'sorin'/theme\ 'powerlevel9k'/g" ~/.zpreztorc +) From 494714049ac1036b23cbfd45ae417577ddf65722 Mon Sep 17 00:00:00 2001 From: Dominik Ritter Date: Wed, 10 Jun 2015 02:38:36 +0200 Subject: [PATCH 06/12] Added provisioning for all frameworks. --- test-vm/Vagrantfile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test-vm/Vagrantfile b/test-vm/Vagrantfile index a526b54b..bc6c8921 100644 --- a/test-vm/Vagrantfile +++ b/test-vm/Vagrantfile @@ -15,10 +15,10 @@ Vagrant.configure(2) do |config| config.vm.box = "ubuntu/precise64" # Bootstrap -# config.vm.provision :shell, path: "bootstrap.sh", privileged: false -# config.vm.provision :shell, path: "plain.sh" -# config.vm.provision :shell, path: "antigen.sh" -# config.vm.provision :shell, path: "prezto.sh" + config.vm.provision :shell, path: "bootstrap.sh", privileged: false + config.vm.provision :shell, path: "plain.sh" + config.vm.provision :shell, path: "antigen.sh" + config.vm.provision :shell, path: "prezto.sh" config.vm.provision :shell, path: "omz.sh" # Disable automatic box update checking. If you disable this, then From 3e13603557cf2859332ea2f6d27d12acaef6af95 Mon Sep 17 00:00:00 2001 From: Dominik Ritter Date: Thu, 11 Jun 2015 00:58:46 +0200 Subject: [PATCH 07/12] It makes no sense, to clone the powerlevel9k-theme in all frameworks. Instead, we can simply use the one, which is mounted in /vagrant_data.. --- test-vm/Vagrantfile | 4 ++-- test-vm/antigen.sh | 4 ++-- test-vm/omz.sh | 6 +++--- test-vm/plain.sh | 6 +----- test-vm/prezto.sh | 5 ++--- 5 files changed, 10 insertions(+), 15 deletions(-) diff --git a/test-vm/Vagrantfile b/test-vm/Vagrantfile index bc6c8921..ee53fcdf 100644 --- a/test-vm/Vagrantfile +++ b/test-vm/Vagrantfile @@ -16,7 +16,7 @@ Vagrant.configure(2) do |config| # Bootstrap config.vm.provision :shell, path: "bootstrap.sh", privileged: false - config.vm.provision :shell, path: "plain.sh" + config.vm.provision :shell, path: "plain.sh", privileged: false config.vm.provision :shell, path: "antigen.sh" config.vm.provision :shell, path: "prezto.sh" config.vm.provision :shell, path: "omz.sh" @@ -44,7 +44,7 @@ Vagrant.configure(2) do |config| # the path on the host to the actual folder. The second argument is # the path on the guest to mount the folder. And the optional third # argument is a set of non-required options. - # config.vm.synced_folder "../data", "/vagrant_data" + config.vm.synced_folder "..", "/vagrant_data" # Provider-specific configuration so you can fine-tune various # backing providers for Vagrant. These expose provider-specific options. diff --git a/test-vm/antigen.sh b/test-vm/antigen.sh index 1ad71af4..0f44c6ca 100644 --- a/test-vm/antigen.sh +++ b/test-vm/antigen.sh @@ -3,7 +3,7 @@ NEW_USER=vagrant-antigen # Create User PASSWORD='$6$OgLg9v2Z$Db38Jr9inZG7y8BzL8kqFK23fF5jZ7FU1oiIBLFjNYR9XVX03fwQayMgA6Rm1rzLbXaf.gkZaTWhB9pv5XLq11' -sudo useradd -p $PASSWORD -g vagrant -s $(which zsh) -m $NEW_USER +useradd -p $PASSWORD -g vagrant -s $(which zsh) -m $NEW_USER echo "$NEW_USER ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers.d/$NEW_USER chmod 440 /etc/sudoers.d/$NEW_USER @@ -16,7 +16,7 @@ chmod 440 /etc/sudoers.d/$NEW_USER echo " source ~/antigen/antigen.zsh\n -antigen theme bhilburn/powerlevel9k powerlevel9k\n +antigen theme /vagrant_data powerlevel9k --no-local-clone\n antigen apply " > ~/.zshrc diff --git a/test-vm/omz.sh b/test-vm/omz.sh index aeb5f897..eead4905 100644 --- a/test-vm/omz.sh +++ b/test-vm/omz.sh @@ -3,7 +3,7 @@ NEW_USER=vagrant-omz # Create User PASSWORD='$6$OgLg9v2Z$Db38Jr9inZG7y8BzL8kqFK23fF5jZ7FU1oiIBLFjNYR9XVX03fwQayMgA6Rm1rzLbXaf.gkZaTWhB9pv5XLq11' -sudo useradd -p $PASSWORD -g vagrant -s $(which zsh) -m $NEW_USER +useradd -p $PASSWORD -g vagrant -s $(which zsh) -m $NEW_USER echo "$NEW_USER ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers.d/$NEW_USER chmod 440 /etc/sudoers.d/$NEW_USER @@ -16,8 +16,8 @@ chmod 440 /etc/sudoers.d/$NEW_USER curl -L https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh | sh - cd ~/.oh-my-zsh/custom - git clone https://github.com/bhilburn/powerlevel9k.git themes/powerlevel9k + mkdir -p ~/.oh-my-zsh/custom/themes + ln -s /vagrant_data ~/.oh-my-zsh/custom/themes/powerlevel9k echo ' export ZSH=$HOME/.oh-my-zsh diff --git a/test-vm/plain.sh b/test-vm/plain.sh index e2fa6a86..9c8445f4 100644 --- a/test-vm/plain.sh +++ b/test-vm/plain.sh @@ -1,7 +1,3 @@ #!/usr/bin/zsh -git clone https://github.com/bhilburn/powerlevel9k.git - -echo " -source powerlevel9k/powerlevel9k.zsh-theme\n -" > ~/.zshrc +echo 'source /vagrant_data/powerlevel9k.zsh-theme' > ~/.zshrc diff --git a/test-vm/prezto.sh b/test-vm/prezto.sh index dda885fd..af4e7454 100644 --- a/test-vm/prezto.sh +++ b/test-vm/prezto.sh @@ -3,7 +3,7 @@ NEW_USER=vagrant-prezto # Create User PASSWORD='$6$OgLg9v2Z$Db38Jr9inZG7y8BzL8kqFK23fF5jZ7FU1oiIBLFjNYR9XVX03fwQayMgA6Rm1rzLbXaf.gkZaTWhB9pv5XLq11' -sudo useradd -p $PASSWORD -g vagrant -s $(which zsh) -m $NEW_USER +useradd -p $PASSWORD -g vagrant -s $(which zsh) -m $NEW_USER echo "$NEW_USER ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers.d/$NEW_USER chmod 440 /etc/sudoers.d/$NEW_USER @@ -21,7 +21,6 @@ chmod 440 /etc/sudoers.d/$NEW_USER ln -s "$rcfile" "${ZDOTDIR:-$HOME}/.${rcfile:t}" done - git clone https://github.com/bhilburn/powerlevel9k.git ~/powerlevel9k - ln -s ~/powerlevel9k/powerlevel9k.zsh-theme ~/.zprezto/modules/prompt/functions/prompt_powerlevel9k_setup + ln -s /vagrant_data/powerlevel9k.zsh-theme ~/.zprezto/modules/prompt/functions/prompt_powerlevel9k_setup sed -i "s/theme\ 'sorin'/theme\ 'powerlevel9k'/g" ~/.zpreztorc ) From 966bf5fe740facfa03286b4c7ceff3794c9a212c Mon Sep 17 00:00:00 2001 From: Dominik Ritter Date: Thu, 11 Jun 2015 18:09:57 +0200 Subject: [PATCH 08/12] Global variables need to be global, so that antigen and prezto see them.. --- powerlevel9k.zsh-theme | 1 - 1 file changed, 1 deletion(-) diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index be4b68da..695a39c3 100644 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -169,7 +169,6 @@ esac # color scheme ################################################################ -local DEFAULT_COLOR DEFAULT_COLOR_INVERTED DEFAULT_COLOR_DARK if [[ "$POWERLEVEL9K_COLOR_SCHEME" == "light" ]]; then DEFAULT_COLOR=white DEFAULT_COLOR_INVERTED=black From e97c216c7b6973e1ce80f3f76d0254e9f52ba894 Mon Sep 17 00:00:00 2001 From: Dominik Ritter Date: Thu, 11 Jun 2015 18:24:16 +0200 Subject: [PATCH 09/12] More Documentation. --- README.md | 51 ++++++++++++++++++++++++++------------------------- 1 file changed, 26 insertions(+), 25 deletions(-) diff --git a/README.md b/README.md index e486a84e..2ba97554 100644 --- a/README.md +++ b/README.md @@ -76,34 +76,14 @@ this theme: #### Install Powerlevel9k -To install this theme, clone this repository into your Oh-My-Zsh `custom/themes` -directory. +##### With plain ZSH - $ cd ~/.oh-my-zsh/custom - $ git clone https://github.com/bhilburn/powerlevel9k.git themes/powerlevel9k +If you use just a plain ZSH, just clone this repository and reference it in your `~/.zshrc`: -You then need to select this theme in your `~/.zshrc`: + $ git clone https://github.com/bhilburn/powerlevel9k.git + $ echo 'source powerlevel9k/powerlevel9k.zsh-theme' >> ~/.zshrc - ZSH_THEME="powerlevel9k/powerlevel9k" - - -#### Install Powerline Fonts for Normal Configuration - -You can find the [installation instructions for Powerline Fonts here] -(https://powerline.readthedocs.org/en/latest/installation/linux.html#fonts-installation). -You can also find the raw font files [in this Github -repository](https://github.com/powerline/fonts) if you want to manually install -them for your OS. - -After you have installed Powerline fonts, make the default font in your terminal -emulator the Powerline font you want to use. - -This is the default mode for `Powerlevel9k`, and no further configuration is -necessary. - -#### Install Powerlevel9k - -##### Within Oh-my-ZSH +##### With Oh-my-ZSH To install this theme, clone this repository into your [Oh-my-Zsh](https://github.com/robbyrussell/oh-my-zsh) `custom/themes` directory. @@ -128,6 +108,27 @@ You then need to select this theme in your `~/.zpreztorc`: zstyle ':prezto:module:prompt' theme 'powerlevel9k' +##### With antigen + +If you prefer [antigen](https://github.com/zsh-users/antigen), just add it to your `~/.zshrc`: + + $ echo 'antigen theme /vagrant_data powerlevel9k' >> ~/.zshrc + $ echo 'antigen apply' >> ~/.zshrc + +#### Install Powerline Fonts for Normal Configuration + +You can find the [installation instructions for Powerline Fonts here] +(https://powerline.readthedocs.org/en/latest/installation/linux.html#fonts-installation). +You can also find the raw font files [in this Github +repository](https://github.com/powerline/fonts) if you want to manually install +them for your OS. + +After you have installed Powerline fonts, make the default font in your terminal +emulator the Powerline font you want to use. + +This is the default mode for `Powerlevel9k`, and no further configuration is +necessary. + #### Alternative Configuration: Über Alternatively, you can install [Awesome Powerline From 2821a0deee22cbb4884023e7343e22901b997c05 Mon Sep 17 00:00:00 2001 From: Dominik Ritter Date: Thu, 11 Jun 2015 18:24:55 +0200 Subject: [PATCH 10/12] Updated TOC. --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 2ba97554..4b430a44 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,10 @@ like with a normal installation and default settings: - [Features](#features) - [Installation](#installation) - [Install Powerlevel9k](#install-powerlevel9k) + - [With plain ZSH](#with-plain-zsh) + - [With Oh-my-ZSH](#with-oh-my-zsh) + - [With Prezto](#with-prezto) + - [With antigen](#with-antigen) - [Install Powerline Fonts for Normal Configuration](#install-powerline-fonts-for-normal-configuration) - [Alternative Configuration: Über](#alternative-configuration-%C3%BCber) - [Alternative Configuration: Bare Bones](#alternative-configuration-bare-bones) From 1e7105918d4505532eb6183254bfa15176711f10 Mon Sep 17 00:00:00 2001 From: Dominik Ritter Date: Thu, 11 Jun 2015 19:50:30 +0200 Subject: [PATCH 11/12] Added a reference to the test-vm folder --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 4b430a44..2f71441c 100644 --- a/README.md +++ b/README.md @@ -370,3 +370,6 @@ Please submit your contribution as a Github pull-request. If you would like to contact me directly, you can find my e-mail address on my [Github profile page](https://github.com/bhilburn). +### Testing + +Check out the [vagrant](https://www.vagrantup.com/) configuration in the [test-vm](test-vm) folder. From fe5ef3cee8178aba2dd290de1597ecc9ef5652b8 Mon Sep 17 00:00:00 2001 From: Dominik Ritter Date: Sat, 13 Jun 2015 00:26:18 +0200 Subject: [PATCH 12/12] All top-level usages of "local" removed. That variables need to be global for antigen and prezto to work correctly. --- powerlevel9k.zsh-theme | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 695a39c3..1ebc31bb 100644 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -179,8 +179,8 @@ else DEFAULT_COLOR_DARK="236" fi -local VCS_FOREGROUND_COLOR=$DEFAULT_COLOR -local VCS_FOREGROUND_COLOR_DARK=$DEFAULT_COLOR_DARK +VCS_FOREGROUND_COLOR=$DEFAULT_COLOR +VCS_FOREGROUND_COLOR_DARK=$DEFAULT_COLOR_DARK # If user has defined custom colors for the `vcs` segment, override the defaults if [[ -n $POWERLEVEL9K_VCS_FOREGROUND ]]; then @@ -197,8 +197,8 @@ fi setopt prompt_subst autoload -Uz vcs_info -local VCS_WORKDIR_DIRTY=false -local VCS_CHANGESET_PREFIX='' +VCS_WORKDIR_DIRTY=false +VCS_CHANGESET_PREFIX='' if [[ "$POWERLEVEL9K_SHOW_CHANGESET" == true ]]; then # Default: Just display the first 12 characters of our changeset-ID. local VCS_CHANGESET_HASH_LENGTH=12 @@ -212,7 +212,7 @@ fi zstyle ':vcs_info:*' enable git hg zstyle ':vcs_info:*' check-for-changes true -local VCS_DEFAULT_FORMAT="$VCS_CHANGESET_PREFIX%F{$VCS_FOREGROUND_COLOR}%b%c%u%m%f" +VCS_DEFAULT_FORMAT="$VCS_CHANGESET_PREFIX%F{$VCS_FOREGROUND_COLOR}%b%c%u%m%f" zstyle ':vcs_info:git:*' formats "%F{$VCS_FOREGROUND_COLOR}$VCS_GIT_ICON%f $VCS_DEFAULT_FORMAT" zstyle ':vcs_info:hg:*' formats "%F{$VCS_FOREGROUND_COLOR}$VCS_HG_ICON%f $VCS_DEFAULT_FORMAT"