From a20ec85ace9bcabc1e970de6c5b2949155f4a9df Mon Sep 17 00:00:00 2001 From: LFDM <1986gh@gmail.com> Date: Sun, 5 Jan 2014 00:29:35 +0100 Subject: [PATCH] Going zsh! --- oh-my-zsh.sh => oh-my-zsh.zsh | 28 +++++++++++++--------------- templates/zshrc.zsh-template | 2 +- 2 files changed, 14 insertions(+), 16 deletions(-) rename oh-my-zsh.sh => oh-my-zsh.zsh (86%) diff --git a/oh-my-zsh.sh b/oh-my-zsh.zsh similarity index 86% rename from oh-my-zsh.sh rename to oh-my-zsh.zsh index e09d9513f..25acf4347 100644 --- a/oh-my-zsh.sh +++ b/oh-my-zsh.zsh @@ -4,7 +4,7 @@ # its awesomeness at a single glance. check_for_updates() { - if [ "$DISABLE_AUTO_UPDATE" != "true" ]; then + if [[ $DISABLE_AUTO_UPDATE != "true" ]]; then /usr/bin/env ZSH=$ZSH DISABLE_UPDATE_PROMPT=$DISABLE_UPDATE_PROMPT \ zsh -f $ZSH/tools/check_for_upgrade.sh fi @@ -20,11 +20,11 @@ find_plugin_paths() { local plugin_path local zsh_path - for plugin ($plugins); do + for plugin in $plugins; do plugin_path="plugins/$plugin/$plugin.plugin.zsh" for zsh_path in $ZSH_CUSTOM $ZSH; do - if [ -f "$zsh_path/$plugin_path" ]; then - ZSH_PLUGIN_PATHS+="$zsh_path/$plugin_path" + if [[ -f $zsh_path/$plugin_path ]]; then + ZSH_PLUGIN_PATHS+=$zsh_path/$plugin_path break fi done @@ -37,20 +37,18 @@ initialize_completions() { short_host=$($(scutil --get ComputerName 2>/dev/null) || echo ${HOST/.*/}) # Save the location of the current completion dump file. - ZSH_COMPDUMP="${ZDOTDIR:-${HOME}}/.zcompdump-${short_host}-${ZSH_VERSION}" + ZSH_COMPDUMP="${ZDOTDIR:-${HOME}}/.zcompdump-$short_host-$ZSH_VERSION" # plugins need to be added to the functions path before compinit fpath=($ZSH_PLUGIN_PATHS $fpath) autoload -U compinit - compinit -i -d "${ZSH_COMPDUMP}" + compinit -i -d $ZSH_COMPDUMP } source_files() { local file - for file in $@; do - source $file - done + for file in $@; { source $file } } load_lib_files() { source_files $ZSH/lib/*.zsh } @@ -60,7 +58,7 @@ load_customizations() { source_files $ZSH_CUSTOM/*.zsh } # Sources ZSH_THEME # Does nothing if ZSH_THEME is an empty string or unset _source_zsh_theme() { - if [ "$ZSH_THEME" = "random" ]; then + if [[ $ZSH_THEME = "random" ]]; then local themes local theme_name themes=($ZSH/themes/*zsh-theme) @@ -69,16 +67,15 @@ _source_zsh_theme() { source "$RANDOM_THEME" echo "[oh-my-zsh] Random theme '$theme_name' loaded..." - elif [ "$ZSH_THEME" != "" ]; then - echo ho + elif [[ $ZSH_THEME != '' ]]; then local theme_path local zsh_path # custom themes take precedence over built-in themes! theme_path="themes/$ZSH_THEME.zsh-theme" for zsh_path in $ZSH_CUSTOM $ZSH; do - if [ -f "$zsh_path/$theme_path" ]; then - source "$zsh_path/$theme_path" + if [[ -f $zsh_path/$theme_path ]]; then + source $zsh_path/$theme_path break fi done @@ -112,10 +109,11 @@ _default_theming() { # are pygmalion or pure) you will see remnants of their prompts if you load # another theme on the fly. Just open a new shell and you're good again. load_zsh_theme() { - if [ ! "$1" = '' ]; then; ZSH_THEME="$1"; fi + [[ $1 != '' ]] && ZSH_THEME=$1 _source_zsh_theme || _default_theming } +# This is where the magic happens check_for_updates find_plugin_paths initialize_completions diff --git a/templates/zshrc.zsh-template b/templates/zshrc.zsh-template index ffad178f6..68fb5f231 100644 --- a/templates/zshrc.zsh-template +++ b/templates/zshrc.zsh-template @@ -48,7 +48,7 @@ ZSH_THEME="robbyrussell" # Example format: plugins=(rails git textmate ruby lighthouse) plugins=(git) -source $ZSH/oh-my-zsh.sh +source $ZSH/oh-my-zsh.zsh # User configuration