diff --git a/lib/functions.zsh b/lib/functions.zsh index f9d4a9717d7d..9f11318d2c06 100644 --- a/lib/functions.zsh +++ b/lib/functions.zsh @@ -3,11 +3,11 @@ function zsh_stats() { } function uninstall_oh_my_zsh() { - env ZSH=$ZSH /bin/sh $ZSH/tools/uninstall.sh + env ZSH=$ZSH sh $ZSH/tools/uninstall.sh } function upgrade_oh_my_zsh() { - env ZSH=$ZSH /bin/sh $ZSH/tools/upgrade.sh + env ZSH=$ZSH sh $ZSH/tools/upgrade.sh } function take() { diff --git a/lib/git.zsh b/lib/git.zsh index 5952f64c0428..5a2758fed037 100644 --- a/lib/git.zsh +++ b/lib/git.zsh @@ -76,9 +76,8 @@ function git_current_branch() { # 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 - local COMMITS - COMMITS=$(command git log @{upstream}..HEAD | grep '^commit' | wc -l | tr -d ' ') + if $(command git rev-parse --git-dir > /dev/null 2>&1); then + local COMMITS="$(git rev-list --count @{upstream}..HEAD)" echo "$ZSH_THEME_GIT_COMMITS_AHEAD_PREFIX$COMMITS$ZSH_THEME_GIT_COMMITS_AHEAD_SUFFIX" fi } diff --git a/lib/nvm.zsh b/lib/nvm.zsh index 61d997fc0780..4a8b6811e9c6 100644 --- a/lib/nvm.zsh +++ b/lib/nvm.zsh @@ -1,6 +1,6 @@ # get the node.js version function nvm_prompt_info() { - [ -f "$HOME/.nvm/nvm.sh" ] || return + [[ -f "$NVM_DIR/nvm.sh" ]] || return local nvm_prompt nvm_prompt=$(node -v 2>/dev/null) [[ "${nvm_prompt}x" == "x" ]] && return diff --git a/plugins/git/git.plugin.zsh b/plugins/git/git.plugin.zsh index c186a6e11f42..554dcbfbe037 100644 --- a/plugins/git/git.plugin.zsh +++ b/plugins/git/git.plugin.zsh @@ -46,7 +46,7 @@ alias gapa='git add --patch' alias gb='git branch' alias gba='git branch -a' -alias gbda='git branch --merged | command grep -vE "^(\*|\s*master\s*$)" | command xargs -n 1 git branch -d' +alias gbda='git branch --no-color --merged | command grep -vE "^(\*|\s*(master|develop|dev)\s*$)" | command xargs -n 1 git branch -d' alias gbl='git blame -b -w' alias gbnm='git branch --no-merged' alias gbr='git branch --remote' @@ -75,68 +75,84 @@ alias gco='git checkout' alias gcount='git shortlog -sn' compdef gcount=git alias gcp='git cherry-pick' +alias gcpa='git cherry-pick --abort' +alias gcpc='git cherry-pick --continue' alias gcs='git commit -S' alias gd='git diff' alias gdca='git diff --cached' alias gdct='git describe --tags `git rev-list --tags --max-count=1`' alias gdt='git diff-tree --no-commit-id --name-only -r' +alias gdw='git diff --word-diff' + gdv() { git diff -w "$@" | view - } compdef _git gdv=git-diff -alias gdw='git diff --word-diff' alias gf='git fetch' alias gfa='git fetch --all --prune' +alias gfo='git fetch origin' + function gfg() { git ls-files | grep $@ } compdef _grep gfg -alias gfo='git fetch origin' alias gg='git gui citool' alias gga='git gui citool --amend' + ggf() { -[[ "$#" != 1 ]] && local b="$(git_current_branch)" -git push --force origin "${b:=$1}" + [[ "$#" != 1 ]] && local b="$(git_current_branch)" + git push --force origin "${b:=$1}" } compdef _git ggf=git-checkout + ggl() { -if [[ "$#" != 0 ]] && [[ "$#" != 1 ]]; then -git pull origin "${*}" -else -[[ "$#" == 0 ]] && local b="$(git_current_branch)" -git pull origin "${b:=$1}" -fi + if [[ "$#" != 0 ]] && [[ "$#" != 1 ]]; then + git pull origin "${*}" + else + [[ "$#" == 0 ]] && local b="$(git_current_branch)" + git pull origin "${b:=$1}" + fi } compdef _git ggl=git-checkout -alias ggpull='git pull origin $(git_current_branch)' -compdef _git ggpull=git-checkout + ggp() { -if [[ "$#" != 0 ]] && [[ "$#" != 1 ]]; then -git push origin "${*}" -else -[[ "$#" == 0 ]] && local b="$(git_current_branch)" -git push origin "${b:=$1}" -fi + if [[ "$#" != 0 ]] && [[ "$#" != 1 ]]; then + git push origin "${*}" + else + [[ "$#" == 0 ]] && local b="$(git_current_branch)" + git push origin "${b:=$1}" + fi } compdef _git ggp=git-checkout -alias ggpush='git push origin $(git_current_branch)' -compdef _git ggpush=git-checkout + ggpnp() { -if [[ "$#" == 0 ]]; then -ggl && ggp -else -ggl "${*}" && ggp "${*}" -fi + if [[ "$#" == 0 ]]; then + ggl && ggp + else + ggl "${*}" && ggp "${*}" + fi } compdef _git ggpnp=git-checkout -alias ggsup='git branch --set-upstream-to=origin/$(git_current_branch)' + ggu() { -[[ "$#" != 1 ]] && local b="$(git_current_branch)" -git pull --rebase origin "${b:=$1}" + [[ "$#" != 1 ]] && local b="$(git_current_branch)" + git pull --rebase origin "${b:=$1}" } compdef _git ggu=git-checkout + alias ggpur='ggu' compdef _git ggpur=git-checkout +alias ggpull='git pull origin $(git_current_branch)' +compdef _git ggpull=git-checkout + +alias ggpush='git push origin $(git_current_branch)' +compdef _git ggpush=git-checkout + +alias ggsup='git branch --set-upstream-to=origin/$(git_current_branch)' +alias gpsup='git push --set-upstream origin $(git_current_branch)' + +alias gh='git help' + alias gignore='git update-index --assume-unchanged' alias gignored='git ls-files -v | grep "^[[:lower:]]"' alias git-svn-dcommit-push='git svn dcommit && git push github master:svntrunk' diff --git a/plugins/kubectl/kubectl.plugin.zsh b/plugins/kubectl/kubectl.plugin.zsh new file mode 100644 index 000000000000..51ae142a2b35 --- /dev/null +++ b/plugins/kubectl/kubectl.plugin.zsh @@ -0,0 +1,7 @@ +# Autocompletion for kubectl, the command line interface for Kubernetes +# +# Author: https://github.com/pstadler + +if [ $commands[kubectl] ]; then + source <(kubectl completion zsh) +fi diff --git a/plugins/mix/_mix b/plugins/mix/_mix index 3b3887b1fc4d..57fdf808a722 100644 --- a/plugins/mix/_mix +++ b/plugins/mix/_mix @@ -38,6 +38,15 @@ _1st_arguments=( 'local.hex:Install hex locally' 'local.rebar:Install rebar locally' 'new:Create a new Elixir project' + 'phoenix.digest:Digests and compress static files' + 'phoenix.gen.channel:Generates a Phoenix channel' + 'phoenix.gen.html:Generates controller, model and views for an HTML based resource' + 'phoenix.gen.json:Generates a controller and model for a JSON based resource' + 'phoenix.gen.model:Generates an Ecto model' + 'phoenix.gen.secret:Generates a secret' + 'phoenix.new:Create a new Phoenix application' + 'phoenix.routes:Prints all routes' + 'phoenix.server:Starts applications and their servers' 'run:Run the given file or expression' "test:Run a project's tests" '--help:Describe available tasks' @@ -49,7 +58,7 @@ __task_list () local expl declare -a tasks - tasks=(app.start archive archive.build archive.install archive.uninstall clean cmd compile compile.protocols deps deps.clean deps.compile deps.get deps.unlock deps.update do escript.build help hex hex.config hex.docs hex.info hex.key hex.outdated hex.owner hex.publish hex.search hex.user loadconfig local local.hex local.rebar new run test) + tasks=(app.start archive archive.build archive.install archive.uninstall clean cmd compile compile.protocols deps deps.clean deps.compile deps.get deps.unlock deps.update do escript.build help hex hex.config hex.docs hex.info hex.key hex.outdated hex.owner hex.publish hex.search hex.user loadconfig local local.hex local.rebar new phoenix.digest phoenix.gen.channel phoenix.gen.html phoenix.gen.json phoenix.gen.model phoenix.gen.secret phoenix.new phoenix.routes phoenix.server run test) _wanted tasks expl 'help' compadd $tasks } @@ -80,4 +89,3 @@ case $state in esac ;; esac - diff --git a/plugins/npm/npm.plugin.zsh b/plugins/npm/npm.plugin.zsh index 38e699ea0197..422d81ceb89f 100644 --- a/plugins/npm/npm.plugin.zsh +++ b/plugins/npm/npm.plugin.zsh @@ -20,3 +20,10 @@ alias npmE='PATH="$(npm bin)":"$PATH"' # Check which npm modules are outdated alias npmO="npm outdated" + +# Run npm start +alias npmst="npm start" + +# Run npm test +alias npmt="npm test" + diff --git a/plugins/nvm/_nvm b/plugins/nvm/_nvm index a95c9e3753e5..1414dcbb1782 100644 --- a/plugins/nvm/_nvm +++ b/plugins/nvm/_nvm @@ -1,7 +1,7 @@ #compdef nvm #autoload -[[ -s ~/.nvm/nvm.sh ]] || return 0 +[[ -f "$NVM_DIR/nvm.sh" ]] || return 0 local -a _1st_arguments _1st_arguments=( diff --git a/plugins/nvm/nvm.plugin.zsh b/plugins/nvm/nvm.plugin.zsh index 9709719fefb4..9dde3a266ae1 100644 --- a/plugins/nvm/nvm.plugin.zsh +++ b/plugins/nvm/nvm.plugin.zsh @@ -1,3 +1,5 @@ -# The addition 'nvm install' attempts in ~/.profile +# Set NVM_DIR if it isn't already defined +[[ -z "$NVM_DIR" ]] && export NVM_DIR="$HOME/.nvm" -[[ -s ~/.nvm/nvm.sh ]] && . ~/.nvm/nvm.sh +# Load nvm if it exists +[[ -f "$NVM_DIR/nvm.sh" ]] && source "$NVM_DIR/nvm.sh" diff --git a/plugins/osx/README.md b/plugins/osx/README.md index a06184a45b90..6de2b061eab1 100644 --- a/plugins/osx/README.md +++ b/plugins/osx/README.md @@ -15,13 +15,15 @@ Original author: [Sorin Ionescu](https://github.com/sorin-ionescu) ## Commands -| Command | Description | -|:--------------|:-----------------------------------------------| -| `tab` | Open the current directory in a new tab | -| `ofd` | Open the current directory in a Finder window | -| `pfd` | Return the path of the frontmost Finder window | -| `pfs` | Return the current Finder selection | -| `cdf` | `cd` to the current Finder directory | -| `pushdf` | `pushd` to the current Finder directory | -| `quick-look` | Quick-Look a specified file | -| `man-preview` | Open a specified man page in Preview app | +| Command | Description | +| :-------------- | :----------------------------------------------- | +| `tab` | Open the current directory in a new tab | +| `ofd` | Open the current directory in a Finder window | +| `pfd` | Return the path of the frontmost Finder window | +| `pfs` | Return the current Finder selection | +| `cdf` | `cd` to the current Finder directory | +| `pushdf` | `pushd` to the current Finder directory | +| `quick-look` | Quick-Look a specified file | +| `man-preview` | Open a specified man page in Preview app | +| `showfiles` | Show hidden files | +| `hidefiles` | Hide the hidden files | diff --git a/plugins/osx/osx.plugin.zsh b/plugins/osx/osx.plugin.zsh index 4dbc7578790b..f69bd7e5d524 100644 --- a/plugins/osx/osx.plugin.zsh +++ b/plugins/osx/osx.plugin.zsh @@ -260,3 +260,7 @@ EOF esac osascript -e "tell application \"iTunes\" to $opt" } + +# Show/hide hidden files in the Finder +alias showfiles="defaults write com.apple.finder AppleShowAllFiles -bool true && killall Finder" +alias hidefiles="defaults write com.apple.finder AppleShowAllFiles -bool false && killall Finder" diff --git a/plugins/rails/rails.plugin.zsh b/plugins/rails/rails.plugin.zsh index 5dfca49e9021..e532639b528e 100644 --- a/plugins/rails/rails.plugin.zsh +++ b/plugins/rails/rails.plugin.zsh @@ -57,6 +57,7 @@ alias rdrs='rake db:reset' alias rdtc='rake db:test:clone' alias rdtp='rake db:test:prepare' alias rdmtc='rake db:migrate db:test:clone' +alias rdsl='rake db:schema:load' alias rlc='rake log:clear' alias rn='rake notes' alias rr='rake routes' diff --git a/plugins/rake-fast/rake-fast.plugin.zsh b/plugins/rake-fast/rake-fast.plugin.zsh index d305eb1f0516..57d699abcddc 100644 --- a/plugins/rake-fast/rake-fast.plugin.zsh +++ b/plugins/rake-fast/rake-fast.plugin.zsh @@ -8,7 +8,19 @@ _rake_refresh () { } _rake_does_task_list_need_generating () { - [[ ! -f .rake_tasks ]] || [[ Rakefile -nt .rake_tasks ]] + [[ ! -f .rake_tasks ]] || [[ Rakefile -nt .rake_tasks ]] || (_is_rails_app && _tasks_changed) +} + +_is_rails_app () { + [[ -e "bin/rails" ]] || [ -e "script/rails" ] +} + +_tasks_changed () { + local is_changed=1 + for file in lib/tasks/**/*.rake; do + if [[ $file -nt .rake_tasks ]]; then is_changed=0; fi + done + return is_changed } _rake_generate () { diff --git a/plugins/shrink-path/README.md b/plugins/shrink-path/README.md new file mode 100644 index 000000000000..51fa8a0510c2 --- /dev/null +++ b/plugins/shrink-path/README.md @@ -0,0 +1,68 @@ +# A plugin to shrink directory paths for brevity and pretty-printing + + +## Examples + +For this directory tree: +``` + /home/ + me/ + foo/ + bar/ + quux/ + biz/ # The prefix b is ambiguous between bar and biz. +``` +here are the results of calling `shrink_path