From a812654cbed305398a078cac3d23e6a498da4f15 Mon Sep 17 00:00:00 2001 From: Simon Gomizelj Date: Mon, 28 Nov 2011 09:24:49 -0500 Subject: [PATCH 1/5] Swapped out ZSH_THEME for two functions, set_theme and random_theme. At the moment I dropped ZSH_THEME variable too. Auto completion to come. Function makes it easier to change themes on-the-fly. --- oh-my-zsh.sh | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/oh-my-zsh.sh b/oh-my-zsh.sh index 891e8d467..460399fc4 100644 --- a/oh-my-zsh.sh +++ b/oh-my-zsh.sh @@ -40,19 +40,12 @@ done # Load all of your custom configurations from custom/ for config_file ($ZSH_CUSTOM/*.zsh) source $config_file -# Load the theme -if [ "$ZSH_THEME" = "random" ] -then - themes=($ZSH/themes/*zsh-theme) - N=${#themes[@]} - ((N=(RANDOM%N)+1)) - RANDOM_THEME=${themes[$N]} - source "$RANDOM_THEME" - echo "[oh-my-zsh] Random theme '$RANDOM_THEME' loaded..." -else - if [ ! "$ZSH_THEME" = "" ] - then - source "$ZSH/themes/$ZSH_THEME.zsh-theme" - fi -fi +set_theme() { + source "$ZSH/themes/$ZSH_THEME.zsh-theme" +} +random_theme() { + local themes + themes=($ZSH/themes/*zsh-theme) + source "$themes[$RANDOM%$#themes+1]" +} From 9e17fe1fc1cbedf8017d60390abcfe7ef1a20d6c Mon Sep 17 00:00:00 2001 From: Simon Gomizelj Date: Mon, 28 Nov 2011 09:27:22 -0500 Subject: [PATCH 2/5] Updated templates to reflect how themeing is set at the moment. Not quite happy with it yet. --- templates/zshrc.arch-zsh-template | 19 ++++++++++--------- templates/zshrc.zsh-template | 11 +++++------ 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/templates/zshrc.arch-zsh-template b/templates/zshrc.arch-zsh-template index 27f4d2e09..b9322b0b9 100644 --- a/templates/zshrc.arch-zsh-template +++ b/templates/zshrc.arch-zsh-template @@ -1,11 +1,9 @@ # Path to your oh-my-zsh configuration. ZSH=/usr/share/oh-my-zsh/ -# Set name of the theme to load. -# Look in /usr/local/share/oh-my-zsh/themes/ -# Optionally, if you set this to "random", it'll load a random theme each -# time that oh-my-zsh is loaded. -ZSH_THEME="arch-blue" +load_oh_my_zshell(){ + source $ZSH/oh-my-zsh.sh +} # Set to this to use case-sensitive completion # CASE_SENSITIVE="true" @@ -24,10 +22,13 @@ DISABLE_AUTO_UPDATE="true" # Which plugins would you like to load? (plugins can be found in /usr/local/share/oh-my-zsh/plugins/*) # Example format: plugins=(rails git textmate ruby lighthouse) -plugins=(git) +plugins=(archlinux sprung git) -load_oh_my_zshell(){ - source $ZSH/oh-my-zsh.sh -} +load_oh_my_zshell + +# Load a theme +# Look in /usr/local/share/oh-my-zsh/themes/ +set_theme "arch-blue" +# random_theme # Customize to your needs... diff --git a/templates/zshrc.zsh-template b/templates/zshrc.zsh-template index 1ab40aba6..6d1db51ed 100644 --- a/templates/zshrc.zsh-template +++ b/templates/zshrc.zsh-template @@ -1,12 +1,6 @@ # Path to your oh-my-zsh configuration. ZSH=$HOME/.oh-my-zsh -# Set name of the theme to load. -# Look in ~/.oh-my-zsh/themes/ -# Optionally, if you set this to "random", it'll load a random theme each -# time that oh-my-zsh is loaded. -ZSH_THEME="robbyrussell" - # Set to this to use case-sensitive completion # CASE_SENSITIVE="true" @@ -28,4 +22,9 @@ plugins=(git) source $ZSH/oh-my-zsh.sh +# Load a theme +# Look in $ZSH/themes/ +set_theme "robbyrussell" +# random_theme + # Customize to your needs... From 01d48a874941c3396d30f6750bc442f437f38028 Mon Sep 17 00:00:00 2001 From: Simon Gomizelj Date: Mon, 28 Nov 2011 09:53:08 -0500 Subject: [PATCH 3/5] Move my theming functions into lib/ --- lib/theming.zsh | 9 +++++++++ oh-my-zsh.sh | 10 ---------- 2 files changed, 9 insertions(+), 10 deletions(-) create mode 100644 lib/theming.zsh diff --git a/lib/theming.zsh b/lib/theming.zsh new file mode 100644 index 000000000..cd88d08af --- /dev/null +++ b/lib/theming.zsh @@ -0,0 +1,9 @@ +set_theme() { + source "$ZSH/themes/$ZSH_THEME.zsh-theme" +} + +random_theme() { + local themes + themes=($ZSH/themes/*zsh-theme) + source "$themes[$RANDOM%$#themes+1]" +} diff --git a/oh-my-zsh.sh b/oh-my-zsh.sh index 460399fc4..d0c77e457 100644 --- a/oh-my-zsh.sh +++ b/oh-my-zsh.sh @@ -39,13 +39,3 @@ done # Load all of your custom configurations from custom/ for config_file ($ZSH_CUSTOM/*.zsh) source $config_file - -set_theme() { - source "$ZSH/themes/$ZSH_THEME.zsh-theme" -} - -random_theme() { - local themes - themes=($ZSH/themes/*zsh-theme) - source "$themes[$RANDOM%$#themes+1]" -} From 1e2cf116b773233e7f453ef85826de871e24e0ef Mon Sep 17 00:00:00 2001 From: Simon Gomizelj Date: Mon, 28 Nov 2011 10:23:29 -0500 Subject: [PATCH 4/5] Why the hell does oh-my-zsh have an .sh extension and not .zsh? --- oh-my-zsh.sh => oh-my-zsh.zsh | 0 templates/zshrc.arch-zsh-template | 2 +- templates/zshrc.zsh-template | 2 +- tools/theme_chooser.sh | 2 +- 4 files changed, 3 insertions(+), 3 deletions(-) rename oh-my-zsh.sh => oh-my-zsh.zsh (100%) diff --git a/oh-my-zsh.sh b/oh-my-zsh.zsh similarity index 100% rename from oh-my-zsh.sh rename to oh-my-zsh.zsh diff --git a/templates/zshrc.arch-zsh-template b/templates/zshrc.arch-zsh-template index b9322b0b9..0e5201f13 100644 --- a/templates/zshrc.arch-zsh-template +++ b/templates/zshrc.arch-zsh-template @@ -2,7 +2,7 @@ ZSH=/usr/share/oh-my-zsh/ load_oh_my_zshell(){ - source $ZSH/oh-my-zsh.sh + source $ZSH/oh-my-zsh.zsh } # Set to this to use case-sensitive completion diff --git a/templates/zshrc.zsh-template b/templates/zshrc.zsh-template index 6d1db51ed..bbec3a9d2 100644 --- a/templates/zshrc.zsh-template +++ b/templates/zshrc.zsh-template @@ -20,7 +20,7 @@ ZSH=$HOME/.oh-my-zsh # Example format: plugins=(rails git textmate ruby lighthouse) plugins=(git) -source $ZSH/oh-my-zsh.sh +source $ZSH/oh-my-zsh.zsh # Load a theme # Look in $ZSH/themes/ diff --git a/tools/theme_chooser.sh b/tools/theme_chooser.sh index 4d7047444..cbf0f6d53 100755 --- a/tools/theme_chooser.sh +++ b/tools/theme_chooser.sh @@ -9,7 +9,7 @@ THEMES_DIR="$ZSH/themes" FAVLIST="${HOME}/.zsh_favlist" -source $ZSH/oh-my-zsh.sh +source $ZSH/oh-my-zsh.zsh function noyes() { read "a?$1 [y/N] " From 7dc0913219730e3f6e4b6c35e9119368cf56e3e2 Mon Sep 17 00:00:00 2001 From: Simon Gomizelj Date: Mon, 28 Nov 2011 13:10:14 -0500 Subject: [PATCH 5/5] Fixed slight gaff in set_theme --- lib/theming.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/theming.zsh b/lib/theming.zsh index cd88d08af..b20306a90 100644 --- a/lib/theming.zsh +++ b/lib/theming.zsh @@ -1,5 +1,5 @@ set_theme() { - source "$ZSH/themes/$ZSH_THEME.zsh-theme" + source "$ZSH/themes/$1.zsh-theme" } random_theme() {