diff --git a/lib/git.zsh b/lib/git.zsh index b0e73bf3a..7aa5a0ea2 100644 --- a/lib/git.zsh +++ b/lib/git.zsh @@ -54,11 +54,19 @@ git_remote_status() { # Checks if there are commits ahead from remote function git_prompt_ahead() { - if $(echo "$(command git log origin/$(current_branch)..HEAD 2> /dev/null)" | grep '^commit' &> /dev/null); then + if $(echo "$(command git log @{upstream}..HEAD 2> /dev/null)" | grep '^commit' &> /dev/null); then echo "$ZSH_THEME_GIT_PROMPT_AHEAD" fi } +# Gets the number of commits ahead from remote +function git_commits_ahead() { + if $(echo "$(command git log @{upstream}..HEAD 2> /dev/null)" | grep '^commit' &> /dev/null); then + COMMITS=$(command git log @{upstream}..HEAD | grep '^commit' | wc -l | tr -d ' ') + echo "$ZSH_THEME_GIT_COMMITS_AHEAD_PREFIX$COMMITS$ZSH_THEME_GIT_COMMITS_AHEAD_SUFFIX" + fi +} + # Formats prompt string for current git commit short SHA function git_prompt_short_sha() { SHA=$(command git rev-parse --short HEAD 2> /dev/null) && echo "$ZSH_THEME_GIT_PROMPT_SHA_BEFORE$SHA$ZSH_THEME_GIT_PROMPT_SHA_AFTER" diff --git a/plugins/brew/brew.plugin.zsh b/plugins/brew/brew.plugin.zsh index c2e95884e..42fb80c9a 100644 --- a/plugins/brew/brew.plugin.zsh +++ b/plugins/brew/brew.plugin.zsh @@ -1 +1,2 @@ alias brews='brew list -1' +alias bubu="brew update && brew upgrade && brew cleanup" diff --git a/plugins/bundler/README.md b/plugins/bundler/README.md new file mode 100644 index 000000000..56f0c7176 --- /dev/null +++ b/plugins/bundler/README.md @@ -0,0 +1,49 @@ +# Bundler + +- adds completion for basic bundler commands +- adds short aliases for common bundler commands + - `be` aliased to `bundle exec` + - `bl` aliased to `bundle list` + - `bp` aliased to `bundle package` + - `bo` aliased to `bundle open` + - `bu` aliased to `bundle update` + - `bi` aliased to `bundle install --jobs=` (only for bundler `>= 1.4.0`) +- adds a wrapper for common gems: + - looks for a binstub under `./bin/` and executes it (if present) + - calls `bundle exec ` otherwise + +For a full list of *common gems* being wrapped by default please look at the `bundler.plugin.zsh` file. + +## Configuration + +Please use the exact name of the executable and not the gem name. + +### Add additional gems to be wrapped + +Add this before the plugin-list in your `.zshrc`: +```sh +BUNDLED_COMMANDS=(rubocop) +plugins=(... bundler ...) +``` +This will add the wrapper for the `rubocop` gem (i.e. the executable). + + +### Exclude gems from being wrapped + +Add this before the plugin-list in your `.zshrc`: +```sh +UNBUNDLED_COMMANDS=(foreman spin) +plugins=(... bundler ...) +``` +This will exclude the `foreman` and `spin` gems (i.e. their executable) from being wrapped. + +## Excluded gems + +These gems should not be called with `bundle exec`. Please see the Issues on GitHub for clarification. + +`berks` +`foreman` +`mailcatcher` +`rails` +`ruby` +`spin` diff --git a/plugins/bundler/_bundler b/plugins/bundler/_bundler index 2ec3a5f9c..ba647ab80 100644 --- a/plugins/bundler/_bundler +++ b/plugins/bundler/_bundler @@ -18,11 +18,13 @@ case $state in "check[Determine whether the requirements for your application are installed]" \ "list[Show all of the gems in the current bundle]" \ "show[Show the source location of a particular gem in the bundle]" \ + "outdated[Show all of the outdated gems in the current bundle]" \ "console[Start an IRB session in the context of the current bundle]" \ "open[Open an installed gem in the editor]" \ "viz[Generate a visual representation of your dependencies]" \ "init[Generate a simple Gemfile, placed in the current directory]" \ "gem[Create a simple gem, suitable for development with bundler]" \ + "platform[Displays platform compatibility information]" \ "clean[Cleans up unused gems in your bundler directory]" \ "help[Describe available tasks or one specific task]" ret=0 @@ -39,11 +41,13 @@ case $state in 'check' \ 'list' \ 'show' \ + 'outdated' \ 'console' \ 'open' \ 'viz' \ 'init' \ 'gem' \ + 'platform' \ 'help' && ret=0 ;; install) @@ -71,6 +75,15 @@ case $state in '(--verbose)--verbose[Enable verbose output mode]' ret=0 ;; + outdated) + _arguments \ + '(--pre)--pre[Check for newer pre-release gems]' \ + '(--source)--source[Check against a specific source]' \ + '(--local)--local[Do not attempt to fetch gems remotely and use the gem cache instead]' \ + '(--no-color)--no-color[Disable colorization in output]' \ + '(--verbose)--verbose[Enable verbose output mode]' + ret=0 + ;; (open|show) _gems=( $(bundle show 2> /dev/null | sed -e '/^ \*/!d; s/^ \* \([^ ]*\) .*/\1/') ) if [[ $_gems != "" ]]; then diff --git a/plugins/bundler/bundler.plugin.zsh b/plugins/bundler/bundler.plugin.zsh index 20931dcef..617dcde71 100644 --- a/plugins/bundler/bundler.plugin.zsh +++ b/plugins/bundler/bundler.plugin.zsh @@ -5,15 +5,49 @@ alias bo="bundle open" alias bu="bundle update" alias bi="bundle_install" -# The following is based on https://github.com/gma/bundler-exec - -bundled_commands=(annotate berks cap capify cucumber foodcritic foreman guard irb jekyll kitchen knife middleman nanoc puma rackup rainbows rake rspec ruby shotgun spec spin spork spring strainer tailor taps thin thor unicorn unicorn_rails) +bundled_commands=( + annotate + cap + capify + cucumber + foodcritic + guard + irb + jekyll + kitchen + knife + middleman + nanoc + pry + puma + rackup + rainbows + rake + rspec + shotgun + sidekiq + spec + spork + spring + strainer + tailor + taps + thin + thor + unicorn + unicorn_rails +) # Remove $UNBUNDLED_COMMANDS from the bundled_commands list for cmd in $UNBUNDLED_COMMANDS; do bundled_commands=(${bundled_commands#$cmd}); done +# Add $BUNDLED_COMMANDS to the bundled_commands list +for cmd in $BUNDLED_COMMANDS; do + bundled_commands+=($cmd); +done + ## Functions bundle_install() { @@ -48,9 +82,17 @@ _within-bundled-project() { false } +_binstubbed() { + [ -f "./bin/${1}" ] +} + _run-with-bundler() { if _bundler-installed && _within-bundled-project; then - bundle exec $@ + if _binstubbed $1; then + ./bin/$@ + else + bundle exec $@ + fi else $@ fi @@ -63,7 +105,6 @@ for cmd in $bundled_commands; do alias $cmd=bundled_$cmd if which _$cmd > /dev/null 2>&1; then - compdef _$cmd bundled_$cmd=$cmd + compdef _$cmd bundled_$cmd=$cmd fi done - diff --git a/plugins/docker/_docker b/plugins/docker/_docker index c291037a3..28568a6e5 100644 --- a/plugins/docker/_docker +++ b/plugins/docker/_docker @@ -214,7 +214,7 @@ __save() { __start() { _arguments \ '(-a,--attach=)'{-a,--attach=}'[Attach container''s stdout/stderr and forward all signals to the process]' \ - '(-i,--interactive=)'{-i, --interactive=}'[Attach container''s stdin]' + '(-i,--interactive=)'{-i,--interactive=}'[Attach container''s stdin]' __docker_containers } diff --git a/plugins/jira/jira.plugin.zsh b/plugins/jira/jira.plugin.zsh index 739ee7142..3d510e430 100644 --- a/plugins/jira/jira.plugin.zsh +++ b/plugins/jira/jira.plugin.zsh @@ -29,15 +29,23 @@ open_jira_issue () { return 0 fi + if [ -f .jira-prefix ]; then + jira_prefix=$(cat .jira-prefix) + elif [ -f ~/.jira-prefix ]; then + jira_prefix=$(cat ~/.jira-prefix) + else + jira_prefix="" + fi + if [ -z "$1" ]; then echo "Opening new issue" $open_cmd "$jira_url/secure/CreateIssue!default.jspa" else echo "Opening issue #$1" if [[ "x$JIRA_RAPID_BOARD" = "xtrue" ]]; then - $open_cmd "$jira_url/issues/$1" + $open_cmd "$jira_url/issues/$jira_prefix$1" else - $open_cmd "$jira_url/browse/$1" + $open_cmd "$jira_url/browse/$jira_prefix$1" fi fi } diff --git a/plugins/mvn/mvn.plugin.zsh b/plugins/mvn/mvn.plugin.zsh index 2b7683078..a70625fcf 100644 --- a/plugins/mvn/mvn.plugin.zsh +++ b/plugins/mvn/mvn.plugin.zsh @@ -129,6 +129,8 @@ function listMavenCompletions { tomcat6:run tomcat6:run-war tomcat6:run-war-only tomcat6:stop tomcat6:deploy tomcat6:undeploy # tomcat7 tomcat7:run tomcat7:run-war tomcat7:run-war-only tomcat7:deploy + # spring-boot + spring-boot:run spring-boot:repackage # exec exec:exec exec:java # versions diff --git a/plugins/osx/osx.plugin.zsh b/plugins/osx/osx.plugin.zsh index 63760b5ff..a63f0ee05 100644 --- a/plugins/osx/osx.plugin.zsh +++ b/plugins/osx/osx.plugin.zsh @@ -174,12 +174,16 @@ function itunes() { next|previous) opt="$opt track" ;; + vol) + opt="set sound volume to $1" #$1 Due to the shift + ;; ""|-h|--help) echo "Usage: itunes