Commit 0ba398f9 authored by James Smith's avatar James Smith
Browse files

Merge in recent stuff

parents a15a8c4a a738ca9b
...@@ -2,4 +2,7 @@ locals.zsh ...@@ -2,4 +2,7 @@ locals.zsh
log/.zsh_history log/.zsh_history
projects.zsh projects.zsh
custom/* custom/*
!custom/example.zsh !custom/example
\ No newline at end of file !custom/example.zsh
cache
*.swp
...@@ -8,7 +8,7 @@ h2. Setup ...@@ -8,7 +8,7 @@ h2. Setup
h3. The automatic installer... (do you trust me?) h3. The automatic installer... (do you trust me?)
@wget https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh -O - | sh@ @wget --no-check-certificate https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh -O - | sh@
h3. The manual way h3. The manual way
...@@ -48,22 +48,26 @@ the "refcard":http://www.bash2zsh.com/zsh_refcard/refcard.pdf is pretty tasty fo ...@@ -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.
\ No newline at end of file
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!
# Add your own custom plugins in the custom/plugins directory. Plugins placed
# here will override ones with the same name in the main plugins directory.
...@@ -22,4 +22,3 @@ alias sl=ls # often screw this up ...@@ -22,4 +22,3 @@ alias sl=ls # often screw this up
alias afind='ack-grep -il' alias afind='ack-grep -il'
alias x=extract
...@@ -4,14 +4,10 @@ unsetopt menu_complete # do not autoselect the first completion entry ...@@ -4,14 +4,10 @@ unsetopt menu_complete # do not autoselect the first completion entry
unsetopt flowcontrol unsetopt flowcontrol
setopt auto_menu # show completion menu on succesive tab press setopt auto_menu # show completion menu on succesive tab press
setopt complete_in_word setopt complete_in_word
setopt complete_aliases
setopt always_to_end setopt 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
......
autoload -U edit-command-line
zle -N edit-command-line
bindkey '\C-x\C-e' edit-command-line
...@@ -15,38 +15,3 @@ function take() { ...@@ -15,38 +15,3 @@ function take() {
cd $1 cd $1
} }
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 $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
}
...@@ -4,8 +4,8 @@ function git_prompt_info() { ...@@ -4,8 +4,8 @@ function git_prompt_info() {
echo "$ZSH_THEME_GIT_PROMPT_PREFIX${ref#refs/heads/}$(parse_git_dirty)$ZSH_THEME_GIT_PROMPT_SUFFIX" echo "$ZSH_THEME_GIT_PROMPT_PREFIX${ref#refs/heads/}$(parse_git_dirty)$ZSH_THEME_GIT_PROMPT_SUFFIX"
} }
# get dirty status of the current working tree # Checks if working tree is dirty
parse_git_dirty () { parse_git_dirty() {
if [[ -n $(git status -s 2> /dev/null) ]]; then if [[ -n $(git status -s 2> /dev/null) ]]; then
echo "$ZSH_THEME_GIT_PROMPT_DIRTY" echo "$ZSH_THEME_GIT_PROMPT_DIRTY"
else else
...@@ -33,7 +33,24 @@ git_remote_status() { ...@@ -33,7 +33,24 @@ git_remote_status() {
fi fi
} }
# get the status of the working tree # 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
}
# 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=""
...@@ -57,6 +74,8 @@ git_prompt_status() { ...@@ -57,6 +74,8 @@ git_prompt_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"
elif $(echo "$INDEX" | grep '^AD ' &> /dev/null); then
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
STATUS="$ZSH_THEME_GIT_PROMPT_UNMERGED$STATUS" STATUS="$ZSH_THEME_GIT_PROMPT_UNMERGED$STATUS"
......
# 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
...@@ -22,6 +20,12 @@ bindkey ' ' magic-space # also do history expansion on space ...@@ -22,6 +20,12 @@ 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 '^?' backward-delete-char
bindkey "^[[3~" delete-char
bindkey "^[3;5~" delete-char
bindkey "\e[3~" delete-char
# consider emacs keybindings: # consider emacs keybindings:
#bindkey -e ## emacs key bindings #bindkey -e ## emacs key bindings
......
...@@ -10,4 +10,4 @@ setopt long_list_jobs ...@@ -10,4 +10,4 @@ setopt long_list_jobs
## pager ## pager
export PAGER=less export PAGER=less
export LC_CTYPE=en_US.UTF-8 export LC_CTYPE=$LANG
...@@ -18,3 +18,11 @@ for color in {000..255}; do ...@@ -18,3 +18,11 @@ for color in {000..255}; do
FG[$color]="%{[38;5;${color}m%}" FG[$color]="%{[38;5;${color}m%}"
BG[$color]="%{[48;5;${color}m%}" BG[$color]="%{[48;5;${color}m%}"
done done
# Show all 256 colors with color number
function spectrum_ls() {
for code in {000..255}; do
print -P -- "$code: %F{$code}Test%f"
done
}
...@@ -3,11 +3,12 @@ ...@@ -3,11 +3,12 @@
#Fully support screen, iterm, and probably most modern xterm and rxvt #Fully support screen, iterm, and probably most modern xterm and rxvt
#Limited support for Apple Terminal (Terminal can't set window or tab separately) #Limited support for Apple Terminal (Terminal can't set window or tab separately)
function title { function title {
if [[ "$TERM" == "screen" ]]; then [ "$DISABLE_AUTO_TITLE" != "true" ] || return
print -Pn "\ek$1\e\\" #set screen hardstatus, usually truncated at 20 chars if [[ "$TERM" == screen* ]]; then
elif [[ ($TERM =~ "^xterm") ]] || [[ ($TERM == "rxvt") ]] || [[ "$TERM_PROGRAM" == "iTerm.app" ]]; then print -Pn "\ek$1:q\e\\" #set screen hardstatus, usually truncated at 20 chars
print -Pn "\e]2;$2\a" #set window name elif [[ "$TERM" == xterm* ]] || [[ $TERM == rxvt* ]] || [[ "$TERM_PROGRAM" == "iTerm.app" ]]; then
print -Pn "\e]1;$1\a" #set icon (=tab) name (will override window name on broken terminal) 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 fi
} }
...@@ -21,6 +22,8 @@ function precmd { ...@@ -21,6 +22,8 @@ function precmd {
#Appears at the beginning of (and during) of command execution #Appears at the beginning of (and during) of command execution
function preexec { 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 local CMD=${1[(wr)^(*=*|sudo|ssh|-*)]} #cmd name only, or if this is sudo or ssh, the next cmd
title "$CMD" "%100>...>$2%<<" title "$CMD" "%100>...>$2%<<"
} }
# Check for updates on initial load...
if [ "$DISABLE_AUTO_UPDATE" != "true" ]
then
/usr/bin/env zsh $ZSH/tools/check_for_upgrade.sh
fi
# 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
# Load all of your custom configurations from custom/ # Add all defined plugins to fpath
for config_file ($ZSH/custom/*.zsh) source $config_file 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 # Load all of the plugins that were defined in ~/.zshrc
plugin=${plugin:=()} for plugin ($plugins); do
for plugin ($plugins) source $ZSH/plugins/$plugin/$plugin.plugin.zsh 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 the theme # Load all of your custom configurations from custom/
source "$ZSH/themes/$ZSH_THEME.zsh-theme" for config_file ($ZSH/custom/*.zsh) source $config_file
# Check for updates on initial load... # Load the theme
if [ "$DISABLE_AUTO_UPDATE" = "true" ] if [ "$ZSH_THEME" = "random" ]
then then
return 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 else
/usr/bin/env zsh $ZSH/tools/check_for_upgrade.sh if [ ! "$ZSH_THEME" = "" ]
then
source "$ZSH/themes/$ZSH_THEME.zsh-theme"
fi
fi fi
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
# 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'
# Archlinux zsh aliases and functions
# Usage is also described at https://github.com/robbyrussell/oh-my-zsh/wiki/Plugins
# Look for yaourt, and add some useful functions if we have it.
if [[ -x `which yaourt` ]]; then
upgrade () {
yaourt -Syu
}
alias yaconf='yaourt -C' # Fix all configuration files with vimdiff
# Pacman - https://wiki.archlinux.org/index.php/Pacman_Tips
alias yaupg='yaourt -Syu' # Synchronize with repositories before upgrading packages that are out of date on the local system.
alias yain='yaourt -S' # Install specific package(s) from the repositories
alias yains='yaourt -U' # Install specific package not from the repositories but from a file
alias yare='yaourt -R' # Remove the specified package(s), retaining its configuration(s) and required dependencies
alias yarem='yaourt -Rns' # Remove the specified package(s), its configuration(s) and unneeded dependencies
alias yarep='yaourt -Si' # Display information about a given package in the repositories
alias yareps='yaourt -Ss' # Search for package(s) in the repositories
alias yaloc='yaourt -Qi' # Display information about a given package in the local database
alias yalocs='yaourt -Qs' # Search for package(s) in the local database
# Additional yaourt alias examples
if [[ -x `which abs` ]]; then
alias yaupd='yaourt -Sy && sudo abs' # Update and refresh the local package and ABS databases against repositories
else
alias yaupd='yaourt -Sy' # Update and refresh the local package and ABS databases against repositories
fi
alias yainsd='yaourt -S --asdeps' # Install given package(s) as dependencies of another package
alias yamir='yaourt -Syy' # Force refresh of all package lists after updating /etc/pacman.d/mirrorlist
else
upgrade() {
sudo pacman -Syu
}
fi
# Pacman - https://wiki.archlinux.org/index.php/Pacman_Tips
alias pacupg='sudo pacman -Syu' # Synchronize with repositories before upgrading packages that are out of date on the local system.
alias pacin='sudo pacman -S' # Install specific package(s) from the repositories
alias pacins='sudo pacman -U' # Install specific package not from the repositories but from a file
alias pacre='sudo pacman -R' # Remove the specified package(s), retaining its configuration(s) and required dependencies
alias pacrem='sudo pacman -Rns' # Remove the specified package(s), its configuration(s) and unneeded dependencies
alias pacrep='pacman -Si' # Display information about a given package in the repositories
alias pacreps='pacman -Ss' # Search for package(s) in the repositories
alias pacloc='pacman -Qi' # Display information about a given package in the local database
alias paclocs='pacman -Qs' # Search for package(s) in the local database
# Additional pacman alias examples
if [[ -x `which abs` ]]; then
alias pacupd='sudo pacman -Sy && sudo abs' # Update and refresh the local package and ABS databases against repositories
else
alias pacupd='sudo pacman -Sy' # Update and refresh the local package and ABS databases against repositories
fi
alias pacinsd='sudo pacman -S --asdeps' # Install given package(s) as dependencies of another package
alias pacmir='sudo pacman -Syy' # Force refresh of all package lists after updating /etc/pacman.d/mirrorlist
# https://bbs.archlinux.org/viewtopic.php?id=93683
paclist() {
sudo pacman -Qei $(pacman -Qu|cut -d" " -f 1)|awk ' BEGIN {FS=":"}/^Name/{printf("\033[1;36m%s\033[1;37m", $2)}/^Description/{print $2}'
}
alias paclsorphans='sudo pacman -Qdt'
alias pacrmorphans='sudo pacman -Rs $(pacman -Qtdq)'
pacdisowned() {
tmp=${TMPDIR-/tmp}/pacman-disowned-$UID-$$
db=$tmp/db
fs=$tmp/fs
mkdir "$tmp"
trap 'rm -rf "$tmp"' EXIT
pacman -Qlq | sort -u > "$db"
find /bin /etc /lib /sbin /usr \
! -name lost+found \
\( -type d -printf '%p/\n' -o -print \) | sort > "$fs"
comm -23 "$fs" "$db"
}
if [ -f `brew --prefix`/etc/autojump ]; then
. `brew --prefix`/etc/autojump
fi
...@@ -25,20 +25,27 @@ _1st_arguments=( ...@@ -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]' \
...@@ -50,20 +57,24 @@ if (( CURRENT == 1 )); then ...@@ -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
# add brew completion function to path alias brews='brew list -1'
fpath=($ZSH/plugins/brew $fpath)
autoload -U compinit
compinit -i
alias be="bundle exec" alias be="bundle exec"
alias bi="bundle install" alias bi="bundle install"
alias bl="bundle list"
alias bu="bundle update" alias bu="bundle update"
alias bp="bundle package"
# The following is based on https://github.com/gma/bundler-exec
bundled_commands=(cap capify cucumber heroku rackup rails rake rspec ruby shotgun spec spork thin unicorn unicorn_rails)
## Functions
_bundler-installed() {
which bundle > /dev/null 2>&1
}
_within-bundled-project() {
local check_dir=$PWD
while [ "$(dirname $check_dir)" != "/" ]; do
[ -f "$check_dir/Gemfile" ] && return
check_dir="$(dirname $check_dir)"
done
false
}
_run-with-bundler() {
if _bundler-installed && _within-bundled-project; then
bundle exec $@
else
$@
fi
}
## Main program
for cmd in $bundled_commands; do
alias $cmd="_run-with-bundler $cmd"
done
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment