Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into personal
Browse files Browse the repository at this point in the history
* origin/master: (22 commits)
  Adding alias to rake db:schema:load command. (ohmyzsh#5281)
  Create an alias to open up sublime project (ohmyzsh#5258)
  Add gcpa and gcpc aliases to git plugin (ohmyzsh#5271)
  Enhancement: Show/Hide OSX hidden files 💯 (ohmyzsh#5275)
  Plugin : Sudo - Add support of sudoedit (ohmyzsh#5035)
  plugins/urltools: add suport for python 3 (ohmyzsh#5039)
  muse theme: Remove extra spaces for none git/virtualenv prompt (ohmyzsh#5278)
  add kubectl plugin (ohmyzsh#5298)
  refresh .rake_tasks when lib/tasks changed (ohmyzsh#5111)
  Add tmux attach -d alias (ohmyzsh#5285)
  add npm aliases (ohmyzsh#5290)
  (git): Add gpsup alias (ohmyzsh#5287)
  Add shrink-path plugin to shorten directory paths (e.g. ~/f/b/quux) (ohmyzsh#5262)
  added mix autocompletion support for phoenix (ohmyzsh#4967)
  update alias of get a list of packages installed locally (ohmyzsh#5276)
  Replace /bin/sh with sh for portability (ohmyzsh#5291)
  nvm plugin improvements (ohmyzsh#5265)
  [git plugin] Fix indentation and organise aliases
  Fix gbda alias to support `color.ui = always` + exclude dev branches (ohmyzsh#4304)
  support for startpage search engine in web-search plugin (ohmyzsh#5245)
  ...
  • Loading branch information
Hamish Downer committed Aug 15, 2016
2 parents 4314b0c + 75f2f4e commit 9ee7c0c
Show file tree
Hide file tree
Showing 24 changed files with 360 additions and 61 deletions.
4 changes: 2 additions & 2 deletions lib/functions.zsh
Expand Up @@ -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() {
Expand Down
5 changes: 2 additions & 3 deletions lib/git.zsh
Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion 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
Expand Down
74 changes: 45 additions & 29 deletions plugins/git/git.plugin.zsh
Expand Up @@ -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'
Expand Down Expand Up @@ -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'
Expand Down
7 changes: 7 additions & 0 deletions 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
12 changes: 10 additions & 2 deletions plugins/mix/_mix
Expand Up @@ -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'
Expand All @@ -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
}
Expand Down Expand Up @@ -80,4 +89,3 @@ case $state in
esac
;;
esac

7 changes: 7 additions & 0 deletions plugins/npm/npm.plugin.zsh
Expand Up @@ -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"

2 changes: 1 addition & 1 deletion 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=(
Expand Down
6 changes: 4 additions & 2 deletions 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"
22 changes: 12 additions & 10 deletions plugins/osx/README.md
Expand Up @@ -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 |
4 changes: 4 additions & 0 deletions plugins/osx/osx.plugin.zsh
Expand Up @@ -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"
1 change: 1 addition & 0 deletions plugins/rails/rails.plugin.zsh
Expand Up @@ -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'
Expand Down
14 changes: 13 additions & 1 deletion plugins/rake-fast/rake-fast.plugin.zsh
Expand Up @@ -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 () {
Expand Down
68 changes: 68 additions & 0 deletions 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 <option> /home/me/foo/bar/quux`:
```
Option Result
<none> /h/m/f/ba/q
-l|--last /h/m/f/ba/quux
-s|--short /h/m/f/b/q
-t|--tilde ~/f/ba/q
-f|--fish ~/f/b/quux
```


## Usage

For a fish-style working directory in your command prompt, add the following to
your theme or zshrc:

```
setopt prompt_subst
PS1='%n@%m $(shrink_path -f)>'
```

The following options are available:

```
-f, --fish fish simulation, equivalent to -l -s -t.
-l, --last Print the last directory's full name.
-s, --short Truncate directory names to the first character. Without
-s, names are truncated without making them ambiguous.
-t, --tilde Substitute ~ for the home directory.
-T, --nameddirs Substitute named directories as well.
```

The long options can also be set via zstyle, like
```
zstyle :prompt:shrink_path fish yes
```

Note: Directory names containing two or more consecutive spaces are not yet
supported.


## License

Copyright (C) 2008 by Daniel Friesel <derf@xxxxxxxxxxxxxxxxxx>

License: WTFPL <http://sam.zoy.org/wtfpl>

Ref: http://www.zsh.org/mla/workers/2009/msg00415.html
http://www.zsh.org/mla/workers/2009/msg00419.html


## Misc

Keywords: prompt directory truncate shrink collapse fish

0 comments on commit 9ee7c0c

Please sign in to comment.