mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2026-02-06 02:51:32 +01:00
Merge branch 'master' of git://github.com/ohmyzsh/ohmyzsh
This commit is contained in:
commit
f93aa9d24b
111 changed files with 2225 additions and 659 deletions
|
|
@ -29,11 +29,13 @@
|
|||
# # This theme's look and feel is based on the Aaron Toponce's zsh theme, more info:
|
||||
# # https://pthree.org/2008/11/23/727/
|
||||
# # enjoy!
|
||||
|
||||
########## 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}]%}'
|
||||
eval PR_$COLOR='%{$fg[${(L)COLOR}]%}'
|
||||
eval PR_BRIGHT_$COLOR='%{$fg_bold[${(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} "
|
||||
|
|
@ -44,14 +46,14 @@ 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}"
|
||||
# ########## COLOR ###########
|
||||
# ########## SVN ###########
|
||||
|
||||
########## 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}"
|
||||
# ########## SVN ###########
|
||||
# ########## GIT ###########
|
||||
|
||||
########## 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}"
|
||||
|
|
@ -62,53 +64,63 @@ 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}"
|
||||
# ########## GIT ###########
|
||||
function precmd {
|
||||
#gets the fortune
|
||||
ps1_fortune () {
|
||||
#Choose from all databases, regardless of whether they are considered "offensive"
|
||||
fortune -a
|
||||
}
|
||||
#obtains the tip
|
||||
ps1_command_tip () {
|
||||
wget -qO - http://www.commandlinefu.com/commands/random/plaintext | sed 1d | sed '/^$/d'
|
||||
}
|
||||
prompt_header () {
|
||||
if [[ "true" == "$ENABLE_COMMAND_TIP" ]]; then
|
||||
ps1_command_tip
|
||||
else
|
||||
ps1_fortune
|
||||
fi
|
||||
}
|
||||
PROMPT_HEAD="${RED_START}${PR_YELLOW}$(prompt_header)${PR_RESET}"
|
||||
# set a simple variable to show when in screen
|
||||
if [[ -n "${WINDOW}" ]]; then
|
||||
SCREEN=""
|
||||
|
||||
# Get a fortune quote
|
||||
ps1_fortune() {
|
||||
(( ${+commands[fortune]} )) && fortune
|
||||
}
|
||||
|
||||
# Obtain a command tip
|
||||
ps1_command_tip() {
|
||||
{
|
||||
if (( ${+commands[wget]} )); then
|
||||
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'
|
||||
}
|
||||
|
||||
function precmd_adben {
|
||||
prompt_header() {
|
||||
if [[ "$ENABLE_COMMAND_TIP" = true ]]; then
|
||||
ps1_command_tip
|
||||
else
|
||||
ps1_fortune
|
||||
fi
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
# Context: user@directory or just directory
|
||||
prompt_context () {
|
||||
if [[ "$USER" != "$DEFAULT_USER" || -n "$SSH_CLIENT" ]]; then
|
||||
echo -n "${PR_RESET}${PR_RED}$USER@%m${PR_RESET}${PR_BRIGHT_YELLOW}%~%<<${PR_RESET}"
|
||||
else
|
||||
echo -n "${PR_RESET}${PR_BRIGHT_YELLOW}%~%<<${PR_RESET}"
|
||||
fi
|
||||
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}"
|
||||
fi
|
||||
}
|
||||
|
||||
set_prompt () {
|
||||
# required for the prompt
|
||||
setopt prompt_subst
|
||||
autoload zsh/terminfo
|
||||
########## SETUP ###########
|
||||
|
||||
# ######### PROMPT #########
|
||||
PROMPT='${PROMPT_HEAD}
|
||||
# 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}'
|
||||
# Matching continuation prompt
|
||||
PROMPT2='${GREEN_BASE_START}${PR_RESET} %_ ${GREEN_BASE_START}${PR_RESET} '
|
||||
# ######### PROMPT #########
|
||||
}
|
||||
RPROMPT='${PR_RESET}$(git_prompt_info)$(svn_prompt_info)${PR_YELLOW}%D{%R.%S %a %b %d %Y} ${GREEN_END}${PR_RESET}'
|
||||
# Matching continuation prompt
|
||||
PROMPT2='${GREEN_BASE_START}${PR_RESET} %_ ${GREEN_BASE_START}${PR_RESET} '
|
||||
|
||||
set_prompt
|
||||
# Prompt head
|
||||
autoload -Uz add-zsh-hook
|
||||
add-zsh-hook precmd precmd_adben
|
||||
|
|
|
|||
|
|
@ -88,7 +88,7 @@ prompt_end() {
|
|||
|
||||
# Context: user@hostname (who am I and where am I)
|
||||
prompt_context() {
|
||||
if [[ "$USER" != "$DEFAULT_USER" || -n "$SSH_CLIENT" ]]; then
|
||||
if [[ "$USERNAME" != "$DEFAULT_USER" || -n "$SSH_CLIENT" ]]; then
|
||||
prompt_segment black default "%(!.%{%F{yellow}%}.)%n@%m"
|
||||
fi
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ function _user_host() {
|
|||
local me
|
||||
if [[ -n $SSH_CONNECTION ]]; then
|
||||
me="%n@%m"
|
||||
elif [[ $LOGNAME != $USER ]]; then
|
||||
elif [[ $LOGNAME != $USERNAME ]]; then
|
||||
me="%n"
|
||||
fi
|
||||
if [[ -n $me ]]; then
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
if [ "$USER" = "root" ]
|
||||
if [ "$USERNAME" = "root" ]
|
||||
then CARETCOLOR="red"
|
||||
else CARETCOLOR="blue"
|
||||
fi
|
||||
|
|
|
|||
|
|
@ -1,8 +1,28 @@
|
|||
function prompt_char {
|
||||
if [ $UID -eq 0 ]; then echo "#"; else echo $; fi
|
||||
autoload -Uz colors && colors
|
||||
|
||||
autoload -Uz vcs_info
|
||||
zstyle ':vcs_info:*' check-for-changes true
|
||||
zstyle ':vcs_info:*' unstagedstr '%F{red}*' # display this when there are unstaged changes
|
||||
zstyle ':vcs_info:*' stagedstr '%F{yellow}+' # display this when there are staged changes
|
||||
zstyle ':vcs_info:*' actionformats '%F{5}(%F{2}%b%F{3}|%F{1}%a%c%u%m%F{5})%f '
|
||||
zstyle ':vcs_info:*' formats '%F{5}(%F{2}%b%c%u%m%F{5})%f '
|
||||
zstyle ':vcs_info:(sv[nk]|bzr):*' branchformat '%b%F{1}:%F{3}%r'
|
||||
zstyle ':vcs_info:*' enable git cvs svn
|
||||
zstyle ':vcs_info:git*+set-message:*' hooks untracked-git
|
||||
|
||||
+vi-untracked-git() {
|
||||
if command git status --porcelain 2>/dev/null | command grep -q '??'; then
|
||||
hook_com[misc]='%F{red}?'
|
||||
else
|
||||
hook_com[misc]=''
|
||||
fi
|
||||
}
|
||||
|
||||
PROMPT='%(!.%{$fg_bold[red]%}.%{$fg_bold[green]%}%n@)%m %{$fg_bold[blue]%}%(!.%1~.%~) $(git_prompt_info)$(prompt_char)%{$reset_color%} '
|
||||
gentoo_precmd() {
|
||||
vcs_info
|
||||
}
|
||||
|
||||
ZSH_THEME_GIT_PROMPT_PREFIX="("
|
||||
ZSH_THEME_GIT_PROMPT_SUFFIX=") "
|
||||
autoload -U add-zsh-hook
|
||||
add-zsh-hook precmd gentoo_precmd
|
||||
|
||||
PROMPT='%(!.%B%F{red}.%B%F{green}%n@)%m %F{blue}%(!.%1~.%~) ${vcs_info_msg_0_}%F{blue}%(!.#.$)%k%b%f '
|
||||
|
|
|
|||
|
|
@ -1,11 +1,12 @@
|
|||
# The Official Theme of
|
||||
## ## ## ## ##
|
||||
### ### ## ## ##
|
||||
#### #### ## ## ##
|
||||
## ### ## ## #########
|
||||
## ## ## ## ##
|
||||
## ## ## ## ##
|
||||
## ## ######## ## ##
|
||||
# The Official Theme of Major League Hacking
|
||||
|
||||
## ## ## ## ##
|
||||
### ### ## ## ##
|
||||
#### #### ## ## ##
|
||||
## ### ## ## #########
|
||||
## ## ## ## ##
|
||||
## ## ## ## ##
|
||||
## ## ######## ## ##
|
||||
|
||||
# # # # # # # # # # # # # # # # # #
|
||||
# # # Feel free to customize! # # #
|
||||
|
|
@ -13,11 +14,17 @@
|
|||
|
||||
# To easily discover colors and their codes, type `spectrum_ls` in the terminal
|
||||
|
||||
# enable or disable particular elements
|
||||
PRINT_EXIT_CODE=true
|
||||
PRINT_TIME=true
|
||||
|
||||
# symbols
|
||||
AT_SYMBOL=" @ "
|
||||
IN_SYMBOL=" in "
|
||||
ON_SYMBOL=" on "
|
||||
SYMBOL="$"
|
||||
SHELL_SYMBOL="$"
|
||||
|
||||
# colors
|
||||
USER_COLOR="%F{001}"
|
||||
DEVICE_COLOR="%F{033}"
|
||||
DIR_COLOR="%F{220}"
|
||||
|
|
@ -25,35 +32,39 @@ BRANCH_COLOR="%F{001}"
|
|||
TIME_COLOR="%F{033}"
|
||||
|
||||
username() {
|
||||
echo "$USER_COLOR%n%f"
|
||||
echo "$USER_COLOR%n%f"
|
||||
}
|
||||
|
||||
# Returns device name
|
||||
# Prints device name
|
||||
device() {
|
||||
echo "$DEVICE_COLOR%m%f"
|
||||
echo "$DEVICE_COLOR%m%f"
|
||||
}
|
||||
|
||||
# The current directory
|
||||
# Prints the current directory
|
||||
directory() {
|
||||
echo "$DIR_COLOR%1~%f"
|
||||
echo "$DIR_COLOR%1~%f"
|
||||
}
|
||||
|
||||
# Current time with milliseconds
|
||||
# Prints current time
|
||||
current_time() {
|
||||
echo "$TIME_COLOR%*%f"
|
||||
if [ "$PRINT_TIME" = true ]; then
|
||||
echo " $TIME_COLOR%*%f"
|
||||
fi
|
||||
}
|
||||
|
||||
# Return status of the last command
|
||||
return_status() {
|
||||
echo "%(?..%F{001}out %?)%f"
|
||||
# Prints exit code of the last executed command
|
||||
exit_code() {
|
||||
if [ "$PRINT_EXIT_CODE" = true ]; then
|
||||
echo "%(?..%F{001}exit %?)%f"
|
||||
fi
|
||||
}
|
||||
|
||||
# Set the git_prompt_info text
|
||||
# Set git_prompt_info text
|
||||
ZSH_THEME_GIT_PROMPT_PREFIX="${ON_SYMBOL}${BRANCH_COLOR}"
|
||||
ZSH_THEME_GIT_PROMPT_SUFFIX="%f"
|
||||
ZSH_THEME_GIT_PROMPT_DIRTY=""
|
||||
ZSH_THEME_GIT_PROMPT_CLEAN=""
|
||||
|
||||
# %B and %b make the text bold
|
||||
PROMPT='%b$(username)$AT_SYMBOL$(device)$IN_SYMBOL$(directory)$(git_prompt_info)%b $SYMBOL '
|
||||
RPROMPT="$(return_status) $(current_time)"
|
||||
PROMPT='%b$(username)$AT_SYMBOL$(device)$IN_SYMBOL$(directory)$(git_prompt_info)%b $SHELL_SYMBOL '
|
||||
RPROMPT="$(exit_code)$(current_time)"
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
if [ "$USER" = "root" ]; then CARETCOLOR="red"; else CARETCOLOR="blue"; fi
|
||||
if [ "$USERNAME" = "root" ]; then CARETCOLOR="red"; else CARETCOLOR="blue"; fi
|
||||
|
||||
local return_code="%(?..%{$fg[red]%}%? ↵%{$reset_color%})"
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
if [ "$USER" = "root" ]; then CARETCOLOR="red"; else CARETCOLOR="magenta"; fi
|
||||
if [ "$USERNAME" = "root" ]; then CARETCOLOR="red"; else CARETCOLOR="magenta"; fi
|
||||
|
||||
local return_code="%(?..%{$fg_bold[red]%}:( %?%{$reset_color%})"
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ Y=$fg_no_bold[yellow]
|
|||
B=$fg_no_bold[blue]
|
||||
RESET=$reset_color
|
||||
|
||||
if [ "$USER" = "root" ]; then
|
||||
if [ "$USERNAME" = "root" ]; then
|
||||
PROMPTCOLOR="%{$R%}" PROMPTPREFIX="-!-";
|
||||
else
|
||||
PROMPTCOLOR="" PROMPTPREFIX="---";
|
||||
|
|
|
|||
|
|
@ -26,15 +26,26 @@ ys_hg_prompt_info() {
|
|||
if [ -d '.hg' ]; then
|
||||
echo -n "${YS_VCS_PROMPT_PREFIX1}hg${YS_VCS_PROMPT_PREFIX2}"
|
||||
echo -n $(hg branch 2>/dev/null)
|
||||
if [ -n "$(hg status 2>/dev/null)" ]; then
|
||||
echo -n "$YS_VCS_PROMPT_DIRTY"
|
||||
else
|
||||
echo -n "$YS_VCS_PROMPT_CLEAN"
|
||||
if [[ "$(hg config oh-my-zsh.hide-dirty 2>/dev/null)" != "1" ]]; then
|
||||
if [ -n "$(hg status 2>/dev/null)" ]; then
|
||||
echo -n "$YS_VCS_PROMPT_DIRTY"
|
||||
else
|
||||
echo -n "$YS_VCS_PROMPT_CLEAN"
|
||||
fi
|
||||
fi
|
||||
echo -n "$YS_VCS_PROMPT_SUFFIX"
|
||||
fi
|
||||
}
|
||||
|
||||
# Virtualenv
|
||||
local venv_info='$(virtenv_prompt)'
|
||||
YS_THEME_VIRTUALENV_PROMPT_PREFIX=" %{$fg[green]%}"
|
||||
YS_THEME_VIRTUALENV_PROMPT_SUFFIX=" %{$reset_color%}%"
|
||||
virtenv_prompt() {
|
||||
[[ -n ${VIRTUAL_ENV} ]] || return
|
||||
echo "${YS_THEME_VIRTUALENV_PROMPT_PREFIX}${VIRTUAL_ENV:t}${YS_THEME_VIRTUALENV_PROMPT_SUFFIX}"
|
||||
}
|
||||
|
||||
local exit_code="%(?,,C:%{$fg[red]%}%?%{$reset_color%})"
|
||||
|
||||
# Prompt format:
|
||||
|
|
@ -55,6 +66,7 @@ PROMPT="
|
|||
%{$terminfo[bold]$fg[yellow]%}%~%{$reset_color%}\
|
||||
${hg_info}\
|
||||
${git_info}\
|
||||
${venv_info}\
|
||||
\
|
||||
%{$fg[white]%}[%*] $exit_code
|
||||
%{$terminfo[bold]$fg[red]%}$ %{$reset_color%}"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue