Skip to content

Commit

Permalink
Merge with upstream.
Browse files Browse the repository at this point in the history
  • Loading branch information
sjl committed Jun 3, 2011
2 parents 3e67320 + 3ed19c4 commit b17f997
Show file tree
Hide file tree
Showing 97 changed files with 2,631 additions and 127 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Expand Up @@ -3,7 +3,7 @@ log/.zsh_history
projects.zsh projects.zsh
custom custom
custom/*.zsh custom/*.zsh
!custom/example.zsh
*.un~ *.un~
cache


.DS_Store .DS_Store
20 changes: 12 additions & 8 deletions README.textile
Expand Up @@ -48,22 +48,26 @@ the "refcard":http://www.bash2zsh.com/zsh_refcard/refcard.pdf is pretty tasty fo
h3. Customization h3. Customization


If you want to override any of the default behavior, just add a new file (ending in @.zsh@) into the @custom/@ directory. If you want to override any of the default behavior, just add a new file (ending in @.zsh@) into the @custom/@ directory.
If you have many functions which go good together you can put them as a *.plugin.zsh file in the @plugin/@ directory and then enable this plugin. If you have many functions which go good together you can put them as a *.plugin.zsh file in the @custom/plugins/@ directory and then enable this plugin.
If you would like to override the functionality of a plugin distributed with oh-my-zsh, create a plugin of the same name in the @custom/plugins/@ directory and it will be loaded instead of the one in @plugins/@.



h3. Uninstalling h3. Uninstalling


If you want to uninstall it, just run @uninstall_oh_my_zsh@ from the command line and it'll remove itself and revert you to bash (or your previous zsh config). If you want to uninstall it, just run @uninstall_oh_my_zsh@ from the command line and it'll remove itself and revert you to bash (or your previous zsh config).


h2. Thanks

* Rick Olson (technoweenie) might remember some of the configuration, which I took from a pastie a few years ago.
* Marcel (noradio) provided Rick the original zsh configuration.
* Nicholas (ulysses) for the "rake autocompletion code":http://weblog.rubyonrails.org/2006/3/9/fast-rake-task-completion-for-zsh.

h2. Help out! h2. Help out!


I'm far from being a zsh-expert and suspect there are many ways to improve. If you have ideas on how to make the configuration easier to maintain (and faster), don't hesitate to fork and send pull requests! I'm far from being a zsh-expert and suspect there are many ways to improve. If you have ideas on how to make the configuration easier to maintain (and faster), don't hesitate to fork and send pull requests!


h3. Send us your theme! h3. Send us your theme!


I'm hoping to collect a bunch of themes for our command prompts. You can see existing ones in the @themes/@ directory. I'm hoping to collect a bunch of themes for our command prompts. You can see existing ones in the @themes/@ directory.

h2. Contributors

This project wouldn't exist without all of our awesome users and contributors.

* "View our growing list of contributors":https://github.com/robbyrussell/oh-my-zsh/contributors

Thank you so much!
3 changes: 0 additions & 3 deletions lib/completion.zsh
Expand Up @@ -6,9 +6,6 @@ unsetopt always_to_end


WORDCHARS='' WORDCHARS=''


autoload -U compinit
compinit -i

zmodload -i zsh/complist zmodload -i zsh/complist


# case-insensitive (all), partial-word and then substring completion # case-insensitive (all), partial-word and then substring completion
Expand Down
6 changes: 5 additions & 1 deletion lib/directories.zsh
Expand Up @@ -30,7 +30,6 @@ cd () {


alias md='mkdir -p' alias md='mkdir -p'
alias rd=rmdir alias rd=rmdir

alias d='dirs -v' alias d='dirs -v'


# List direcory contents # List direcory contents
Expand All @@ -44,3 +43,8 @@ alias ll3='tree --dirsfirst -ChFupDaL 3'


alias l='l1' alias l='l1'
alias ll='ll1' alias ll='ll1'

# mkdir & cd to it
function mcd() {
mkdir -p "$1" && cd "$1";
}
36 changes: 36 additions & 0 deletions lib/functions.zsh
Expand Up @@ -9,3 +9,39 @@ function uninstall_oh_my_zsh() {
function upgrade_oh_my_zsh() { function upgrade_oh_my_zsh() {
/bin/sh $ZSH/tools/upgrade.sh /bin/sh $ZSH/tools/upgrade.sh
} }

function extract() {
unset REMOVE_ARCHIVE

if test "$1" = "-r"; then
REMOVE=1
shift
fi
if [[ -f $1 ]]; then
case $1 in
*.tar.bz2) tar xvjf $1;;
*.tar.gz) tar xvzf $1;;
*.tar.xz) tar xvJf $1;;
*.tar.lzma) tar --lzma -xvf $1;;
*.bz2) bunzip $1;;
*.rar) unrar x $1;;
*.gz) gunzip $1;;
*.tar) tar xvf $1;;
*.tbz2) tar xvjf $1;;
*.tgz) tar xvzf $1;;
*.zip) unzip $1;;
*.Z) uncompress $1;;
*.7z) 7z x $1;;
*) echo "'$1' cannot be extracted via >extract<";;
esac

if [[ $REMOVE_ARCHIVE -eq 1 ]]; then
echo removing "$1";
/bin/rm "$1";
fi

else
echo "'$1' is not a valid file"
fi
}

25 changes: 23 additions & 2 deletions lib/git.zsh
Expand Up @@ -20,6 +20,13 @@ parse_git_dirty () {
fi fi
} }


# Checks if there are commits ahead from remote
function git_prompt_ahead() {
if $(echo "$(git log origin/$(current_branch)..HEAD 2> /dev/null)" | grep '^commit' &> /dev/null); then
echo "$ZSH_THEME_GIT_PROMPT_AHEAD"
fi
}

# #
# Will return the current branch name # Will return the current branch name
# Usage example: git pull origin $(current_branch) # Usage example: git pull origin $(current_branch)
Expand All @@ -29,7 +36,17 @@ function current_branch() {
echo ${ref#refs/heads/} echo ${ref#refs/heads/}
} }


# get the status of the working tree # Formats prompt string for current git commit short SHA
function git_prompt_short_sha() {
SHA=$(git rev-parse --short HEAD 2> /dev/null) && echo "$ZSH_THEME_GIT_PROMPT_SHA_BEFORE$SHA$ZSH_THEME_GIT_PROMPT_SHA_AFTER"
}

# Formats prompt string for current git commit long SHA
function git_prompt_long_sha() {
SHA=$(git rev-parse HEAD 2> /dev/null) && echo "$ZSH_THEME_GIT_PROMPT_SHA_BEFORE$SHA$ZSH_THEME_GIT_PROMPT_SHA_AFTER"
}

# Get the status of the working tree
git_prompt_status() { git_prompt_status() {
INDEX=$(git status --porcelain 2> /dev/null) INDEX=$(git status --porcelain 2> /dev/null)
STATUS="" STATUS=""
Expand All @@ -43,11 +60,15 @@ git_prompt_status() {
fi fi
if $(echo "$INDEX" | grep '^ M ' &> /dev/null); then if $(echo "$INDEX" | grep '^ M ' &> /dev/null); then
STATUS="$ZSH_THEME_GIT_PROMPT_MODIFIED$STATUS" STATUS="$ZSH_THEME_GIT_PROMPT_MODIFIED$STATUS"
elif $(echo "$INDEX" | grep '^AM ' &> /dev/null); then
STATUS="$ZSH_THEME_GIT_PROMPT_MODIFIED$STATUS"
elif $(echo "$INDEX" | grep '^ T ' &> /dev/null); then
STATUS="$ZSH_THEME_GIT_PROMPT_MODIFIED$STATUS"
fi fi
if $(echo "$INDEX" | grep '^R ' &> /dev/null); then if $(echo "$INDEX" | grep '^R ' &> /dev/null); then
STATUS="$ZSH_THEME_GIT_PROMPT_RENAMED$STATUS" STATUS="$ZSH_THEME_GIT_PROMPT_RENAMED$STATUS"
fi fi
if $(echo "$INDEX" | grep '^ D ' &> /dev/null); then if $(echo "$INDEX" | grep '^D ' &> /dev/null); then
STATUS="$ZSH_THEME_GIT_PROMPT_DELETED$STATUS" STATUS="$ZSH_THEME_GIT_PROMPT_DELETED$STATUS"
fi fi
if $(echo "$INDEX" | grep '^UU ' &> /dev/null); then if $(echo "$INDEX" | grep '^UU ' &> /dev/null); then
Expand Down
11 changes: 9 additions & 2 deletions lib/key-bindings.zsh
@@ -1,6 +1,4 @@
# TODO: Explain what some of this does.. # TODO: Explain what some of this does..
autoload -U compinit
compinit -i


bindkey -e bindkey -e
bindkey '\ew' kill-region bindkey '\ew' kill-region
Expand All @@ -21,3 +19,12 @@ bindkey "^[[4~" end-of-line
bindkey ' ' magic-space # also do history expansion on space bindkey ' ' magic-space # also do history expansion on space


bindkey '^[[Z' reverse-menu-complete bindkey '^[[Z' reverse-menu-complete

# Make the delete key (or Fn + Delete on the Mac) work instead of outputting a ~
bindkey "^[[3~" delete-char
bindkey "^[3;5~" delete-char
bindkey "\e[3~" delete-char

## Fix weird sequence that rxvt produces
#bindkey -s '^[[Z' '\t'
#
29 changes: 29 additions & 0 deletions lib/termsupport.zsh
@@ -0,0 +1,29 @@
#usage: title short_tab_title looooooooooooooooooooooggggggg_windows_title
#http://www.faqs.org/docs/Linux-mini/Xterm-Title.html#ss3.1
#Fully support screen, iterm, and probably most modern xterm and rxvt
#Limited support for Apple Terminal (Terminal can't set window or tab separately)
function title {
[ "$DISABLE_AUTO_TITLE" != "true" ] || return
if [[ "$TERM" == screen* ]]; then
print -Pn "\ek$1:q\e\\" #set screen hardstatus, usually truncated at 20 chars
elif [[ "$TERM" == xterm* ]] || [[ $TERM == rxvt* ]] || [[ "$TERM_PROGRAM" == "iTerm.app" ]]; then
print -Pn "\e]2;$2:q\a" #set window name
print -Pn "\e]1;$1:q\a" #set icon (=tab) name (will override window name on broken terminal)
fi
}

ZSH_THEME_TERM_TAB_TITLE_IDLE="%15<..<%~%<<" #15 char left truncated PWD
ZSH_THEME_TERM_TITLE_IDLE="%n@%m: %~"

#Appears when you have the prompt
function precmd {
title $ZSH_THEME_TERM_TAB_TITLE_IDLE $ZSH_THEME_TERM_TITLE_IDLE
}

#Appears at the beginning of (and during) of command execution
function preexec {
emulate -L zsh
setopt extended_glob
local CMD=${1[(wr)^(*=*|sudo|ssh|-*)]} #cmd name only, or if this is sudo or ssh, the next cmd
title "$CMD" "%100>...>$2%<<"
}
2 changes: 0 additions & 2 deletions lib/appearance.zsh → lib/theme-and-appearance.zsh
Expand Up @@ -33,5 +33,3 @@ ZSH_THEME_GIT_PROMPT_CLEAN="" # Text to display if the branch is c
# Setup the prompt with pretty colors # Setup the prompt with pretty colors
setopt prompt_subst setopt prompt_subst


# Load the theme
source "$ZSH/themes/$ZSH_THEME.zsh-theme"
36 changes: 32 additions & 4 deletions oh-my-zsh.sh
@@ -1,18 +1,46 @@
# Initializes Oh My Zsh # Initializes Oh My Zsh


# add a function path # add a function path
fpath=($ZSH/functions $fpath) fpath=($ZSH/functions $ZSH/completions $fpath)


# Load all of the config files in ~/oh-my-zsh that end in .zsh # Load all of the config files in ~/oh-my-zsh that end in .zsh
# TIP: Add files you don't want in git to .gitignore # TIP: Add files you don't want in git to .gitignore
for config_file ($ZSH/lib/*.zsh) source $config_file for config_file ($ZSH/lib/*.zsh) source $config_file


# Add all defined plugins to fpath
plugin=${plugin:=()}
for plugin ($plugins) fpath=($ZSH/plugins/$plugin $fpath)

# Load and run compinit
autoload -U compinit
compinit -i

# Load all of the plugins that were defined in ~/.zshrc
for plugin ($plugins); do
if [ -f $ZSH/custom/plugins/$plugin/$plugin.plugin.zsh ]; then
source $ZSH/custom/plugins/$plugin/$plugin.plugin.zsh
elif [ -f $ZSH/plugins/$plugin/$plugin.plugin.zsh ]; then
source $ZSH/plugins/$plugin/$plugin.plugin.zsh
fi
done

# Load all of your custom configurations from custom/ # Load all of your custom configurations from custom/
for config_file ($ZSH/custom/*.zsh) source $config_file for config_file ($ZSH/custom/*.zsh) source $config_file


# Load all of the plugins that were defined in ~/.zshrc # Load the theme
plugin=${plugin:=()} # Check for updates on initial load...
for plugin ($plugins) source $ZSH/plugins/$plugin/$plugin.plugin.zsh if [ "$ZSH_THEME" = "random" ]
then
themes=($ZSH/themes/*zsh-theme)
N=${#themes[@]}
((N=(RANDOM%N)+1))
RANDOM_THEME=${themes[$N]}
source "$RANDOM_THEME"
echo "[oh-my-zsh] Random theme '$RANDOM_THEME' loaded..."
else
source "$ZSH/themes/$ZSH_THEME.zsh-theme"
fi



# Check for updates on initial load... # Check for updates on initial load...
if [ "$DISABLE_AUTO_UPDATE" = "true" ] if [ "$DISABLE_AUTO_UPDATE" = "true" ]
Expand Down
26 changes: 26 additions & 0 deletions plugins/ant/ant.plugin.zsh
@@ -0,0 +1,26 @@
stat -f%m . > /dev/null 2>&1
if [ "$?" = 0 ]; then
stat_cmd=(stat -f%m)
else
stat_cmd=(stat -L --format=%Y)
fi

_ant_does_target_list_need_generating () {
if [ ! -f .ant_targets ]; then return 0;
else
accurate=$($stat_cmd .ant_targets)
changed=$($stat_cmd build.xml)
return $(expr $accurate '>=' $changed)
fi
}

_ant () {
if [ -f build.xml ]; then
if _ant_does_target_list_need_generating; then
sed -n '/<target/s/<target.*name="\([^"]*\).*$/\1/p' build.xml > .ant_targets
fi
compadd `cat .ant_targets`
fi
}

compdef _ant ant
6 changes: 6 additions & 0 deletions plugins/apache2-macports/apache2-macports.plugin.zsh
@@ -0,0 +1,6 @@
# commands to control local apache2 server installation
# paths are for osx installation via macports

alias apache2start='sudo /opt/local/etc/LaunchDaemons/org.macports.apache2/apache2.wrapper start'
alias apache2stop='sudo /opt/local/etc/LaunchDaemons/org.macports.apache2/apache2.wrapper stop'
alias apache2restart='sudo /opt/local/etc/LaunchDaemons/org.macports.apache2/apache2.wrapper restart'
3 changes: 3 additions & 0 deletions plugins/autojump/autojump.plugin.zsh
@@ -0,0 +1,3 @@
if [ -f `brew --prefix`/etc/autojump ]; then
. `brew --prefix`/etc/autojump
fi
25 changes: 18 additions & 7 deletions plugins/brew/_brew
Expand Up @@ -25,20 +25,27 @@ _1st_arguments=(
'link:link a formula' 'link:link a formula'
'list:list files in a formula or not-installed formulae' 'list:list files in a formula or not-installed formulae'
'log:git commit log for a formula' 'log:git commit log for a formula'
'missing:check all installed formuale for missing dependencies.'
'outdated:list formulas for which a newer version is available' 'outdated:list formulas for which a newer version is available'
'prune:remove dead links' 'prune:remove dead links'
'remove:remove a formula' 'remove:remove a formula'
'search:search for a formula (/regex/ or string)' 'search:search for a formula (/regex/ or string)'
'server:start a local web app that lets you browse formulae (requires Sinatra)'
'unlink:unlink a formula' 'unlink:unlink a formula'
'update:freshen up links' 'update:freshen up links'
'upgrade:upgrade outdated formulae'
'uses:show formulas which depend on a formula' 'uses:show formulas which depend on a formula'
) )


local expl local expl
local -a formula installed_formulae local -a formulae installed_formulae


_arguments \ _arguments \
'(-v --verbose)'{-v,--verbose}'[verbose]' \ '(-v)-v[verbose]' \
'(--cellar)--cellar[brew cellar]' \
'(--config)--config[brew configuration]' \
'(--env)--env[brew environment]' \
'(--repository)--repository[brew repository]' \
'(--version)--version[version information]' \ '(--version)--version[version information]' \
'(--prefix)--prefix[where brew lives on this system]' \ '(--prefix)--prefix[where brew lives on this system]' \
'(--cache)--cache[brew cache]' \ '(--cache)--cache[brew cache]' \
Expand All @@ -50,20 +57,24 @@ if (( CURRENT == 1 )); then
fi fi


case "$words[1]" in case "$words[1]" in
list) search|-S)
_arguments \
'(--macports)--macports[search the macports repository]' \
'(--fink)--fink[search the fink repository]' ;;
list|ls)
_arguments \ _arguments \
'(--unbrewed)--unbrewed[files in brew --prefix not controlled by brew]' \ '(--unbrewed)--unbrewed[files in brew --prefix not controlled by brew]' \
'(--versions)--versions[list all installed versions of a formula]' \
'1: :->forms' && return 0 '1: :->forms' && return 0


if [[ "$state" == forms ]]; then if [[ "$state" == forms ]]; then
_brew_installed_formulae _brew_installed_formulae
_requested installed_formulae expl 'installed formulae' compadd -a installed_formulae _wanted installed_formulae expl 'installed formulae' compadd -a installed_formulae
fi ;; fi ;;
install|home|log|info|uses|cat|deps) install|home|homepage|log|info|abv|uses|cat|deps|edit|options)
_brew_all_formulae _brew_all_formulae
_wanted formulae expl 'all formulae' compadd -a formulae ;; _wanted formulae expl 'all formulae' compadd -a formulae ;;
remove|edit|xo) remove|rm|uninstall|unlink|cleanup|link|ln)
_brew_installed_formulae _brew_installed_formulae
_wanted installed_formulae expl 'installed formulae' compadd -a installed_formulae ;; _wanted installed_formulae expl 'installed formulae' compadd -a installed_formulae ;;
esac esac

5 changes: 1 addition & 4 deletions plugins/brew/brew.plugin.zsh
@@ -1,4 +1 @@
# add brew completion function to path alias brews='brew list -1'
fpath=($ZSH/plugins/brew $fpath)
autoload -U compinit
compinit -i
3 changes: 3 additions & 0 deletions plugins/bundler/bundler.plugin.zsh
@@ -0,0 +1,3 @@
alias be="bundle exec"
alias bi="bundle install"
alias bu="bundle update"
2 changes: 1 addition & 1 deletion plugins/cap/cap.plugin.zsh
Expand Up @@ -18,4 +18,4 @@ function _cap () {
fi fi
} }


compctl -K _cap cap compctl -K _cap cap

0 comments on commit b17f997

Please sign in to comment.