1
0
Fork 0

Added helper functions.

pull/3/head
Sorin Ionescu 14 years ago
parent 330bcabd8b
commit 8705ded762

@ -2,7 +2,7 @@ setopt correct # Correct commands.
setopt correct_all # Correct all arguments. setopt correct_all # Correct all arguments.
# The 'ls' Family # The 'ls' Family
if [[ "$DISABLE_COLOR" != 'true' ]]; then if ! check-bool "$DISABLE_COLOR"; then
if [[ -f "$HOME/.dir_colors" ]] && ( (( $+commands[dircolors] )) || ( (( $+plugins[(er)gnu-utils] )) && (( $+commands[gdircolors] )) ) ); then if [[ -f "$HOME/.dir_colors" ]] && ( (( $+commands[dircolors] )) || ( (( $+plugins[(er)gnu-utils] )) && (( $+commands[gdircolors] )) ) ); then
eval $("${commands[dircolors]:-$commands[gdircolors]}" "$HOME/.dir_colors") eval $("${commands[dircolors]:-$commands[gdircolors]}" "$HOME/.dir_colors")
alias ls='ls -hF --group-directories-first --color=auto' alias ls='ls -hF --group-directories-first --color=auto'
@ -79,7 +79,7 @@ else
fi fi
# Diff/Make # Diff/Make
if [[ "$DISABLE_COLOR" != 'true' ]]; then if ! check-bool "$DISABLE_COLOR"; then
if (( $+commands[colordiff] )); then if (( $+commands[colordiff] )); then
alias diff='colordiff -u' alias diff='colordiff -u'
compdef colordiff=diff compdef colordiff=diff

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

@ -0,0 +1,10 @@
# Checks if a file can be autoloaded by trying to load it in a subshell.
function autoloadable() {
( unfunction $1 ; autoload -U +X $1 ) &>/dev/null
}
# Checks boolean variable for "true" (case insensitive "1", "y", "yes", "t", and "true").
function check-bool {
[[ -n "$1" && "$1" == (1|[Yy]([Ee][Ss]|)|[Tt]([Rr][Uu][Ee]|)) ]]
}

@ -14,7 +14,7 @@ fi
# Partially supports Mac OS X Terminal since it can't set window and tab separately. # Partially supports Mac OS X Terminal since it can't set window and tab separately.
# Usage: title "tab title" "window title" # Usage: title "tab title" "window title"
function terminal-title { function terminal-title {
if [[ "$DISABLE_AUTO_TITLE" != 'true' ]]; then if ! check-bool "$DISABLE_AUTO_TITLE"; then
if [[ "$TERM" == screen* ]]; then if [[ "$TERM" == screen* ]]; then
# Set GNU Screen's hardstatus (usually truncated at 20 characters). # Set GNU Screen's hardstatus (usually truncated at 20 characters).
printf "\ek%s\e\\" ${(V)1} printf "\ek%s\e\\" ${(V)1}

@ -2,14 +2,14 @@
# FILE: compleat.plugin.zsh # FILE: compleat.plugin.zsh
# DESCRIPTION: oh-my-zsh plugin file. # DESCRIPTION: oh-my-zsh plugin file.
# AUTHOR: Sorin Ionescu <sorin.ionescu@gmail.com> # AUTHOR: Sorin Ionescu <sorin.ionescu@gmail.com>
# VERSION: 1.0.1 # VERSION: 1.0.2
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
if (( ${+commands[compleat]} )); then if (( ${+commands[compleat]} )); then
compleat_setup="${commands[compleat]:h:h}/share/compleat-1.0/compleat_setup" compleat_setup="${commands[compleat]:h:h}/share/compleat-1.0/compleat_setup"
if [[ -f "$compleat_setup" ]]; then if [[ -f "$compleat_setup" ]]; then
if ! bashcompinit >/dev/null 2>&1; then if autoloadable bashcompinit; then
autoload -Uz bashcompinit && bashcompinit -i autoload -Uz bashcompinit && bashcompinit -i
fi fi

@ -85,27 +85,27 @@ function git-prompt-status() {
fi fi
while IFS=$'\n' read line; do while IFS=$'\n' read line; do
if [[ "$line" == \?\?\ * ]] && [[ untracked != 'yes' ]]; then if [[ "$line" == \?\?\ * ]] && ! check-bool "$untracked"; then
untracked='yes' untracked='yes'
indicators="${ZSH_THEME_GIT_PROMPT_UNTRACKED}${indicators}" indicators="${ZSH_THEME_GIT_PROMPT_UNTRACKED}${indicators}"
fi fi
if [[ "$line" == (((A|M|D|T) )|(AD|AM|AT|MM))\ * ]] && [[ added != 'yes' ]]; then if [[ "$line" == (((A|M|D|T) )|(AD|AM|AT|MM))\ * ]] && ! check-bool "$added"; then
added='yes' added='yes'
indicators="${ZSH_THEME_GIT_PROMPT_ADDED}${indicators}" indicators="${ZSH_THEME_GIT_PROMPT_ADDED}${indicators}"
fi fi
if [[ "$line" == (( (M|T))|(AM|AT|MM))\ * ]] && [[ modified != 'yes' ]]; then if [[ "$line" == (( (M|T))|(AM|AT|MM))\ * ]] && ! check-bool "$modified"; then
modified='yes' modified='yes'
indicators="${ZSH_THEME_GIT_PROMPT_MODIFIED}${indicators}" indicators="${ZSH_THEME_GIT_PROMPT_MODIFIED}${indicators}"
fi fi
if [[ "$line" == R\ \ * ]] && [[ renamed != 'yes' ]]; then if [[ "$line" == R\ \ * ]] && ! check-bool "$renamed"; then
renamed='yes' renamed='yes'
indicators="${ZSH_THEME_GIT_PROMPT_RENAMED}${indicators}" indicators="${ZSH_THEME_GIT_PROMPT_RENAMED}${indicators}"
fi fi
if [[ "$line" == ( D|AD)\ * ]] && [[ deleted != 'yes' ]]; then if [[ "$line" == ( D|AD)\ * ]] && ! check-bool "$deleted"; then
deleted='yes' deleted='yes'
indicators="${ZSH_THEME_GIT_PROMPT_DELETED}${indicators}" indicators="${ZSH_THEME_GIT_PROMPT_DELETED}${indicators}"
fi fi
if [[ "$line" == UU\ * ]] && [[ unmerged != 'yes' ]]; then if [[ "$line" == UU\ * ]] && ! check-bool "$unmerged"; then
unmerged='yes' unmerged='yes'
indicators="${ZSH_THEME_GIT_PROMPT_UNMERGED}${indicators}" indicators="${ZSH_THEME_GIT_PROMPT_UNMERGED}${indicators}"
fi fi

Loading…
Cancel
Save