From 531c41cdfee9e3bbba16d0bf19ca973ad4bb4af5 Mon Sep 17 00:00:00 2001 From: LE Manh Cuong Date: Tue, 1 Dec 2015 11:50:55 +0700 Subject: Allow loading themes from predefined list --- oh-my-zsh.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'oh-my-zsh.sh') diff --git a/oh-my-zsh.sh b/oh-my-zsh.sh index 6cc5ac630..0324543d5 100644 --- a/oh-my-zsh.sh +++ b/oh-my-zsh.sh @@ -94,7 +94,11 @@ unset config_file # Load the theme if [ "$ZSH_THEME" = "random" ]; then - themes=($ZSH/themes/*zsh-theme) + if [ "${(t)ZSH_THEME_RANDOM_CANDICATES}" = "array" ] && [ "${#ZSH_THEME_RANDOM_CANDICATES[@]}" -gt 0 ]; then + themes=($ZSH/themes/${^ZSH_THEME_RANDOM_CANDICATES}.zsh-theme) + else + themes=($ZSH/themes/*zsh-theme) + fi N=${#themes[@]} ((N=(RANDOM%N)+1)) RANDOM_THEME=${themes[$N]} -- cgit v1.2.3-70-g09d2 From 5e77e00ad522a5d6a84067d22015b85b0080a19f Mon Sep 17 00:00:00 2001 From: LE Manh Cuong Date: Tue, 1 Dec 2015 12:03:00 +0700 Subject: Some improvements - Adding documentation - Note the effect empty array - Fix spelling - Using new test `[[...]]` --- README.markdown | 8 ++++++++ oh-my-zsh.sh | 6 +++--- templates/zshrc.zsh-template | 3 ++- 3 files changed, 13 insertions(+), 4 deletions(-) (limited to 'oh-my-zsh.sh') diff --git a/README.markdown b/README.markdown index 9d7210f77..0d3144dde 100644 --- a/README.markdown +++ b/README.markdown @@ -88,6 +88,14 @@ If you're feeling feisty, you can let the computer select one randomly for you e ZSH_THEME="random" # (...please let it be pie... please be some pie..) ``` +And if you want to pick random theme from a list of your favorite themes: + +```shell +ZSH_THEM_RANDOM_CANDIDATES=( + "robbyrussell" + "agnoster" +) +``` ## Advanced Topics diff --git a/oh-my-zsh.sh b/oh-my-zsh.sh index 0324543d5..4517a2ba0 100644 --- a/oh-my-zsh.sh +++ b/oh-my-zsh.sh @@ -93,9 +93,9 @@ done unset config_file # Load the theme -if [ "$ZSH_THEME" = "random" ]; then - if [ "${(t)ZSH_THEME_RANDOM_CANDICATES}" = "array" ] && [ "${#ZSH_THEME_RANDOM_CANDICATES[@]}" -gt 0 ]; then - themes=($ZSH/themes/${^ZSH_THEME_RANDOM_CANDICATES}.zsh-theme) +if [[ "$ZSH_THEME" == "random" ]]; then + if [[ "${(t)ZSH_THEME_RANDOM_CANDIDATES}" = "array" ]] && [[ "${#ZSH_THEME_RANDOM_CANDIDATES[@]}" -gt 0 ]]; then + themes=($ZSH/themes/${^ZSH_THEME_RANDOM_CANDIDATES}.zsh-theme) else themes=($ZSH/themes/*zsh-theme) fi diff --git a/templates/zshrc.zsh-template b/templates/zshrc.zsh-template index baedf0675..2f39308a9 100644 --- a/templates/zshrc.zsh-template +++ b/templates/zshrc.zsh-template @@ -11,7 +11,8 @@ ZSH_THEME="robbyrussell" # Setting this variable when ZSH_THEME=random # cause zsh load theme from this variable instead of # looking in ~/.oh-my-zsh/themes/ -# ZSH_THEME_RANDOM_CANDICATES=() +# An empty array have no effect +# ZSH_THEME_RANDOM_CANDIDATES=( "robbyrussell" "agnoster" ) # Uncomment the following line to use case-sensitive completion. # CASE_SENSITIVE="true" -- cgit v1.2.3-70-g09d2 From f94d4e6a4019ed7fcc5470655b1154b3d1f67913 Mon Sep 17 00:00:00 2001 From: Mason Date: Tue, 18 Oct 2016 13:42:27 -0500 Subject: Change from OSX to macOS in README (#5545) --- oh-my-zsh.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'oh-my-zsh.sh') diff --git a/oh-my-zsh.sh b/oh-my-zsh.sh index ed258f0ea..a7de646f2 100644 --- a/oh-my-zsh.sh +++ b/oh-my-zsh.sh @@ -53,7 +53,7 @@ done # Figure out the SHORT hostname if [[ "$OSTYPE" = darwin* ]]; then - # OS X's $HOST changes with dhcp, etc. Use ComputerName if possible. + # macOS's $HOST changes with dhcp, etc. Use ComputerName if possible. SHORT_HOST=$(scutil --get ComputerName 2>/dev/null) || SHORT_HOST=${HOST/.*/} else SHORT_HOST=${HOST/.*/} -- cgit v1.2.3-70-g09d2 From afba4f6b9feb3a9dde4331cd2ed892c4da2df6e3 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Tue, 15 May 2018 21:22:47 +0200 Subject: Load insecure completion files if compfix is disabled We have to assume that if people disabled the compfix system they really want their completion to work, ignoring any permission issues. Fixes #5651 Fixes #5957 Fixes #6461 --- oh-my-zsh.sh | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'oh-my-zsh.sh') diff --git a/oh-my-zsh.sh b/oh-my-zsh.sh index 7f78e4140..c0e2ba8f6 100644 --- a/oh-my-zsh.sh +++ b/oh-my-zsh.sh @@ -11,8 +11,6 @@ fpath=($ZSH/functions $ZSH/completions $fpath) # Load all stock functions (from $fpath files) called below. autoload -U compaudit compinit -: ${ZSH_DISABLE_COMPFIX:=true} - # Set ZSH_CUSTOM to the path where your custom config files # and plugins exists, or else we will use the default custom/ if [[ -z "$ZSH_CUSTOM" ]]; then @@ -74,7 +72,7 @@ if [[ $ZSH_DISABLE_COMPFIX != true ]]; then compinit -d "${ZSH_COMPDUMP}" fi else - compinit -i -d "${ZSH_COMPDUMP}" + compinit -u -d "${ZSH_COMPDUMP}" fi # Load all of the plugins that were defined in ~/.zshrc -- cgit v1.2.3-70-g09d2 From b91659951e15c288c8b9d6b947dfde9c6dceae22 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Sat, 26 May 2018 21:26:49 +0200 Subject: Always load secure completion directories --- oh-my-zsh.sh | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'oh-my-zsh.sh') diff --git a/oh-my-zsh.sh b/oh-my-zsh.sh index c0e2ba8f6..72527362f 100644 --- a/oh-my-zsh.sh +++ b/oh-my-zsh.sh @@ -63,15 +63,14 @@ if [ -z "$ZSH_COMPDUMP" ]; then fi if [[ $ZSH_DISABLE_COMPFIX != true ]]; then - # If completion insecurities exist, warn the user without enabling completions. + # If completion insecurities exist, warn the user if ! compaudit &>/dev/null; then - # This function resides in the "lib/compfix.zsh" script sourced above. handle_completion_insecurities - # Else, enable and cache completions to the desired file. - else - compinit -d "${ZSH_COMPDUMP}" fi + # Load only from secure directories + compinit -i -d "${ZSH_COMPDUMP}" else + # If the user wants it, load from all found directories compinit -u -d "${ZSH_COMPDUMP}" fi -- cgit v1.2.3-70-g09d2 From de8299d6c4f50bc40286a05cd7e802b6bffe41f0 Mon Sep 17 00:00:00 2001 From: Chao Du Date: Mon, 2 Nov 2015 14:29:37 +0800 Subject: Fixed Issue #4550: Move ~/.zsh-update file to $ZSH_CACHE_DIR --- oh-my-zsh.sh | 14 +++++++------- tools/check_for_upgrade.sh | 8 ++++---- 2 files changed, 11 insertions(+), 11 deletions(-) (limited to 'oh-my-zsh.sh') diff --git a/oh-my-zsh.sh b/oh-my-zsh.sh index 72527362f..ca505d1ba 100644 --- a/oh-my-zsh.sh +++ b/oh-my-zsh.sh @@ -1,6 +1,12 @@ +# Set ZSH_CACHE_DIR to the path where cache files should be created +# or else we will use the default cache/ +if [[ -z "$ZSH_CACHE_DIR" ]]; then + ZSH_CACHE_DIR="$ZSH/cache" +fi + # Check for updates on initial load... if [ "$DISABLE_AUTO_UPDATE" != "true" ]; then - env ZSH=$ZSH DISABLE_UPDATE_PROMPT=$DISABLE_UPDATE_PROMPT zsh -f $ZSH/tools/check_for_upgrade.sh + env ZSH=$ZSH ZSH_CACHE_DIR=$ZSH_CACHE_DIR DISABLE_UPDATE_PROMPT=$DISABLE_UPDATE_PROMPT zsh -f $ZSH/tools/check_for_upgrade.sh fi # Initializes Oh My Zsh @@ -17,12 +23,6 @@ if [[ -z "$ZSH_CUSTOM" ]]; then ZSH_CUSTOM="$ZSH/custom" fi -# Set ZSH_CACHE_DIR to the path where cache files should be created -# or else we will use the default cache/ -if [[ -z "$ZSH_CACHE_DIR" ]]; then - ZSH_CACHE_DIR="$ZSH/cache" -fi - # Load all of the config files in ~/oh-my-zsh that end in .zsh # TIP: Add files you don't want in git to .gitignore diff --git a/tools/check_for_upgrade.sh b/tools/check_for_upgrade.sh index b42b87750..05b31e8d4 100644 --- a/tools/check_for_upgrade.sh +++ b/tools/check_for_upgrade.sh @@ -7,7 +7,7 @@ function _current_epoch() { } function _update_zsh_update() { - echo "LAST_EPOCH=$(_current_epoch)" >! ~/.zsh-update + echo "LAST_EPOCH=$(_current_epoch)" >! ${ZSH_CACHE_DIR}/.zsh-update } function _upgrade_zsh() { @@ -30,11 +30,11 @@ fi whence git >/dev/null || return 0 if mkdir "$ZSH/log/update.lock" 2>/dev/null; then - if [ -f ~/.zsh-update ]; then - . ~/.zsh-update + if [ -f ${ZSH_CACHE_DIR}/.zsh-update ]; then + . ${ZSH_CACHE_DIR}/.zsh-update if [[ -z "$LAST_EPOCH" ]]; then - _update_zsh_update && return 0; + _update_zsh_update && return 0 fi epoch_diff=$(($(_current_epoch) - $LAST_EPOCH)) -- cgit v1.2.3-70-g09d2 From e96a7b728a9c15f5615f4e41a79a5f0fe2b97712 Mon Sep 17 00:00:00 2001 From: Chao Du Date: Tue, 29 Dec 2015 11:17:02 +0800 Subject: migrate .zsh-update file --- oh-my-zsh.sh | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'oh-my-zsh.sh') diff --git a/oh-my-zsh.sh b/oh-my-zsh.sh index ca505d1ba..d7c68d35c 100644 --- a/oh-my-zsh.sh +++ b/oh-my-zsh.sh @@ -4,6 +4,11 @@ if [[ -z "$ZSH_CACHE_DIR" ]]; then ZSH_CACHE_DIR="$ZSH/cache" fi +# Migrate .zsh-update file to $ZSH_CACHE_DIR +if [ -f ~/.zsh-update ] && [ ! -f ${ZSH_CACHE_DIR}/.zsh-update ]; then + mv ~/.zsh-update ${ZSH_CACHE_DIR}/.zsh-update +fi + # Check for updates on initial load... if [ "$DISABLE_AUTO_UPDATE" != "true" ]; then env ZSH=$ZSH ZSH_CACHE_DIR=$ZSH_CACHE_DIR DISABLE_UPDATE_PROMPT=$DISABLE_UPDATE_PROMPT zsh -f $ZSH/tools/check_for_upgrade.sh -- cgit v1.2.3-70-g09d2 From 4cdffcd4858c7818e5325c03909d75e41995eeae Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Mon, 25 Feb 2019 21:30:00 +0100 Subject: init: cut down on the number of compaudit calls --- oh-my-zsh.sh | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'oh-my-zsh.sh') diff --git a/oh-my-zsh.sh b/oh-my-zsh.sh index d7c68d35c..4f6bfd5a5 100644 --- a/oh-my-zsh.sh +++ b/oh-my-zsh.sh @@ -69,14 +69,12 @@ fi if [[ $ZSH_DISABLE_COMPFIX != true ]]; then # If completion insecurities exist, warn the user - if ! compaudit &>/dev/null; then - handle_completion_insecurities - fi + handle_completion_insecurities # Load only from secure directories - compinit -i -d "${ZSH_COMPDUMP}" + compinit -i -C -d "${ZSH_COMPDUMP}" else # If the user wants it, load from all found directories - compinit -u -d "${ZSH_COMPDUMP}" + compinit -u -C -d "${ZSH_COMPDUMP}" fi # Load all of the plugins that were defined in ~/.zshrc -- cgit v1.2.3-70-g09d2 From 779ff24c2d0091ebbddae938d12b3f117123fc29 Mon Sep 17 00:00:00 2001 From: SomeDer <48731521+SomeDer@users.noreply.github.com> Date: Thu, 21 Mar 2019 19:25:41 +0000 Subject: init: notify user if plugin isn't found (#7679) --- oh-my-zsh.sh | 2 ++ 1 file changed, 2 insertions(+) (limited to 'oh-my-zsh.sh') diff --git a/oh-my-zsh.sh b/oh-my-zsh.sh index 4f6bfd5a5..fbb10dd82 100644 --- a/oh-my-zsh.sh +++ b/oh-my-zsh.sh @@ -83,6 +83,8 @@ for plugin ($plugins); do source $ZSH_CUSTOM/plugins/$plugin/$plugin.plugin.zsh elif [ -f $ZSH/plugins/$plugin/$plugin.plugin.zsh ]; then source $ZSH/plugins/$plugin/$plugin.plugin.zsh + else + echo "Warning: plugin $plugin not found" fi done -- cgit v1.2.3-70-g09d2 From 1e11a3c112f47ee87f432a5410755239ff43b0bb Mon Sep 17 00:00:00 2001 From: Avi ד Date: Fri, 22 Mar 2019 14:37:08 -0400 Subject: init: fix erroneous plugin not found warning (#7686) Co-authored-by: Se De --- oh-my-zsh.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'oh-my-zsh.sh') diff --git a/oh-my-zsh.sh b/oh-my-zsh.sh index fbb10dd82..e080257c1 100644 --- a/oh-my-zsh.sh +++ b/oh-my-zsh.sh @@ -44,6 +44,7 @@ is_plugin() { test -f $base_dir/plugins/$name/$name.plugin.zsh \ || test -f $base_dir/plugins/$name/_$name } + # Add all defined plugins to fpath. This must be done # before running compinit. for plugin ($plugins); do @@ -51,6 +52,8 @@ for plugin ($plugins); do fpath=($ZSH_CUSTOM/plugins/$plugin $fpath) elif is_plugin $ZSH $plugin; then fpath=($ZSH/plugins/$plugin $fpath) + else + echo "Warning: plugin $plugin not found" fi done @@ -83,8 +86,6 @@ for plugin ($plugins); do source $ZSH_CUSTOM/plugins/$plugin/$plugin.plugin.zsh elif [ -f $ZSH/plugins/$plugin/$plugin.plugin.zsh ]; then source $ZSH/plugins/$plugin/$plugin.plugin.zsh - else - echo "Warning: plugin $plugin not found" fi done -- cgit v1.2.3-70-g09d2 From 3a6bf6bd26b809577d42cb606e05e9ea75373d5e Mon Sep 17 00:00:00 2001 From: Greg Date: Wed, 3 Apr 2019 12:20:16 +0100 Subject: init: more informative warning if plugin not found (#7727) --- oh-my-zsh.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'oh-my-zsh.sh') diff --git a/oh-my-zsh.sh b/oh-my-zsh.sh index e080257c1..b1460b1d7 100644 --- a/oh-my-zsh.sh +++ b/oh-my-zsh.sh @@ -53,7 +53,7 @@ for plugin ($plugins); do elif is_plugin $ZSH $plugin; then fpath=($ZSH/plugins/$plugin $fpath) else - echo "Warning: plugin $plugin not found" + echo "[oh-my-zsh] plugin '$plugin' not found" fi done -- cgit v1.2.3-70-g09d2 From ea3e666e04bfae31b37ef42dfe54801484341e46 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Tue, 7 May 2019 21:29:10 +0200 Subject: init: run compinit before loading lib/ files --- lib/directories.zsh | 1 + oh-my-zsh.sh | 19 ++++++++++--------- 2 files changed, 11 insertions(+), 9 deletions(-) (limited to 'oh-my-zsh.sh') diff --git a/lib/directories.zsh b/lib/directories.zsh index 355c442d2..cf87bd7e4 100644 --- a/lib/directories.zsh +++ b/lib/directories.zsh @@ -21,6 +21,7 @@ alias 9='cd -9' alias md='mkdir -p' alias rd=rmdir + function d () { if [[ -n $1 ]]; then dirs "$@" diff --git a/oh-my-zsh.sh b/oh-my-zsh.sh index b1460b1d7..6b2662d5e 100644 --- a/oh-my-zsh.sh +++ b/oh-my-zsh.sh @@ -29,15 +29,6 @@ if [[ -z "$ZSH_CUSTOM" ]]; then fi -# Load all of the config files in ~/oh-my-zsh that end in .zsh -# TIP: Add files you don't want in git to .gitignore -for config_file ($ZSH/lib/*.zsh); do - custom_config_file="${ZSH_CUSTOM}/lib/${config_file:t}" - [ -f "${custom_config_file}" ] && config_file=${custom_config_file} - source $config_file -done - - is_plugin() { local base_dir=$1 local name=$2 @@ -71,6 +62,7 @@ if [ -z "$ZSH_COMPDUMP" ]; then fi if [[ $ZSH_DISABLE_COMPFIX != true ]]; then + source $ZSH/lib/compfix.zsh # If completion insecurities exist, warn the user handle_completion_insecurities # Load only from secure directories @@ -80,6 +72,15 @@ else compinit -u -C -d "${ZSH_COMPDUMP}" fi + +# Load all of the config files in ~/oh-my-zsh that end in .zsh +# TIP: Add files you don't want in git to .gitignore +for config_file ($ZSH/lib/*.zsh); do + custom_config_file="${ZSH_CUSTOM}/lib/${config_file:t}" + [ -f "${custom_config_file}" ] && config_file=${custom_config_file} + source $config_file +done + # Load all of the plugins that were defined in ~/.zshrc for plugin ($plugins); do if [ -f $ZSH_CUSTOM/plugins/$plugin/$plugin.plugin.zsh ]; then -- cgit v1.2.3-70-g09d2