Update 30.01.2022
This commit is contained in:
@@ -45,9 +45,7 @@ function rvm_gemset() {
|
||||
function git_time_since_commit() {
|
||||
if git rev-parse --git-dir > /dev/null 2>&1; then
|
||||
# Only proceed if there is actually a commit.
|
||||
if [[ $(git log 2>&1 > /dev/null | grep -c "^fatal: bad default revision") == 0 ]]; then
|
||||
# Get the last commit.
|
||||
last_commit=`git log --pretty=format:'%at' -1 2> /dev/null`
|
||||
if last_commit=`git -c log.showSignature=false log --pretty=format:'%at' -1 2> /dev/null`; then
|
||||
now=`date +%s`
|
||||
seconds_since_last_commit=$((now-last_commit))
|
||||
|
||||
|
||||
@@ -32,42 +32,44 @@
|
||||
|
||||
########## COLOR ###########
|
||||
for COLOR in CYAN WHITE YELLOW MAGENTA BLACK BLUE RED DEFAULT GREEN GREY; do
|
||||
eval PR_$COLOR='%{$fg[${(L)COLOR}]%}'
|
||||
eval PR_BRIGHT_$COLOR='%{$fg_bold[${(L)COLOR}]%}'
|
||||
typeset -g PR_$COLOR="%b%{$fg[${(L)COLOR}]%}"
|
||||
typeset -g PR_BRIGHT_$COLOR="%B%{$fg[${(L)COLOR}]%}"
|
||||
done
|
||||
|
||||
PR_RESET="%{$reset_color%}"
|
||||
RED_START="${PR_RESET}${PR_GREY}<${PR_RESET}${PR_RED}<${PR_BRIGHT_RED}<${PR_RESET} "
|
||||
RED_END="${PR_RESET}${PR_BRIGHT_RED}>${PR_RESET}${PR_RED}>${PR_GREY}>${PR_RESET} "
|
||||
GREEN_END="${PR_RESET}${PR_BRIGHT_GREEN}>${PR_RESET}${PR_GREEN}>${PR_GREY}>${PR_RESET} "
|
||||
GREEN_BASE_START="${PR_RESET}${PR_GREY}>${PR_RESET}${PR_GREEN}>${PR_BRIGHT_GREEN}>${PR_RESET}"
|
||||
GREEN_START_P1="${PR_RESET}${GREEN_BASE_START}${PR_RESET} "
|
||||
DIVISION="${PR_RESET}${PR_RED} < ${PR_RESET}"
|
||||
VCS_DIRTY_COLOR="${PR_RESET}${PR_YELLOW}"
|
||||
VCS_CLEAN_COLOR="${PR_RESET}${PR_GREEN}"
|
||||
VCS_SUFIX_COLOR="${PR_RESET}${PR_RED}› ${PR_RESET}"
|
||||
|
||||
RED_START="${PR_GREY}<${PR_RED}<${PR_BRIGHT_RED}<${PR_RESET} "
|
||||
RED_END="${PR_BRIGHT_RED}>${PR_RED}>${PR_GREY}>${PR_RESET} "
|
||||
GREEN_START="${PR_GREY}>${PR_GREEN}>${PR_BRIGHT_GREEN}>${PR_RESET}"
|
||||
GREEN_END="${PR_BRIGHT_GREEN}>${PR_GREEN}>${PR_GREY}>${PR_RESET} "
|
||||
|
||||
########## VCS ###########
|
||||
VCS_DIRTY_COLOR="${PR_YELLOW}"
|
||||
VCS_CLEAN_COLOR="${PR_GREEN}"
|
||||
VCS_SUFFIX_COLOR="${PR_RED}› ${PR_RESET}"
|
||||
|
||||
########## SVN ###########
|
||||
ZSH_THEME_SVN_PROMPT_PREFIX="${PR_RESET}${PR_RED}‹svn:"
|
||||
ZSH_THEME_SVN_PROMPT_SUFFIX=""
|
||||
ZSH_THEME_SVN_PROMPT_DIRTY="${VCS_DIRTY_COLOR} ✘${VCS_SUFIX_COLOR}"
|
||||
ZSH_THEME_SVN_PROMPT_CLEAN="${VCS_CLEAN_COLOR} ✔${VCS_SUFIX_COLOR}"
|
||||
ZSH_THEME_SVN_PROMPT_PREFIX="${PR_RED}‹svn:"
|
||||
ZSH_THEME_SVN_PROMPT_SUFFIX="${VCS_SUFFIX_COLOR}"
|
||||
ZSH_THEME_SVN_PROMPT_DIRTY="${VCS_DIRTY_COLOR} ✘"
|
||||
ZSH_THEME_SVN_PROMPT_CLEAN="${VCS_CLEAN_COLOR} ✔"
|
||||
|
||||
########## GIT ###########
|
||||
ZSH_THEME_GIT_PROMPT_PREFIX="${PR_RESET}${PR_RED}‹git:"
|
||||
ZSH_THEME_GIT_PROMPT_SUFFIX=""
|
||||
ZSH_THEME_GIT_PROMPT_DIRTY="${VCS_DIRTY_COLOR} ✘${VCS_SUFIX_COLOR}"
|
||||
ZSH_THEME_GIT_PROMPT_CLEAN="${VCS_CLEAN_COLOR} ✔${VCS_SUFIX_COLOR}"
|
||||
ZSH_THEME_GIT_PROMPT_ADDED="${PR_RESET}${PR_YELLOW} ✚${PR_RESET}"
|
||||
ZSH_THEME_GIT_PROMPT_MODIFIED="${PR_RESET}${PR_YELLOW} ✹${PR_RESET}"
|
||||
ZSH_THEME_GIT_PROMPT_DELETED="${PR_RESET}${PR_YELLOW} ✖${PR_RESET}"
|
||||
ZSH_THEME_GIT_PROMPT_RENAMED="${PR_RESET}${PR_YELLOW} ➜${PR_RESET}"
|
||||
ZSH_THEME_GIT_PROMPT_UNMERGED="${PR_RESET}${PR_YELLOW} ═${PR_RESET}"
|
||||
ZSH_THEME_GIT_PROMPT_UNTRACKED="${PR_RESET}${PR_YELLOW} ✭${PR_RESET}"
|
||||
ZSH_THEME_GIT_PROMPT_PREFIX="${PR_RED}‹git:"
|
||||
ZSH_THEME_GIT_PROMPT_SUFFIX="${VCS_SUFFIX_COLOR}"
|
||||
ZSH_THEME_GIT_PROMPT_DIRTY="${VCS_DIRTY_COLOR} ✘"
|
||||
ZSH_THEME_GIT_PROMPT_CLEAN="${VCS_CLEAN_COLOR} ✔"
|
||||
ZSH_THEME_GIT_PROMPT_ADDED="${PR_YELLOW} ✚"
|
||||
ZSH_THEME_GIT_PROMPT_MODIFIED="${PR_YELLOW} ✹"
|
||||
ZSH_THEME_GIT_PROMPT_DELETED="${PR_YELLOW} ✖"
|
||||
ZSH_THEME_GIT_PROMPT_RENAMED="${PR_YELLOW} ➜"
|
||||
ZSH_THEME_GIT_PROMPT_UNMERGED="${PR_YELLOW} ═"
|
||||
ZSH_THEME_GIT_PROMPT_UNTRACKED="${PR_YELLOW} ✭"
|
||||
|
||||
# Get a fortune quote
|
||||
ps1_fortune() {
|
||||
(( ${+commands[fortune]} )) && fortune
|
||||
if (( ${+commands[fortune]} )); then
|
||||
fortune
|
||||
fi
|
||||
}
|
||||
|
||||
# Obtain a command tip
|
||||
@@ -77,33 +79,27 @@ 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
|
||||
} | sed 1d | sed '/^$/d'
|
||||
fi
|
||||
} | sed '1d;/^$/d'
|
||||
}
|
||||
|
||||
function precmd_adben {
|
||||
prompt_header() {
|
||||
if [[ "$ENABLE_COMMAND_TIP" = true ]]; then
|
||||
ps1_command_tip
|
||||
else
|
||||
ps1_fortune
|
||||
fi
|
||||
}
|
||||
# Show prompt header (fortune / command tip)
|
||||
prompt_header() {
|
||||
local header=$(
|
||||
case "${ENABLE_COMMAND_TIP:-}" in
|
||||
true) ps1_command_tip ;;
|
||||
*) ps1_fortune ;;
|
||||
esac
|
||||
)
|
||||
|
||||
PROMPT_HEAD="${RED_START}${PR_YELLOW}$(prompt_header)${PR_RESET}"
|
||||
|
||||
# set a simple variable to show when in screen
|
||||
if [[ -n "${WINDOW}" ]]; then
|
||||
SCREEN=""
|
||||
fi
|
||||
# Make sure to quote % so that they're not expanded by the prompt
|
||||
echo -n "${header:gs/%/%%}"
|
||||
}
|
||||
|
||||
# Context: user@directory or just directory
|
||||
prompt_context() {
|
||||
if [[ "$USERNAME" != "$DEFAULT_USER" || -n "$SSH_CLIENT" ]]; then
|
||||
echo -n "${PR_RESET}${PR_RED}$USERNAME@%m${PR_RESET}${PR_BRIGHT_YELLOW}%~%<<${PR_RESET}"
|
||||
else
|
||||
echo -n "${PR_RESET}${PR_BRIGHT_YELLOW}%~%<<${PR_RESET}"
|
||||
echo -n "${PR_RESET}${PR_RED}%n@%m"
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -111,16 +107,12 @@ prompt_context() {
|
||||
|
||||
# Required for the prompt
|
||||
setopt prompt_subst
|
||||
autoload zsh/terminfo
|
||||
|
||||
# Prompt
|
||||
PROMPT='${PROMPT_HEAD}
|
||||
${RED_START}$(prompt_context)
|
||||
${GREEN_START_P1}'
|
||||
RPROMPT='${PR_RESET}$(git_prompt_info)$(svn_prompt_info)${PR_YELLOW}%D{%R.%S %a %b %d %Y} ${GREEN_END}${PR_RESET}'
|
||||
# Prompt: header, context (user@host), directory
|
||||
PROMPT="${RED_START}${PR_YELLOW}\$(prompt_header)${PR_RESET}
|
||||
${RED_START}\$(prompt_context)${PR_BRIGHT_YELLOW}%~${PR_RESET}
|
||||
${GREEN_START} "
|
||||
# Right prompt: vcs status + time
|
||||
RPROMPT="\$(git_prompt_info)\$(svn_prompt_info)${PR_YELLOW}%D{%R.%S %a %b %d %Y} ${GREEN_END}"
|
||||
# Matching continuation prompt
|
||||
PROMPT2='${GREEN_BASE_START}${PR_RESET} %_ ${GREEN_BASE_START}${PR_RESET} '
|
||||
|
||||
# Prompt head
|
||||
autoload -Uz add-zsh-hook
|
||||
add-zsh-hook precmd precmd_adben
|
||||
PROMPT2="${GREEN_START} %_ ${GREEN_START} "
|
||||
|
||||
@@ -1,47 +1,46 @@
|
||||
# af-magic.zsh-theme
|
||||
# Repo: https://github.com/andyfleming/oh-my-zsh
|
||||
# Direct Link: https://github.com/andyfleming/oh-my-zsh/blob/master/themes/af-magic.zsh-theme
|
||||
#
|
||||
# Author: Andy Fleming
|
||||
# URL: http://andyfleming.com/
|
||||
|
||||
|
||||
# settings
|
||||
typeset +H return_code="%(?..%{$fg[red]%}%? ↵%{$reset_color%})"
|
||||
typeset +H my_gray="$FG[237]"
|
||||
typeset +H my_orange="$FG[214]"
|
||||
|
||||
# separator dashes size
|
||||
# dashed separator size
|
||||
function afmagic_dashes {
|
||||
local PYTHON_ENV="$VIRTUAL_ENV"
|
||||
[[ -z "$PYTHON_ENV" ]] && PYTHON_ENV="$CONDA_DEFAULT_ENV"
|
||||
# check either virtualenv or condaenv variables
|
||||
local python_env="${VIRTUAL_ENV:-$CONDA_DEFAULT_ENV}"
|
||||
|
||||
if [[ -n "$PYTHON_ENV" && "$PS1" = \(* ]]; then
|
||||
echo $(( COLUMNS - ${#PYTHON_ENV} - 3 ))
|
||||
else
|
||||
echo $COLUMNS
|
||||
fi
|
||||
# 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
|
||||
echo $(( COLUMNS - ${#python_env} - 3 ))
|
||||
else
|
||||
echo $COLUMNS
|
||||
fi
|
||||
}
|
||||
|
||||
# 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}'
|
||||
# primary prompt: dashed separator, directory and vcs info
|
||||
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%}"
|
||||
|
||||
# right prompt
|
||||
(( $+functions[virtualenv_prompt_info] )) && RPS1+='$(virtualenv_prompt_info)'
|
||||
RPS1+=' $my_gray%n@%m%{$reset_color%}%'
|
||||
# right prompt: return code, virtualenv and context (user@host)
|
||||
RPS1="%(?..%{$fg[red]%}%? ↵%{$reset_color%})"
|
||||
if (( $+functions[virtualenv_prompt_info] )); then
|
||||
RPS1+='$(virtualenv_prompt_info)'
|
||||
fi
|
||||
RPS1+=" ${FG[237]}%n@%m%{$reset_color%}"
|
||||
|
||||
# git settings
|
||||
ZSH_THEME_GIT_PROMPT_PREFIX="$FG[075]($FG[078]"
|
||||
ZSH_THEME_GIT_PROMPT_PREFIX=" ${FG[075]}(${FG[078]}"
|
||||
ZSH_THEME_GIT_PROMPT_CLEAN=""
|
||||
ZSH_THEME_GIT_PROMPT_DIRTY="$my_orange*%{$reset_color%}"
|
||||
ZSH_THEME_GIT_PROMPT_SUFFIX="$FG[075])%{$reset_color%}"
|
||||
ZSH_THEME_GIT_PROMPT_DIRTY="${FG[214]}*%{$reset_color%}"
|
||||
ZSH_THEME_GIT_PROMPT_SUFFIX="${FG[075]})%{$reset_color%}"
|
||||
|
||||
# hg settings
|
||||
ZSH_THEME_HG_PROMPT_PREFIX="$FG[075]($FG[078]"
|
||||
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%}"
|
||||
ZSH_THEME_HG_PROMPT_DIRTY="${FG[214]}*%{$reset_color%}"
|
||||
ZSH_THEME_HG_PROMPT_SUFFIX="${FG[075]})%{$reset_color%}"
|
||||
|
||||
# virtualenv settings
|
||||
ZSH_THEME_VIRTUALENV_PREFIX=" $FG[075]["
|
||||
ZSH_THEME_VIRTUALENV_PREFIX=" ${FG[075]}["
|
||||
ZSH_THEME_VIRTUALENV_SUFFIX="]%{$reset_color%}"
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
if [ $UID -eq 0 ]; then CARETCOLOR="red"; else CARETCOLOR="blue"; fi
|
||||
|
||||
local return_code="%(?..%{$fg[red]%}%? ↵%{$reset_color%})"
|
||||
|
||||
PROMPT='%m %{${fg_bold[blue]}%}:: %{$reset_color%}%{${fg[green]}%}%3~ $(git_prompt_info)%{${fg_bold[$CARETCOLOR]}%}»%{${reset_color}%} '
|
||||
|
||||
RPS1="${return_code}"
|
||||
PROMPT='%m %B%F{blue}:: %b%F{green}%3~ $(hg_prompt_info)$(git_prompt_info)%B%(!.%F{red}.%F{blue})»%f%b '
|
||||
RPS1='%(?..%F{red}%? ↵%f)'
|
||||
|
||||
ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg[yellow]%}‹"
|
||||
ZSH_THEME_GIT_PROMPT_SUFFIX="› %{$reset_color%}"
|
||||
|
||||
ZSH_THEME_HG_PROMPT_PREFIX="%{$fg[magenta]%}hg:‹%{$fg[yellow]%}"
|
||||
ZSH_THEME_HG_PROMPT_SUFFIX="%{$fg[magenta]%}› %{$reset_color%}"
|
||||
ZSH_THEME_HG_PROMPT_DIRTY=" %{$fg[red]%}✗"
|
||||
ZSH_THEME_HG_PROMPT_CLEAN=""
|
||||
|
||||
@@ -135,7 +135,7 @@ prompt_git() {
|
||||
zstyle ':vcs_info:*' formats ' %u%c'
|
||||
zstyle ':vcs_info:*' actionformats ' %u%c'
|
||||
vcs_info
|
||||
echo -n "${ref/refs\/heads\//$PL_BRANCH_CHAR }${vcs_info_msg_0_%% }${mode}"
|
||||
echo -n "${${ref:gs/%/%%}/refs\/heads\//$PL_BRANCH_CHAR }${vcs_info_msg_0_%% }${mode}"
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -153,7 +153,7 @@ prompt_bzr() {
|
||||
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)
|
||||
revision=${$(bzr log -r-1 --log-format line | cut -d: -f1):gs/%/%%}
|
||||
if [[ $status_mod -gt 0 ]] ; then
|
||||
prompt_segment yellow black "bzr@$revision ✚"
|
||||
else
|
||||
@@ -183,7 +183,7 @@ prompt_hg() {
|
||||
# if working copy is clean
|
||||
prompt_segment green $CURRENT_FG
|
||||
fi
|
||||
echo -n $(hg prompt "☿ {rev}@{branch}") $st
|
||||
echo -n ${$(hg prompt "☿ {rev}@{branch}"):gs/%/%%} $st
|
||||
else
|
||||
st=""
|
||||
rev=$(hg id -n 2>/dev/null | sed 's/[^-0-9]//g')
|
||||
@@ -197,7 +197,7 @@ prompt_hg() {
|
||||
else
|
||||
prompt_segment green $CURRENT_FG
|
||||
fi
|
||||
echo -n "☿ $rev@$branch" $st
|
||||
echo -n "☿ ${rev:gs/%/%%}@${branch:gs/%/%%}" $st
|
||||
fi
|
||||
fi
|
||||
}
|
||||
@@ -209,9 +209,8 @@ prompt_dir() {
|
||||
|
||||
# Virtualenv: current working virtualenv
|
||||
prompt_virtualenv() {
|
||||
local virtualenv_path="$VIRTUAL_ENV"
|
||||
if [[ -n $virtualenv_path && -n $VIRTUAL_ENV_DISABLE_PROMPT ]]; then
|
||||
prompt_segment blue black "(`basename $virtualenv_path`)"
|
||||
if [[ -n "$VIRTUAL_ENV" && -n "$VIRTUAL_ENV_DISABLE_PROMPT" ]]; then
|
||||
prompt_segment blue black "(${VIRTUAL_ENV:t:gs/%/%%})"
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -237,8 +236,8 @@ prompt_status() {
|
||||
prompt_aws() {
|
||||
[[ -z "$AWS_PROFILE" || "$SHOW_AWS_PROMPT" = false ]] && return
|
||||
case "$AWS_PROFILE" in
|
||||
*-prod|*production*) prompt_segment red yellow "AWS: $AWS_PROFILE" ;;
|
||||
*) prompt_segment green black "AWS: $AWS_PROFILE" ;;
|
||||
*-prod|*production*) prompt_segment red yellow "AWS: ${AWS_PROFILE:gs/%/%%}" ;;
|
||||
*) prompt_segment green black "AWS: ${AWS_PROFILE:gs/%/%%}" ;;
|
||||
esac
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
|
||||
PROMPT='$fg_bold[blue][ $fg[red]%t $fg_bold[blue]] $fg_bold[blue] [ $fg[red]%n@%m:%~$(git_prompt_info)$fg[yellow]$(rvm_prompt_info)$fg_bold[blue] ]$reset_color
|
||||
PROMPT='$fg_bold[blue][ $fg[red]%t $fg_bold[blue]] $fg_bold[blue] [ $fg[red]%n@%m:%~$(git_prompt_info)$fg[yellow]$(ruby_prompt_info)$fg_bold[blue] ]$reset_color
|
||||
$ '
|
||||
# git theming
|
||||
ZSH_THEME_GIT_PROMPT_PREFIX="$fg_bold[green]("
|
||||
|
||||
@@ -31,7 +31,7 @@ function _git_time_since_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
|
||||
if last_commit=$(command git -c log.showSignature=false log --format='%at' -1 2>/dev/null); then
|
||||
now=$(date +%s)
|
||||
seconds_since_last_commit=$((now-last_commit))
|
||||
|
||||
|
||||
@@ -1,32 +1,32 @@
|
||||
# ZSH Theme - Preview: https://gyazo.com/8becc8a7ed5ab54a0262a470555c3eed.png
|
||||
local return_code="%(?..%{$fg[red]%}%? ↵%{$reset_color%})"
|
||||
local user_host="%B%(!.%{$fg[red]%}.%{$fg[green]%})%n@%m%{$reset_color%} "
|
||||
local user_symbol='%(!.#.$)'
|
||||
local current_dir="%B%{$fg[blue]%}%~ %{$reset_color%}"
|
||||
|
||||
if [[ $UID -eq 0 ]]; then
|
||||
local user_host='%{$terminfo[bold]$fg[red]%}%n@%m %{$reset_color%}'
|
||||
local user_symbol='#'
|
||||
else
|
||||
local user_host='%{$terminfo[bold]$fg[green]%}%n@%m %{$reset_color%}'
|
||||
local user_symbol='$'
|
||||
fi
|
||||
|
||||
local current_dir='%{$terminfo[bold]$fg[blue]%}%~ %{$reset_color%}'
|
||||
local git_branch='$(git_prompt_info)'
|
||||
local vcs_branch='$(git_prompt_info)$(hg_prompt_info)'
|
||||
local rvm_ruby='$(ruby_prompt_info)'
|
||||
local venv_prompt='$(virtualenv_prompt_info)'
|
||||
|
||||
ZSH_THEME_RVM_PROMPT_OPTIONS="i v g"
|
||||
|
||||
PROMPT="╭─${user_host}${current_dir}${rvm_ruby}${git_branch}${venv_prompt}
|
||||
PROMPT="╭─${user_host}${current_dir}${rvm_ruby}${vcs_branch}${venv_prompt}
|
||||
╰─%B${user_symbol}%b "
|
||||
RPROMPT="%B${return_code}%b"
|
||||
|
||||
ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg[yellow]%}‹"
|
||||
ZSH_THEME_GIT_PROMPT_SUFFIX="› %{$reset_color%}"
|
||||
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[red]%}●%{$fg[yellow]%}"
|
||||
ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg[yellow]%}"
|
||||
|
||||
ZSH_THEME_HG_PROMPT_PREFIX="$ZSH_THEME_GIT_PROMPT_PREFIX"
|
||||
ZSH_THEME_HG_PROMPT_SUFFIX="$ZSH_THEME_GIT_PROMPT_SUFFIX"
|
||||
ZSH_THEME_HG_PROMPT_DIRTY="$ZSH_THEME_GIT_PROMPT_DIRTY"
|
||||
ZSH_THEME_HG_PROMPT_CLEAN="$ZSH_THEME_GIT_PROMPT_CLEAN"
|
||||
|
||||
ZSH_THEME_RUBY_PROMPT_PREFIX="%{$fg[red]%}‹"
|
||||
ZSH_THEME_RUBY_PROMPT_SUFFIX="› %{$reset_color%}"
|
||||
|
||||
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
|
||||
ZSH_THEME_VIRTUALENV_PREFIX="$ZSH_THEME_VIRTUAL_ENV_PROMPT_PREFIX"
|
||||
ZSH_THEME_VIRTUALENV_SUFFIX="$ZSH_THEME_VIRTUAL_ENV_PROMPT_SUFFIX"
|
||||
|
||||
@@ -17,64 +17,68 @@ ZSH_THEME_GIT_PROMPT_UNSTAGED="%{$fg_bold[yellow]%}●%{$reset_color%}"
|
||||
ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg_bold[red]%}●%{$reset_color%}"
|
||||
|
||||
bureau_git_branch () {
|
||||
local ref
|
||||
ref=$(command git symbolic-ref HEAD 2> /dev/null) || \
|
||||
ref=$(command git rev-parse --short HEAD 2> /dev/null) || return
|
||||
echo "${ref#refs/heads/}"
|
||||
}
|
||||
|
||||
bureau_git_status() {
|
||||
_STATUS=""
|
||||
local result gitstatus
|
||||
|
||||
# check status of files
|
||||
_INDEX=$(command git status --porcelain 2> /dev/null)
|
||||
if [[ -n "$_INDEX" ]]; then
|
||||
if $(echo "$_INDEX" | command grep -q '^[AMRD]. '); then
|
||||
_STATUS="$_STATUS$ZSH_THEME_GIT_PROMPT_STAGED"
|
||||
gitstatus=$(command git status --porcelain -b 2> /dev/null)
|
||||
if [[ -n "$gitstatus" ]]; then
|
||||
if $(echo "$gitstatus" | command grep -q '^[AMRD]. '); then
|
||||
result+="$ZSH_THEME_GIT_PROMPT_STAGED"
|
||||
fi
|
||||
if $(echo "$_INDEX" | command grep -q '^.[MTD] '); then
|
||||
_STATUS="$_STATUS$ZSH_THEME_GIT_PROMPT_UNSTAGED"
|
||||
if $(echo "$gitstatus" | command grep -q '^.[MTD] '); then
|
||||
result+="$ZSH_THEME_GIT_PROMPT_UNSTAGED"
|
||||
fi
|
||||
if $(echo "$_INDEX" | command grep -q -E '^\?\? '); then
|
||||
_STATUS="$_STATUS$ZSH_THEME_GIT_PROMPT_UNTRACKED"
|
||||
if $(echo "$gitstatus" | command grep -q -E '^\?\? '); then
|
||||
result+="$ZSH_THEME_GIT_PROMPT_UNTRACKED"
|
||||
fi
|
||||
if $(echo "$_INDEX" | command grep -q '^UU '); then
|
||||
_STATUS="$_STATUS$ZSH_THEME_GIT_PROMPT_UNMERGED"
|
||||
if $(echo "$gitstatus" | command grep -q '^UU '); then
|
||||
result+="$ZSH_THEME_GIT_PROMPT_UNMERGED"
|
||||
fi
|
||||
else
|
||||
_STATUS="$_STATUS$ZSH_THEME_GIT_PROMPT_CLEAN"
|
||||
result+="$ZSH_THEME_GIT_PROMPT_CLEAN"
|
||||
fi
|
||||
|
||||
# check status of local repository
|
||||
_INDEX=$(command git status --porcelain -b 2> /dev/null)
|
||||
if $(echo "$_INDEX" | command grep -q '^## .*ahead'); then
|
||||
_STATUS="$_STATUS$ZSH_THEME_GIT_PROMPT_AHEAD"
|
||||
if $(echo "$gitstatus" | command grep -q '^## .*ahead'); then
|
||||
result+="$ZSH_THEME_GIT_PROMPT_AHEAD"
|
||||
fi
|
||||
if $(echo "$_INDEX" | command grep -q '^## .*behind'); then
|
||||
_STATUS="$_STATUS$ZSH_THEME_GIT_PROMPT_BEHIND"
|
||||
if $(echo "$gitstatus" | command grep -q '^## .*behind'); then
|
||||
result+="$ZSH_THEME_GIT_PROMPT_BEHIND"
|
||||
fi
|
||||
if $(echo "$_INDEX" | command grep -q '^## .*diverged'); then
|
||||
_STATUS="$_STATUS$ZSH_THEME_GIT_PROMPT_DIVERGED"
|
||||
if $(echo "$gitstatus" | command grep -q '^## .*diverged'); then
|
||||
result+="$ZSH_THEME_GIT_PROMPT_DIVERGED"
|
||||
fi
|
||||
|
||||
if $(command git rev-parse --verify refs/stash &> /dev/null); then
|
||||
_STATUS="$_STATUS$ZSH_THEME_GIT_PROMPT_STASHED"
|
||||
result+="$ZSH_THEME_GIT_PROMPT_STASHED"
|
||||
fi
|
||||
|
||||
echo $_STATUS
|
||||
echo $result
|
||||
}
|
||||
|
||||
bureau_git_prompt () {
|
||||
local _branch=$(bureau_git_branch)
|
||||
local _status=$(bureau_git_status)
|
||||
local _result=""
|
||||
if [[ "${_branch}x" != "x" ]]; then
|
||||
_result="$ZSH_THEME_GIT_PROMPT_PREFIX$_branch"
|
||||
if [[ "${_status}x" != "x" ]]; then
|
||||
_result="$_result $_status"
|
||||
fi
|
||||
_result="$_result$ZSH_THEME_GIT_PROMPT_SUFFIX"
|
||||
bureau_git_prompt() {
|
||||
local gitbranch=$(bureau_git_branch)
|
||||
local gitstatus=$(bureau_git_status)
|
||||
local info
|
||||
|
||||
if [[ -z "$gitbranch" ]]; then
|
||||
return
|
||||
fi
|
||||
echo $_result
|
||||
|
||||
info="${gitbranch:gs/%/%%}"
|
||||
|
||||
if [[ -n "$gitstatus" ]]; then
|
||||
info+=" $gitstatus"
|
||||
fi
|
||||
|
||||
echo "${ZSH_THEME_GIT_PROMPT_PREFIX}${info}${ZSH_THEME_GIT_PROMPT_SUFFIX}"
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -11,7 +11,9 @@ patches: <patches|join( → )|pre_applied(%{$fg[yellow]%})|post_applied(%{$reset
|
||||
fi
|
||||
|
||||
function box_name {
|
||||
[ -f ~/.box-name ] && cat ~/.box-name || echo ${SHORT_HOST:-$HOST}
|
||||
local box="${SHORT_HOST:-$HOST}"
|
||||
[[ -f ~/.box-name ]] && box="$(< ~/.box-name)"
|
||||
echo "${box:gs/%/%%}"
|
||||
}
|
||||
|
||||
PROMPT='
|
||||
|
||||
@@ -9,7 +9,7 @@ DALLAS_CURRENT_MACH_="%{$fg[green]%}%m%{$fg[white]%}:%{$reset_color%}"
|
||||
DALLAS_CURRENT_LOCA_="%{$fg[cyan]%}%~\$(git_prompt_info)%{$reset_color%}\$(parse_git_dirty)"
|
||||
# Grab the current username: dallas
|
||||
DALLAS_CURRENT_USER_="%{$fg[red]%}%n%{$reset_color%}"
|
||||
# Use a % for normal users and a # for privelaged (root) users.
|
||||
# Use a % for normal users and a # for privileged (root) users.
|
||||
DALLAS_PROMPT_CHAR_="%{$fg[white]%}%(!.#.%%)%{$reset_color%}"
|
||||
# For the git prompt, use a white @ and blue text for the branch name
|
||||
ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg[white]%}@%{$fg[blue]%}"
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
# The exit code visual cues will only display once.
|
||||
# (i.e. they will be reset, even if you hit enter a few times on empty command prompts)
|
||||
|
||||
typeset -A host_repr
|
||||
typeset -g -A host_repr
|
||||
|
||||
# translate hostnames into shortened, colorcoded strings
|
||||
host_repr=('dieter-ws-a7n8x-arch' "%{$fg_bold[green]%}ws" 'dieter-p4sci-arch' "%{$fg_bold[blue]%}p4")
|
||||
|
||||
@@ -37,9 +37,7 @@ ZSH_THEME_GIT_TIME_SINCE_COMMIT_NEUTRAL="%{$fg[cyan]%}"
|
||||
function git_time_since_commit() {
|
||||
if git rev-parse --git-dir > /dev/null 2>&1; then
|
||||
# Only proceed if there is actually a commit.
|
||||
if git log -n 1 > /dev/null 2>&1; then
|
||||
# Get the last commit.
|
||||
last_commit=`git log --pretty=format:'%at' -1 2> /dev/null`
|
||||
if last_commit=`git -c log.showSignature=false log --pretty=format:'%at' -1 2> /dev/null`; then
|
||||
now=`date +%s`
|
||||
seconds_since_last_commit=$((now-last_commit))
|
||||
|
||||
|
||||
@@ -51,9 +51,9 @@ root_prompt="$emoji[skull]"
|
||||
warn_prompt="$emoji[collision_symbol]"
|
||||
|
||||
vcs_unstaged_glyph="%{$emoji[circled_latin_capital_letter_m]$emoji2[emoji_style] %2G%}"
|
||||
vcs_staged_glyph="%{$emoji[high_voltage_sign] %2G%}"
|
||||
vcs_branch_glyph=$(print -P $'\Ue0a0') #
|
||||
vcs_action_glyph=$(print -P $'\U276f') # ❯
|
||||
vcs_staged_glyph="%{$emoji[high_voltage_sign]%2G%}"
|
||||
vcs_branch_glyph=$'\Ue0a0' #
|
||||
vcs_action_glyph=$'\U276f' # ❯
|
||||
|
||||
red="$FG[001]"
|
||||
yellow="$FG[003]"
|
||||
|
||||
@@ -39,7 +39,7 @@ 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
|
||||
# also prefix prompt inside a docker contrainer
|
||||
# also prefix prompt inside a docker container
|
||||
ZSH_ESSEMBEH_PREFIX="%{$fg[yellow]%}[docker]%{$reset_color%} "
|
||||
fi
|
||||
if [[ $UID = 0 ]]; then
|
||||
|
||||
@@ -21,10 +21,11 @@ function prompt_char {
|
||||
}
|
||||
|
||||
function box_name {
|
||||
[ -f ~/.box-name ] && cat ~/.box-name || echo ${SHORT_HOST:-$HOST}
|
||||
local box="${SHORT_HOST:-$HOST}"
|
||||
[[ -f ~/.box-name ]] && box="$(< ~/.box-name)"
|
||||
echo "${box:gs/%/%%}"
|
||||
}
|
||||
|
||||
|
||||
PROMPT="╭─%{$FG[040]%}%n%{$reset_color%} %{$FG[239]%}at%{$reset_color%} %{$FG[033]%}$(box_name)%{$reset_color%} %{$FG[239]%}in%{$reset_color%} %{$terminfo[bold]$FG[226]%}%~%{$reset_color%}\$(git_prompt_info)\$(ruby_prompt_info) %D - %*
|
||||
╰─\$(virtualenv_info)\$(prompt_char) "
|
||||
|
||||
|
||||
@@ -21,7 +21,9 @@ function prompt_char {
|
||||
}
|
||||
|
||||
function box_name {
|
||||
[ -f ~/.box-name ] && cat ~/.box-name || echo ${SHORT_HOST:-$HOST}
|
||||
local box="${SHORT_HOST:-$HOST}"
|
||||
[[ -f ~/.box-name ]] && box="$(< ~/.box-name)"
|
||||
echo "${box:gs/%/%%}"
|
||||
}
|
||||
|
||||
local ruby_env='$(ruby_prompt_info)'
|
||||
|
||||
@@ -7,31 +7,22 @@
|
||||
# git untracked files modification from Brian Carper:
|
||||
# https://briancarper.net/blog/570/git-info-in-your-zsh-prompt
|
||||
|
||||
function virtualenv_info {
|
||||
[ $VIRTUAL_ENV ] && echo '('`basename $VIRTUAL_ENV`') '
|
||||
}
|
||||
PR_GIT_UPDATE=1
|
||||
|
||||
setopt prompt_subst
|
||||
|
||||
autoload -U add-zsh-hook
|
||||
autoload -Uz vcs_info
|
||||
|
||||
#use extended color palette if available
|
||||
if [[ $TERM = *256color* || $TERM = *rxvt* ]]; then
|
||||
turquoise="%F{81}"
|
||||
orange="%F{166}"
|
||||
purple="%F{135}"
|
||||
hotpink="%F{161}"
|
||||
limegreen="%F{118}"
|
||||
if [[ $TERM = (*256color|*rxvt*) ]]; then
|
||||
turquoise="%{${(%):-"%F{81}"}%}"
|
||||
orange="%{${(%):-"%F{166}"}%}"
|
||||
purple="%{${(%):-"%F{135}"}%}"
|
||||
hotpink="%{${(%):-"%F{161}"}%}"
|
||||
limegreen="%{${(%):-"%F{118}"}%}"
|
||||
else
|
||||
turquoise="$fg[cyan]"
|
||||
orange="$fg[yellow]"
|
||||
purple="$fg[magenta]"
|
||||
hotpink="$fg[red]"
|
||||
limegreen="$fg[green]"
|
||||
turquoise="%{${(%):-"%F{cyan}"}%}"
|
||||
orange="%{${(%):-"%F{yellow}"}%}"
|
||||
purple="%{${(%):-"%F{magenta}"}%}"
|
||||
hotpink="%{${(%):-"%F{red}"}%}"
|
||||
limegreen="%{${(%):-"%F{green}"}%}"
|
||||
fi
|
||||
|
||||
autoload -Uz vcs_info
|
||||
# enable VCS systems you use
|
||||
zstyle ':vcs_info:*' enable git svn
|
||||
|
||||
@@ -47,10 +38,10 @@ zstyle ':vcs_info:*:prompt:*' check-for-changes true
|
||||
# %R - repository path
|
||||
# %S - path in the repository
|
||||
PR_RST="%{${reset_color}%}"
|
||||
FMT_BRANCH=" on %{$turquoise%}%b%u%c${PR_RST}"
|
||||
FMT_ACTION=" performing a %{$limegreen%}%a${PR_RST}"
|
||||
FMT_UNSTAGED="%{$orange%} ●"
|
||||
FMT_STAGED="%{$limegreen%} ●"
|
||||
FMT_BRANCH=" on ${turquoise}%b%u%c${PR_RST}"
|
||||
FMT_ACTION=" performing a ${limegreen}%a${PR_RST}"
|
||||
FMT_UNSTAGED="${orange} ●"
|
||||
FMT_STAGED="${limegreen} ●"
|
||||
|
||||
zstyle ':vcs_info:*:prompt:*' unstagedstr "${FMT_UNSTAGED}"
|
||||
zstyle ':vcs_info:*:prompt:*' stagedstr "${FMT_STAGED}"
|
||||
@@ -59,38 +50,44 @@ zstyle ':vcs_info:*:prompt:*' formats "${FMT_BRANCH}"
|
||||
zstyle ':vcs_info:*:prompt:*' nvcsformats ""
|
||||
|
||||
|
||||
function steeef_preexec {
|
||||
case "$2" in
|
||||
*git*)
|
||||
PR_GIT_UPDATE=1
|
||||
;;
|
||||
*svn*)
|
||||
PR_GIT_UPDATE=1
|
||||
;;
|
||||
esac
|
||||
}
|
||||
add-zsh-hook preexec steeef_preexec
|
||||
|
||||
function steeef_chpwd {
|
||||
PR_GIT_UPDATE=1
|
||||
PR_GIT_UPDATE=1
|
||||
}
|
||||
|
||||
function steeef_preexec {
|
||||
case "$2" in
|
||||
*git*|*svn*) PR_GIT_UPDATE=1 ;;
|
||||
esac
|
||||
}
|
||||
add-zsh-hook chpwd steeef_chpwd
|
||||
|
||||
function steeef_precmd {
|
||||
if [[ -n "$PR_GIT_UPDATE" ]] ; then
|
||||
# check for untracked files or updated submodules, since vcs_info doesn't
|
||||
if [[ ! -z $(git ls-files --other --exclude-standard 2> /dev/null) ]]; then
|
||||
PR_GIT_UPDATE=1
|
||||
FMT_BRANCH="${PM_RST} on %{$turquoise%}%b%u%c%{$hotpink%} ●${PR_RST}"
|
||||
else
|
||||
FMT_BRANCH="${PM_RST} on %{$turquoise%}%b%u%c${PR_RST}"
|
||||
fi
|
||||
zstyle ':vcs_info:*:prompt:*' formats "${FMT_BRANCH}"
|
||||
(( PR_GIT_UPDATE )) || return
|
||||
|
||||
vcs_info 'prompt'
|
||||
PR_GIT_UPDATE=
|
||||
fi
|
||||
# check for untracked files or updated submodules, since vcs_info doesn't
|
||||
if [[ -n "$(git ls-files --other --exclude-standard 2>/dev/null)" ]]; then
|
||||
PR_GIT_UPDATE=1
|
||||
FMT_BRANCH="${PM_RST} on ${turquoise}%b%u%c${hotpink} ●${PR_RST}"
|
||||
else
|
||||
FMT_BRANCH="${PM_RST} on ${turquoise}%b%u%c${PR_RST}"
|
||||
fi
|
||||
zstyle ':vcs_info:*:prompt:*' formats "${FMT_BRANCH}"
|
||||
|
||||
vcs_info 'prompt'
|
||||
PR_GIT_UPDATE=
|
||||
}
|
||||
add-zsh-hook precmd steeef_precmd
|
||||
|
||||
PROMPT=$'%{$purple%}%n%{$reset_color%} in %{$limegreen%}%~%{$reset_color%}$(ruby_prompt_info " with%{$fg[red]%} " v g "%{$reset_color%}")$vcs_info_msg_0_%{$orange%} λ%{$reset_color%} '
|
||||
# vcs_info running hooks
|
||||
PR_GIT_UPDATE=1
|
||||
|
||||
autoload -U add-zsh-hook
|
||||
add-zsh-hook chpwd steeef_chpwd
|
||||
add-zsh-hook precmd steeef_precmd
|
||||
add-zsh-hook preexec steeef_preexec
|
||||
|
||||
# ruby prompt settings
|
||||
ZSH_THEME_RUBY_PROMPT_PREFIX="with%F{red} "
|
||||
ZSH_THEME_RUBY_PROMPT_SUFFIX="%{$reset_color%}"
|
||||
ZSH_THEME_RVM_PROMPT_OPTIONS="v g"
|
||||
|
||||
setopt prompt_subst
|
||||
PROMPT="${purple}%n%{$reset_color%} in ${limegreen}%~%{$reset_color%}\$(ruby_prompt_info)\$vcs_info_msg_0_${orange} λ%{$reset_color%} "
|
||||
|
||||
@@ -1,153 +1,124 @@
|
||||
functions rbenv_prompt_info >& /dev/null || rbenv_prompt_info(){}
|
||||
|
||||
function theme_precmd {
|
||||
local TERMWIDTH
|
||||
(( TERMWIDTH = ${COLUMNS} - 1 ))
|
||||
local TERMWIDTH=$(( COLUMNS - ${ZLE_RPROMPT_INDENT:-1} ))
|
||||
|
||||
PR_FILLBAR=""
|
||||
PR_PWDLEN=""
|
||||
|
||||
###
|
||||
# Truncate the path if it's too long.
|
||||
|
||||
PR_FILLBAR=""
|
||||
PR_PWDLEN=""
|
||||
|
||||
local promptsize=${#${(%):---(%n@%m:%l)---()--}}
|
||||
local rubyprompt=`rvm_prompt_info || rbenv_prompt_info`
|
||||
local rubypromptsize=${#${rubyprompt}}
|
||||
local pwdsize=${#${(%):-%~}}
|
||||
|
||||
if [[ "$promptsize + $rubypromptsize + $pwdsize" -gt $TERMWIDTH ]]; then
|
||||
((PR_PWDLEN=$TERMWIDTH - $promptsize))
|
||||
else
|
||||
PR_FILLBAR="\${(l.(($TERMWIDTH - ($promptsize + $rubypromptsize + $pwdsize)))..${PR_HBAR}.)}"
|
||||
fi
|
||||
local promptsize=${#${(%):---(%n@%m:%l)---()--}}
|
||||
local rubypromptsize=${#${(%)$(ruby_prompt_info)}}
|
||||
local pwdsize=${#${(%):-%~}}
|
||||
|
||||
# Truncate the path if it's too long.
|
||||
if (( promptsize + rubypromptsize + pwdsize > TERMWIDTH )); then
|
||||
(( PR_PWDLEN = TERMWIDTH - promptsize ))
|
||||
elif [[ "${langinfo[CODESET]}" = UTF-8 ]]; then
|
||||
PR_FILLBAR="\${(l:$(( TERMWIDTH - (promptsize + rubypromptsize + pwdsize) ))::${PR_HBAR}:)}"
|
||||
else
|
||||
PR_FILLBAR="${PR_SHIFT_IN}\${(l:$(( TERMWIDTH - (promptsize + rubypromptsize + pwdsize) ))::${altchar[q]:--}:)}${PR_SHIFT_OUT}"
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
setopt extended_glob
|
||||
theme_preexec () {
|
||||
if [[ "$TERM" == "screen" ]]; then
|
||||
local CMD=${1[(wr)^(*=*|sudo|-*)]}
|
||||
echo -n "\ek$CMD\e\\"
|
||||
fi
|
||||
function theme_preexec {
|
||||
setopt local_options extended_glob
|
||||
if [[ "$TERM" = "screen" ]]; then
|
||||
local CMD=${1[(wr)^(*=*|sudo|-*)]}
|
||||
echo -n "\ek$CMD\e\\"
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
setprompt () {
|
||||
###
|
||||
# Need this so the prompt will work.
|
||||
|
||||
setopt prompt_subst
|
||||
|
||||
|
||||
###
|
||||
# See if we can use colors.
|
||||
|
||||
autoload zsh/terminfo
|
||||
for color in RED GREEN YELLOW BLUE MAGENTA CYAN WHITE GREY; do
|
||||
eval PR_$color='%{$terminfo[bold]$fg[${(L)color}]%}'
|
||||
eval PR_LIGHT_$color='%{$fg[${(L)color}]%}'
|
||||
(( count = $count + 1 ))
|
||||
done
|
||||
PR_NO_COLOUR="%{$terminfo[sgr0]%}"
|
||||
|
||||
###
|
||||
# Modify Git prompt
|
||||
ZSH_THEME_GIT_PROMPT_PREFIX=" on %{$fg[green]%}"
|
||||
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}"
|
||||
ZSH_THEME_GIT_PROMPT_DIRTY=""
|
||||
ZSH_THEME_GIT_PROMPT_CLEAN=""
|
||||
|
||||
ZSH_THEME_GIT_PROMPT_ADDED="%{$fg[green]%} ✚"
|
||||
ZSH_THEME_GIT_PROMPT_MODIFIED="%{$fg[blue]%} ✹"
|
||||
ZSH_THEME_GIT_PROMPT_DELETED="%{$fg[red]%} ✖"
|
||||
ZSH_THEME_GIT_PROMPT_RENAMED="%{$fg[magenta]%} ➜"
|
||||
ZSH_THEME_GIT_PROMPT_UNMERGED="%{$fg[yellow]%} ═"
|
||||
ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg[cyan]%} ✭"
|
||||
|
||||
###
|
||||
# See if we can use extended characters to look nicer.
|
||||
# UTF-8 Fixed
|
||||
|
||||
if [[ $(locale charmap) == "UTF-8" ]]; then
|
||||
PR_SET_CHARSET=""
|
||||
PR_SHIFT_IN=""
|
||||
PR_SHIFT_OUT=""
|
||||
PR_HBAR="─"
|
||||
PR_ULCORNER="┌"
|
||||
PR_LLCORNER="└"
|
||||
PR_LRCORNER="┘"
|
||||
PR_URCORNER="┐"
|
||||
else
|
||||
typeset -A altchar
|
||||
set -A altchar ${(s..)terminfo[acsc]}
|
||||
# Some stuff to help us draw nice lines
|
||||
PR_SET_CHARSET="%{$terminfo[enacs]%}"
|
||||
PR_SHIFT_IN="%{$terminfo[smacs]%}"
|
||||
PR_SHIFT_OUT="%{$terminfo[rmacs]%}"
|
||||
PR_HBAR='$PR_SHIFT_IN${altchar[q]:--}$PR_SHIFT_OUT'
|
||||
PR_ULCORNER='$PR_SHIFT_IN${altchar[l]:--}$PR_SHIFT_OUT'
|
||||
PR_LLCORNER='$PR_SHIFT_IN${altchar[m]:--}$PR_SHIFT_OUT'
|
||||
PR_LRCORNER='$PR_SHIFT_IN${altchar[j]:--}$PR_SHIFT_OUT'
|
||||
PR_URCORNER='$PR_SHIFT_IN${altchar[k]:--}$PR_SHIFT_OUT'
|
||||
fi
|
||||
|
||||
|
||||
###
|
||||
# Decide if we need to set titlebar text.
|
||||
|
||||
case $TERM in
|
||||
xterm*)
|
||||
PR_TITLEBAR=$'%{\e]0;%(!.-=*[ROOT]*=- | .)%n@%m:%~ | ${COLUMNS}x${LINES} | %y\a%}'
|
||||
;;
|
||||
screen)
|
||||
PR_TITLEBAR=$'%{\e_screen \005 (\005t) | %(!.-=[ROOT]=- | .)%n@%m:%~ | ${COLUMNS}x${LINES} | %y\e\\%}'
|
||||
;;
|
||||
*)
|
||||
PR_TITLEBAR=''
|
||||
;;
|
||||
esac
|
||||
|
||||
|
||||
###
|
||||
# Decide whether to set a screen title
|
||||
if [[ "$TERM" == "screen" ]]; then
|
||||
PR_STITLE=$'%{\ekzsh\e\\%}'
|
||||
else
|
||||
PR_STITLE=''
|
||||
fi
|
||||
|
||||
|
||||
###
|
||||
# Finally, the prompt.
|
||||
|
||||
PROMPT='$PR_SET_CHARSET$PR_STITLE${(e)PR_TITLEBAR}\
|
||||
$PR_CYAN$PR_ULCORNER$PR_HBAR$PR_GREY(\
|
||||
$PR_GREEN%$PR_PWDLEN<...<%~%<<\
|
||||
$PR_GREY)`rvm_prompt_info || rbenv_prompt_info`$PR_CYAN$PR_HBAR$PR_HBAR${(e)PR_FILLBAR}$PR_HBAR$PR_GREY(\
|
||||
$PR_CYAN%(!.%SROOT%s.%n)$PR_GREY@$PR_GREEN%m:%l\
|
||||
$PR_GREY)$PR_CYAN$PR_HBAR$PR_URCORNER\
|
||||
|
||||
$PR_CYAN$PR_LLCORNER$PR_BLUE$PR_HBAR(\
|
||||
$PR_YELLOW%D{%H:%M:%S}\
|
||||
$PR_LIGHT_BLUE%{$reset_color%}`git_prompt_info``git_prompt_status`$PR_BLUE)$PR_CYAN$PR_HBAR\
|
||||
$PR_HBAR\
|
||||
>$PR_NO_COLOUR '
|
||||
|
||||
# display exitcode on the right when >0
|
||||
return_code="%(?..%{$fg[red]%}%? ↵ %{$reset_color%})"
|
||||
RPROMPT=' $return_code$PR_CYAN$PR_HBAR$PR_BLUE$PR_HBAR\
|
||||
($PR_YELLOW%D{%a,%b%d}$PR_BLUE)$PR_HBAR$PR_CYAN$PR_LRCORNER$PR_NO_COLOUR'
|
||||
|
||||
PS2='$PR_CYAN$PR_HBAR\
|
||||
$PR_BLUE$PR_HBAR(\
|
||||
$PR_LIGHT_GREEN%_$PR_BLUE)$PR_HBAR\
|
||||
$PR_CYAN$PR_HBAR$PR_NO_COLOUR '
|
||||
}
|
||||
|
||||
setprompt
|
||||
|
||||
autoload -U add-zsh-hook
|
||||
add-zsh-hook precmd theme_precmd
|
||||
add-zsh-hook preexec theme_preexec
|
||||
|
||||
|
||||
# Set the prompt
|
||||
|
||||
# Need this so the prompt will work.
|
||||
setopt prompt_subst
|
||||
|
||||
# See if we can use colors.
|
||||
autoload zsh/terminfo
|
||||
for color in RED GREEN YELLOW BLUE MAGENTA CYAN WHITE GREY; do
|
||||
typeset -g PR_$color="%{$terminfo[bold]$fg[${(L)color}]%}"
|
||||
typeset -g PR_LIGHT_$color="%{$fg[${(L)color}]%}"
|
||||
done
|
||||
PR_NO_COLOUR="%{$terminfo[sgr0]%}"
|
||||
|
||||
# Modify Git prompt
|
||||
ZSH_THEME_GIT_PROMPT_PREFIX=" on %{$fg[green]%}"
|
||||
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}"
|
||||
ZSH_THEME_GIT_PROMPT_DIRTY=""
|
||||
ZSH_THEME_GIT_PROMPT_CLEAN=""
|
||||
|
||||
ZSH_THEME_GIT_PROMPT_ADDED="%{$fg[green]%} %{%G✚%}"
|
||||
ZSH_THEME_GIT_PROMPT_MODIFIED="%{$fg[blue]%} %{%G✹%}"
|
||||
ZSH_THEME_GIT_PROMPT_DELETED="%{$fg[red]%} %{%G✖%}"
|
||||
ZSH_THEME_GIT_PROMPT_RENAMED="%{$fg[magenta]%} %{%G➜%}"
|
||||
ZSH_THEME_GIT_PROMPT_UNMERGED="%{$fg[yellow]%} %{%G═%}"
|
||||
ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg[cyan]%} %{%G✭%}"
|
||||
|
||||
# Use extended characters to look nicer if supported.
|
||||
if [[ "${langinfo[CODESET]}" = UTF-8 ]]; then
|
||||
PR_SET_CHARSET=""
|
||||
PR_HBAR="─"
|
||||
PR_ULCORNER="┌"
|
||||
PR_LLCORNER="└"
|
||||
PR_LRCORNER="┘"
|
||||
PR_URCORNER="┐"
|
||||
else
|
||||
typeset -g -A altchar
|
||||
set -A altchar ${(s..)terminfo[acsc]}
|
||||
# Some stuff to help us draw nice lines
|
||||
PR_SET_CHARSET="%{$terminfo[enacs]%}"
|
||||
PR_SHIFT_IN="%{$terminfo[smacs]%}"
|
||||
PR_SHIFT_OUT="%{$terminfo[rmacs]%}"
|
||||
PR_HBAR="${PR_SHIFT_IN}${altchar[q]:--}${PR_SHIFT_OUT}"
|
||||
PR_ULCORNER="${PR_SHIFT_IN}${altchar[l]:--}${PR_SHIFT_OUT}"
|
||||
PR_LLCORNER="${PR_SHIFT_IN}${altchar[m]:--}${PR_SHIFT_OUT}"
|
||||
PR_LRCORNER="${PR_SHIFT_IN}${altchar[j]:--}${PR_SHIFT_OUT}"
|
||||
PR_URCORNER="${PR_SHIFT_IN}${altchar[k]:--}${PR_SHIFT_OUT}"
|
||||
fi
|
||||
|
||||
# Decide if we need to set titlebar text.
|
||||
case $TERM in
|
||||
xterm*)
|
||||
PR_TITLEBAR=$'%{\e]0;%(!.-=*[ROOT]*=- | .)%n@%m:%~ | ${COLUMNS}x${LINES} | %y\a%}'
|
||||
;;
|
||||
screen)
|
||||
PR_TITLEBAR=$'%{\e_screen \005 (\005t) | %(!.-=[ROOT]=- | .)%n@%m:%~ | ${COLUMNS}x${LINES} | %y\e\\%}'
|
||||
;;
|
||||
*)
|
||||
PR_TITLEBAR=""
|
||||
;;
|
||||
esac
|
||||
|
||||
# Decide whether to set a screen title
|
||||
if [[ "$TERM" = "screen" ]]; then
|
||||
PR_STITLE=$'%{\ekzsh\e\\%}'
|
||||
else
|
||||
PR_STITLE=""
|
||||
fi
|
||||
|
||||
# Finally, the prompt.
|
||||
PROMPT='${PR_SET_CHARSET}${PR_STITLE}${(e)PR_TITLEBAR}\
|
||||
${PR_CYAN}${PR_ULCORNER}${PR_HBAR}${PR_GREY}(\
|
||||
${PR_GREEN}%${PR_PWDLEN}<...<%~%<<\
|
||||
${PR_GREY})$(ruby_prompt_info)${PR_CYAN}${PR_HBAR}${PR_HBAR}${(e)PR_FILLBAR}${PR_HBAR}${PR_GREY}(\
|
||||
${PR_CYAN}%(!.%SROOT%s.%n)${PR_GREY}@${PR_GREEN}%m:%l\
|
||||
${PR_GREY})${PR_CYAN}${PR_HBAR}${PR_URCORNER}\
|
||||
|
||||
${PR_CYAN}${PR_LLCORNER}${PR_BLUE}${PR_HBAR}(\
|
||||
${PR_YELLOW}%D{%H:%M:%S}\
|
||||
${PR_LIGHT_BLUE}%{$reset_color%}$(git_prompt_info)$(git_prompt_status)${PR_BLUE})${PR_CYAN}${PR_HBAR}\
|
||||
${PR_HBAR}\
|
||||
>${PR_NO_COLOUR} '
|
||||
|
||||
# display exitcode on the right when > 0
|
||||
return_code="%(?..%{$fg[red]%}%? ↵ %{$reset_color%})"
|
||||
RPROMPT=' $return_code${PR_CYAN}${PR_HBAR}${PR_BLUE}${PR_HBAR}\
|
||||
(${PR_YELLOW}%D{%a,%b%d}${PR_BLUE})${PR_HBAR}${PR_CYAN}${PR_LRCORNER}${PR_NO_COLOUR}'
|
||||
|
||||
PS2='${PR_CYAN}${PR_HBAR}\
|
||||
${PR_BLUE}${PR_HBAR}(\
|
||||
${PR_LIGHT_GREEN}%_${PR_BLUE})${PR_HBAR}\
|
||||
${PR_CYAN}${PR_HBAR}${PR_NO_COLOUR} '
|
||||
|
||||
@@ -10,7 +10,7 @@ function josh_prompt {
|
||||
prompt=" "
|
||||
|
||||
branch=$(git_current_branch)
|
||||
ruby_version=$(rvm_prompt_info || rbenv_prompt_info)
|
||||
ruby_version=$(ruby_prompt_info)
|
||||
path_size=${#PWD}
|
||||
branch_size=${#branch}
|
||||
ruby_size=${#ruby_version}
|
||||
@@ -31,7 +31,7 @@ function josh_prompt {
|
||||
prompt=" $prompt"
|
||||
done
|
||||
|
||||
prompt="%{%F{green}%}$PWD$prompt%{%F{red}%}$(rvm_prompt_info || rbenv_prompt_info)%{$reset_color%} $(git_current_branch)"
|
||||
prompt="%{%F{green}%}$PWD$prompt%{%F{red}%}$(ruby_prompt_info)%{$reset_color%} $(git_current_branch)"
|
||||
|
||||
echo $prompt
|
||||
}
|
||||
|
||||
@@ -2,23 +2,25 @@ ZSH_THEME_GIT_PROMPT_PREFIX="%{$reset_color%}%{$fg[white]%}["
|
||||
ZSH_THEME_GIT_PROMPT_SUFFIX=""
|
||||
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[red]%}●%{$fg[white]%}]%{$reset_color%} "
|
||||
ZSH_THEME_GIT_PROMPT_CLEAN="]%{$reset_color%} "
|
||||
ZSH_THEME_SVN_PROMPT_PREFIX=$ZSH_THEME_GIT_PROMPT_PREFIX
|
||||
ZSH_THEME_SVN_PROMPT_SUFFIX=$ZSH_THEME_GIT_PROMPT_SUFFIX
|
||||
ZSH_THEME_SVN_PROMPT_DIRTY=$ZSH_THEME_GIT_PROMPT_DIRTY
|
||||
ZSH_THEME_SVN_PROMPT_CLEAN=$ZSH_THEME_GIT_PROMPT_CLEAN
|
||||
ZSH_THEME_HG_PROMPT_PREFIX=$ZSH_THEME_GIT_PROMPT_PREFIX
|
||||
ZSH_THEME_HG_PROMPT_SUFFIX=$ZSH_THEME_GIT_PROMPT_SUFFIX
|
||||
ZSH_THEME_HG_PROMPT_DIRTY=$ZSH_THEME_GIT_PROMPT_DIRTY
|
||||
ZSH_THEME_HG_PROMPT_CLEAN=$ZSH_THEME_GIT_PROMPT_CLEAN
|
||||
|
||||
ZSH_THEME_SVN_PROMPT_PREFIX="$ZSH_THEME_GIT_PROMPT_PREFIX"
|
||||
ZSH_THEME_SVN_PROMPT_SUFFIX="$ZSH_THEME_GIT_PROMPT_SUFFIX"
|
||||
ZSH_THEME_SVN_PROMPT_DIRTY="$ZSH_THEME_GIT_PROMPT_DIRTY"
|
||||
ZSH_THEME_SVN_PROMPT_CLEAN="$ZSH_THEME_GIT_PROMPT_CLEAN"
|
||||
|
||||
ZSH_THEME_HG_PROMPT_PREFIX="$ZSH_THEME_GIT_PROMPT_PREFIX"
|
||||
ZSH_THEME_HG_PROMPT_SUFFIX="$ZSH_THEME_GIT_PROMPT_SUFFIX"
|
||||
ZSH_THEME_HG_PROMPT_DIRTY="$ZSH_THEME_GIT_PROMPT_DIRTY"
|
||||
ZSH_THEME_HG_PROMPT_CLEAN="$ZSH_THEME_GIT_PROMPT_CLEAN"
|
||||
|
||||
vcs_status() {
|
||||
if [[ $(whence in_svn) != "" ]] && in_svn; then
|
||||
svn_prompt_info
|
||||
elif [[ $(whence in_hg) != "" ]] && in_hg; then
|
||||
hg_prompt_info
|
||||
else
|
||||
git_prompt_info
|
||||
fi
|
||||
if (( ${+functions[in_svn]} )) && in_svn; then
|
||||
svn_prompt_info
|
||||
elif (( ${+functions[in_hg]} )) && in_hg; then
|
||||
hg_prompt_info
|
||||
else
|
||||
git_prompt_info
|
||||
fi
|
||||
}
|
||||
|
||||
PROMPT='%2~ $(vcs_status)»%b '
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
local return_code="%(?..%{$fg[red]%}%? ↵%{$reset_color%})"
|
||||
local user_host='%{$terminfo[bold]$fg[green]%}%n@%m%{$reset_color%}'
|
||||
local current_dir='%{$terminfo[bold]$fg[blue]%}%~%{$reset_color%}'
|
||||
local rvm_ruby='%{$fg[red]%}$(rvm_prompt_info || rbenv_prompt_info)%{$reset_color%}'
|
||||
local rvm_ruby='%{$fg[red]%}$(ruby_prompt_info)%{$reset_color%}'
|
||||
local git_branch='%{$fg[blue]%}$(git_prompt_info)%{$reset_color%}'
|
||||
|
||||
PROMPT="${user_host}:${current_dir} ${rvm_ruby}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
# * Only shows the path on the left prompt by default.
|
||||
# * Crops the path to a defined length and only shows the path relative to
|
||||
# the current VCS repository root.
|
||||
# * Wears a different color wether the last command succeeded/failed.
|
||||
# * Wears a different color whether the last command succeeded/failed.
|
||||
# * Shows user@hostname if connected through SSH.
|
||||
# * Shows if logged in as root or not.
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
@@ -2,10 +2,9 @@ if [ "$USERNAME" = "root" ]; then CARETCOLOR="red"; else CARETCOLOR="blue"; fi
|
||||
|
||||
local return_code="%(?..%{$fg[red]%}%? ↵%{$reset_color%})"
|
||||
|
||||
PROMPT='%{$fg[green]%}[%*]%{$reset_color%} %{$fg_no_bold[cyan]%}%n %{${fg_bold[blue]}%}::%{$reset_color%} %{$fg[yellow]%}%m%{$reset_color%} %{$fg_no_bold[magenta]%} ➜ %{$reset_color%} %{${fg[green]}%}%3~ $(git_prompt_info)%{${fg_bold[$CARETCOLOR]}%}»%{${reset_color}%} '
|
||||
PROMPT='%{$fg[green]%}[%D{%H:%M:%S}]%{$reset_color%} %{$fg_no_bold[cyan]%}%n %{${fg_bold[blue]}%}::%{$reset_color%} %{$fg[yellow]%}%m%{$reset_color%} %{$fg_no_bold[magenta]%} ➜ %{$reset_color%} %{${fg[green]}%}%3~ $(git_prompt_info)%{${fg_bold[$CARETCOLOR]}%}»%{${reset_color}%} '
|
||||
|
||||
RPS1="${return_code}"
|
||||
|
||||
ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg[red]%}‹"
|
||||
ZSH_THEME_GIT_PROMPT_SUFFIX="› %{$reset_color%}"
|
||||
|
||||
|
||||
@@ -35,19 +35,20 @@ prompt_setup_pygmalion(){
|
||||
}
|
||||
|
||||
prompt_pygmalion_precmd(){
|
||||
setopt localoptions extendedglob
|
||||
setopt localoptions nopromptsubst extendedglob
|
||||
|
||||
local gitinfo=$(git_prompt_info)
|
||||
local gitinfo_nocolor=${gitinfo//\%\{[^\}]##\}}
|
||||
local exp_nocolor="$(print -P \"$base_prompt_nocolor$gitinfo_nocolor$post_prompt_nocolor\")"
|
||||
local exp_nocolor="$(print -P \"${base_prompt_nocolor}${gitinfo_nocolor}${post_prompt_nocolor}\")"
|
||||
local prompt_length=${#exp_nocolor}
|
||||
|
||||
# add new line on prompt longer than 40 characters
|
||||
local nl=""
|
||||
|
||||
if [[ $prompt_length -gt 40 ]]; then
|
||||
nl=$'\n%{\r%}';
|
||||
nl=$'\n%{\r%}'
|
||||
fi
|
||||
PROMPT="$base_prompt$gitinfo$nl$post_prompt"
|
||||
|
||||
PROMPT="${base_prompt}\$(git_prompt_info)${nl}${post_prompt}"
|
||||
}
|
||||
|
||||
prompt_setup_pygmalion
|
||||
|
||||
@@ -19,14 +19,14 @@ prompt_setup_pygmalion(){
|
||||
}
|
||||
|
||||
prompt_pygmalion_precmd(){
|
||||
setopt localoptions extendedglob
|
||||
setopt localoptions nopromptsubst extendedglob
|
||||
|
||||
local gitinfo=$(git_prompt_info)
|
||||
local gitinfo_nocolor=${gitinfo//\%\{[^\}]##\}}
|
||||
local exp_nocolor="$(print -P \"$base_prompt_nocolor$gitinfo_nocolor$post_prompt_nocolor\")"
|
||||
local exp_nocolor="$(print -P \"${base_prompt_nocolor}${gitinfo_nocolor}${post_prompt_nocolor}\")"
|
||||
local prompt_length=${#exp_nocolor}
|
||||
|
||||
PROMPT="${base_prompt}${gitinfo}${post_prompt}"
|
||||
PROMPT="${base_prompt}\$(git_prompt_info)${post_prompt}"
|
||||
}
|
||||
|
||||
prompt_setup_pygmalion
|
||||
|
||||
@@ -42,6 +42,6 @@ else
|
||||
return 1
|
||||
fi
|
||||
|
||||
if [[ -z "$ZSH_THEME_RANDOM_QUIET" ]]; then
|
||||
if [[ "$ZSH_THEME_RANDOM_QUIET" != true ]]; then
|
||||
echo "[oh-my-zsh] Random theme '${RANDOM_THEME}' loaded"
|
||||
fi
|
||||
|
||||
@@ -33,8 +33,8 @@ autoload -Uz vcs_info
|
||||
zstyle ':vcs_info:*' enable hg bzr git
|
||||
zstyle ':vcs_info:*:*' unstagedstr '!'
|
||||
zstyle ':vcs_info:*:*' stagedstr '+'
|
||||
zstyle ':vcs_info:*:*' formats "$FX[bold]%r$FX[no-bold]/%S" "%s/%b" "%%u%c"
|
||||
zstyle ':vcs_info:*:*' actionformats "$FX[bold]%r$FX[no-bold]/%S" "%s/%b" "%u%c (%a)"
|
||||
zstyle ':vcs_info:*:*' formats "$FX[bold]%r$FX[no-bold]/%S" "%s:%b" "%%u%c"
|
||||
zstyle ':vcs_info:*:*' actionformats "$FX[bold]%r$FX[no-bold]/%S" "%s:%b" "%u%c (%a)"
|
||||
zstyle ':vcs_info:*:*' nvcsformats "%~" "" ""
|
||||
|
||||
# Fastest possible way to check if repo is dirty
|
||||
@@ -70,6 +70,7 @@ preexec() {
|
||||
# Output additional information about paths, repos and exec time
|
||||
#
|
||||
precmd() {
|
||||
setopt localoptions nopromptsubst
|
||||
vcs_info # Get version control info before we start outputting stuff
|
||||
print -P "\n$(repo_information) %F{yellow}$(cmd_exec_time)%f"
|
||||
unset cmd_timestamp #Reset cmd exec time.
|
||||
|
||||
@@ -1,130 +1,95 @@
|
||||
# Prompt
|
||||
#
|
||||
# Below are the color init strings for the basic file types. A color init
|
||||
# string consists of one or more of the following numeric codes:
|
||||
# Attribute codes:
|
||||
# 00=none 01=bold 04=underscore 05=blink 07=reverse 08=concealed
|
||||
# Text color codes:
|
||||
# 30=black 31=red 32=green 33=yellow 34=blue 35=magenta 36=cyan 37=white
|
||||
# Background color codes:
|
||||
# 40=black 41=red 42=green 43=yellow 44=blue 45=magenta 46=cyan 47=white
|
||||
function precmd {
|
||||
function theme_precmd {
|
||||
PR_FILLBAR=""
|
||||
PR_PWDLEN=""
|
||||
|
||||
local TERMWIDTH
|
||||
(( TERMWIDTH = ${COLUMNS} - 1 ))
|
||||
local promptsize=${#${(%):--(%n@%M:)--(%l)-}}
|
||||
local pwdsize=${#${(%):-%~}}
|
||||
local gitbranchsize="${#${(%)$(git_prompt_info)}:-}"
|
||||
local rvmpromptsize="${#${(%)$(ruby_prompt_info):-}}"
|
||||
|
||||
|
||||
###
|
||||
# Truncate the path if it's too long.
|
||||
|
||||
PR_FILLBAR=""
|
||||
PR_PWDLEN=""
|
||||
|
||||
local promptsize=${#${(%):---(%n@%M:%l)---()}}
|
||||
local pwdsize=${#${(%):-%~}}
|
||||
local gitbranch="$(git_prompt_info)"
|
||||
local rvmprompt="$(ruby_prompt_info)"
|
||||
local gitbranchsize=${#${gitbranch:-''}}
|
||||
local rvmpromptsize=${#${rvmprompt:-''}}
|
||||
|
||||
if [[ "$promptsize + $pwdsize + $rvmpromptsize + $gitbranchsize" -gt $TERMWIDTH ]]; then
|
||||
((PR_PWDLEN=$TERMWIDTH - $promptsize))
|
||||
else
|
||||
PR_FILLBAR="\${(l.(($TERMWIDTH - ($promptsize + $pwdsize + $rvmpromptsize + $gitbranchsize)))..${PR_SPACE}.)}"
|
||||
fi
|
||||
# Truncate the path if it's too long.
|
||||
if (( promptsize + pwdsize + rvmpromptsize + gitbranchsize > COLUMNS )); then
|
||||
(( PR_PWDLEN = COLUMNS - promptsize ))
|
||||
else
|
||||
PR_FILLBAR="\${(l.$(( COLUMNS - (promptsize + pwdsize + rvmpromptsize + gitbranchsize) ))..${PR_SPACE}.)}"
|
||||
fi
|
||||
}
|
||||
|
||||
function theme_preexec {
|
||||
setopt local_options extended_glob
|
||||
if [[ "$TERM" == "screen" ]]; then
|
||||
local CMD=${1[(wr)^(*=*|sudo|-*)]}
|
||||
echo -n "\ek$CMD\e\\"
|
||||
fi
|
||||
|
||||
setopt extended_glob
|
||||
if [[ "$TERM" == "xterm" ]]; then
|
||||
print -Pn "\e]0;$1\a"
|
||||
fi
|
||||
|
||||
preexec () {
|
||||
if [[ "$TERM" == "screen" ]]; then
|
||||
local CMD=${1[(wr)^(*=*|sudo|-*)]}
|
||||
echo -n "\ek$CMD\e\\"
|
||||
fi
|
||||
|
||||
if [[ "$TERM" == "xterm" ]]; then
|
||||
print -Pn "\e]0;$1\a"
|
||||
fi
|
||||
|
||||
if [[ "$TERM" == "rxvt" ]]; then
|
||||
print -Pn "\e]0;$1\a"
|
||||
fi
|
||||
if [[ "$TERM" == "rxvt" ]]; then
|
||||
print -Pn "\e]0;$1\a"
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
setprompt () {
|
||||
###
|
||||
autoload -U add-zsh-hook
|
||||
add-zsh-hook precmd theme_precmd
|
||||
add-zsh-hook preexec theme_preexec
|
||||
|
||||
|
||||
# Set the prompt
|
||||
|
||||
# Need this so the prompt will work.
|
||||
setopt prompt_subst
|
||||
|
||||
setopt prompt_subst
|
||||
|
||||
|
||||
###
|
||||
# See if we can use colors.
|
||||
autoload zsh/terminfo
|
||||
for color in RED GREEN YELLOW BLUE MAGENTA CYAN WHITE GREY; do
|
||||
typeset -g PR_$color="%{$terminfo[bold]$fg[${(L)color}]%}"
|
||||
typeset -g PR_LIGHT_$color="%{$fg[${(L)color}]%}"
|
||||
done
|
||||
PR_NO_COLOUR="%{$terminfo[sgr0]%}"
|
||||
|
||||
autoload zsh/terminfo
|
||||
for color in RED GREEN YELLOW BLUE MAGENTA CYAN WHITE; do
|
||||
eval PR_$color='%{$terminfo[bold]$fg[${(L)color}]%}'
|
||||
eval PR_LIGHT_$color='%{$fg[${(L)color}]%}'
|
||||
(( count = $count + 1 ))
|
||||
done
|
||||
PR_NO_COLOUR="%{$terminfo[sgr0]%}"
|
||||
# Use extended characters to look nicer
|
||||
PR_HBAR="-"
|
||||
PR_ULCORNER="-"
|
||||
PR_LLCORNER="-"
|
||||
PR_LRCORNER="-"
|
||||
PR_URCORNER="-"
|
||||
|
||||
# Modify Git prompt
|
||||
ZSH_THEME_GIT_PROMPT_PREFIX=" ["
|
||||
ZSH_THEME_GIT_PROMPT_SUFFIX="]"
|
||||
|
||||
###
|
||||
# See if we can use extended characters to look nicer.
|
||||
# Modify RVM prompt
|
||||
ZSH_THEME_RUBY_PROMPT_PREFIX=" ["
|
||||
ZSH_THEME_RUBY_PROMPT_SUFFIX="]"
|
||||
|
||||
typeset -A altchar
|
||||
# set -A altchar "${(s..)terminfo[acsc]}"
|
||||
PR_SET_CHARSET="%{$terminfo[enacs]%}"
|
||||
PR_HBAR=${altchar[q]:--}
|
||||
PR_ULCORNER=${altchar[l]:--}
|
||||
PR_LLCORNER=${altchar[m]:--}
|
||||
PR_LRCORNER=${altchar[j]:--}
|
||||
PR_URCORNER=${altchar[k]:--}
|
||||
|
||||
###
|
||||
# Modify Git prompt
|
||||
ZSH_THEME_GIT_PROMPT_PREFIX=" ["
|
||||
ZSH_THEME_GIT_PROMPT_SUFFIX="]"
|
||||
###
|
||||
# Modify RVM prompt
|
||||
ZSH_THEME_RUBY_PROMPT_PREFIX=" ["
|
||||
ZSH_THEME_RUBY_PROMPT_SUFFIX="]"
|
||||
|
||||
|
||||
###
|
||||
# Decide if we need to set titlebar text.
|
||||
case $TERM in
|
||||
xterm*|*rxvt*)
|
||||
PR_TITLEBAR=$'%{\e]0;%(!.-=*[ROOT]*=- | .)%n@%M:%~ $(git_prompt_info) $(ruby_prompt_info) | ${COLUMNS}x${LINES} | %y\a%}'
|
||||
;;
|
||||
screen)
|
||||
PR_TITLEBAR=$'%{\e_screen \005 (\005t) | %(!.-=[ROOT]=- | .)%n@%m:%~ | ${COLUMNS}x${LINES} | %y\e\\%}'
|
||||
;;
|
||||
*)
|
||||
PR_TITLEBAR=""
|
||||
;;
|
||||
esac
|
||||
|
||||
case $TERM in
|
||||
xterm*|*rxvt*)
|
||||
PR_TITLEBAR=$'%{\e]0;%(!.-=*[ROOT]*=- | .)%n@%M:%~ $(git_prompt_info) $(rvm_prompt_info) | ${COLUMNS}x${LINES} | %y\a%}'
|
||||
;;
|
||||
screen)
|
||||
PR_TITLEBAR=$'%{\e_screen \005 (\005t) | %(!.-=[ROOT]=- | .)%n@%m:%~ | ${COLUMNS}x${LINES} | %y\e\\%}'
|
||||
;;
|
||||
*)
|
||||
PR_TITLEBAR=''
|
||||
;;
|
||||
esac
|
||||
|
||||
|
||||
###
|
||||
# Decide whether to set a screen title
|
||||
if [[ "$TERM" == "screen" ]]; then
|
||||
PR_STITLE=$'%{\ekzsh\e\\%}'
|
||||
else
|
||||
PR_STITLE=''
|
||||
fi
|
||||
if [[ "$TERM" == "screen" ]]; then
|
||||
PR_STITLE=$'%{\ekzsh\e\\%}'
|
||||
else
|
||||
PR_STITLE=""
|
||||
fi
|
||||
|
||||
###
|
||||
# Finally, the prompt.
|
||||
#
|
||||
PROMPT='$PR_SET_CHARSET$PR_STITLE${(e)PR_TITLEBAR}\
|
||||
PROMPT='$PR_SET_CHARSET$PR_STITLE${(e)PR_TITLEBAR}\
|
||||
$PR_RED$PR_HBAR<\
|
||||
$PR_BLUE%(!.$PR_RED%SROOT%s.%n)$PR_GREEN@$PR_BLUE%M:$PR_GREEN%$PR_PWDLEN<...<%~$PR_CYAN$(git_prompt_info)$(rvm_prompt_info)\
|
||||
$PR_RED>$PR_HBAR$PR_SPACE${(e)PR_FILLBAR}\
|
||||
$PR_BLUE%(!.$PR_RED%SROOT%s.%n)$PR_GREEN@$PR_BLUE%M:$PR_GREEN%$PR_PWDLEN<...<%~$PR_CYAN$(git_prompt_info)$(ruby_prompt_info)\
|
||||
$PR_RED>$PR_HBAR${(e)PR_FILLBAR}\
|
||||
$PR_RED$PR_HBAR<\
|
||||
$PR_GREEN%l$PR_RED>$PR_HBAR\
|
||||
|
||||
@@ -132,7 +97,3 @@ $PR_RED$PR_HBAR<\
|
||||
%(?..$PR_LIGHT_RED%?$PR_BLUE:)\
|
||||
$PR_LIGHT_BLUE%(!.$PR_RED.$PR_WHITE)%#$PR_RED>$PR_HBAR\
|
||||
$PR_NO_COLOUR '
|
||||
|
||||
}
|
||||
|
||||
setprompt
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
PROMPT='%(!.%{$fg[red]%}.%{$fg[green]%})%~%{$fg_bold[blue]%}$(git_prompt_info)%{$reset_color%} '
|
||||
PROMPT='%(!.%{$fg[red]%}.%{$fg[green]%})%~$(git_prompt_info)%{$reset_color%} '
|
||||
|
||||
ZSH_THEME_GIT_PROMPT_PREFIX="("
|
||||
ZSH_THEME_GIT_PROMPT_SUFFIX=")"
|
||||
ZSH_THEME_GIT_PROMPT_DIRTY=" ✗"
|
||||
ZSH_THEME_GIT_PROMPT_CLEAN=" ✔"
|
||||
ZSH_THEME_GIT_PROMPT_PREFIX=" %{$fg_bold[blue]%}("
|
||||
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$fg_bold[blue]%})"
|
||||
ZSH_THEME_GIT_PROMPT_DIRTY=" %{$fg[red]%}✗"
|
||||
ZSH_THEME_GIT_PROMPT_CLEAN=" %{$fg[green]%}✔"
|
||||
|
||||
@@ -40,7 +40,7 @@ function git_time_since_commit() {
|
||||
local last_commit seconds_since_last_commit
|
||||
|
||||
# Only proceed if there is actually a commit
|
||||
if ! last_commit=$(command git log --pretty=format:'%at' -1 2>/dev/null); then
|
||||
if ! last_commit=$(command git -c log.showSignature=false log --pretty=format:'%at' -1 2>/dev/null); then
|
||||
echo "[$ZSH_THEME_GIT_TIME_SINCE_COMMIT_NEUTRAL~%{$reset_color%}]"
|
||||
return
|
||||
fi
|
||||
|
||||
@@ -38,6 +38,8 @@ local c13=$'\e[38;5;196m\e[1m'
|
||||
|
||||
|
||||
zsh_path() {
|
||||
setopt localoptions nopromptsubst
|
||||
|
||||
local colors
|
||||
colors=$(echoti colors)
|
||||
|
||||
|
||||
@@ -69,9 +69,7 @@ function rvm_gemset() {
|
||||
function git_time_since_commit() {
|
||||
if git rev-parse --git-dir > /dev/null 2>&1; then
|
||||
# Only proceed if there is actually a commit.
|
||||
if [[ $(git log 2>&1 > /dev/null | grep -c "^fatal: bad default revision") == 0 ]]; then
|
||||
# Get the last commit.
|
||||
last_commit=`git log --pretty=format:'%at' -1 2> /dev/null`
|
||||
if last_commit=`git -c log.showSignature=false log --pretty=format:'%at' -1 2> /dev/null`; then
|
||||
now=`date +%s`
|
||||
seconds_since_last_commit=$((now-last_commit))
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
# Mar 2013 Yad Smood
|
||||
|
||||
# VCS
|
||||
YS_VCS_PROMPT_PREFIX1=" %{$fg[white]%}on%{$reset_color%} "
|
||||
YS_VCS_PROMPT_PREFIX1=" %{$reset_color%}on%{$fg[blue]%} "
|
||||
YS_VCS_PROMPT_PREFIX2=":%{$fg[cyan]%}"
|
||||
YS_VCS_PROMPT_SUFFIX="%{$reset_color%}"
|
||||
YS_VCS_PROMPT_DIRTY=" %{$fg[red]%}x"
|
||||
@@ -19,6 +19,13 @@ ZSH_THEME_GIT_PROMPT_SUFFIX="$YS_VCS_PROMPT_SUFFIX"
|
||||
ZSH_THEME_GIT_PROMPT_DIRTY="$YS_VCS_PROMPT_DIRTY"
|
||||
ZSH_THEME_GIT_PROMPT_CLEAN="$YS_VCS_PROMPT_CLEAN"
|
||||
|
||||
# SVN info
|
||||
local svn_info='$(svn_prompt_info)'
|
||||
ZSH_THEME_SVN_PROMPT_PREFIX="${YS_VCS_PROMPT_PREFIX1}svn${YS_VCS_PROMPT_PREFIX2}"
|
||||
ZSH_THEME_SVN_PROMPT_SUFFIX="$YS_VCS_PROMPT_SUFFIX"
|
||||
ZSH_THEME_SVN_PROMPT_DIRTY="$YS_VCS_PROMPT_DIRTY"
|
||||
ZSH_THEME_SVN_PROMPT_CLEAN="$YS_VCS_PROMPT_CLEAN"
|
||||
|
||||
# HG info
|
||||
local hg_info='$(ys_hg_prompt_info)'
|
||||
ys_hg_prompt_info() {
|
||||
@@ -60,13 +67,14 @@ local exit_code="%(?,,C:%{$fg[red]%}%?%{$reset_color%})"
|
||||
PROMPT="
|
||||
%{$terminfo[bold]$fg[blue]%}#%{$reset_color%} \
|
||||
%(#,%{$bg[yellow]%}%{$fg[black]%}%n%{$reset_color%},%{$fg[cyan]%}%n) \
|
||||
%{$fg[white]%}@ \
|
||||
%{$reset_color%}@ \
|
||||
%{$fg[green]%}%m \
|
||||
%{$fg[white]%}in \
|
||||
%{$reset_color%}in \
|
||||
%{$terminfo[bold]$fg[yellow]%}%~%{$reset_color%}\
|
||||
${hg_info}\
|
||||
${git_info}\
|
||||
${svn_info}\
|
||||
${venv_info}\
|
||||
\
|
||||
%{$fg[white]%}[%*] $exit_code
|
||||
[%*] $exit_code
|
||||
%{$terminfo[bold]$fg[red]%}$ %{$reset_color%}"
|
||||
|
||||
Reference in New Issue
Block a user