summaryrefslogtreecommitdiff
path: root/themes
diff options
context:
space:
mode:
Diffstat (limited to 'themes')
-rw-r--r--themes/af-magic.zsh-theme39
-rw-r--r--themes/agnoster.zsh-theme40
-rw-r--r--themes/avit.zsh-theme81
-rw-r--r--themes/norm.zsh-theme5
-rw-r--r--themes/random.zsh-theme38
5 files changed, 115 insertions, 88 deletions
diff --git a/themes/af-magic.zsh-theme b/themes/af-magic.zsh-theme
index 30e997f8c..148991fec 100644
--- a/themes/af-magic.zsh-theme
+++ b/themes/af-magic.zsh-theme
@@ -2,29 +2,28 @@
# Repo: https://github.com/andyfleming/oh-my-zsh
# Direct Link: https://github.com/andyfleming/oh-my-zsh/blob/master/themes/af-magic.zsh-theme
-if [ $UID -eq 0 ]; then NCOLOR="red"; else NCOLOR="green"; fi
-local return_code="%(?..%{$fg[red]%}%? ↵%{$reset_color%})"
-# primary prompt
-PROMPT='$FG[237]${(l.COLUMNS..-.)}%{$reset_color%}
-$FG[032]%~\
-$(git_prompt_info)$(hg_prompt_info) \
-$FG[105]%(!.#.»)%{$reset_color%} '
-PROMPT2='%{$fg[red]%}\ %{$reset_color%}'
-RPS1='${return_code}'
+# settings
+typeset +H return_code="%(?..%{$fg[red]%}%? ↵%{$reset_color%})"
+typeset +H my_gray="$FG[237]"
+typeset +H my_orange="$FG[214]"
+# separator dashes size
+function afmagic_dashes {
+ [[ -n "${VIRTUAL_ENV-}" && -z "${VIRTUAL_ENV_DISABLE_PROMPT-}" && "$PS1" = \(* ]] \
+ && echo $(( COLUMNS - ${#VIRTUAL_ENV} - 3 )) \
+ || echo $COLUMNS
+}
-# color vars
-eval my_gray='$FG[237]'
-eval my_orange='$FG[214]'
+# primary prompt
+PS1='$FG[237]${(l.$(afmagic_dashes)..-.)}%{$reset_color%}
+$FG[032]%~$(git_prompt_info)$(hg_prompt_info) $FG[105]%(!.#.»)%{$reset_color%} '
+PS2='%{$fg[red]%}\ %{$reset_color%}'
+RPS1='${return_code}'
# right prompt
-if type "virtualenv_prompt_info" > /dev/null
-then
- RPROMPT="${RPROMPT}"'$FG[078]$(virtualenv_prompt_info)%{$reset_color%} $my_gray%n@%m%{$reset_color%}%'
-else
- RPROMPT="${RPROMPT}"'$my_gray%n@%m%{$reset_color%}%'
-fi
+(( $+functions[virtualenv_prompt_info] )) && RPS1+='$(virtualenv_prompt_info)'
+RPS1+=' $my_gray%n@%m%{$reset_color%}%'
# git settings
ZSH_THEME_GIT_PROMPT_PREFIX="$FG[075]($FG[078]"
@@ -37,3 +36,7 @@ ZSH_THEME_HG_PROMPT_PREFIX="$FG[075]($FG[078]"
ZSH_THEME_HG_PROMPT_CLEAN=""
ZSH_THEME_HG_PROMPT_DIRTY="$my_orange*%{$reset_color%}"
ZSH_THEME_HG_PROMPT_SUFFIX="$FG[075])%{$reset_color%}"
+
+# virtualenv settings
+ZSH_THEME_VIRTUALENV_PREFIX=" $FG[075]["
+ZSH_THEME_VIRTUALENV_SUFFIX="]%{$reset_color%}"
diff --git a/themes/agnoster.zsh-theme b/themes/agnoster.zsh-theme
index 05a50cd2b..89b75aa55 100644
--- a/themes/agnoster.zsh-theme
+++ b/themes/agnoster.zsh-theme
@@ -140,24 +140,30 @@ prompt_git() {
}
prompt_bzr() {
- (( $+commands[bzr] )) || return
- if (bzr status >/dev/null 2>&1); then
- status_mod=`bzr status | head -n1 | grep "modified" | wc -m`
- status_all=`bzr status | head -n1 | wc -m`
- revision=`bzr log | head -n2 | tail -n1 | sed 's/^revno: //'`
- if [[ $status_mod -gt 0 ]] ; then
- prompt_segment yellow black
- echo -n "bzr@"$revision "✚ "
- else
- if [[ $status_all -gt 0 ]] ; then
- prompt_segment yellow black
- echo -n "bzr@"$revision
- else
- prompt_segment green black
- echo -n "bzr@"$revision
- fi
- fi
+ (( $+commands[bzr] )) || return
+
+ # Test if bzr repository in directory hierarchy
+ local dir="$PWD"
+ while [[ ! -d "$dir/.bzr" ]]; do
+ [[ "$dir" = "/" ]] && return
+ dir="${dir:h}"
+ done
+
+ local bzr_status status_mod status_all revision
+ if bzr_status=$(bzr status 2>&1); then
+ status_mod=$(echo -n "$bzr_status" | head -n1 | grep "modified" | wc -m)
+ status_all=$(echo -n "$bzr_status" | head -n1 | wc -m)
+ revision=$(bzr log -r-1 --log-format line | cut -d: -f1)
+ if [[ $status_mod -gt 0 ]] ; then
+ prompt_segment yellow black "bzr@$revision ✚"
+ else
+ if [[ $status_all -gt 0 ]] ; then
+ prompt_segment yellow black "bzr@$revision"
+ else
+ prompt_segment green black "bzr@$revision"
+ fi
fi
+ fi
}
prompt_hg() {
diff --git a/themes/avit.zsh-theme b/themes/avit.zsh-theme
index aec14e4a6..0261f0ff3 100644
--- a/themes/avit.zsh-theme
+++ b/themes/avit.zsh-theme
@@ -1,27 +1,20 @@
# AVIT ZSH Theme
-PROMPT='
-$(_user_host)${_current_dir} $(git_prompt_info) $(_ruby_version)
-%{$fg[$CARETCOLOR]%}▶%{$resetcolor%} '
-
-PROMPT2='%{$fg[$CARETCOLOR]%}◀%{$reset_color%} '
+# settings
+typeset +H _current_dir="%{$fg_bold[blue]%}%3~%{$reset_color%} "
+typeset +H _return_status="%{$fg_bold[red]%}%(?..⍉)%{$reset_color%}"
+typeset +H _hist_no="%{$fg[grey]%}%h%{$reset_color%}"
-RPROMPT='$(_vi_status)%{$(echotc UP 1)%}$(_git_time_since_commit) $(git_prompt_status) ${_return_status}%{$(echotc DO 1)%}'
+PROMPT='
+$(_user_host)${_current_dir} $(git_prompt_info) $(ruby_prompt_info)
+%{%(!.%F{red}.%F{white})%}▶%{$resetcolor%} '
-local _current_dir="%{$fg_bold[blue]%}%3~%{$reset_color%} "
-local _return_status="%{$fg_bold[red]%}%(?..⍉)%{$reset_color%}"
-local _hist_no="%{$fg[grey]%}%h%{$reset_color%}"
+PROMPT2='%{%(!.%F{red}.%F{white})%}◀%{$reset_color%} '
-function _current_dir() {
- local _max_pwd_length="65"
- if [[ $(echo -n $PWD | wc -c) -gt ${_max_pwd_length} ]]; then
- echo "%{$fg_bold[blue]%}%-2~ ... %3~%{$reset_color%} "
- else
- echo "%{$fg_bold[blue]%}%~%{$reset_color%} "
- fi
-}
+RPROMPT='$(vi_mode_prompt_info)%{$(echotc UP 1)%}$(_git_time_since_commit) $(git_prompt_status) ${_return_status}%{$(echotc DO 1)%}'
function _user_host() {
+ local me
if [[ -n $SSH_CONNECTION ]]; then
me="%n@%m"
elif [[ $LOGNAME != $USER ]]; then
@@ -32,61 +25,41 @@ function _user_host() {
fi
}
-function _vi_status() {
- if {echo $fpath | grep -q "plugins/vi-mode"}; then
- echo "$(vi_mode_prompt_info)"
- fi
-}
-
-function _ruby_version() {
- if {echo $fpath | grep -q "plugins/rvm"}; then
- echo "%{$fg[grey]%}$(rvm_prompt_info)%{$reset_color%}"
- elif {echo $fpath | grep -q "plugins/rbenv"}; then
- echo "%{$fg[grey]%}$(rbenv_prompt_info)%{$reset_color%}"
- fi
-}
-
# Determine the time since last commit. If branch is clean,
# use a neutral color, otherwise colors will vary according to time.
function _git_time_since_commit() {
-# Only proceed if there is actually a commit.
+ local last_commit now seconds_since_last_commit
+ local minutes hours days years commit_age
+ # Only proceed if there is actually a commit.
if last_commit=$(git log --pretty=format:'%at' -1 2> /dev/null); then
now=$(date +%s)
seconds_since_last_commit=$((now-last_commit))
# Totals
minutes=$((seconds_since_last_commit / 60))
- hours=$((seconds_since_last_commit/3600))
-
- # Sub-hours and sub-minutes
- days=$((seconds_since_last_commit / 86400))
- sub_hours=$((hours % 24))
- sub_minutes=$((minutes % 60))
-
- if [ $hours -ge 24 ]; then
- commit_age="${days}d"
- elif [ $minutes -gt 60 ]; then
- commit_age="${sub_hours}h${sub_minutes}m"
+ hours=$((minutes / 60))
+ days=$((hours / 24))
+ years=$((days / 365))
+
+ if [[ $years -gt 0 ]]; then
+ commit_age="${years}y$((days % 365 ))d"
+ elif [[ $days -gt 0 ]]; then
+ commit_age="${days}d$((hours % 24))h"
+ elif [[ $hours -gt 0 ]]; then
+ commit_age+="${hours}h$(( minutes % 60 ))m"
else
commit_age="${minutes}m"
fi
- color=$ZSH_THEME_GIT_TIME_SINCE_COMMIT_NEUTRAL
- echo "$color$commit_age%{$reset_color%}"
+ echo "${ZSH_THEME_GIT_TIME_SINCE_COMMIT_NEUTRAL}${commit_age}%{$reset_color%}"
fi
}
-if [[ $USER == "root" ]]; then
- CARETCOLOR="red"
-else
- CARETCOLOR="white"
-fi
-
MODE_INDICATOR="%{$fg_bold[yellow]%}❮%{$reset_color%}%{$fg[yellow]%}❮❮%{$reset_color%}"
+# Git prompt settings
ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg[green]%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}"
-
ZSH_THEME_GIT_PROMPT_DIRTY=" %{$fg[red]%}✗%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_CLEAN=" %{$fg[green]%}✔%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_ADDED="%{$fg[green]%}✚ "
@@ -96,6 +69,10 @@ ZSH_THEME_GIT_PROMPT_RENAMED="%{$fg[blue]%}▴ "
ZSH_THEME_GIT_PROMPT_UNMERGED="%{$fg[cyan]%}§ "
ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg[white]%}◒ "
+# Ruby prompt settings
+ZSH_THEME_RUBY_PROMPT_PREFIX="%{$fg[grey]%}"
+ZSH_THEME_RUBY_PROMPT_SUFFIX="%{$reset_color%}"
+
# Colors vary depending on time lapsed.
ZSH_THEME_GIT_TIME_SINCE_COMMIT_SHORT="%{$fg[green]%}"
ZSH_THEME_GIT_TIME_SHORT_COMMIT_MEDIUM="%{$fg[yellow]%}"
diff --git a/themes/norm.zsh-theme b/themes/norm.zsh-theme
index 13077ccf5..bd7ca568a 100644
--- a/themes/norm.zsh-theme
+++ b/themes/norm.zsh-theme
@@ -1,4 +1,7 @@
-PROMPT='%{$fg[yellow]%}λ %m %{$fg[green]%}%c %{$fg[yellow]%}→ $(git_prompt_info)%{$reset_color%}'
+PROMPT='%{$fg[yellow]%}λ %m %{$fg[green]%}%c %{$fg[yellow]%}→ $(git_prompt_info)$(hg_prompt_info)%{$reset_color%}'
ZSH_THEME_GIT_PROMPT_PREFIX="λ %{$fg[blue]%}git %{$fg[red]%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$fg[yellow]%} → %{$reset_color%}"
+ZSH_THEME_HG_PROMPT_PREFIX="λ %{$fg[blue]%}hg %{$fg[red]%}"
+ZSH_THEME_HG_PROMPT_SUFFIX="%{$fg[yellow]%} → %{$reset_color%}"
+
diff --git a/themes/random.zsh-theme b/themes/random.zsh-theme
new file mode 100644
index 000000000..43f6cbb60
--- /dev/null
+++ b/themes/random.zsh-theme
@@ -0,0 +1,38 @@
+# Make themes a unique array
+typeset -Ua themes
+
+if [[ "${(t)ZSH_THEME_RANDOM_CANDIDATES}" = array && ${#ZSH_THEME_RANDOM_CANDIDATES[@]} -gt 0 ]]; then
+ # Use ZSH_THEME_RANDOM_CANDIDATES if properly defined
+ themes=($ZSH_THEME_RANDOM_CANDIDATES)
+else
+ # Look for themes in $ZSH_CUSTOM and $ZSH and add only the theme name
+ themes=(
+ "$ZSH_CUSTOM"/*.zsh-theme(N:t:r)
+ "$ZSH_CUSTOM"/themes/*.zsh-theme(N:t:r)
+ "$ZSH"/themes/*.zsh-theme(N:t:r)
+ )
+ # Remove blacklisted themes from the list
+ for theme in ${ZSH_THEME_RANDOM_BLACKLIST[@]}; do
+ themes=("${(@)themes:#$theme}")
+ done
+fi
+
+# Choose a theme out of the pool of candidates
+N=${#themes[@]}
+(( N = (RANDOM%N) + 1 ))
+RANDOM_THEME="${themes[$N]}"
+unset N themes theme
+
+# Source theme
+if [[ -f "$ZSH_CUSTOM/$RANDOM_THEME.zsh-theme" ]]; then
+ source "$ZSH_CUSTOM/$RANDOM_THEME.zsh-theme"
+elif [[ -f "$ZSH_CUSTOM/themes/$RANDOM_THEME.zsh-theme" ]]; then
+ source "$ZSH_CUSTOM/themes/$RANDOM_THEME.zsh-theme"
+elif [[ -f "$ZSH/themes/$RANDOM_THEME.zsh-theme" ]]; then
+ source "$ZSH/themes/$RANDOM_THEME.zsh-theme"
+else
+ echo "[oh-my-zsh] Random theme '${RANDOM_THEME}' not found"
+ return 1
+fi
+
+echo "[oh-my-zsh] Random theme '${RANDOM_THEME}' loaded"