Commit 67b2781f authored by yleo77's avatar yleo77
Browse files

Merge remote-tracking branch 'robbyrussell/master'

parents 6b832b93 7f74294d
...@@ -10,6 +10,8 @@ alias migrate='rake db:migrate && rake db:test:prepare' ...@@ -10,6 +10,8 @@ alias migrate='rake db:migrate && rake db:test:prepare'
alias sc='ruby script/console' alias sc='ruby script/console'
alias sd='ruby script/server --debugger' alias sd='ruby script/server --debugger'
alias devlog='tail -f log/development.log' alias devlog='tail -f log/development.log'
alias testlog='tail -f log/test.log'
alias prodlog='tail -f log/production.log'
alias -g RET='RAILS_ENV=test' alias -g RET='RAILS_ENV=test'
alias -g REP='RAILS_ENV=production' alias -g REP='RAILS_ENV=production'
alias -g RED='RAILS_ENV=development' alias -g RED='RAILS_ENV=development'
......
#compdef rails
#autoload
# rails 3 zsh completion, based on homebrew completion
# Extracted from https://github.com/robbyrussell/oh-my-zsh/blob/30620d463850c17f86e7a56fbf6a8b5e793a4e07/plugins/rails3/_rails3
# Published by Christopher Chow
local -a _1st_arguments
_1st_arguments=(
'generate:Generate new code (short-cut alias: "g")'
'console:Start the Rails console (short-cut alias: "c")'
'server:Start the Rails server (short-cut alias: "s")'
'dbconsole:Start a console for the database specified in config/database.yml (short-cut alias: "db")'
'new:Create a new Rails application. "rails new my_app" creates a new application called MyApp in "./my_app"'
'application:Generate the Rails application code'
'destroy:Undo code generated with "generate"'
'benchmarker:See how fast a piece of code runs'
'profiler:Get profile information from a piece of code'
'plugin:Install a plugin'
)
_rails_generate_arguments() {
generate_arguments=(
controller
generator
helper
integration_test
mailer
migration
model
observer
performance_test
plugin
resource
scaffold
scaffold_controller
session_migration
stylesheets
)
}
_arguments \
'(--version)--version[show version]' \
'(--help)--help[show help]' \
'*:: :->subcmds' && return 0
if (( CURRENT == 1 )); then
_describe -t commands "rails subcommand" _1st_arguments
return
fi
case "$words[1]" in
generate)
_rails_generate_arguments
_wanted generate_arguments expl 'all generate' compadd -a generate_arguments ;;
esac
...@@ -19,6 +19,8 @@ alias ru='_rails_command runner' ...@@ -19,6 +19,8 @@ alias ru='_rails_command runner'
alias rs='_rails_command server' alias rs='_rails_command server'
alias rsd='_rails_command server --debugger' alias rsd='_rails_command server --debugger'
alias devlog='tail -f log/development.log' alias devlog='tail -f log/development.log'
alias testlog='tail -f log/test.log'
alias prodlog='tail -f log/production.log'
alias rdm='rake db:migrate' alias rdm='rake db:migrate'
alias rdr='rake db:rollback' alias rdr='rake db:rollback'
alias -g RET='RAILS_ENV=test' alias -g RET='RAILS_ENV=test'
......
...@@ -21,6 +21,8 @@ alias ru='_rails_command runner' ...@@ -21,6 +21,8 @@ alias ru='_rails_command runner'
alias rs='_rails_command server' alias rs='_rails_command server'
alias rsd='_rails_command server --debugger' alias rsd='_rails_command server --debugger'
alias devlog='tail -f log/development.log' alias devlog='tail -f log/development.log'
alias testlog='tail -f log/test.log'
alias prodlog='tail -f log/production.log'
alias rdm='rake db:migrate' alias rdm='rake db:migrate'
alias rdc='rake db:create' alias rdc='rake db:create'
alias rdr='rake db:rollback' alias rdr='rake db:rollback'
......
# Get a random quote fron the site http://www.quotationspage.com/random.php3
# Created by Eduardo San Martin Morote aka Posva
# http://posva.github.io
# Sun Jun 09 10:59:36 CEST 2013
# Don't remove this header, thank you
# Usage: quote
if [[ -x `which curl` ]]; then
function quote()
{
Q=$(curl -s --connect-timeout 2 "http://www.quotationspage.com/random.php3" | grep -m 1 "dt ")
TXT=$(echo "$Q" | sed -e 's/<\/dt>.*//g' -e 's/.*html//g' -e 's/^[^a-zA-Z]*//' -e 's/<\/a..*$//g')
W=$(echo "$Q" | sed -e 's/.*\/quotes\///g' -e 's/<.*//g' -e 's/.*">//g')
echo "\e[0;33m${W}\e[0;30m: \e[0;35m“${TXT}\e[m"
}
#quote
fi
## repo
**Maintainer:** [Stibbons](https://github.com/Stibbons)
This plugin mainly add support automatic completion for the repo command line tool:
http://code.google.com/p/git-repo/
* `r` aliases `repo`
#compdef repo
__git_apply_whitespace_strategies ()
{
declare -a strategies
strategies=(
'nowarn:turn off the trailing-whitespace warning'
'warn:output trailing-whitespace warning, but apply patch'
'fix:output trailing-whitespace warning and strip trailing whitespace'
'error:output trailing-whitespace warning and refuse to apply patch'
'error-all:same as "error", but output warnings for all files')
_describe -t strategies 'trailing-whitespace resolution strategy' strategies $*
}
_repo()
{
local context state state_descr line curcontext="$curcontext"
typeset -A opt_args
local ret=1
_arguments -C \
'(- 1 *)--help[show usage]'\
'1:command:->command'\
'*::args:->args' && ret=0
case $state in
(command)
repo list 2> /dev/null > /dev/null
if [[ $? == 0 ]]; then
local commands;
commands=(
'abandon:Permanently abandon a development branch'
'branch:View current topic branches'
'branches:View current topic branches'
'checkout:Checkout a branch for development'
'cherry-pick:Cherry-pick a change.'
'diff:Show changes between commit and working tree'
'download:Download and checkout a change'
'forall:execute command on several project'
'grep:Print lines matching a pattern'
'help:Display detailed help on a command'
'init:Initialize repo in the current directory'
'list:List projects and their associated directories'
'manifest:Manifest inspection utility'
'overview:Display overview of unmerged project branches'
'prune:Prune (delete) already merged topics'
'rebase:Rebase local branches on upstream branch'
'selfupdate:Update repo to the latest version'
'smartsync:Update working tree to the latest known good revision'
'stage:Stage file(s) for commit'
'start:Start a new branch for development'
'status:Show the working tree status'
'sync:Update working tree to the latest revision'
'upload:Upload changes for code review'
'version:Display the version of repo'
)
_describe -t commands 'command' commands && ret=0
else
local commands;
commands=(
'init:Install repo in the current working directory'
'help:Display detailed help on a command'
)
_describe -t commands 'command' commands && ret=0
fi
;;
(args)
case $words[1] in
(branch | branches)
# TODO : list available projects and add them in list to feed compadd with
_arguments : \
"(-h --help)"{-h,--help}"[Show help]" \
': :__repo_projects' \
&& ret=0
;;
(abandon)
# TODO : list available projects and add them in list to feed compadd with
_arguments : \
"(-h --help)"{-h,--help}"[Show help]" \
':branch name:__repo_branch' \
': :__repo_projects'\
&& ret=0
;;
(checkout)
# TODO : list available projects and add them in list to feed compadd with
_arguments : \
"(-h --help)"{-h,--help}"[Show help]" \
':branch name:__repo_branch' \
': :__repo_projects'\
&& ret=0
;;
(init)
_arguments : \
"(-h --help)"{-h,--help}"[Show help]" \
"(-q --quiet)"{-q,--quiet}"[be quiet]" \
"(-u --manifest-url)"{-u,--manifest-url=}"[manifest repository location]":url:__repo_url_prompt \
"(-b --manifest-branch)"{-b,--manifest-branch=}"[manifest branch or revision]":branch:__repo_branch\
"(-m --manifest-name)"{-m,--manifest-name=}"[initial manifest file]":manifest_name:__repo_manifest_name\
"(--mirror)--mirror[mirror the forrest]"\
"(--reference)--reference=[location of mirror directory]":dir:_dirs\
"(--depth)--depth=[create a shallow clone with given depth; see git clone]":depth:__repo_depth_prompt\
"(-g --group=)"{-g,--group=}"[restrict manifest projects to ones with a specified group]":group:_group\
"(-p --platform=)"{-p,--platform=}"[restrict manifest projects to ones with a specified platform group(auto|all|none|linux|darwin|...)]":platform:"(auto all none linux darwin)"\
"(--repo-url)--repo-url=[repo repository location]":url:__repo_url_prompt\
"(--repo-branch)--repo-branch[repo branch or revision]":branch_or_rev:__repo__repo_branch_or_rev\
"(--no-repo-verify)--no-repo-verify[do not verify repo source code]"\
"(--config-name)--config-name[Always prompt for name/e-mail]"\
&& ret=0
;;
(start)
_arguments : \
"(-h --help)"{-h,--help}"[Show help]" \
"(--all)--all=[begin branch in all projects]"\
':branch name:__repo_new__repo_branch_name' \
':projects:__repo_projects_or_all' \
&& ret=0
;;
(rebase)
_arguments : \
"(-h --help)"{-h,--help}"[Show help]" \
"(-i --interactive)"{-i,--interactive}"[interactive rebase (single project only)]: :__repo_projects" \
"(-f --force-rebase)"{-f,--force-rebase}"[Pass --force-rebase to git rebase]" \
"(--no-ff)--no-ff=[Pass --no-ff to git rebase]"\
"(-q --quiet)"{-q,--quiet}"[Pass --quiet to git rebase]" \
"(--autosquash)--no-ff[Pass --autosquash to git rebase]"\
"(--whitespace=)--whitespace=[Pass --whitespace to git rebase]: :__git_apply_whitespace_strategies"\
"(--auto-stash)--auto-stash[Stash local modifications before starting]"\
&& ret=0
;;
(checkout)
_arguments : \
"(-h --help)"{-h,--help}"[Show help]" \
':branch name:__git_branch_names' \
':projects:__repo_projects' \
&& ret=0
;;
(list)
_arguments : \
"(-h --help)"{-h,--help}"[Show help]" \
&& ret=0
;;
(status)
_arguments : \
"(-h --help)"{-h,--help}"[Show help]" \
"(-j --jobs)"{-j,--jobs}"[number of projects to check simultaneously]" \
':projects:__repo_projects' \
&& ret=0
;;
(sync)
_arguments : \
"(-h --help)"{-h,--help}"[Show help]" \
"(--no-force-broken)--no-force-broken[stop sync if a project fails to sync (probably because of permissions)]" \
"(-l --local-only)"{-l,--local-only}"[only update working tree, don't fetch]" \
"(-n --network-only)"{-n,--network-branch}"[fetch only, don't update working tree]" \
"(-d --detach)"{-d,--detach}"[detach projects back to manifest revision]" \
"(-c --current-branch)"{-c,--current-branch}"[fetch only current branch from server]" \
"(-q --quiet)"{-q,--quiet}"[be more quiet]" \
"(-j --jobs=)"{-j,--jobs=}"[projects to fetch simultaneously (default 1) (limited to 5)]:projects to fetch simultaneously (default 1) (limited to 5)" \
"(-m --manifest-name=)"{-m,--manifest-name=}"[temporary manifest to use for this sync]:manifest xml file:_files -g *.xml" \
"(--no-clone-bundle)--no-clone-bundle[disable use of /clone.bundle on HTTP/HTTPS]" \
"(-s --smart-sync)"{-s,--smart-sync=}"[smart sync using manifest from a known tag]:tag:" \
'(--no-repo-verify)--no-repo-verify[do not verify repo source code]' \
': :__repo_projects' \
&& ret=0
;;
(upload)
_arguments : \
"(-h --help)"{-h,--help}"[Show help]" \
"(-t)-t[Send local branch name to Gerrit Code Review]" \
"(--re= --reviewers=)"{--re=,--reviewers=}"[Request reviews from these people]:Request reviews from these people:" \
"(--cc=)--cc=[Also send email to these email addresses.]:email addresses:_email_addresses" \
"(--br=)--br=[Branch to upload.]:branch:__repo_branch" \
"(--cbr --current-branch)"{--cbr,--current-branch}"[Upload current git branch]" \
"(-d --draft)"{-d,--draft}"[If specified, upload as a draft.]" \
"(--verify --no-verify)--no-verify[Do not run the upload hook.]" \
'(--verify --no-verify)--verify[Run the upload hook without prompting]' \
': :__repo_projects' \
&& ret=0
;;
(forall)
_arguments : \
"(-h --help)"{-h,--help}"[Show help]" \
"(-v --verbose)"{-v,--verbose}"[Show command error messages]" \
'(-p)-p[Show project headers before output]' \
': :__repo_projects_mandatory' \
"(-c --command -h --help -v --verbose -p)"{-c,--command}"[Command (and arguments) to execute]" \
&& ret=0
;;
*)
ret=0
esac
;;
esac
return $ret
}
__repo_reviewers()
{
# _message -e url 'reviewers'
}
__repo_url_prompt()
{
_message -e url 'url'
}
__repo_manifest_name()
{
_message -e manifest_name 'manifest name'
}
_group()
{
_message -e group 'group'
}
__repo_branch()
{
#_message -e branch 'Repo branch'
branches=($(repo branches| cut -c4- | grep '|' | cut -d' ' -f1))
_describe -t branches 'Select repo branch' branches
}
__repo__repo_branch_or_rev()
{
_message -e branch_or_rev 'repo branch or revision'
}
__repo_depth_prompt()
{
_message -e depth 'depth'
}
__repo_projects()
{
_message -e depth 'Optional option : <projects>...'
projects=($(repo list | cut -d' ' -f1))
_describe -t projects 'Select projects (keep empty for selecting all projects)' projects
}
__repo_projects_mandatory()
{
projects=($(repo list | cut -d' ' -f1))
#_describe -t projects 'Select projects to apply commands' projects
_values -s ' ' "Select projects to apply commands" $projects
}
__repo_new__repo_branch_name()
{
branches=($(repo branches| cut -c4- | grep '|' | cut -d' ' -f1))
_describe "" branches
_message -e "branch name" 'Enter new branch name or select an existing repo branch'
}
__repo_projects_or_all()
{
#_message -e depth '[--all | <project>...]'
projects=(--all $(repo list | cut -d' ' -f1))
_describe -t projects 'Select projects or --all' projects
_describe -t --all 'All projects'
}
_repo "$@"
return $?
# Aliases
alias r='repo'
...@@ -3,9 +3,9 @@ fpath=($rvm_path/scripts/zsh/Completion $fpath) ...@@ -3,9 +3,9 @@ fpath=($rvm_path/scripts/zsh/Completion $fpath)
alias rubies='rvm list rubies' alias rubies='rvm list rubies'
alias gemsets='rvm gemset list' alias gemsets='rvm gemset list'
local ruby18='ruby-1.8.7-p371' local ruby18='ruby-1.8.7'
local ruby19='ruby-1.9.3-p392' local ruby19='ruby-1.9.3'
local ruby20='ruby-2.0.0-p0' local ruby20='ruby-2.0.0'
function rb18 { function rb18 {
if [ -z "$1" ]; then if [ -z "$1" ]; then
...@@ -42,7 +42,6 @@ compdef _rb20 rb20 ...@@ -42,7 +42,6 @@ compdef _rb20 rb20
function rvm-update { function rvm-update {
rvm get head rvm get head
rvm reload # TODO: Reload rvm completion?
} }
# TODO: Make this usable w/o rvm. # TODO: Make this usable w/o rvm.
......
...@@ -14,6 +14,8 @@ if which tmux &> /dev/null ...@@ -14,6 +14,8 @@ if which tmux &> /dev/null
[[ -n "$ZSH_TMUX_AUTOQUIT" ]] || ZSH_TMUX_AUTOQUIT=$ZSH_TMUX_AUTOSTART [[ -n "$ZSH_TMUX_AUTOQUIT" ]] || ZSH_TMUX_AUTOQUIT=$ZSH_TMUX_AUTOSTART
# Set term to screen or screen-256color based on current terminal support # Set term to screen or screen-256color based on current terminal support
[[ -n "$ZSH_TMUX_FIXTERM" ]] || ZSH_TMUX_FIXTERM=true [[ -n "$ZSH_TMUX_FIXTERM" ]] || ZSH_TMUX_FIXTERM=true
# Set '-CC' option for iTerm2 tmux integration
[[ -n "$ZSH_TMUX_ITERM2" ]] || ZSH_TMUX_ITERM2=false
# The TERM to use for non-256 color terminals. # The TERM to use for non-256 color terminals.
# Tmux states this should be screen, but you may need to change it on # Tmux states this should be screen, but you may need to change it on
# systems without the proper terminfo # systems without the proper terminfo
...@@ -36,7 +38,7 @@ if which tmux &> /dev/null ...@@ -36,7 +38,7 @@ if which tmux &> /dev/null
fi fi
# Set the correct local config file to use. # Set the correct local config file to use.
if [[ -f $HOME/.tmux.conf || -h $HOME/.tmux.conf ]] if [[ "$ZSH_TMUX_ITERM2" == "false" ]] && (( [[ -f $HOME/.tmux.conf ]] || -h $HOME/.tmux.conf ]] ))
then then
#use this when they have a ~/.tmux.conf #use this when they have a ~/.tmux.conf
export _ZSH_TMUX_FIXED_CONFIG="$zsh_tmux_plugin_path/tmux.extra.conf" export _ZSH_TMUX_FIXED_CONFIG="$zsh_tmux_plugin_path/tmux.extra.conf"
...@@ -55,11 +57,11 @@ if which tmux &> /dev/null ...@@ -55,11 +57,11 @@ if which tmux &> /dev/null
# Try to connect to an existing session. # Try to connect to an existing session.
elif [[ "$ZSH_TMUX_AUTOCONNECT" == "true" ]] elif [[ "$ZSH_TMUX_AUTOCONNECT" == "true" ]]
then then
\tmux attach || \tmux `[[ "$ZSH_TMUX_FIXTERM" == "true" ]] && echo '-f '$_ZSH_TMUX_FIXED_CONFIG` new-session \tmux `[[ "$ZSH_TMUX_ITERM2" == "true" ]] && echo '-CC '` attach || \tmux `[[ "$ZSH_TMUX_ITERM2" == "true" ]] && echo '-CC '` `[[ "$ZSH_TMUX_FIXTERM" == "true" ]] && echo '-f '$_ZSH_TMUX_FIXED_CONFIG` new-session
[[ "$ZSH_TMUX_AUTOQUIT" == "true" ]] && exit [[ "$ZSH_TMUX_AUTOQUIT" == "true" ]] && exit
# Just run tmux, fixing the TERM variable if requested. # Just run tmux, fixing the TERM variable if requested.
else else
\tmux `[[ "$ZSH_TMUX_FIXTERM" == "true" ]] && echo '-f '$_ZSH_TMUX_FIXED_CONFIG` \tmux `[[ "$ZSH_TMUX_ITERM2" == "true" ]] && echo '-CC '` `[[ "$ZSH_TMUX_FIXTERM" == "true" ]] && echo '-f '$_ZSH_TMUX_FIXED_CONFIG`
[[ "$ZSH_TMUX_AUTOQUIT" == "true" ]] && exit [[ "$ZSH_TMUX_AUTOQUIT" == "true" ]] && exit
fi fi
} }
......
function virtualenv_prompt_info(){ function virtualenv_prompt_info(){
local virtualenv_path="$VIRTUAL_ENV" if [[ -n $VIRTUAL_ENV ]]; then
if [[ -n $virtualenv_path ]]; then printf "%s[%s] " "%{${fg[yellow]}%}" ${${VIRTUAL_ENV}:t}
local virtualenv_name=`basename $virtualenv_path`
printf "%s[%s] " "%{${fg[yellow]}%}" $virtualenv_name
fi fi
} }
# disables prompt mangling in virtual_env/bin/activate
export VIRTUAL_ENV_DISABLE_PROMPT=1 export VIRTUAL_ENV_DISABLE_PROMPT=1
wrapsource=`which virtualenvwrapper_lazy.sh` virtualenvwrapper='virtualenvwrapper_lazy.sh'
if (( $+commands[$virtualenvwrapper] )); then
if [[ -f "$wrapsource" ]]; then source ${${virtualenvwrapper}:c}
source $wrapsource
if [[ ! $DISABLE_VENV_CD -eq 1 ]]; then if [[ ! $DISABLE_VENV_CD -eq 1 ]]; then
# Automatically activate Git projects' virtual environments based on the # Automatically activate Git projects's virtual environments based on the
# directory name of the project. Virtual environment name can be overridden # directory name of the project. Virtual environment name can be overridden
# by placing a .venv file in the project root with a virtualenv name in it # by placing a .venv file in the project root with a virtualenv name in it
function workon_cwd { function workon_cwd {
# Check that this is a Git repo if [ ! $WORKON_CWD ]; then
PROJECT_ROOT=`git rev-parse --show-toplevel 2> /dev/null` WORKON_CWD=1
if (( $? == 0 )); then # Check if this is a Git repo
PROJECT_ROOT=`git rev-parse --show-toplevel 2> /dev/null`
if (( $? != 0 )); then
PROJECT_ROOT="."
fi
# Check for virtualenv name override # Check for virtualenv name override
ENV_NAME=`basename "$PROJECT_ROOT"`
if [[ -f "$PROJECT_ROOT/.venv" ]]; then if [[ -f "$PROJECT_ROOT/.venv" ]]; then
ENV_NAME=`cat "$PROJECT_ROOT/.venv"` ENV_NAME=`cat "$PROJECT_ROOT/.venv"`
elif [[ "$PROJECT_ROOT" != "." ]]; then
ENV_NAME=`basename "$PROJECT_ROOT"`
else
ENV_NAME=""
fi fi
# Activate the environment only if it is not already active if [[ "$ENV_NAME" != "" ]]; then
if [[ "$VIRTUAL_ENV" != "$WORKON_HOME/$ENV_NAME" ]]; then # Activate the environment only if it is not already active
if [[ -e "$WORKON_HOME/$ENV_NAME/bin/activate" ]]; then if [[ "$VIRTUAL_ENV" != "$WORKON_HOME/$ENV_NAME" ]]; then
workon "$ENV_NAME" && export CD_VIRTUAL_ENV="$ENV_NAME" if [[ -e "$WORKON_HOME/$ENV_NAME/bin/activate" ]]; then
workon "$ENV_NAME" && export CD_VIRTUAL_ENV="$ENV_NAME"
fi
fi fi
elif [ $CD_VIRTUAL_ENV ]; then
# We've just left the repo, deactivate the environment
# Note: this only happens if the virtualenv was activated automatically
deactivate && unset CD_VIRTUAL_ENV
fi fi
elif [ $CD_VIRTUAL_ENV ]; then unset PROJECT_ROOT
# We've just left the repo, deactivate the environment unset WORKON_CWD
# Note: this only happens if the virtualenv was activated automatically
deactivate && unset CD_VIRTUAL_ENV
fi fi
unset PROJECT_ROOT
} }
# New cd function that does the virtualenv magic # Append workon_cwd to the chpwd_functions array, so it will be called on cd
function cd { # http://zsh.sourceforge.net/Doc/Release/Functions.html
builtin cd "$@" && workon_cwd # TODO: replace with 'add-zsh-hook chpwd workon_cwd' when oh-my-zsh min version is raised above 4.3.4
} if (( ${+chpwd_functions} )); then
if (( $chpwd_functions[(I)workon_cwd] == 0 )); then
set -A chpwd_functions $chpwd_functions workon_cwd
fi
else
set -A chpwd_functions workon_cwd
fi
fi fi
else else
print "zsh virtualenvwrapper plugin: Cannot find virtualenvwrapper_lazy.sh. Please install with \`pip install virtualenvwrapper\`." print "zsh virtualenvwrapper plugin: Cannot find ${virtualenvwrapper}. Please install with \`pip install virtualenvwrapper\`."
fi fi
# web_search from terminal
function web_search() {
# get the open command
local open_cmd
if [[ $(uname -s) == 'Darwin' ]]; then
open_cmd='open'
else
open_cmd='xdg-open'
fi
# check whether the search engine is supported
if [[ ! $1 =~ '(google|bing|yahoo)' ]];
then
echo "Search engine $1 not supported."
return 1
fi
local url="http://www.$1.com"
# no keyword provided, simply open the search engine homepage
if [[ $# -le 1 ]]; then
$open_cmd "$url"
return
fi
url="${url}/search?q="
shift # shift out $1
while [[ $# -gt 0 ]]; do
url="${url}$1+"
shift
done
url="${url%?}" # remove the last '+'
$open_cmd "$url"
}
alias bing='web_search bing'
alias google='web_search google'
alias yahoo='web_search yahoo'
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
# A few utility functions to make it easy and re-usable to draw segmented prompts # A few utility functions to make it easy and re-usable to draw segmented prompts
CURRENT_BG='NONE' CURRENT_BG='NONE'
SEGMENT_SEPARATOR='' SEGMENT_SEPARATOR=''
# Begin a segment # Begin a segment
# Takes two arguments, background and foreground. Both can be omitted, # Takes two arguments, background and foreground. Both can be omitted,
...@@ -90,7 +90,7 @@ prompt_git() { ...@@ -90,7 +90,7 @@ prompt_git() {
zstyle ':vcs_info:*' formats ' %u%c' zstyle ':vcs_info:*' formats ' %u%c'
zstyle ':vcs_info:*' actionformats '%u%c' zstyle ':vcs_info:*' actionformats '%u%c'
vcs_info vcs_info
echo -n "${ref/refs\/heads\// }${vcs_info_msg_0_}" echo -n "${ref/refs\/heads\// }${vcs_info_msg_0_}"
fi fi
} }
...@@ -110,7 +110,7 @@ prompt_hg() { ...@@ -110,7 +110,7 @@ prompt_hg() {
# if working copy is clean # if working copy is clean
prompt_segment green black prompt_segment green black
fi fi
echo -n $(hg prompt " {rev}@{branch}") $st echo -n $(hg prompt " {rev}@{branch}") $st
else else
st="" st=""
rev=$(hg id -n 2>/dev/null | sed 's/[^-0-9]//g') rev=$(hg id -n 2>/dev/null | sed 's/[^-0-9]//g')
...@@ -124,7 +124,7 @@ prompt_hg() { ...@@ -124,7 +124,7 @@ prompt_hg() {
else else
prompt_segment green black prompt_segment green black
fi fi
echo -n " $rev@$branch" $st echo -n " $rev@$branch" $st
fi fi
fi fi
} }
...@@ -134,6 +134,14 @@ prompt_dir() { ...@@ -134,6 +134,14 @@ prompt_dir() {
prompt_segment blue black '%~' prompt_segment blue black '%~'
} }
# Virtualenv: current working virtualenv
prompt_virtualenv() {
local virtualenv_path="$VIRTUAL_ENV"
if [[ -n $virtualenv_path ]]; then
prompt_segment blue black "(`basename $virtualenv_path`)"
fi
}
# Status: # Status:
# - was there an error # - was there an error
# - am I root # - am I root
...@@ -152,6 +160,7 @@ prompt_status() { ...@@ -152,6 +160,7 @@ prompt_status() {
build_prompt() { build_prompt() {
RETVAL=$? RETVAL=$?
prompt_status prompt_status
prompt_virtualenv
prompt_context prompt_context
prompt_dir prompt_dir
prompt_git prompt_git
......
...@@ -22,6 +22,8 @@ function mygit() { ...@@ -22,6 +22,8 @@ function mygit() {
echo "$ZSH_THEME_GIT_PROMPT_PREFIX${ref#refs/heads/}$( git_prompt_status )%{$reset_color%}$ZSH_THEME_GIT_PROMPT_SUFFIX" echo "$ZSH_THEME_GIT_PROMPT_PREFIX${ref#refs/heads/}$( git_prompt_status )%{$reset_color%}$ZSH_THEME_GIT_PROMPT_SUFFIX"
} }
function retcode() {}
# alternate prompt with git & hg # alternate prompt with git & hg
PROMPT=$'%{\e[0;34m%}%B┌─[%b%{\e[0m%}%{\e[1;32m%}%n%{\e[1;30m%}@%{\e[0m%}%{\e[0;36m%}%m%{\e[0;34m%}%B]%b%{\e[0m%} - %b%{\e[0;34m%}%B[%b%{\e[1;37m%}%~%{\e[0;34m%}%B]%b%{\e[0m%} - %{\e[0;34m%}%B[%b%{\e[0;33m%}'%D{"%Y-%m-%d %I:%M:%S"}%b$'%{\e[0;34m%}%B]%b%{\e[0m%} PROMPT=$'%{\e[0;34m%}%B┌─[%b%{\e[0m%}%{\e[1;32m%}%n%{\e[1;30m%}@%{\e[0m%}%{\e[0;36m%}%m%{\e[0;34m%}%B]%b%{\e[0m%} - %b%{\e[0;34m%}%B[%b%{\e[1;37m%}%~%{\e[0;34m%}%B]%b%{\e[0m%} - %{\e[0;34m%}%B[%b%{\e[0;33m%}'%D{"%Y-%m-%d %I:%M:%S"}%b$'%{\e[0;34m%}%B]%b%{\e[0m%}
%{\e[0;34m%}%B└─%B[%{\e[1;35m%}%?$(retcode)%{\e[0;34m%}%B] <$(mygit)$(hg_prompt_info)>%{\e[0m%}%b ' %{\e[0;34m%}%B└─%B[%{\e[1;35m%}%?$(retcode)%{\e[0;34m%}%B] <$(mygit)$(hg_prompt_info)>%{\e[0m%}%b '
......
...@@ -2,7 +2,8 @@ ...@@ -2,7 +2,8 @@
# on two lines for easier vgrepping # on two lines for easier vgrepping
# entry in a nice long thread on the Arch Linux forums: http://bbs.archlinux.org/viewtopic.php?pid=521888#p521888 # entry in a nice long thread on the Arch Linux forums: http://bbs.archlinux.org/viewtopic.php?pid=521888#p521888
function retcode() {}
PROMPT=$'%{\e[0;34m%}%B┌─[%b%{\e[0m%}%{\e[1;32m%}%n%{\e[1;30m%}@%{\e[0m%}%{\e[0;36m%}%m%{\e[0;34m%}%B]%b%{\e[0m%} - %b%{\e[0;34m%}%B[%b%{\e[1;37m%}%~%{\e[0;34m%}%B]%b%{\e[0m%} - %{\e[0;34m%}%B[%b%{\e[0;33m%}'%D{"%Y-%m-%d %I:%M:%S"}%b$'%{\e[0;34m%}%B]%b%{\e[0m%} PROMPT=$'%{\e[0;34m%}%B┌─[%b%{\e[0m%}%{\e[1;32m%}%n%{\e[1;30m%}@%{\e[0m%}%{\e[0;36m%}%m%{\e[0;34m%}%B]%b%{\e[0m%} - %b%{\e[0;34m%}%B[%b%{\e[1;37m%}%~%{\e[0;34m%}%B]%b%{\e[0m%} - %{\e[0;34m%}%B[%b%{\e[0;33m%}'%D{"%Y-%m-%d %I:%M:%S"}%b$'%{\e[0;34m%}%B]%b%{\e[0m%}
%{\e[0;34m%}%B└─%B[%{\e[1;35m%}%?$(retcode)%{\e[0;34m%}%B]%{\e[0m%}%b ' %{\e[0;34m%}%B└─%B[%{\e[1;35m%}%?$(retcode)%{\e[0;34m%}%B]%{\e[0m%}%b '
...@@ -11,13 +11,13 @@ fi ...@@ -11,13 +11,13 @@ fi
# Append the current git branch, if in a git repository # Append the current git branch, if in a git repository
JARIN_CURRENT_LOCA_="%{$fg_bold[cyan]%}%~\$(git_prompt_info)%{$reset_color%}" JARIN_CURRENT_LOCA_="%{$fg_bold[cyan]%}%~\$(git_prompt_info)%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg[white]%} <%{$fg[magenta]%}" ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg[white]%} <%{$fg[magenta]%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}" ZSH_THEME_GIT_PROMPT_SUFFIX="%{$fg[white]%}"
# Do nothing if the branch is clean (no changes). # Do nothing if the branch is clean (no changes).
ZSH_THEME_GIT_PROMPT_CLEAN="%{$reset_color%}>" ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg[white]%}>"
# Add a yellow ✗ if the branch is dirty # Add a yellow ✗ if the branch is dirty
ZSH_THEME_GIT_PROMPT_DIRTY="%{$reset_color%}> %{$fg[yellow]%}✗" ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[white]%}> %{$fg[yellow]%}✗"
# Put it all together! # Put it all together!
PROMPT="$JARIN_CURRENT_RUBY_ $JARIN_CURRENT_LOCA_ " PROMPT="$JARIN_CURRENT_RUBY_ $JARIN_CURRENT_LOCA_ "
......
current_path=`pwd`
current_path=${current_path/ /\\ }
printf '\033[0;34m%s\033[0m\n' "Upgrading Oh My Zsh" printf '\033[0;34m%s\033[0m\n' "Upgrading Oh My Zsh"
cd "$ZSH" cd "$ZSH"
if git pull --rebase origin master
if git pull origin master
then then
printf '\033[0;32m%s\033[0m\n' ' __ __ ' printf '\033[0;32m%s\033[0m\n' ' __ __ '
printf '\033[0;32m%s\033[0m\n' ' ____ / /_ ____ ___ __ __ ____ _____/ /_ ' printf '\033[0;32m%s\033[0m\n' ' ____ / /_ ____ ___ __ __ ____ _____/ /_ '
...@@ -17,4 +14,3 @@ else ...@@ -17,4 +14,3 @@ else
printf '\033[0;31m%s\033[0m\n' 'There was an error updating. Try again later?' printf '\033[0;31m%s\033[0m\n' 'There was an error updating. Try again later?'
fi fi
cd "$current_path"
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