Skip to content

Commit

Permalink
Merge and join Rails plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
tinogomes committed Aug 21, 2013
2 parents 9fbc06c + 434f3bc commit f7a2486
Show file tree
Hide file tree
Showing 45 changed files with 1,758 additions and 182 deletions.
2 changes: 2 additions & 0 deletions README.textile
Expand Up @@ -72,6 +72,8 @@ To disable updates entirely, put this in your ~/.zshrc

@DISABLE_AUTO_UPDATE=true@

To upgrade directly from the command line, just run @upgrade_oh_my_zsh@

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).
Expand Down
28 changes: 14 additions & 14 deletions lib/git.zsh
@@ -1,7 +1,7 @@
# get the name of the branch we are on
function git_prompt_info() {
ref=$(git symbolic-ref HEAD 2> /dev/null) || \
ref=$(git rev-parse --short HEAD 2> /dev/null) || return
ref=$(command git symbolic-ref HEAD 2> /dev/null) || \
ref=$(command git rev-parse --short HEAD 2> /dev/null) || return
echo "$ZSH_THEME_GIT_PROMPT_PREFIX${ref#refs/heads/}$(parse_git_dirty)$ZSH_THEME_GIT_PROMPT_SUFFIX"
}

Expand All @@ -11,14 +11,14 @@ parse_git_dirty() {
local SUBMODULE_SYNTAX=''
local GIT_STATUS=''
local CLEAN_MESSAGE='nothing to commit (working directory clean)'
if [[ "$(git config --get oh-my-zsh.hide-status)" != "1" ]]; then
if [[ "$(command git config --get oh-my-zsh.hide-status)" != "1" ]]; then
if [[ $POST_1_7_2_GIT -gt 0 ]]; then
SUBMODULE_SYNTAX="--ignore-submodules=dirty"
fi
if [[ "$DISABLE_UNTRACKED_FILES_DIRTY" == "true" ]]; then
GIT_STATUS=$(git status -s ${SUBMODULE_SYNTAX} -uno 2> /dev/null | tail -n1)
GIT_STATUS=$(command git status -s ${SUBMODULE_SYNTAX} -uno 2> /dev/null | tail -n1)
else
GIT_STATUS=$(git status -s ${SUBMODULE_SYNTAX} 2> /dev/null | tail -n1)
GIT_STATUS=$(command git status -s ${SUBMODULE_SYNTAX} 2> /dev/null | tail -n1)
fi
if [[ -n $GIT_STATUS ]]; then
echo "$ZSH_THEME_GIT_PROMPT_DIRTY"
Expand All @@ -32,10 +32,10 @@ parse_git_dirty() {

# get the difference between the local and remote branches
git_remote_status() {
remote=${$(git rev-parse --verify ${hook_com[branch]}@{upstream} --symbolic-full-name 2>/dev/null)/refs\/remotes\/}
remote=${$(command git rev-parse --verify ${hook_com[branch]}@{upstream} --symbolic-full-name 2>/dev/null)/refs\/remotes\/}
if [[ -n ${remote} ]] ; then
ahead=$(git rev-list ${hook_com[branch]}@{upstream}..HEAD 2>/dev/null | wc -l)
behind=$(git rev-list HEAD..${hook_com[branch]}@{upstream} 2>/dev/null | wc -l)
ahead=$(command git rev-list ${hook_com[branch]}@{upstream}..HEAD 2>/dev/null | wc -l)
behind=$(command git rev-list HEAD..${hook_com[branch]}@{upstream} 2>/dev/null | wc -l)

if [ $ahead -eq 0 ] && [ $behind -gt 0 ]
then
Expand All @@ -52,24 +52,24 @@ git_remote_status() {

# 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
if $(echo "$(command 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"
SHA=$(command 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"
SHA=$(command 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() {
INDEX=$(git status --porcelain -b 2> /dev/null)
INDEX=$(command git status --porcelain -b 2> /dev/null)
STATUS=""
if $(echo "$INDEX" | grep -E '^\?\? ' &> /dev/null); then
STATUS="$ZSH_THEME_GIT_PROMPT_UNTRACKED$STATUS"
Expand All @@ -96,7 +96,7 @@ git_prompt_status() {
elif $(echo "$INDEX" | grep '^AD ' &> /dev/null); then
STATUS="$ZSH_THEME_GIT_PROMPT_DELETED$STATUS"
fi
if $(git rev-parse --verify refs/stash >/dev/null 2>&1); then
if $(command git rev-parse --verify refs/stash >/dev/null 2>&1); then
STATUS="$ZSH_THEME_GIT_PROMPT_STASHED$STATUS"
fi
if $(echo "$INDEX" | grep '^UU ' &> /dev/null); then
Expand All @@ -121,7 +121,7 @@ function git_compare_version() {
local INPUT_GIT_VERSION=$1;
local INSTALLED_GIT_VERSION
INPUT_GIT_VERSION=(${(s/./)INPUT_GIT_VERSION});
INSTALLED_GIT_VERSION=($(git --version 2>/dev/null));
INSTALLED_GIT_VERSION=($(command git --version 2>/dev/null));
INSTALLED_GIT_VERSION=(${(s/./)INSTALLED_GIT_VERSION[3]});

for i in {1..3}; do
Expand Down
4 changes: 3 additions & 1 deletion lib/termsupport.zsh
Expand Up @@ -27,7 +27,9 @@ function omz_termsupport_preexec {
emulate -L zsh
setopt extended_glob
local CMD=${1[(wr)^(*=*|sudo|ssh|rake|-*)]} #cmd name only, or if this is sudo or ssh, the next cmd
title "$CMD" "%100>...>${2:gs/%/%%}%<<"
local LINE="${2:gs/$/\\$}"
LINE="${LINE:gs/%/%%}"
title "$CMD" "%100>...>$LINE%<<"
}

autoload -U add-zsh-hook
Expand Down
101 changes: 72 additions & 29 deletions plugins/bower/bower.plugin.zsh
Expand Up @@ -2,37 +2,80 @@ alias bi="bower install"
alias bl="bower list"
alias bs="bower search"

bower_package_list=''

_bower_installed_packages () {
bower_package_list=$(bower ls --no-color 2>/dev/null| awk 'NR>3{print p}{p=$0}'| cut -d ' ' -f 2|sed 's/#.*//')
}
_bower ()
{
local curcontext="$curcontext" state line
typeset -A opt_args

_arguments -C \
':command:->command' \
'*::options:->options'

case $state in
(command)

local -a subcommands
subcommands=(${=$(bower help | grep help | sed -e 's/,//g')})
_describe -t commands 'bower' subcommands
;;

(options)
case $line[1] in

(install)
if [ -z "$bower_package_list" ];then
bower_package_list=$(bower search | awk 'NR > 2' | cut -d '-' -f 2 | cut -d ' ' -f 2 | sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g")
fi
compadd "$@" $(echo $bower_package_list)
;;
esac
;;
esac
local -a _1st_arguments _no_color _dopts _save_dev _force_lastest _production
local expl
typeset -A opt_args

_no_color=('--no-color[Do not print colors (available in all commands)]')

_dopts=(
'(--save)--save[Save installed packages into the project"s bower.json dependencies]'
'(--force)--force[Force fetching remote resources even if a local copy exists on disk]'
)

_save_dev=('(--save-dev)--save-dev[Save installed packages into the project"s bower.json devDependencies]')

_force_lastest=('(--force-latest)--force-latest[Force latest version on conflict]')

_production=('(--production)--production[Do not install project devDependencies]')

_1st_arguments=(
'cache-clean:Clean the Bower cache, or the specified package caches' \
'help:Display help information about Bower' \
'info:Version info and description of a particular package' \
'init:Interactively create a bower.json file' \
'install:Install a package locally' \
'link:Symlink a package folder' \
'lookup:Look up a package URL by name' \
'register:Register a package' \
'search:Search for a package by name' \
'uninstall:Remove a package' \
'update:Update a package' \
{ls,list}:'[List all installed packages]'
)
_arguments \
$_no_color \
'*:: :->subcmds' && return 0

if (( CURRENT == 1 )); then
_describe -t commands "bower subcommand" _1st_arguments
return
fi

case "$words[1]" in
install)
_arguments \
$_dopts \
$_save_dev \
$_force_lastest \
$_no_color \
$_production
;;
update)
_arguments \
$_dopts \
$_no_color \
$_force_lastest
_bower_installed_packages
compadd "$@" $(echo $bower_package_list)
;;
uninstall)
_arguments \
$_no_color \
$_dopts
_bower_installed_packages
compadd "$@" $(echo $bower_package_list)
;;
*)
$_no_color \
;;
esac

}

compdef _bower bower
2 changes: 1 addition & 1 deletion plugins/bundler/bundler.plugin.zsh
Expand Up @@ -7,7 +7,7 @@ alias bu="bundle update"

# The following is based on https://github.com/gma/bundler-exec

bundled_commands=(annotate cap capify cucumber foreman guard jekyll middleman nanoc rackup rainbows rake rspec ruby shotgun spec spin spork thin thor unicorn unicorn_rails puma)
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)

## Functions

Expand Down
36 changes: 36 additions & 0 deletions plugins/cabal/cabal.plugin.zsh
@@ -0,0 +1,36 @@
function _cabal_commands() {
local ret=1 state
_arguments ':subcommand:->subcommand' && ret=0

case $state in
subcommand)
subcommands=(
"bench:Run the benchmark, if any (configure with UserHooks)"
"build:Make this package ready for installation"
"check:Check the package for common mistakes"
"clean:Clean up after a build"
"copy:Copy teh files into the install locations"
"configure:Prepare to build the package"
"fetch:Downloads packages for later installation"
"haddock:Generate HAddock HTML documentation"
"help:Help about commands"
"hscolour:Generate HsColour colourised code, in HTML format"
"info:Display detailed information about a particular package"
"init:Interactively create a .cabal file"
"install:Installs a list of packages"
"list:List packages matching a search string"
"register:Register this package with the compiler"
"report:Upload build reports to a remote server"
"sdist:Generate a source distribution file (.tar.gz)"
"test:Run the test suite, if any (configure with UserHooks)"
"unpack:Unpacks packages for user inspection"
"update:Updates list of known packages"
"upload:Uploads source packages to Hackage"
)
_describe -t subcommands 'cabal subcommands' subcommands && ret=0
esac

return ret
}

compdef _cabal_commands cabal
2 changes: 1 addition & 1 deletion plugins/capistrano/_capistrano
Expand Up @@ -4,7 +4,7 @@
if [[ -f config/deploy.rb || -f Capfile ]]; then
if [[ ! -f .cap_tasks~ || config/deploy.rb -nt .cap_tasks~ ]]; then
echo "\nGenerating .cap_tasks~..." > /dev/stderr
cap --tasks | grep '#' | cut -d " " -f 2 > .cap_tasks~
cap -v --tasks | grep '#' | cut -d " " -f 2 > .cap_tasks~
fi
compadd `cat .cap_tasks~`
fi

0 comments on commit f7a2486

Please sign in to comment.