Merge remote-tracking branch 'robbyrussell/master'

This commit is contained in:
yleo77 2013-09-19 12:40:45 +08:00
commit 0240ac6496
8 changed files with 106 additions and 20 deletions

View File

@ -1,3 +1,5 @@
!https://s3.amazonaws.com/ohmyzsh/oh-my-zsh-logo.png!
oh-my-zsh is an open source, community-driven framework for managing your ZSH configuration. It comes bundled with a ton of helpful functions, helpers, plugins, themes, and few things that make you shout...
bq. "OH MY ZSHELL!"

View File

@ -38,10 +38,20 @@ for plugin ($plugins); do
fi
done
# Figure out the SHORT hostname
if [ -n "$commands[scutil]" ]; then
# OS X
SHORT_HOST=$(scutil --get ComputerName)
else
SHORT_HOST=${HOST/.*/}
fi
# Save the location of the current completion dump file.
ZSH_COMPDUMP="${ZDOTDIR:-${HOME}}/.zcompdump-${SHORT_HOST}-${ZSH_VERSION}"
# Load and run compinit
autoload -U compinit
compinit -i
compinit -i -d "${ZSH_COMPDUMP}"
# Load all of the plugins that were defined in ~/.zshrc
for plugin ($plugins); do

View File

@ -28,6 +28,7 @@ _1st_arguments=(
'missing:check all installed formuale for missing dependencies.'
'outdated:list formulas for which a newer version is available'
'prune:remove dead links'
'reinstall:reinstall a formula'
'remove:remove a formula'
'search:search for a formula (/regex/ or string)'
'server:start a local web app that lets you browse formulae (requires Sinatra)'
@ -75,7 +76,7 @@ case "$words[1]" in
install|home|homepage|log|info|abv|uses|cat|deps|edit|options|versions)
_brew_all_formulae
_wanted formulae expl 'all formulae' compadd -a formulae ;;
remove|rm|uninstall|unlink|cleanup|link|ln)
reinstall|remove|rm|uninstall|unlink|cleanup|link|ln)
_brew_installed_formulae
_wanted installed_formulae expl 'installed formulae' compadd -a installed_formulae ;;
esac

View File

@ -1,10 +1,17 @@
alias be="bundle exec"
alias bi="bundle install"
alias bl="bundle list"
alias bp="bundle package"
alias bo="bundle open"
alias bu="bundle update"
if [[ "$(uname)" == 'Darwin' ]]
then
local cores_num="$(sysctl hw.ncpu | awk '{print $2}')"
else
local cores_num="$(nproc)"
fi
eval "alias bi='bundle install --jobs=$cores_num'"
# The following is based on https://github.com/gma/bundler-exec
bundled_commands=(annotate berks cap capify cucumber foodcritic foreman guard jekyll kitchen knife middleman nanoc rackup rainbows rake rspec ruby shotgun spec spin spork strainer tailor thin thor unicorn unicorn_rails puma)
@ -42,3 +49,4 @@ for cmd in $bundled_commands; do
compdef _$cmd bundled_$cmd=$cmd
fi
done

View File

@ -0,0 +1,52 @@
# Easily jump around the file system by manually adding marks
# marks are stored as symbolic links in the directory $MARKPATH (default $HOME/.marks)
#
# jump FOO: jump to a mark named FOO
# mark FOO: create a mark named FOO
# unmark FOO: delete a mark
# marks: lists all marks
#
export MARKPATH=$HOME/.marks
jump() {
cd -P "$MARKPATH/$1" 2>/dev/null || echo "No such mark: $1"
}
mark() {
if (( $# == 0 )); then
MARK=$(basename "$(pwd)")
else
MARK="$1"
fi
if read -q \?"Mark $(pwd) as ${MARK}? (y/n) "; then
mkdir -p "$MARKPATH"; ln -s "$(pwd)" "$MARKPATH/$MARK"
fi
}
unmark() {
rm -i "$MARKPATH/$1"
}
autoload colors
marks() {
for link in $MARKPATH/*(@); do
local markname="$fg[cyan]${link:t}$reset_color"
local markpath="$fg[blue]$(readlink $link)$reset_color"
printf "%s\t" $markname
printf "-> %s \t\n" $markpath
done
}
_completemarks() {
reply=($(ls $MARKPATH/**/*(-) | grep : | sed -E 's/(.*)\/([_\da-zA-Z\-]*):$/\2/g'))
}
compctl -K _completemarks jump
compctl -K _completemarks unmark
_mark_expansion() {
setopt extendedglob
autoload -U modify-current-argument
modify-current-argument '$(readlink "$MARKPATH/$ARG")'
}
zle -N _mark_expansion
bindkey "^g" _mark_expansion

View File

@ -38,7 +38,7 @@ if which tmux &> /dev/null
fi
# Set the correct local config file to use.
if [[ "$ZSH_TMUX_ITERM2" == "false" ]] && (( [[ -f $HOME/.tmux.conf ]] || -h $HOME/.tmux.conf ]] ))
if [[ "$ZSH_TMUX_ITERM2" == "false" ]] && [[ -f $HOME/.tmux.conf || -h $HOME/.tmux.conf ]]
then
#use this when they have a ~/.tmux.conf
export _ZSH_TMUX_FIXED_CONFIG="$zsh_tmux_plugin_path/tmux.extra.conf"

View File

@ -11,7 +11,7 @@ function web_search() {
fi
# check whether the search engine is supported
if [[ ! $1 =~ '(google|bing|yahoo)' ]];
if [[ ! $1 =~ '(google|bing|yahoo|duckduckgo)' ]];
then
echo "Search engine $1 not supported."
return 1
@ -24,8 +24,12 @@ function web_search() {
$open_cmd "$url"
return
fi
url="${url}/search?q="
if [[ $1 == 'duckduckgo' ]]; then
#slightly different search syntax for DDG
url="${url}/?q="
else
url="${url}/search?q="
fi
shift # shift out $1
while [[ $# -gt 0 ]]; do
@ -34,10 +38,19 @@ function web_search() {
done
url="${url%?}" # remove the last '+'
$open_cmd "$url"
}
alias bing='web_search bing'
alias google='web_search google'
alias yahoo='web_search yahoo'
alias ddg='web_search duckduckgo'
#add your own !bang searches here
alias wiki='web_search duckduckgo \!w'
alias news='web_search duckduckgo \!n'
alias youtube='web_search duckduckgo \!yt'
alias map='web_search duckduckgo \!m'
alias image='web_search duckduckgo \!i'
alias ducky='web_search duckduckgo \!'

View File

@ -5,16 +5,15 @@
#-------------------------------------------------------------------------------
# Color shortcuts
R=$fg[red]
G=$fg[green]
M=$fg[magenta]
RB=$fg_bold[red]
YB=$fg_bold[yellow]
BB=$fg_bold[blue]
R=$fg_no_bold[red]
G=$fg_no_bold[green]
M=$fg_no_bold[magenta]
Y=$fg_no_bold[yellow]
B=$fg_no_bold[blue]
RESET=$reset_color
if [ "$(whoami)" = "root" ]; then
PROMPTCOLOR="%{$RB%}" PREFIX="-!-";
PROMPTCOLOR="%{$R%}" PREFIX="-!-";
else
PROMPTCOLOR="" PREFIX="---";
fi
@ -73,13 +72,14 @@ function custom_git_prompt() {
PROMPT='%B$PREFIX %2~ $(custom_git_prompt)%{$M%}%B»%b%{$RESET%} '
RPS1="${return_code}"
ZSH_THEME_GIT_PROMPT_PREFIX="%{$YB%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$YB%}%{$RESET%} "
ZSH_THEME_GIT_PROMPT_PREFIX="%{$Y%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$Y%}%{$RESET%} "
ZSH_THEME_GIT_PROMPT_DIRTY="%{$R%}*"
ZSH_THEME_GIT_PROMPT_CLEAN=""
ZSH_THEME_GIT_PROMPT_AHEAD="%{$BB%}➔"
ZSH_THEME_GIT_PROMPT_AHEAD="%{$B%}➔"
ZSH_THEME_GIT_STATUS_PREFIX=" "
@ -90,7 +90,7 @@ ZSH_THEME_GIT_PROMPT_STAGED_RENAMED="%{$G%}R"
ZSH_THEME_GIT_PROMPT_STAGED_DELETED="%{$G%}D"
# Not-staged
ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$R%}"
ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$R%}?"
ZSH_THEME_GIT_PROMPT_MODIFIED="%{$R%}M"
ZSH_THEME_GIT_PROMPT_DELETED="%{$R%}D"
ZSH_THEME_GIT_PROMPT_UNMERGED="%{$R%}UU"