Merge branch 'ohmyzsh:master' into master

This commit is contained in:
Ruize Tang 2024-04-09 22:00:52 +08:00 committed by GitHub
commit dc8b99cabe
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
395 changed files with 11190 additions and 4939 deletions

View file

@ -5,10 +5,10 @@ ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg[white]%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%})"
# Text to display if the branch is dirty
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[red]%}*%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[red]%}*%{$reset_color%}"
# Text to display if the branch is clean
ZSH_THEME_GIT_PROMPT_CLEAN=""
ZSH_THEME_GIT_PROMPT_CLEAN=""
# Colors vary depending on time lapsed.
ZSH_THEME_GIT_TIME_SINCE_COMMIT_SHORT="%{$fg[green]%}"
@ -36,7 +36,7 @@ function rvm_gemset() {
GEMSET=`rvm gemset list | grep '=>' | cut -b4-`
if [[ -n $GEMSET ]]; then
echo "%{$fg[yellow]%}$GEMSET%{$reset_color%}|"
fi
fi
fi
}
@ -52,12 +52,12 @@ function git_time_since_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 [[ -n $(git status -s 2> /dev/null) ]]; then
if [ "$MINUTES" -gt 30 ]; then
COLOR="$ZSH_THEME_GIT_TIME_SINCE_COMMIT_LONG"

View file

@ -79,7 +79,7 @@ ps1_command_tip() {
command wget -qO- https://www.commandlinefu.com/commands/random/plaintext
elif (( ${+commands[curl]} )); then
command curl -fsL https://www.commandlinefu.com/commands/random/plaintext
fi
fi
} | sed '1d;/^$/d'
}

View file

@ -6,11 +6,12 @@
# dashed separator size
function afmagic_dashes {
# check either virtualenv or condaenv variables
local python_env="${VIRTUAL_ENV:-$CONDA_DEFAULT_ENV}"
local python_env_dir="${VIRTUAL_ENV:-$CONDA_DEFAULT_ENV}"
local python_env="${python_env_dir##*/}"
# if there is a python virtual environment and it is displayed in
# the prompt, account for it when returning the number of dashes
if [[ -n "$python_env" && "$PS1" = \(* ]]; then
if [[ -n "$python_env" && "$PS1" = *\(${python_env}\)* ]]; then
echo $(( COLUMNS - ${#python_env} - 3 ))
else
echo $COLUMNS

View file

@ -109,13 +109,26 @@ prompt_git() {
if [[ "$(git rev-parse --is-inside-work-tree 2>/dev/null)" = "true" ]]; then
repo_path=$(git rev-parse --git-dir 2>/dev/null)
dirty=$(parse_git_dirty)
ref=$(git symbolic-ref HEAD 2> /dev/null) || ref="➦ $(git rev-parse --short HEAD 2> /dev/null)"
ref=$(git symbolic-ref HEAD 2> /dev/null) || \
ref="◈ $(git describe --exact-match --tags HEAD 2> /dev/null)" || \
ref="➦ $(git rev-parse --short HEAD 2> /dev/null)"
if [[ -n $dirty ]]; then
prompt_segment yellow black
else
prompt_segment green $CURRENT_FG
fi
local ahead behind
ahead=$(git log --oneline @{upstream}.. 2>/dev/null)
behind=$(git log --oneline ..@{upstream} 2>/dev/null)
if [[ -n "$ahead" ]] && [[ -n "$behind" ]]; then
PL_BRANCH_CHAR=$'\u21c5'
elif [[ -n "$ahead" ]]; then
PL_BRANCH_CHAR=$'\u21b1'
elif [[ -n "$behind" ]]; then
PL_BRANCH_CHAR=$'\u21b0'
fi
if [[ -e "${repo_path}/BISECT_LOG" ]]; then
mode=" <B>"
elif [[ -e "${repo_path}/MERGE_HEAD" ]]; then

View file

@ -11,8 +11,14 @@ ZSH_THEME_RUBY_PROMPT_PREFIX="%{$fg_bold[red]%}"
ZSH_THEME_RUBY_PROMPT_SUFFIX="%{$reset_color%}"
PROMPT='
%{$fg_bold[green]%}%~%{$reset_color%}$(git_prompt_info) ⌚ %{$fg_bold[red]%}%*%{$reset_color%}
%{$fg_bold[green]%}%~%{$reset_color%}$(git_prompt_info)$(virtualenv_prompt_info) ⌚ %{$fg_bold[red]%}%*%{$reset_color%}
$ '
RPROMPT='$(ruby_prompt_info)'
VIRTUAL_ENV_DISABLE_PROMPT=0
ZSH_THEME_VIRTUAL_ENV_PROMPT_PREFIX=" %{$fg[green]%}🐍"
ZSH_THEME_VIRTUAL_ENV_PROMPT_SUFFIX="%{$reset_color%}"
ZSH_THEME_VIRTUALENV_PREFIX=$ZSH_THEME_VIRTUAL_ENV_PROMPT_PREFIX
ZSH_THEME_VIRTUALENV_SUFFIX=$ZSH_THEME_VIRTUAL_ENV_PROMPT_SUFFIX

View file

@ -11,7 +11,12 @@ $(_user_host)${_current_dir} $(git_prompt_info) $(ruby_prompt_info)
PROMPT2='%{%(!.${fg[red]}.${fg[white]})%}◀%{$reset_color%} '
RPROMPT='$(vi_mode_prompt_info)%{$(echotc UP 1)%}$(_git_time_since_commit) $(git_prompt_status) ${_return_status}%{$(echotc DO 1)%}'
__RPROMPT='$(vi_mode_prompt_info)%{$(echotc UP 1)%}$(_git_time_since_commit) $(git_prompt_status) ${_return_status}%{$(echotc DO 1)%}'
if [[ -z $RPROMPT ]]; then
RPROMPT=$__RPROMPT
else
RPROMPT="${RPROMPT} ${__RPROMPT}"
fi
function _user_host() {
local me
@ -82,4 +87,4 @@ ZSH_THEME_GIT_TIME_SINCE_COMMIT_NEUTRAL="%{$fg[white]%}"
# LS colors, made with https://geoff.greer.fm/lscolors/
export LSCOLORS="exfxcxdxbxegedabagacad"
export LS_COLORS='di=34;40:ln=35;40:so=32;40:pi=33;40:ex=31;40:bd=34;46:cd=34;43:su=0;41:sg=0;46:tw=0;42:ow=0;43:'
export GREP_COLOR='1;33'
export GREP_COLORS='mt=1;33'

View file

@ -1,6 +1,6 @@
# the svn plugin has to be activated for this to work.
local ret_status="%(?:%{$fg_bold[green]%}➜ :%{$fg_bold[red]%}➜ %s)"
PROMPT='${ret_status}%{$fg_bold[green]%} %{$fg[cyan]%}%c %{$fg_bold[blue]%}$(git_prompt_info)%{$fg_bold[blue]%}$(svn_prompt_info)%{$reset_color%}'
PROMPT='%{${ret_status}%}%{$fg_bold[green]%} %{$fg[cyan]%}%c %{$fg_bold[blue]%}$(git_prompt_info)%{$fg_bold[blue]%}$(svn_prompt_info)%{$reset_color%}'
ZSH_THEME_GIT_PROMPT_PREFIX="git:(%{$fg[red]%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}"

View file

@ -6,10 +6,15 @@ local current_dir="%B%{$fg[blue]%}%~ %{$reset_color%}"
local vcs_branch='$(git_prompt_info)$(hg_prompt_info)'
local rvm_ruby='$(ruby_prompt_info)'
local venv_prompt='$(virtualenv_prompt_info)'
if [[ "${plugins[@]}" =~ 'kube-ps1' ]]; then
local kube_prompt='$(kube_ps1)'
else
local kube_prompt=''
fi
ZSH_THEME_RVM_PROMPT_OPTIONS="i v g"
PROMPT="╭─${user_host}${current_dir}${rvm_ruby}${vcs_branch}${venv_prompt}
PROMPT="╭─${user_host}${current_dir}${rvm_ruby}${vcs_branch}${venv_prompt}${kube_prompt}
╰─%B${user_symbol}%b "
RPROMPT="%B${return_code}%b"

View file

@ -15,6 +15,7 @@ ZSH_THEME_GIT_PROMPT_BEHIND="%{$fg[magenta]%}▾%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_STAGED="%{$fg_bold[green]%}●%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_UNSTAGED="%{$fg_bold[yellow]%}●%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg_bold[red]%}●%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_STASHED="(%{$fg_bold[blue]%}✹%{$reset_color%})"
bureau_git_info () {
local ref
@ -67,6 +68,12 @@ bureau_git_status() {
}
bureau_git_prompt() {
# ignore non git folders and hidden repos (adapted from lib/git.zsh)
if ! command git rev-parse --git-dir &> /dev/null \
|| [[ "$(command git config --get oh-my-zsh.hide-info 2>/dev/null)" == 1 ]]; then
return
fi
# check git information
local gitinfo=$(bureau_git_info)
if [[ -z "$gitinfo" ]]; then

View file

@ -1,15 +1,15 @@
# CRUNCH - created from Steve Eley's cat waxing.
# Initially hacked from the Dallas theme. Thanks, Dallas Reedy.
#
# This theme assumes you do most of your oh-my-zsh'ed "colorful" work at a single machine,
# and eschews the standard space-consuming user and hostname info. Instead, only the
# This theme assumes you do most of your oh-my-zsh'ed "colorful" work at a single machine,
# and eschews the standard space-consuming user and hostname info. Instead, only the
# things that vary in my own workflow are shown:
#
# * The time (not the date)
# * The RVM version and gemset (omitting the 'ruby' name if it's MRI)
# * The current directory
# * The Git branch and its 'dirty' state
#
#
# Colors are at the top so you can mess with those separately if you like.
# For the most part I stuck with Dallas's.

View file

@ -1,5 +1,5 @@
# RVM settings
if [[ -s ~/.rvm/scripts/rvm ]] ; then
if [[ -s ~/.rvm/scripts/rvm ]] ; then
RPS1="%{$fg[yellow]%}rvm:%{$reset_color%}%{$fg[red]%}\$(~/.rvm/bin/rvm-prompt)%{$reset_color%} $EPS1"
else
if which rbenv &> /dev/null; then

View file

@ -11,7 +11,7 @@
#
# There are pre-defined different emoji sets to choose from, e.g.:
# emoji, stellar, floral, zodiac, love (see emotty plugin).
#
#
# To choose a different emotty set than the default (emoji)
# % export emotty_set=nature
#
@ -95,7 +95,7 @@ zstyle ':vcs_info:*' stagedstr "${green}${vcs_staged_glyph}"
# %(k|f) reset (back|fore)ground color
zstyle ':vcs_info:*' max-exports 3
zstyle ':vcs_info:*' nvcsformats "${prompt_glyph}" '%3~' ''
zstyle ':vcs_info:*' formats "${yellow}%u%c%b${vcs_branch_glyph}%f" '%S|' "$FX[bold]%r$FX[no-bold]"
zstyle ':vcs_info:*' formats "${yellow}%u%c%b${vcs_branch_glyph}%f" '%S|' "$FX[bold]%r$FX[no-bold]"
zstyle ':vcs_info:*' actionformats "${red}%K{white}%a${vcs_action_glyph}%k%f" '%S|' "$FX[bold]%r$FX[no-bold]"
red_if_root="%(!.%F{red}.)"

View file

@ -8,7 +8,7 @@
# - prefix to detect docker containers or chroot
# - git plugin to display current branch and status
# git plugin
# git plugin
ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg[cyan]%}("
ZSH_THEME_GIT_PROMPT_SUFFIX=") %{$reset_color%}"
ZSH_THEME_GIT_PROMPT_UNTRACKED="%%"
@ -35,7 +35,7 @@ if [[ -n "$SSH_CONNECTION" ]]; then
ZSH_ESSEMBEH_PREFIX="%{$fg[yellow]%}[$(echo $SSH_CONNECTION | awk '{print $1}')]%{$reset_color%} "
# use red color to highlight a remote connection
ZSH_ESSEMBEH_COLOR="red"
elif [[ -r /etc/debian_chroot ]]; then
elif [[ -r /etc/debian_chroot ]]; then
# prefix prompt in case of chroot
ZSH_ESSEMBEH_PREFIX="%{$fg[yellow]%}[chroot:$(cat /etc/debian_chroot)]%{$reset_color%} "
elif [[ -r /.dockerenv ]]; then

View file

@ -12,6 +12,7 @@
# Also borrowing from http://stevelosh.com/blog/2010/02/my-extravagant-zsh-prompt/
function virtualenv_info {
[ $CONDA_DEFAULT_ENV ] && echo "($CONDA_DEFAULT_ENV) "
[ $VIRTUAL_ENV ] && echo '('`basename $VIRTUAL_ENV`') '
}

View file

@ -1,7 +1,7 @@
PROMPT='
%{$fg_bold[gray]%}%~%{$fg_bold[blue]%}%{$fg_bold[blue]%} % %{$reset_color%}
%{$fg[green]%}➞ %{$reset_color%'
%{$fg[green]%}➞ %{$reset_color%}'
RPROMPT='$(git_prompt_info) $(ruby_prompt_info)'

View file

@ -1,24 +1,140 @@
# Depends on the git plugin for work_in_progress()
(( $+functions[work_in_progress] )) || work_in_progress() {}
ZSH_THEME_GIT_PROMPT_PREFIX="%{$reset_color%}%{$fg[green]%}["
ZSH_THEME_GIT_PROMPT_SUFFIX="]%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[red]%}*%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg[cyan]%}[%{$fg[green]%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$fg[cyan]%}]"
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[red]%}"
ZSH_THEME_GIT_PROMPT_CLEAN=""
# Customized git status, oh-my-zsh currently does not allow render dirty status before branch
git_custom_status() {
local branch=$(git_current_branch)
[[ -n "$branch" ]] || return 0
echo "$(parse_git_dirty)\
%{${fg_bold[yellow]}%}$(work_in_progress)%{$reset_color%}\
${ZSH_THEME_GIT_PROMPT_PREFIX}${branch}${ZSH_THEME_GIT_PROMPT_SUFFIX}"
print "%{${fg_bold[yellow]}%}$(work_in_progress)%{$reset_color%}\
${ZSH_THEME_GIT_PROMPT_PREFIX}$(parse_git_dirty)${branch}\
${ZSH_THEME_GIT_PROMPT_SUFFIX}"
}
autoload -U colors && colors
#export VCS_PROMPT=hg_prompt_info
export VCS_PROMPT=git_custom_status
base_prompt="%{$fg[cyan]%}[%~% ]%(?.%{$fg[green]%}.%{$fg[red]%})%B$%b "
custom_prompt=""
last_run_time=""
last_vcs_info=""
function pipestatus_parse {
PIPESTATUS="$pipestatus"
ERROR=0
for i in "${(z)PIPESTATUS}"; do
if [[ "$i" -ne 0 ]]; then
ERROR=1
fi
done
if [[ "$ERROR" -ne 0 ]]; then
print "[%{$fg[red]%}$PIPESTATUS%{$fg[cyan]%}]"
fi
}
# RVM component of prompt
ZSH_THEME_RUBY_PROMPT_PREFIX="%{$fg[red]%}["
ZSH_THEME_RUBY_PROMPT_SUFFIX="]%{$reset_color%}"
# Combine it all into a final right-side prompt
RPS1="\$(git_custom_status)\$(ruby_prompt_info)${RPS1:+ $RPS1}"
PROMPT='%{$fg[cyan]%}[%~% ]%(?.%{$fg[green]%}.%{$fg[red]%})%B$%b '
function preexec() {
last_run_time=$(perl -MTime::HiRes=time -e 'printf "%.9f\n", time')
}
function duration() {
local duration
local now=$(perl -MTime::HiRes=time -e 'printf "%.9f\n", time')
local last=$1
local last_split=("${(@s/./)last}")
local now_split=("${(@s/./)now}")
local T=$((now_split[1] - last_split[1]))
local D=$((T/60/60/24))
local H=$((T/60/60%24))
local M=$((T/60%60))
local S=$((T%60))
local s=$(((now_split[2] - last_split[2]) / 1000000000.))
local m=$(((now_split[2] - last_split[2]) / 1000000.))
(( $D > 0 )) && duration+="${D}d"
(( $H > 0 )) && duration+="${H}h"
(( $M > 0 )) && duration+="${M}m"
if [[ $S -le 0 ]]; then
printf "%ims" "$m"
else
if ! [[ -z $duration ]] && printf "%s" "$duration"
local sec_milli=$((S + s))
printf "%.3fs" "$sec_milli"
fi
}
function precmd() {
RETVAL=$(pipestatus_parse)
local info=""
if [ ! -z "$last_run_time" ]; then
local elapsed=$(duration $last_run_time)
last_run_time=$(print $last_run_time | tr -d ".")
if [ $(( $(perl -MTime::HiRes=time -e 'printf "%.9f\n", time' | tr -d ".") - $last_run_time )) -gt $(( 120 * 1000 * 1000 * 1000 )) ]; then
local elapsed_color="%{$fg[magenta]%}"
elif [ $(( $(perl -MTime::HiRes=time -e 'printf "%.9f\n", time' | tr -d ".") - $last_run_time )) -gt $(( 60 * 1000 * 1000 * 1000 )) ]; then
local elapsed_color="%{$fg[red]%}"
elif [ $(( $(perl -MTime::HiRes=time -e 'printf "%.9f\n", time' | tr -d ".") - $last_run_time )) -gt $(( 10 * 1000 * 1000 * 1000 )) ]; then
local elapsed_color="%{$fg[yellow]%}"
else
local elapsed_color="%{$fg[green]%}"
fi
info=$(printf "%s%s%s%s%s" "%{$fg[cyan]%}[" "$elapsed_color" "$elapsed" "%{$fg[cyan]%}]" "$RETVAL")
unset last_run_time
fi
if [ -z "$info" -a ! -z "$last_vcs_info" ]; then
custom_prompt="$last_vcs_info$base_prompt"
return;
fi
if (( ${+VCS_PROMPT} )); then
last_vcs_info=$($VCS_PROMPT)
if [ ! -z "$last_vcs_info" ]; then
[ -z "$info" ] && info=$last_vcs_info || info="$info$last_vcs_info"
fi
fi
[ -z "$info" ] && custom_prompt="$base_prompt" || custom_prompt="$info$base_prompt"
}
function hg_prompt_info() {
unset output info parts branch_parts branch
local output=""
if ! output="$(hg status 2> /dev/null)"; then
return
fi
local info=$(hg log -l1 --template '{author}:{node|short}:{remotenames}:{phabdiff}')
local parts=(${(@s/:/)info})
local branch_parts=(${(@s,/,)parts[3]})
local branch=${branch_parts[-1]}
[ ! -z "${parts[3]}" ] && [[ "${parts[1]}" =~ "$USER@" ]] && branch=${parts[3]}
[ -z "${parts[3]}" ] && branch=${parts[2]}
if [[ ! -z "$output" ]]; then
local color="%{$fg[red]%}"
elif [[ "${branch}" == "master" || "${branch}" == "warm" ]]; then
local color="%{$fg[yellow]%}"
else
local color="%{$fg[green]%}"
fi
print "%{$fg[cyan]%}[${color}${branch}%{$fg[cyan]%}]"
}
setopt PROMPT_SUBST
PROMPT='$custom_prompt'

View file

@ -21,7 +21,7 @@ fi
if [[ -n "$SSH_CLIENT" || -n "$SSH2_CLIENT" ]]; then
PR_HOST='%F{red}%M%f' # SSH
else
PR_HOST='%F{green}%M%f' # no SSH
PR_HOST='%F{green}%m%f' # no SSH
fi

View file

@ -89,5 +89,9 @@ ZSH_THEME_RUBY_PROMPT_PREFIX="with%F{red} "
ZSH_THEME_RUBY_PROMPT_SUFFIX="%{$reset_color%}"
ZSH_THEME_RVM_PROMPT_OPTIONS="v g"
# virtualenv prompt settings
ZSH_THEME_VIRTUALENV_PREFIX=" with%F{red} "
ZSH_THEME_VIRTUALENV_SUFFIX="%{$reset_color%}"
setopt prompt_subst
PROMPT="${purple}%n%{$reset_color%} in ${limegreen}%~%{$reset_color%}\$(ruby_prompt_info)\$vcs_info_msg_0_${orange} λ%{$reset_color%} "
PROMPT="${purple}%n%{$reset_color%} in ${limegreen}%~%{$reset_color%}\$(virtualenv_prompt_info)\$(ruby_prompt_info)\$vcs_info_msg_0_${orange} λ%{$reset_color%} "

View file

@ -15,7 +15,7 @@ function josh_prompt {
branch_size=${#branch}
ruby_size=${#ruby_version}
user_machine_size=${#${(%):-%n@%m-}}
if [[ ${#branch} -eq 0 ]]
then (( ruby_size = ruby_size + 1 ))
else
@ -24,15 +24,15 @@ function josh_prompt {
(( branch_size = branch_size + 2 ))
fi
fi
(( spare_width = ${spare_width} - (${user_machine_size} + ${path_size} + ${branch_size} + ${ruby_size}) ))
while [ ${#prompt} -lt $spare_width ]; do
prompt=" $prompt"
done
prompt="%{%F{green}%}$PWD$prompt%{%F{red}%}$(ruby_prompt_info)%{$reset_color%} $(git_current_branch)"
echo $prompt
}

View file

@ -3,10 +3,10 @@
# Grab the current date (%W) and time (%t):
JUNKFOOD_TIME_="%{$fg_bold[red]%}#%{$fg_bold[white]%}( %{$fg_bold[yellow]%}%W%{$reset_color%}@%{$fg_bold[white]%}%t )( %{$reset_color%}"
# Grab the current machine name
# Grab the current machine name
JUNKFOOD_MACHINE_="%{$fg_bold[blue]%}%m%{$fg[white]%} ):%{$reset_color%}"
# Grab the current username
# Grab the current username
JUNKFOOD_CURRENT_USER_="%{$fg_bold[green]%}%n%{$reset_color%}"
# Grab the current filepath, use shortcuts: ~/Desktop

View file

@ -29,14 +29,13 @@ local cyan="%{$fg_bold[cyan]%}"
local yellow="%{$fg_bold[yellow]%}"
local blue="%{$fg_bold[blue]%}"
local magenta="%{$fg_bold[magenta]%}"
local white="%{$fg_bold[white]%}"
local reset="%{$reset_color%}"
local -a color_array
color_array=($green $red $cyan $yellow $blue $magenta $white)
color_array=($green $red $cyan $yellow $blue $magenta)
local username_color=$white
local hostname_color=$color_array[$[((#HOST))%7+1]] # choose hostname color based on first character
local username_color=$blue
local hostname_color=$color_array[$[((#HOST))%6+1]] # choose hostname color based on first character
local current_dir_color=$blue
local username="%n"
@ -66,10 +65,10 @@ function michelebologna_git_prompt {
local out=$(git_prompt_info)$(git_prompt_status)$(git_remote_status)
[[ -n $out ]] || return
printf " %s(%s%s%s)%s" \
"%{$fg_bold[white]%}" \
"%{$fg_bold[blue]%}" \
"%{$fg_bold[green]%}" \
"$out" \
"%{$fg_bold[white]%}" \
"%{$fg_bold[blue]%}" \
"%{$reset_color%}"
}

View file

@ -15,7 +15,7 @@
# To customize symbols (e.g MLH_AT_SYMBOL), simply set them as environment variables
# for example in your ~/.zshrc file, like this:
# MLH_AT_SYMBOL=" at "
#
#
# Settings *must* be set before sourcing oh-my-zsh.sh the .zshrc file.
#
# To easily discover colors and their codes, type `spectrum_ls` in the terminal
@ -47,6 +47,10 @@ if [ -z "$MLH_SHELL_SYMBOL" ]; then
MLH_SHELL_SYMBOL="$ "
fi
if [ -z "$MLH_SHELL_SYMBOL_ROOT" ]; then
MLH_SHELL_SYMBOL_ROOT="# "
fi
# colors
USER_COLOR="%F{001}"
DEVICE_COLOR="%F{033}"
@ -83,7 +87,11 @@ exit_code() {
}
prompt_end() {
printf "\n$MLH_SHELL_SYMBOL"
if [ "$UID" -eq 0 ]; then
printf "\n$MLH_SHELL_SYMBOL_ROOT"
else
printf "\n$MLH_SHELL_SYMBOL"
fi
}
# Set git_prompt_info text

View file

@ -1,6 +1,6 @@
function my_git_prompt() {
tester=$(git rev-parse --git-dir 2> /dev/null) || return
INDEX=$(git status --porcelain 2> /dev/null)
STATUS=""
@ -51,8 +51,14 @@ function ssh_connection() {
fi
}
function _toolbox_prompt_info() {
if typeset -f toolbox_prompt_info > /dev/null; then
toolbox_prompt_info
fi
}
local ret_status="%(?:%{$fg_bold[green]%}:%{$fg_bold[red]%})%?%{$reset_color%}"
PROMPT=$'\n$(ssh_connection)%{$fg_bold[green]%}%n@%m%{$reset_color%}$(my_git_prompt) : %~\n[${ret_status}] %# '
PROMPT=$'\n$(_toolbox_prompt_info)$(ssh_connection)%{$fg_bold[green]%}%n@%m%{$reset_color%}$(my_git_prompt) : %~\n[${ret_status}] %# '
ZSH_THEME_PROMPT_RETURNCODE_PREFIX="%{$fg_bold[red]%}"
ZSH_THEME_GIT_PROMPT_PREFIX=" $fg[white] %{$fg_bold[yellow]%}"

View file

@ -0,0 +1,24 @@
# Depends on the git plugin for work_in_progress()
(( $+functions[work_in_progress] )) || work_in_progress() {}
ZSH_THEME_GIT_PROMPT_PREFIX="%{$reset_color%}%{$fg[green]%}["
ZSH_THEME_GIT_PROMPT_SUFFIX="]%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[red]%}*%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_CLEAN=""
# Customized git status, oh-my-zsh currently does not allow render dirty status before branch
git_custom_status() {
local branch=$(git_current_branch)
[[ -n "$branch" ]] || return 0
echo "$(parse_git_dirty)\
%{${fg_bold[yellow]}%}$(work_in_progress)%{$reset_color%}\
${ZSH_THEME_GIT_PROMPT_PREFIX}${branch}${ZSH_THEME_GIT_PROMPT_SUFFIX}"
}
# RVM component of prompt
ZSH_THEME_RUBY_PROMPT_PREFIX="%{$fg[red]%}["
ZSH_THEME_RUBY_PROMPT_SUFFIX="]%{$reset_color%}"
# Combine it all into a final right-side prompt
RPS1="\$(git_custom_status)\$(ruby_prompt_info)${RPS1:+ $RPS1}"
PROMPT='%{$fg[cyan]%}[%~% ]%(?.%{$fg[green]%}.%{$fg[red]%})%B$%b '

View file

@ -11,11 +11,11 @@
# more about both of these fantastic two people here:
#
# Sindre Sorhus
# Github: https://github.com/sindresorhus
# GitHub: https://github.com/sindresorhus
# Twitter: https://twitter.com/sindresorhus
#
# Julien Nicoulaud
# Github: https://github.com/nicoulaj
# GitHub: https://github.com/nicoulaj
# Twitter: https://twitter.com/nicoulaj
#
# ------------------------------------------------------------------------------

View file

@ -1,7 +1,7 @@
# user, host, full path, and time/date on two lines for easier vgrepping
function hg_prompt_info {
if (( $+commands[hg] )) && grep -q "prompt" ~/.hgrc; then
if (( $+commands[hg] )) && [[ -e ~/.hgrc ]] && grep -q "prompt" ~/.hgrc; then
hg prompt --angle-brackets "\
<hg:%{$fg[magenta]%}<branch>%{$reset_color%}><:%{$fg[magenta]%}<bookmark>%{$reset_color%}>\
</%{$fg[yellow]%}<tags|%{$reset_color%}, %{$fg[yellow]%}>%{$reset_color%}>\

View file

@ -1,7 +1,7 @@
PROMPT="%(?:%{$fg_bold[green]%}➜ :%{$fg_bold[red]%}➜ )"
PROMPT+=' %{$fg[cyan]%}%c%{$reset_color%} $(git_prompt_info)'
PROMPT="%(?:%{$fg_bold[green]%}%1{➜%} :%{$fg_bold[red]%}%1{➜%} ) %{$fg[cyan]%}%c%{$reset_color%}"
PROMPT+=' $(git_prompt_info)'
ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg_bold[blue]%}git:(%{$fg[red]%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%} "
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[blue]%}) %{$fg[yellow]%}"
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[blue]%}) %{$fg[yellow]%}%1{✗%}"
ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg[blue]%})"

View file

@ -1,4 +1,4 @@
#!/usr/bin/env zsh
#!/usr/bin/env zsh
#local return_code="%(?..%{$fg[red]%}%? ↵%{$reset_color%})"
setopt promptsubst

View file

@ -5,9 +5,9 @@
# - Place that bundle in ~/Library/Application\ Support/SIMBL/Plugins (create that folder if it doesn't exist)
# - Open Terminal preferences. Go to Settings -> Text -> More
# - Change default colours to your liking.
#
#
# Here are the colours from Textmate's Monokai theme:
#
#
# Black: 0, 0, 0
# Red: 229, 34, 34
# Green: 166, 227, 45
@ -28,7 +28,7 @@ PROMPT='%{$fg[magenta]%}[%c] %{$reset_color%}'
RPROMPT='${time} %{$fg[magenta]%}$(git_prompt_info)%{$reset_color%}$(git_prompt_status)%{$reset_color%}$(git_prompt_ahead)%{$reset_color%}'
# Add this at the start of RPROMPT to include rvm info showing ruby-version@gemset-name
# $(ruby_prompt_info)
# $(ruby_prompt_info)
# local time, color coded by last return code
time_enabled="%(?.%{$fg[green]%}.%{$fg[red]%})%*%{$reset_color%}"
@ -53,7 +53,7 @@ ZSH_THEME_RUBY_PROMPT_SUFFIX="%{$reset_color%}"
# More symbols to choose from:
# ☀ ✹ ☄ ♆ ♀ ♁ ♐ ♇ ♈ ♉ ♚ ♛ ♜ ♝ ♞ ♟ ♠ ♣ ⚢ ⚲ ⚳ ⚴ ⚥ ⚤ ⚦ ⚒ ⚑ ⚐ ♺ ♻ ♼ ☰ ☱ ☲ ☳ ☴ ☵ ☶ ☷
# ✡ ✔ ✖ ✚ ✱ ✤ ✦ ❤ ➜ ➟ ➼ ✂ ✎ ✐ ⨀ ⨁ ⨂ ⨍ ⨎ ⨏ ⨷ ⩚ ⩛ ⩡ ⩱ ⩲ ⩵ ⩶ ⨠
# ✡ ✔ ✖ ✚ ✱ ✤ ✦ ❤ ➜ ➟ ➼ ✂ ✎ ✐ ⨀ ⨁ ⨂ ⨍ ⨎ ⨏ ⨷ ⩚ ⩛ ⩡ ⩱ ⩲ ⩵ ⩶ ⨠
# ⬅ ⬆ ⬇ ⬈ ⬉ ⬊ ⬋ ⬒ ⬓ ⬔ ⬕ ⬖ ⬗ ⬘ ⬙ ⬟ ⬤ 〒 ǀ ǁ ǂ ĭ Ť Ŧ
# Determine if we are using a gemset.
@ -61,7 +61,7 @@ function rvm_gemset() {
GEMSET=`rvm gemset list | grep '=>' | cut -b4-`
if [[ -n $GEMSET ]]; then
echo "%{$fg[yellow]%}$GEMSET%{$reset_color%}|"
fi
fi
}
# Determine the time since last commit. If branch is clean,
@ -76,12 +76,12 @@ function git_time_since_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 [[ -n $(git status -s 2> /dev/null) ]]; then
if [ "$MINUTES" -gt 30 ]; then
COLOR="$ZSH_THEME_GIT_TIME_SINCE_COMMIT_LONG"