Use zstyle instead of variables for configuration.

main
Sorin Ionescu 13 years ago
parent 60f39d8d91
commit f0499b76c3

@ -2,9 +2,9 @@ setopt CORRECT # Correct commands.
setopt CORRECT_ALL # Correct all arguments.
# The 'ls' Family
if check-bool "$COLOR"; then
if [[ -f "$HOME/.dir_colors" ]] && ( (( $+commands[dircolors] )) || ( (( $+plugins[(er)gnu-utils] )) && (( $+commands[gdircolors] )) ) ); then
eval $("${commands[dircolors]:-$commands[gdircolors]}" "$HOME/.dir_colors")
if zstyle -t ':omz:alias:ls' color; then
if [[ -f "$HOME/.dir_colors" ]] && (( $+commands[dircolors] )); then
eval $(dircolors "$HOME/.dir_colors")
alias ls='ls -hF --group-directories-first --color=auto'
else
export CLICOLOR=1
@ -80,7 +80,7 @@ else
fi
# Diff/Make
if check-bool "$COLOR"; then
if zstyle -t ':omz:alias:diff' color; then
if (( $+commands[colordiff] )); then
alias diff='colordiff -u'
compdef colordiff=diff

@ -20,7 +20,7 @@ zstyle ':completion::complete:*' use-cache on
zstyle ':completion::complete:*' cache-path "$HOME/.zcache"
# Case-insensitive (all), partial-word, and then substring completion.
if check-bool "$CASE_SENSITIVE"; then
if zstyle -t ':omz:completion:*' case-sensitive; then
zstyle ':completion:*' matcher-list 'r:|[._-]=* r:|=*' 'l:|=* r:|=*'
setopt CASE_GLOB
else

@ -64,7 +64,7 @@ export VISUAL="vim"
export PAGER='less'
# Grep
if check-bool "$COLOR"; then
if zstyle -t ':omz:environment:grep' color; then
export GREP_COLOR='37;45'
export GREP_OPTIONS='--color=auto'
fi
@ -89,7 +89,7 @@ if (( $+commands[lesspipe.sh] )); then
fi
# Termcap
if check-bool "$COLOR"; then
if zstyle -t ':omz:environment:termcap' color; then
export LESS_TERMCAP_mb=$'\E[01;31m' # begin blinking
export LESS_TERMCAP_md=$'\E[01;31m' # begin bold
export LESS_TERMCAP_me=$'\E[0m' # end mode

@ -3,15 +3,19 @@
# Check for the minimum supported version.
min_zsh_version=4.3.9
if ! autoload -Uz is-at-least || ! is-at-least "$min_zsh_version"; then
print "oh-my-zsh: The minimum supported Zsh version is $min_zsh_version."
print "omz: The minimum supported Zsh version is $min_zsh_version."
fi
unset min_zsh_version
# Disable color in dumb terminals.
# Disable color and theme in dumb terminals.
if [[ "$TERM" == 'dumb' ]]; then
COLOR='false'
zstyle ':omz:*:*' color 'no'
zstyle ':omz:prompt' theme 'off'
fi
# Get enabled plugins.
zstyle -a ':omz:load' plugin 'plugins'
# Add functions to fpath.
fpath=(
${0:h}/themes/*(/FN)
@ -43,6 +47,7 @@ autoload -Uz zmv
# Source plugins defined in ~/.zshrc.
for plugin in "$plugins[@]"; do
zstyle ":omz:plugin:$plugin" enable 'yes'
if [[ -f "${0:h}/plugins/$plugin/init.zsh" ]]; then
source "${0:h}/plugins/$plugin/init.zsh"
fi
@ -66,6 +71,11 @@ fi
# Load and run the prompt theming system.
autoload -Uz promptinit && promptinit
# Load the prompt theme.
zstyle -a ':omz:prompt' theme 'prompt_argv'
prompt "$prompt_argv[@]"
unset prompt_argv
# Compile zcompdump, if modified, to increase startup speed.
if [[ "$HOME/.zcompdump" -nt "$HOME/.zcompdump.zwc" ]] || [[ ! -f "$HOME/.zcompdump.zwc" ]]; then
zcompile "$HOME/.zcompdump"

@ -4,8 +4,12 @@ if [[ "$TERM" == 'dumb' ]]; then
fi
# The default styles.
zstyle ':prompt:' vicmd '<<<' # Indicator to notify of vi command mode.
zstyle ':prompt:' completion "..." # Indicator to notify of generating completion.
# Indicator to notify of vi command mode.
zstyle ':omz:prompt' vicmd '<<<'
# Indicator to notify of generating completion.
zstyle ':omz:completion:indicator' format "..."
# Beep on error in line editor.
setopt BEEP
@ -50,7 +54,7 @@ keyinfo=(
'BackTab' "$terminfo[kcbt]"
)
if [[ "$KEYMAP" == (emacs|) ]]; then
if zstyle -m ':omz:editor' keymap 'emacs'; then
# Use Emacs key bindings.
bindkey -e
@ -77,7 +81,7 @@ if [[ "$KEYMAP" == (emacs|) ]]; then
bindkey "$keyinfo[Control]x$keyinfo[Control]e" edit-command-line
# Expand .... to ../..
if check-bool "$DOT_EXPANSION"; then
if zstyle -t ':omz:editor' dot-expansion; then
bindkey "." expand-dot-to-parent-directory-path
fi
@ -90,7 +94,7 @@ if [[ "$KEYMAP" == (emacs|) ]]; then
bindkey "$keyinfo[Control]r" history-incremental-search-backward
bindkey "$keyinfo[Control]s" history-incremental-search-forward
fi
elif [[ "$KEYMAP" == 'vi' ]]; then
elif zstyle -m ':omz:editor' keymap 'vi'; then
# Use vi key bindings.
bindkey -v
@ -110,7 +114,7 @@ elif [[ "$KEYMAP" == 'vi' ]]; then
function zle-keymap-select() {
if ! vi-restore-rprompt && [[ "$KEYMAP" == 'vicmd' ]]; then
RPROMPT_CACHED="$RPROMPT"
zstyle -s ':prompt:' vicmd RPROMPT
zstyle -s ':omz:prompt' vicmd RPROMPT
zle reset-prompt
fi
}
@ -139,7 +143,7 @@ elif [[ "$KEYMAP" == 'vi' ]]; then
bindkey -M vicmd "$keyinfo[Control]r" redo
# Expand .... to ../..
if check-bool "$DOT_EXPANSION"; then
if zstyle -t ':omz:editor' dot-expansion; then
bindkey -M viins "." expand-dot-to-parent-directory-path
fi
@ -194,7 +198,7 @@ elif [[ "$KEYMAP" == 'vi' ]]; then
bindkey -M viins "$keyinfo[Control]s" history-incremental-search-forward
fi
else
print "oh-my-zsh: KEYMAP must be set 'emacs' or 'vi' but is set to '$KEYMAP'" >&2
print "omz: \`zstyle ':omz:editor' keymap\` must be set to 'emacs' or 'vi'" >&2
return 1
fi
@ -240,7 +244,7 @@ bindkey "$keyinfo[BackTab]" reverse-menu-complete
bindkey "$keyinfo[Control]i" expand-or-complete-prefix
# Convert .... to ../.. automatically.
if check-bool "$DOT_EXPANSION"; then
if zstyle -t ':omz:editor' dot-expansion; then
function expand-dot-to-parent-directory-path() {
if [[ $LBUFFER = *.. ]]; then
LBUFFER+=/..
@ -254,9 +258,9 @@ if check-bool "$DOT_EXPANSION"; then
fi
# Display an indicator when completing.
if check-bool "$COMPLETION_INDICATOR"; then
if zstyle -t ':omz:completion:indicator' enable; then
function expand-or-complete-prefix-with-indicator() {
zstyle -s ':prompt:' completion indicator
zstyle -s ':omz:completion:indicator' format indicator
print -Pn "$indicator"
unset indicator
zle expand-or-complete-prefix

@ -174,18 +174,18 @@ function git-info() {
# Format commit (short).
commit_short="$commit[1,7]"
zstyle -s ':git-info:' commit commit_format
zstyle -s ':omz:plugin:git:prompt' commit commit_format
zformat -f commit_formatted "$commit_format" "c:$commit_short"
# Stashed
if [[ -f "$(git-root)/.git/refs/stash" ]]; then
stashed="$(git stash list 2>/dev/null | wc -l)"
zstyle -s ':git-info:' stashed stashed_format
zstyle -s ':omz:plugin:git:prompt' stashed stashed_format
zformat -f stashed_formatted "$stashed_format" "S:$stashed"
fi
# Assume that the working copy is clean.
zstyle -s ':git-info:' clean clean_formatted
zstyle -s ':omz:plugin:git:prompt' clean clean_formatted
while IFS=$'\n' read line; do
(( line_number++ ))
@ -197,7 +197,7 @@ function git-info() {
# Get action.
action="$(_git-action)"
if [[ -n "$action" ]]; then
zstyle -s ':git-info:' action action_format
zstyle -s ':omz:plugin:git:prompt' action action_format
zformat -f action_formatted "$action_format" "s:$action"
fi
elif (( line_number == 1 )) \
@ -231,7 +231,7 @@ function git-info() {
fi
else
# Format dirty.
[[ -z "$dirty" ]] && zstyle -s ':git-info:' dirty dirty_formatted && unset clean_formatted
[[ -z "$dirty" ]] && zstyle -s ':omz:plugin:git:prompt' dirty dirty_formatted && unset clean_formatted
# Count: added/deleted/modified/renamed/unmerged/untracked
[[ "$line" == (((A|M|D|T) )|(AD|AM|AT|MM))\ * ]] && (( added++ ))
@ -244,7 +244,7 @@ function git-info() {
done < <(git status --short --branch 2> /dev/null)
# Format branch.
zstyle -s ':git-info:' branch branch_format
zstyle -s ':omz:plugin:git:prompt' branch branch_format
zformat -f branch_formatted "$branch_format" "b:$branch"
# Format remote.
@ -252,61 +252,61 @@ function git-info() {
[[ -z $remote ]] \
&& remote=${$(git rev-parse --verify ${branch}@{upstream} \
--symbolic-full-name 2> /dev/null)#refs/remotes/}
zstyle -s ':git-info:' remote remote_format
zstyle -s ':omz:plugin:git:prompt' remote remote_format
zformat -f remote_formatted "$remote_format" "R:$remote"
fi
# Format ahead.
if [[ -n "$ahead" ]]; then
zstyle -s ':git-info:' ahead ahead_format
zstyle -s ':omz:plugin:git:prompt' ahead ahead_format
zformat -f ahead_formatted "$ahead_format" "A:$ahead"
fi
# Format behind.
if [[ -n "$behind" ]]; then
zstyle -s ':git-info:' behind behind_format
zstyle -s ':omz:plugin:git:prompt' behind behind_format
zformat -f behind_formatted "$behind_format" "B:$behind"
fi
# Format added.
if (( $added > 0 )); then
zstyle -s ':git-info:' added added_format
zstyle -s ':omz:plugin:git:prompt' added added_format
zformat -f added_formatted "$added_format" "a:$added_format"
fi
# Format deleted.
if (( $deleted > 0 )); then
zstyle -s ':git-info:' deleted deleted_format
zstyle -s ':omz:plugin:git:prompt' deleted deleted_format
zformat -f deleted_formatted "$deleted_format" "d:$deleted_format"
fi
# Format modified.
if (( $modified > 0 )); then
zstyle -s ':git-info:' modified modified_format
zstyle -s ':omz:plugin:git:prompt' modified modified_format
zformat -f modified_formatted "$modified_format" "m:$modified"
fi
# Format renamed.
if (( $renamed > 0 )); then
zstyle -s ':git-info:' renamed renamed_format
zstyle -s ':omz:plugin:git:prompt' renamed renamed_format
zformat -f renamed_formatted "$renamed_format" "r:$renamed"
fi
# Format unmerged.
if (( $unmerged > 0 )); then
zstyle -s ':git-info:' unmerged unmerged_format
zstyle -s ':omz:plugin:git:prompt' unmerged unmerged_format
zformat -f unmerged_formatted "$unmerged_format" "U:$unmerged"
fi
# Format untracked.
if (( $untracked > 0 )); then
zstyle -s ':git-info:' untracked untracked_format
zstyle -s ':omz:plugin:git:prompt' untracked untracked_format
zformat -f untracked_formatted "$untracked_format" "u:$untracked"
fi
# Format prompts.
zstyle -s ':git-info:' prompt prompt_format
zstyle -s ':git-info:' rprompt rprompt_format
zstyle -s ':omz:plugin:git:prompt' prompt prompt_format
zstyle -s ':omz:plugin:git:prompt' rprompt rprompt_format
git_info_vars=(
git_prompt_info "$prompt_format"

@ -1,18 +1,53 @@
# The default styles.
zstyle ':git-info:' action 'action:%s' # %s - Special action name (am, merge, rebase).
zstyle ':git-info:' added 'added:%a' # %a - Indicator to notify of added files.
zstyle ':git-info:' ahead 'ahead:%A' # %A - Indicator to notify of ahead branch.
zstyle ':git-info:' behind 'behind:%B' # %B - Indicator to notify of behind branch.
zstyle ':git-info:' branch '%b' # %b - Branch name.
zstyle ':git-info:' clean 'clean' # %C - Indicator to notify of clean branch.
zstyle ':git-info:' commit 'commit:%c' # %c - SHA-1 hash.
zstyle ':git-info:' deleted 'deleted:%d' # %d - Indicator to notify of deleted files.
zstyle ':git-info:' dirty 'dirty' # %D - Indicator to notify of dirty branch.
zstyle ':git-info:' modified 'modified:%m' # %m - Indicator to notify of modified files.
zstyle ':git-info:' remote '%R' # %R - Remote name.
zstyle ':git-info:' renamed 'renamed:%r' # %r - Indicator to notify of renamed files.
zstyle ':git-info:' stashed 'stashed:%S' # %S - Indicator to notify of stashed files.
zstyle ':git-info:' unmerged 'unmerged:%U' # %U - Indicator to notify of unmerged files.
zstyle ':git-info:' untracked 'untracked:%u' # %u - Indicator to notify of untracked files.
zstyle ':git-info:' prompt ' git:(%b %D%C)' # Left prompt.
zstyle ':git-info:' rprompt '' # Right prompt.
# %s - Special action name (am, merge, rebase).
zstyle ':omz:plugin:git:prompt' action 'action:%s'
# %a - Indicator to notify of added files.
zstyle ':omz:plugin:git:prompt' added 'added:%a'
# %A - Indicator to notify of ahead branch.
zstyle ':omz:plugin:git:prompt' ahead 'ahead:%A'
# %B - Indicator to notify of behind branch.
zstyle ':omz:plugin:git:prompt' behind 'behind:%B'
# %b - Branch name.
zstyle ':omz:plugin:git:prompt' branch '%b'
# %C - Indicator to notify of clean branch.
zstyle ':omz:plugin:git:prompt' clean 'clean'
# %c - SHA-1 hash.
zstyle ':omz:plugin:git:prompt' commit 'commit:%c'
# %d - Indicator to notify of deleted files.
zstyle ':omz:plugin:git:prompt' deleted 'deleted:%d'
# %D - Indicator to notify of dirty branch.
zstyle ':omz:plugin:git:prompt' dirty 'dirty'
# %m - Indicator to notify of modified files.
zstyle ':omz:plugin:git:prompt' modified 'modified:%m'
# %R - Remote name.
zstyle ':omz:plugin:git:prompt' remote '%R'
# %r - Indicator to notify of renamed files.
zstyle ':omz:plugin:git:prompt' renamed 'renamed:%r'
# %S - Indicator to notify of stashed files.
zstyle ':omz:plugin:git:prompt' stashed 'stashed:%S'
# %U - Indicator to notify of unmerged files.
zstyle ':omz:plugin:git:prompt' unmerged 'unmerged:%U'
# %u - Indicator to notify of untracked files.
zstyle ':omz:plugin:git:prompt' untracked 'untracked:%u'
# Left prompt.
zstyle ':omz:plugin:git:prompt' prompt ' git:(%b %D%C)'
# Right prompt.
zstyle ':omz:plugin:git:prompt' rprompt ''

@ -2,11 +2,11 @@
# FILE: gnu-utils.plugin.zsh
# DESCRIPTION: oh-my-zsh plugin file.
# AUTHOR: Sorin Ionescu <sorin.ionescu@gmail.com>
# VERSION: 1.0.1
# VERSION: 1.0.2
# ------------------------------------------------------------------------------
if (( $+commands[gwhoami] )); then
if (( $+commands[gdircolors] )); then
function __gnu_utils() {
emulate -L zsh
local gcmds
@ -59,5 +59,13 @@ if (( $+commands[gwhoami] )); then
function rehash() {
hash -r "$@"
}
# A sensible default for ls.
if zstyle -t ':omz:alias:ls' color && [[ -f "$HOME/.dir_colors" ]]; then
eval $(gdircolors "$HOME/.dir_colors")
alias ls='ls -hF --group-directories-first --color=auto'
else
alias ls='ls -hF --group-directories-first'
fi
fi

@ -2,11 +2,11 @@
source "${0:h}/history-substring-search.zsh"
if check-bool "$CASE_SENSITIVE"; then
if zstyle -t ':omz:plugin:history-substring-search' case-sensitive; then
unset HISTORY_SUBSTRING_SEARCH_GLOBBING_FLAGS
fi
if ! check-bool "$COLOR"; then
if ! zstyle -t ':omz:plugin:history-substring-search' color; then
unset HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_FOUND
unset HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_NOT_FOUND
fi

@ -4,12 +4,12 @@
# To enabled agent forwarding support, add the following to
# your .zshrc file:
#
# zstyle :omz:plugins:ssh-agent agent-forwarding on
# zstyle ':omz:plugin:ssh-agent' forwarding 'on'
#
# To load multiple identies, use the identities style, For
# example:
#
# zstyle :omz:plugins:ssh-agent id_rsa id_rsa2 id_github
# zstyle ':omz:plugin:ssh-agent' identities 'id_rsa' 'id_rsa2' 'id_github'
#
#
# CREDITS
@ -33,13 +33,13 @@ function _ssh-agent-start() {
source "${_ssh_agent_env}" > /dev/null
# Load identies.
zstyle -a :omz:plugins:ssh-agent identities identities
zstyle -a ':omz:plugin:ssh-agent' identities 'identities'
print starting...
/usr/bin/ssh-add "$HOME/.ssh/${^identities}"
}
# Test if agent-forwarding is enabled.
zstyle -b :omz:plugins:ssh-agent agent-forwarding _ssh_agent_forwarding
zstyle -b ':omz:plugin:ssh-agent' forwarding '_ssh_agent_forwarding'
if check-bool "${_ssh_agent_forwarding}" && [[ -n "$SSH_AUTH_SOCK" ]]; then
# Add a nifty symlink for screen/tmux if agent forwarding.
[[ -L "$SSH_AUTH_SOCK" ]] || ln -sf "$SSH_AUTH_SOCK" /tmp/ssh-agent-$USER-screen

@ -1,34 +1,30 @@
# Set the path to Oh My Zsh.
OMZ="$HOME/.oh-my-zsh"
# Set the key mapping style to 'emacs' or 'vi'.
KEYMAP='emacs'
zstyle ':omz:editor' keymap 'emacs'
# Auto convert .... to ../..
zstyle ':omz:editor' dot-expansion 'no'
# Set case-sensitivity for completion, history lookup, etc.
CASE_SENSITIVE='false'
zstyle ':omz:*:*' case-sensitive 'no'
# Color output (auto set to 'false' on dumb terminals).
COLOR='true'
# Color output (auto set to 'no' on dumb terminals).
zstyle ':omz:*:*' color 'yes'
# Auto set the tab and window titles.
AUTO_TITLE='true'
# Auto convert .... to ../..
DOT_EXPANSION='false'
zstyle ':omz:terminal' auto-title 'yes'
# Indicate that completions are being generated.
COMPLETION_INDICATOR='false'
zstyle ':omz:completion:indicator' enable 'no'
# Set the plugins to load (see $OMZ/plugins/).
# Example: plugins=(git lighthouse rails ruby textmate)
plugins=(git)
zstyle ':omz:load' plugin 'archive' 'git'
# This will make you shout: OH MY ZSHELL!
source "$OMZ/init.zsh"
# Load the prompt theme (type prompt -l to list all themes).
# Setting it to 'random' loads a random theme.
[[ "$TERM" != 'dumb' ]] && prompt sorin || prompt off
# Auto set to 'off' on dumb terminals.
zstyle ':omz:prompt' theme 'sorin'
# This will make you shout: OH MY ZSHELL!
source "$HOME/.oh-my-zsh/init.zsh"
# Customize to your needs...

@ -70,7 +70,7 @@ autoload -Uz add-zsh-hook
# Sets the tab and window titles before the prompt is displayed.
function set-title-precmd {
if [[ "$TERM_PROGRAM" != "Apple_Terminal" ]] && check-bool "$AUTO_TITLE"; then
if [[ "$TERM_PROGRAM" != "Apple_Terminal" ]] && zstyle -t ':omz:terminal' auto-title; then
set-window-title "${(%):-%~}"
for kind in tab screen; do
# Left-truncate the current working directory to 15 characters.
@ -85,7 +85,7 @@ add-zsh-hook precmd set-title-precmd
# Sets the tab and window titles before command execution.
function set-title-preexec {
if check-bool "$AUTO_TITLE"; then
if zstyle -t ':omz:terminal' auto-title; then
set-title-by-command "$2"
fi
}

@ -22,22 +22,22 @@ function prompt_sorin_setup() {
autoload -Uz add-zsh-hook
add-zsh-hook precmd prompt_sorin_precmd
zstyle ':prompt:' vicmd '%F{yellow}%f%B%F{red}%f%b%F{red}%f'
zstyle ':prompt:' completion '%B%F{red}...%f%b'
zstyle ':git-info:' action ':%%B%F{yellow}%s%f%%b'
zstyle ':git-info:' added ' %%B%F{green}✚%f%%b'
zstyle ':git-info:' ahead ' %%B%F{yellow}⬆%f%%b'
zstyle ':git-info:' behind ' %%B%F{yellow}⬇%f%%b'
zstyle ':git-info:' branch ':%F{red}%b%f'
zstyle ':git-info:' deleted ' %%B%F{red}✖%f%%b'
zstyle ':git-info:' modified ' %%B%F{blue}✱%f%%b'
zstyle ':git-info:' renamed ' %%B%F{magenta}➜%f%%b'
zstyle ':git-info:' commit '%c'
zstyle ':git-info:' stashed ' %%B%F{cyan}✭%f%%b'
zstyle ':git-info:' unmerged ' %%B%F{yellow}═%f%%b'
zstyle ':git-info:' untracked ' %%B%F{white}◼%f%%b'
zstyle ':git-info:' prompt ' %F{blue}git%f%b%s'
zstyle ':git-info:' rprompt '%A%B%S%a%d%m%r%U%u'
zstyle ':omz:completion:indicator' format '%B%F{red}...%f%b'
zstyle ':omz:prompt' vicmd '%F{yellow}%f%B%F{red}%f%b%F{red}%f'
zstyle ':omz:plugin:git:prompt' action ':%%B%F{yellow}%s%f%%b'
zstyle ':omz:plugin:git:prompt' added ' %%B%F{green}✚%f%%b'
zstyle ':omz:plugin:git:prompt' ahead ' %%B%F{yellow}⬆%f%%b'
zstyle ':omz:plugin:git:prompt' behind ' %%B%F{yellow}⬇%f%%b'
zstyle ':omz:plugin:git:prompt' branch ':%F{red}%b%f'
zstyle ':omz:plugin:git:prompt' deleted ' %%B%F{red}✖%f%%b'
zstyle ':omz:plugin:git:prompt' modified ' %%B%F{blue}✱%f%%b'
zstyle ':omz:plugin:git:prompt' renamed ' %%B%F{magenta}➜%f%%b'
zstyle ':omz:plugin:git:prompt' commit '%c'
zstyle ':omz:plugin:git:prompt' stashed ' %%B%F{cyan}✭%f%%b'
zstyle ':omz:plugin:git:prompt' unmerged ' %%B%F{yellow}═%f%%b'
zstyle ':omz:plugin:git:prompt' untracked ' %%B%F{white}◼%f%%b'
zstyle ':omz:plugin:git:prompt' prompt ' %F{blue}git%f%b%s'
zstyle ':omz:plugin:git:prompt' rprompt '%A%B%S%a%d%m%r%U%u'
PROMPT='%F{cyan}%1~%f${git_prompt_info} %(!.%B%F{red}#%f%b.%B%F{green}%f%b) '
RPROMPT='%(?::%F{red}⏎%f)${git_rprompt_info}'

Loading…
Cancel
Save