From 16ae4e127f6af2f8f3332025ce46d45ab5bcadac Mon Sep 17 00:00:00 2001 From: Pablo Cantero Date: Sun, 26 Jan 2014 10:18:04 -0200 Subject: Adds support capistrano multistage completion --- plugins/capistrano/_capistrano | 53 +++++++++++++++++++++++++++----- plugins/capistrano/capistrano.plugin.zsh | 11 +++++++ 2 files changed, 57 insertions(+), 7 deletions(-) create mode 100644 plugins/capistrano/capistrano.plugin.zsh (limited to 'plugins') diff --git a/plugins/capistrano/_capistrano b/plugins/capistrano/_capistrano index 3cadf3d54..7a74b3732 100644 --- a/plugins/capistrano/_capistrano +++ b/plugins/capistrano/_capistrano @@ -1,10 +1,49 @@ -#compdef cap +#compdef xcap cap #autoload -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 -v --tasks | grep '#' | cut -d " " -f 2 > .cap_tasks~ +# Added `xcap` because `cap` is a reserved word. `cap` completion doesn't work. +# http://zsh.sourceforge.net/Doc/Release/Zsh-Modules.html#The-zsh_002fcap-Module + +local curcontext="$curcontext" state line ret=1 +local -a _configs + +_arguments -C \ + '1: :->cmds' \ + '2:: :->args' && ret=0 + +_cap_tasks() { + if [[ -f config/deploy.rb || -f Capfile ]]; then + if [[ ! -f .cap_tasks~ ]]; then + xcap -v --tasks | awk '{command=$2; $1=$2=$3=""; gsub(/^[ \t\r\n]+/, "", $0); gsub(":", "\\:", command); print command"["$0"]"}' > .cap_tasks~ + fi + + OLD_IFS=$IFS + IFS=$'\n' + _values 'cap commands' $(< .cap_tasks~) + IFS=$OLD_IFS + # zmodload zsh/mapfile + # _values ${(f)mapfile[.cap_tasks~]} fi - compadd `cat .cap_tasks~` -fi +} + +_cap_stages() { + compadd $(find config/deploy -name \*.rb | cut -d/ -f3 | sed s:.rb::g) +} + +case $state in + cmds) + # check if it uses multistage + if [[ -d config/deploy ]]; then + _cap_stages + else + _cap_tasks + fi + ret=0 + ;; + args) + _cap_tasks + ret=0 + ;; +esac + +return ret diff --git a/plugins/capistrano/capistrano.plugin.zsh b/plugins/capistrano/capistrano.plugin.zsh new file mode 100644 index 000000000..9a4a2cc34 --- /dev/null +++ b/plugins/capistrano/capistrano.plugin.zsh @@ -0,0 +1,11 @@ +# Added `xcap` because `cap` is a reserved word. `cap` completion doesn't work. +# http://zsh.sourceforge.net/Doc/Release/Zsh-Modules.html#The-zsh_002fcap-Module + +func xcap() { + if [ -f Gemfile ] + then + bundle exec cap $* + else + cap $* + fi +} -- cgit v1.2.3-70-g09d2 From c9fbfc9f48b25c724265e06f0bce8d737c7ea13b Mon Sep 17 00:00:00 2001 From: Pablo Cantero Date: Fri, 4 Apr 2014 21:20:01 -0300 Subject: Uses `shipit` instead of `xcap` --- plugins/capistrano/_capistrano | 6 +++--- plugins/capistrano/capistrano.plugin.zsh | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'plugins') diff --git a/plugins/capistrano/_capistrano b/plugins/capistrano/_capistrano index 7a74b3732..c181b55ca 100644 --- a/plugins/capistrano/_capistrano +++ b/plugins/capistrano/_capistrano @@ -1,7 +1,7 @@ -#compdef xcap cap +#compdef shipit #autoload -# Added `xcap` because `cap` is a reserved word. `cap` completion doesn't work. +# Added `shipit` because `cap` is a reserved word. `cap` completion doesn't work. # http://zsh.sourceforge.net/Doc/Release/Zsh-Modules.html#The-zsh_002fcap-Module local curcontext="$curcontext" state line ret=1 @@ -14,7 +14,7 @@ _arguments -C \ _cap_tasks() { if [[ -f config/deploy.rb || -f Capfile ]]; then if [[ ! -f .cap_tasks~ ]]; then - xcap -v --tasks | awk '{command=$2; $1=$2=$3=""; gsub(/^[ \t\r\n]+/, "", $0); gsub(":", "\\:", command); print command"["$0"]"}' > .cap_tasks~ + shipit -v --tasks | awk '{command=$2; $1=$2=$3=""; gsub(/^[ \t\r\n]+/, "", $0); gsub(":", "\\:", command); print command"["$0"]"}' > .cap_tasks~ fi OLD_IFS=$IFS diff --git a/plugins/capistrano/capistrano.plugin.zsh b/plugins/capistrano/capistrano.plugin.zsh index 9a4a2cc34..c85eb474c 100644 --- a/plugins/capistrano/capistrano.plugin.zsh +++ b/plugins/capistrano/capistrano.plugin.zsh @@ -1,7 +1,7 @@ -# Added `xcap` because `cap` is a reserved word. `cap` completion doesn't work. +# Added `shipit` because `cap` is a reserved word. `cap` completion doesn't work. # http://zsh.sourceforge.net/Doc/Release/Zsh-Modules.html#The-zsh_002fcap-Module -func xcap() { +func shipit() { if [ -f Gemfile ] then bundle exec cap $* -- cgit v1.2.3-70-g09d2 From 8f9a72aa7b6d23f82b027a28ffe3f3f6cec8c863 Mon Sep 17 00:00:00 2001 From: André König Date: Thu, 18 Sep 2014 19:55:44 +0200 Subject: Moved plugin. --- gulp/gulp.plugin.zsh | 29 ----------------------------- plugins/gulp/gulp.plugin.zsh | 29 +++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 29 deletions(-) delete mode 100644 gulp/gulp.plugin.zsh create mode 100644 plugins/gulp/gulp.plugin.zsh (limited to 'plugins') diff --git a/gulp/gulp.plugin.zsh b/gulp/gulp.plugin.zsh deleted file mode 100644 index 6017c7b60..000000000 --- a/gulp/gulp.plugin.zsh +++ /dev/null @@ -1,29 +0,0 @@ -#!/usr/bin/env zsh - -# -# gulp-autocompletion-zsh -# -# Autocompletion for your gulp.js tasks -# -# Copyright(c) 2014 André König -# MIT Licensed -# - -# -# André König -# Github: https://github.com/akoenig -# Twitter: https://twitter.com/caiifr -# - -# -# Grabs all available tasks from the `gulpfile.js` -# in the current directory. -# -function $$gulp_completion() { - compls=$(grep -Eo "gulp.task\(('(([a-zA-Z0-9]|-)*)',)" gulpfile.js 2>/dev/null | grep -Eo "'(([a-zA-Z0-9]|-)*)'" | sed s/"'"//g | sort) - - completions=(${=compls}) - compadd -- $completions -} - -compdef $$gulp_completion gulp \ No newline at end of file diff --git a/plugins/gulp/gulp.plugin.zsh b/plugins/gulp/gulp.plugin.zsh new file mode 100644 index 000000000..6017c7b60 --- /dev/null +++ b/plugins/gulp/gulp.plugin.zsh @@ -0,0 +1,29 @@ +#!/usr/bin/env zsh + +# +# gulp-autocompletion-zsh +# +# Autocompletion for your gulp.js tasks +# +# Copyright(c) 2014 André König +# MIT Licensed +# + +# +# André König +# Github: https://github.com/akoenig +# Twitter: https://twitter.com/caiifr +# + +# +# Grabs all available tasks from the `gulpfile.js` +# in the current directory. +# +function $$gulp_completion() { + compls=$(grep -Eo "gulp.task\(('(([a-zA-Z0-9]|-)*)',)" gulpfile.js 2>/dev/null | grep -Eo "'(([a-zA-Z0-9]|-)*)'" | sed s/"'"//g | sort) + + completions=(${=compls}) + compadd -- $completions +} + +compdef $$gulp_completion gulp \ No newline at end of file -- cgit v1.2.3-70-g09d2 From 0c77e4ba6f52642d7f94e6cd72c869ad2e47c62f Mon Sep 17 00:00:00 2001 From: spacewander Date: Mon, 15 Dec 2014 12:41:22 +0800 Subject: update git-extras plugin --- plugins/git-extras/git-extras.plugin.zsh | 194 +++++++++++++++++++------------ 1 file changed, 120 insertions(+), 74 deletions(-) (limited to 'plugins') diff --git a/plugins/git-extras/git-extras.plugin.zsh b/plugins/git-extras/git-extras.plugin.zsh index 8419166ab..d91c1af81 100644 --- a/plugins/git-extras/git-extras.plugin.zsh +++ b/plugins/git-extras/git-extras.plugin.zsh @@ -3,19 +3,20 @@ # Description # ----------- # -# Completion script for git-extras (http://github.com/visionmedia/git-extras). +# Completion script for git-extras (http://github.com/tj/git-extras). # # ------------------------------------------------------------------------------ # Authors # ------- # # * Alexis GRIMALDI (https://github.com/agrimaldi) +# * spacewander (https://github.com/spacewander) # # ------------------------------------------------------------------------------ # Inspirations # ----------- # -# * git-extras (http://github.com/visionmedia/git-extras) +# * git-extras (http://github.com/tj/git-extras) # * git-flow-completion (http://github.com/bobthecow/git-flow-completion) # # ------------------------------------------------------------------------------ @@ -30,10 +31,21 @@ __git_command_successful () { } +__git_commits() { + declare -A commits + git log --oneline -15 | sed 's/\([[:alnum:]]\{7\}\) /\1:/' | while read commit + do + hash=$(echo $commit | cut -d':' -f1) + commits[$hash]="$commit" + done + local ret=1 + _describe -t commits commit commits && ret=0 +} + __git_tag_names() { local expl declare -a tag_names - tag_names=(${${(f)"$(_call_program branchrefs git for-each-ref --format='"%(refname)"' refs/tags 2>/dev/null)"}#refs/tags/}) + tag_names=(${${(f)"$(_call_program tags git for-each-ref --format='"%(refname)"' refs/tags 2>/dev/null)"}#refs/tags/}) __git_command_successful || return _wanted tag-names expl tag-name compadd $* - $tag_names } @@ -47,31 +59,27 @@ __git_branch_names() { _wanted branch-names expl branch-name compadd $* - $branch_names } - -__git_feature_branch_names() { +__git_specific_branch_names() { local expl declare -a branch_names - branch_names=(${${(f)"$(_call_program branchrefs git for-each-ref --format='"%(refname)"' refs/heads/feature 2>/dev/null)"}#refs/heads/feature/}) + branch_names=(${${(f)"$(_call_program branchrefs git for-each-ref --format='"%(refname)"' refs/heads/"$1" 2>/dev/null)"}#refs/heads/$1/}) __git_command_successful || return _wanted branch-names expl branch-name compadd $* - $branch_names } +__git_feature_branch_names() { + __git_specific_branch_names 'feature' +} + + __git_refactor_branch_names() { - local expl - declare -a branch_names - branch_names=(${${(f)"$(_call_program branchrefs git for-each-ref --format='"%(refname)"' refs/heads/refactor 2>/dev/null)"}#refs/heads/refactor/}) - __git_command_successful || return - _wanted branch-names expl branch-name compadd $* - $branch_names + __git_specific_branch_names 'refactor' } __git_bug_branch_names() { - local expl - declare -a branch_names - branch_names=(${${(f)"$(_call_program branchrefs git for-each-ref --format='"%(refname)"' refs/heads/bug 2>/dev/null)"}#refs/heads/bug/}) - __git_command_successful || return - _wanted branch-names expl branch-name compadd $* - $branch_names + __git_specific_branch_names 'bug' } @@ -92,19 +100,43 @@ __git_author_names() { _wanted author-names expl author-name compadd $* - $author_names } +# subcommands -_git-changelog() { - _arguments \ - '(-l --list)'{-l,--list}'[list commits]' \ +_git-bug() { + local curcontext=$curcontext state line ret=1 + declare -A opt_args + + _arguments -C \ + ': :->command' \ + '*:: :->option-or-argument' && ret=0 + + case $state in + (command) + declare -a commands + commands=( + 'finish:merge bug into the current branch' + ) + _describe -t commands command commands && ret=0 + ;; + (option-or-argument) + curcontext=${curcontext%:*}-$line[1]: + case $line[1] in + (finish) + _arguments -C \ + ':branch-name:__git_bug_branch_names' + ;; + esac + esac } -_git-effort() { +_git-changelog() { _arguments \ - '--above[ignore file with less than x commits]' \ + '(-l --list)'{-l,--list}'[list commits]' \ } + _git-contrib() { _arguments \ ':author:__git_author_names' @@ -135,6 +167,11 @@ _git-delete-tag() { } +_git-effort() { + _arguments \ + '--above[ignore file with less than x commits]' +} + _git-extras() { local curcontext=$curcontext state line ret=1 declare -A opt_args @@ -154,20 +191,7 @@ _git-extras() { esac _arguments \ - '(-v --version)'{-v,--version}'[show current version]' \ -} - - -_git-graft() { - _arguments \ - ':src-branch-name:__git_branch_names' \ - ':dest-branch-name:__git_branch_names' -} - - -_git-squash() { - _arguments \ - ':branch-name:__git_branch_names' + '(-v --version)'{-v,--version}'[show current version]' } @@ -199,6 +223,25 @@ _git-feature() { } +_git-graft() { + _arguments \ + ':src-branch-name:__git_branch_names' \ + ':dest-branch-name:__git_branch_names' +} + + +_git-ignore() { + _arguments -C \ + '(--local -l)'{--local,-l}'[show local gitignore]' \ + '(--global -g)'{--global,-g}'[show global gitignore]' +} + +_git-missing() { + _arguments \ + ':first-branch-name:__git_branch_names' \ + ':second-branch-name:__git_branch_names' +} + _git-refactor() { local curcontext=$curcontext state line ret=1 declare -A opt_args @@ -227,59 +270,62 @@ _git-refactor() { } -_git-bug() { - local curcontext=$curcontext state line ret=1 - declare -A opt_args - - _arguments -C \ - ': :->command' \ - '*:: :->option-or-argument' && ret=0 +_git-squash() { + _arguments \ + ':branch-name:__git_branch_names' +} - case $state in - (command) - declare -a commands - commands=( - 'finish:merge bug into the current branch' - ) - _describe -t commands command commands && ret=0 - ;; - (option-or-argument) - curcontext=${curcontext%:*}-$line[1]: - case $line[1] in - (finish) - _arguments -C \ - ':branch-name:__git_bug_branch_names' - ;; - esac - esac +_git-summary() { + _arguments '--line[summarize with lines other than commits]' + __git_commits } +_git-undo(){ + _arguments -C \ + '(--soft -s)'{--soft,-s}'[only rolls back the commit but changes remain un-staged]' \ + '(--hard -h)'{--hard,-h}'[wipes your commit(s)]' +} + zstyle ':completion:*:*:git:*' user-commands \ + alias:'define, search and show aliases' \ + archive-file:'export the current HEAD of the git repository to a archive' \ + back:'undo and stage latest commits' \ + bug:'create a bug branch' \ changelog:'populate changelog file with commits since the previous tag' \ + commits-since:'list commits since a given date' \ contrib:'display author contributions' \ count:'count commits' \ + create-branch:'create local and remote branch' \ delete-branch:'delete local and remote branch' \ + delete-merged-brancees:'delete merged branches'\ delete-submodule:'delete submodule' \ delete-tag:'delete local and remote tag' \ + effort:'display effort statistics' \ extras:'git-extras' \ - graft:'merge commits from source branch to destination branch' \ - squash:'merge commits from source branch into the current one as a single commit' \ feature:'create a feature branch' \ - refactor:'create a refactor branch' \ - bug:'create a bug branch' \ - summary:'repository summary' \ - effort:'display effort statistics' \ - repl:'read-eval-print-loop' \ - commits-since:'list commits since a given date' \ - release:'release commit with the given tag' \ - alias:'define, search and show aliases' \ + fork:'fork a repo on github' \ + fresh-branch:'create empty local branch' \ + gh-pages:'create the GitHub Pages branch' \ + graft:'merge commits from source branch to destination branch' \ ignore:'add patterns to .gitignore' \ info:'show info about the repository' \ - create-branch:'create local and remote branch' \ - fresh-branch:'create empty local branch' \ - undo:'remove the latest commit' \ + local-commits:'list unpushed commits on the local branch' \ + lock:'lock a file excluded from version control' \ + locked:'ls files that have been locked' \ + missing:'show commits missing from another branch' \ + pr:'checks out a pull request locally' \ + rebase-patch:'rebases a patch' \ + refactor:'create a refactor branch' \ + release:'commit, tag and push changes to the repository' \ + rename-tag:'rename a tag' \ + repl:'read-eval-print-loop' \ + reset-file:'reset one file' \ + root:'show path of root' \ setup:'setup a git repository' \ + show-tree:'show branch tree of commit history' \ + squash:'merge commits from source branch into the current one as a single commit' \ + summary:'repository summary' \ touch:'one step creation of new files' \ - obliterate:'Completely remove a file from the repository, including past commits and tags' \ - local-commits:'list unpushed commits on the local branch' \ + undo:'remove the latest commit' \ + unlock:'unlock a file excluded from version control' -- cgit v1.2.3-70-g09d2 From a9e97e5d2da90cf3e2b4575888fe585972ebcc74 Mon Sep 17 00:00:00 2001 From: Andrew Janke Date: Sat, 14 Feb 2015 19:05:27 -0500 Subject: Remove terminalapp plugin and fold its implementation in to lib/termsupport.zsh. Replaces the redundant Terminal.app support that was recently added to termsupport. --- lib/termsupport.zsh | 43 +++++++++++++++++++++++------- plugins/terminalapp/terminalapp.plugin.zsh | 39 --------------------------- 2 files changed, 33 insertions(+), 49 deletions(-) delete mode 100644 plugins/terminalapp/terminalapp.plugin.zsh (limited to 'plugins') diff --git a/lib/termsupport.zsh b/lib/termsupport.zsh index e1c2e2f93..da74dfdba 100644 --- a/lib/termsupport.zsh +++ b/lib/termsupport.zsh @@ -53,14 +53,37 @@ precmd_functions+=(omz_termsupport_precmd) preexec_functions+=(omz_termsupport_preexec) -# Runs before showing the prompt, to update the current directory in Terminal.app -function omz_termsupport_cwd { - # Notify Terminal.app of current directory using undocumented OSC sequence - # found in OS X 10.9 and 10.10's /etc/bashrc - if [[ $TERM_PROGRAM == Apple_Terminal ]] && [[ -z $INSIDE_EMACS ]]; then - local PWD_URL="file://$HOSTNAME${PWD// /%20}" - printf '\e]7;%s\a' "$PWD_URL" - fi -} +# Keep Apple Terminal.app's current working directory updated +# Based on this answer: http://superuser.com/a/315029 + +if [[ "$TERM_PROGRAM" == "Apple_Terminal" ]] && [[ -z "$INSIDE_EMACS" ]]; then + # Emits the control sequence to notify Terminal.app of the cwd + function update_terminalapp_cwd() { + # Identify the directory using a "file:" scheme URL, including + # the host name to disambiguate local vs. remote paths. + + # Percent-encode the pathname. + local URL_PATH='' + { + # Use LANG=C to process text byte-by-byte. + local i ch hexch LANG=C + for ((i = 1; i <= ${#PWD}; ++i)); do + ch="$PWD[i]" + if [[ "$ch" =~ [/._~A-Za-z0-9-] ]]; then + URL_PATH+="$ch" + else + hexch=$(printf "%02X" "'$ch") + URL_PATH+="%$hexch" + fi + done + } + + local PWD_URL="file://$HOST$URL_PATH" + printf '\e]7;%s\a' "$PWD_URL" + } -precmd_functions+=(omz_termsupport_cwd) + # Use a precmd hook instead of a chpwd hook to avoid contaminating output + precmd_functions+=(update_terminalapp_cwd) + # Run once to get initial cwd set + update_terminalapp_cwd +fi diff --git a/plugins/terminalapp/terminalapp.plugin.zsh b/plugins/terminalapp/terminalapp.plugin.zsh deleted file mode 100644 index 6e47ee188..000000000 --- a/plugins/terminalapp/terminalapp.plugin.zsh +++ /dev/null @@ -1,39 +0,0 @@ -# Set Apple Terminal.app resume directory -# based on this answer: http://superuser.com/a/315029 -# 2012-10-26: (javageek) Changed code using the updated answer - -# Tell the terminal about the working directory whenever it changes. -if [[ "$TERM_PROGRAM" == "Apple_Terminal" ]] && [[ -z "$INSIDE_EMACS" ]]; then - update_terminal_cwd() { - # Identify the directory using a "file:" scheme URL, including - # the host name to disambiguate local vs. remote paths. - - # Percent-encode the pathname. - local URL_PATH='' - { - # Use LANG=C to process text byte-by-byte. - local i ch hexch LANG=C - for ((i = 1; i <= ${#PWD}; ++i)); do - ch="$PWD[i]" - if [[ "$ch" =~ [/._~A-Za-z0-9-] ]]; then - URL_PATH+="$ch" - else - hexch=$(printf "%02X" "'$ch") - URL_PATH+="%$hexch" - fi - done - } - - local PWD_URL="file://$HOST$URL_PATH" - #echo "$PWD_URL" # testing - printf '\e]7;%s\a' "$PWD_URL" - } - - # Register the function so it is called whenever the working - # directory changes. - autoload add-zsh-hook - add-zsh-hook precmd update_terminal_cwd - - # Tell the terminal about the initial directory. - update_terminal_cwd -fi -- cgit v1.2.3-70-g09d2 From 5f907817836ea1186120b9165556d7894f2c8481 Mon Sep 17 00:00:00 2001 From: Andrew Janke Date: Thu, 19 Feb 2015 23:53:48 -0500 Subject: plugins/chucknorris: Add automatic updating of the compiled fortune data file. Use local variable for readability, and anonymous function to provide a scope for the local variable. --- plugins/chucknorris/chucknorris.plugin.zsh | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'plugins') diff --git a/plugins/chucknorris/chucknorris.plugin.zsh b/plugins/chucknorris/chucknorris.plugin.zsh index 096364633..fd52f2b78 100644 --- a/plugins/chucknorris/chucknorris.plugin.zsh +++ b/plugins/chucknorris/chucknorris.plugin.zsh @@ -1,6 +1,12 @@ -if [ ! -f $ZSH/plugins/chucknorris/fortunes/chucknorris.dat ]; then - strfile $ZSH/plugins/chucknorris/fortunes/chucknorris $ZSH/plugins/chucknorris/fortunes/chucknorris.dat -fi +() { + # Automatically generate or update Chuck's compiled fortune data file + local fdir=$ZSH/plugins/chucknorris/fortunes + if [[ ! -f $fdir/chucknorris.dat ]] || [[ $fdir/chucknorris.dat -ot $fdir/chucknorris ]]; then + strfile $fdir/chucknorris $fdir/chucknorris.dat + fi + + # Aliases + alias chuck="fortune -a $fdir" + alias chuck_cow="chuck | cowthink" +} -alias chuck="fortune -a $ZSH/plugins/chucknorris/fortunes" -alias chuck_cow="chuck | cowthink" -- cgit v1.2.3-70-g09d2 From cb0718c14785de7cf808ef4e2d7ddf5ab3eda8e0 Mon Sep 17 00:00:00 2001 From: Andrew Janke Date: Sat, 21 Feb 2015 18:24:07 -0500 Subject: chucknorris: locate plugin dir using $0 instead of hardcoded $ZSH --- plugins/chucknorris/chucknorris.plugin.zsh | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'plugins') diff --git a/plugins/chucknorris/chucknorris.plugin.zsh b/plugins/chucknorris/chucknorris.plugin.zsh index fd52f2b78..1cdc945d1 100644 --- a/plugins/chucknorris/chucknorris.plugin.zsh +++ b/plugins/chucknorris/chucknorris.plugin.zsh @@ -1,12 +1,11 @@ -() { - # Automatically generate or update Chuck's compiled fortune data file - local fdir=$ZSH/plugins/chucknorris/fortunes - if [[ ! -f $fdir/chucknorris.dat ]] || [[ $fdir/chucknorris.dat -ot $fdir/chucknorris ]]; then - strfile $fdir/chucknorris $fdir/chucknorris.dat - fi +# Automatically generate or update Chuck's compiled fortune data file +DIR=${0:h}/fortunes +if [[ ! -f $DIR/chucknorris.dat ]] || [[ $DIR/chucknorris.dat -ot $DIR/chucknorris ]]; then + strfile $DIR/chucknorris $DIR/chucknorris.dat +fi - # Aliases - alias chuck="fortune -a $fdir" - alias chuck_cow="chuck | cowthink" -} +# Aliases +alias chuck="fortune -a $DIR" +alias chuck_cow="chuck | cowthink" +unset DIR \ No newline at end of file -- cgit v1.2.3-70-g09d2 From 10c92cc083203d757a257f8d13731e2556a99246 Mon Sep 17 00:00:00 2001 From: Eubene Sa Date: Thu, 11 Jun 2015 01:09:44 -0700 Subject: Updates to ember-cli plugin --- plugins/ember-cli/README.md | 31 ++++++++++++++----------------- plugins/ember-cli/ember-cli.plugin.zsh | 7 ++----- 2 files changed, 16 insertions(+), 22 deletions(-) (limited to 'plugins') diff --git a/plugins/ember-cli/README.md b/plugins/ember-cli/README.md index d1dedf884..482c347d2 100644 --- a/plugins/ember-cli/README.md +++ b/plugins/ember-cli/README.md @@ -1,22 +1,19 @@ -# Ember-cli +# Ember CLI -**Maintainer:** [BilalBudhani](http://www.github.com/BilalBudhani) +**Maintainers:** [BilalBudhani](http://www.github.com/BilalBudhani), [eubenesa](http://www.github.com/eubenesa) -Ember-cli (http://www.ember-cli.com/) +Ember CLI (http://www.ember-cli.com/) ### List of Aliases -alias es='ember serve' -alias ea='ember addon' -alias eb='ember build' -alias ed='ember destroy' -alias eg='ember generate' -alias eh='ember help' -alias ein='ember init' -alias eia='ember install:addon' -alias eib='ember install:bower' -alias ein='ember install:npm' -alias ei='ember install' -alias et='ember test' -alias eu='ember update' -alias ev='ember version' + alias es='ember serve' + alias ea='ember addon' + alias eb='ember build' + alias ed='ember destroy' + alias eg='ember generate' + alias eh='ember help' + alias ein='ember init' + alias ei='ember install' + alias et='ember test' + alias eu='ember update' + alias ev='ember version' diff --git a/plugins/ember-cli/ember-cli.plugin.zsh b/plugins/ember-cli/ember-cli.plugin.zsh index 044a2c043..a0f346829 100644 --- a/plugins/ember-cli/ember-cli.plugin.zsh +++ b/plugins/ember-cli/ember-cli.plugin.zsh @@ -1,5 +1,5 @@ -# Ember ClI -# visit http://www.ember-cli.com/ to view user guid +# Ember CLI +# Visit http://www.ember-cli.com/ to view user guide alias es='ember serve' alias ea='ember addon' @@ -8,9 +8,6 @@ alias ed='ember destroy' alias eg='ember generate' alias eh='ember help' alias ein='ember init' -alias eia='ember install:addon' -alias eib='ember install:bower' -alias ein='ember install:npm' alias ei='ember install' alias et='ember test' alias eu='ember update' -- cgit v1.2.3-70-g09d2 From 689b5ab3c8c8bf30ee63cafb8401d7d95e41f359 Mon Sep 17 00:00:00 2001 From: Andrew Janke Date: Fri, 26 Jun 2015 01:48:17 -0400 Subject: osx: fix tab* functions so cd works in iTerm2, exit status is correct, and error messages are not discarded. --- plugins/osx/osx.plugin.zsh | 84 +++++++++++++++++++++++++--------------------- 1 file changed, 45 insertions(+), 39 deletions(-) (limited to 'plugins') diff --git a/plugins/osx/osx.plugin.zsh b/plugins/osx/osx.plugin.zsh index a6e3a83e6..2cbb95977 100644 --- a/plugins/osx/osx.plugin.zsh +++ b/plugins/osx/osx.plugin.zsh @@ -5,29 +5,35 @@ # VERSION: 1.1.0 # ------------------------------------------------------------------------------ -function tab() { - local command="cd \\\"$PWD\\\"; clear; " - (( $# > 0 )) && command="${command}; $*" - - the_app=$( +function _omz_osx_get_frontmost_app() { + local the_app=$( osascript 2>/dev/null </dev/null < 0 )) && command="${command}; $*" + + local the_app=$(_omz_osx_get_frontmost_app) + + if [[ "$the_app" == 'Terminal' ]]; then + # Discarding stdout to quash "tab N of window id XXX" output + osascript >/dev/null </dev/null < 0 )) && command="${command}; $*" - the_app=$( - osascript 2>/dev/null </dev/null <&2 + false + + fi } function split_tab() { - local command="cd \\\"$PWD\\\"" + local command="cd \\\"$PWD\\\"; clear" (( $# > 0 )) && command="${command}; $*" - the_app=$( - osascript 2>/dev/null </dev/null <&2 + false + + fi } function pfd() { -- cgit v1.2.3-70-g09d2 From efb04d66a0bc775dfb95f2bbc648935004212d48 Mon Sep 17 00:00:00 2001 From: Zhiye Li Date: Tue, 30 Jun 2015 17:50:01 -0500 Subject: add git alias `gcam` - git commit -am add git alias `gcam` - `git commit -am` --- plugins/git/git.plugin.zsh | 1 + 1 file changed, 1 insertion(+) (limited to 'plugins') diff --git a/plugins/git/git.plugin.zsh b/plugins/git/git.plugin.zsh index cc6eb1031..ea651d12f 100644 --- a/plugins/git/git.plugin.zsh +++ b/plugins/git/git.plugin.zsh @@ -68,6 +68,7 @@ alias gc!='git commit -v --amend' alias gca='git commit -v -a' alias gca!='git commit -v -a --amend' alias gcan!='git commit -v -a -s --no-edit --amend' +alias gcam='git commit -a -m' alias gcb='git checkout -b' alias gcf='git config --list' alias gcl='git clone --recursive' -- cgit v1.2.3-70-g09d2 From 2e92ff8ae5e6ddbac5040bb235518a4337aeb983 Mon Sep 17 00:00:00 2001 From: nextgenthemes Date: Thu, 2 Jul 2015 17:33:30 +0200 Subject: Adds agar = apt-get autoremove Since #3902 lacks the auto-completion I made a PR for this as well. Also fixes some typos. --- plugins/ubuntu/ubuntu.plugin.zsh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'plugins') diff --git a/plugins/ubuntu/ubuntu.plugin.zsh b/plugins/ubuntu/ubuntu.plugin.zsh index 0211d3374..85db3ce19 100644 --- a/plugins/ubuntu/ubuntu.plugin.zsh +++ b/plugins/ubuntu/ubuntu.plugin.zsh @@ -28,6 +28,7 @@ compdef _ppap ppap='sudo ppa-purge' alias ag='sudo apt-get' # age - but without sudo alias aga='sudo apt-get autoclean' # aac +alias agar='sudo apt-get autoremove' alias agb='sudo apt-get build-dep' # abd alias agc='sudo apt-get clean' # adc alias agd='sudo apt-get dselect-upgrade' # ads @@ -41,6 +42,7 @@ alias aguu='sudo apt-get update && sudo apt-get upgrade' #adg compdef _ag ag='sudo apt-get' compdef _aga aga='sudo apt-get autoclean' +compdef _agar agar='sudo apt-get autoremove' compdef _agb agb='sudo apt-get build-dep' compdef _agc agc='sudo apt-get clean' compdef _agd agd='sudo apt-get dselect-upgrade' @@ -65,7 +67,7 @@ alias mydeb='time dpkg-buildpackage -rfakeroot -us -uc' # apt-add-repository with automatic install/upgrade of the desired package # Usage: aar ppa:xxxxxx/xxxxxx [packagename] -# If packagename is not given as 2nd arument the function will ask for it and guess the defaupt by taking +# If packagename is not given as 2nd argument the function will ask for it and guess the default by taking # the part after the / from the ppa name wich is sometimes the right name for the package you want to install aar() { if [ -n "$2" ]; then -- cgit v1.2.3-70-g09d2 From a2e01e9a87c0d120482cc7bbe21ccab21bf71fb1 Mon Sep 17 00:00:00 2001 From: Andrew Janke Date: Thu, 2 Jul 2015 20:27:48 -0400 Subject: chucknorris: check for strfile dependency Gives a better error message than "command not found: strfile", because it's not obvious to many users that strfile is part of fortune. Also handles the weird /usr/sbin install location for strfile on Cygwin. --- plugins/chucknorris/chucknorris.plugin.zsh | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) (limited to 'plugins') diff --git a/plugins/chucknorris/chucknorris.plugin.zsh b/plugins/chucknorris/chucknorris.plugin.zsh index 1cdc945d1..1dbb04ef0 100644 --- a/plugins/chucknorris/chucknorris.plugin.zsh +++ b/plugins/chucknorris/chucknorris.plugin.zsh @@ -1,11 +1,28 @@ +# chucknorris: Chuck Norris fortunes + # Automatically generate or update Chuck's compiled fortune data file -DIR=${0:h}/fortunes +# $0 must be used outside a local function. This variable name is unlikly to collide. +CHUCKNORRIS_PLUGIN_DIR=${0:h} + +() { +local DIR=$CHUCKNORRIS_PLUGIN_DIR/fortunes if [[ ! -f $DIR/chucknorris.dat ]] || [[ $DIR/chucknorris.dat -ot $DIR/chucknorris ]]; then - strfile $DIR/chucknorris $DIR/chucknorris.dat + # For some reason, Cygwin puts strfile in /usr/sbin, which is not on the path by default + local strfile=strfile + if ! which strfile &>/dev/null && [[ -f /usr/sbin/strfile ]]; then + strfile=/usr/sbin/strfile + fi + if which $strfile &> /dev/null; then + $strfile $DIR/chucknorris $DIR/chucknorris.dat >/dev/null + else + echo "[oh-my-zsh] chucknorris depends on strfile, which is not installed" >&2 + echo "[oh-my-zsh] strfile is often provided as part of the 'fortune' package" >&2 + fi fi # Aliases alias chuck="fortune -a $DIR" alias chuck_cow="chuck | cowthink" +} -unset DIR \ No newline at end of file +unset CHUCKNORRIS_PLUGIN_DIR -- cgit v1.2.3-70-g09d2 From b1da3bbc6f5e26cd0b06cd858e696d4f47f340d2 Mon Sep 17 00:00:00 2001 From: Patryk Małek Date: Mon, 6 Jul 2015 22:00:53 +0200 Subject: Adding ability to add JIRA_PREFIX as an env variable (e.g. in .zshrc) and minor refactor to bash curly variable braces --- plugins/jira/jira.plugin.zsh | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'plugins') diff --git a/plugins/jira/jira.plugin.zsh b/plugins/jira/jira.plugin.zsh index ca540c84c..a22e19363 100644 --- a/plugins/jira/jira.plugin.zsh +++ b/plugins/jira/jira.plugin.zsh @@ -1,6 +1,7 @@ # To use: add a .jira-url file in the base of your project # You can also set JIRA_URL in your .zshrc or put .jira-url in your home directory -# .jira-url in the current directory takes precedence +# .jira-url in the current directory takes precedence. The same goes with .jira-prefix +# and JIRA_PREFIX. # # If you use Rapid Board, set: #JIRA_RAPID_BOARD="true" @@ -22,8 +23,8 @@ open_jira_issue () { jira_url=$(cat .jira-url) elif [ -f ~/.jira-url ]; then jira_url=$(cat ~/.jira-url) - elif [[ "x$JIRA_URL" != "x" ]]; then - jira_url=$JIRA_URL + elif [[ "${JIRA_URL}" != "" ]]; then + jira_url=${JIRA_URL} else echo "JIRA url is not specified anywhere." return 1 @@ -33,6 +34,8 @@ open_jira_issue () { jira_prefix=$(cat .jira-prefix) elif [ -f ~/.jira-prefix ]; then jira_prefix=$(cat ~/.jira-prefix) + elif [[ "${JIRA_PREFIX}" != "" ]]; then + jira_prefix=${JIRA_PREFIX} else jira_prefix="" fi @@ -51,7 +54,7 @@ open_jira_issue () { echo "Opening issue #$1" fi - if [[ "x$JIRA_RAPID_BOARD" = "xtrue" ]]; then + if [[ "$JIRA_RAPID_BOARD" = "true" ]]; then $open_cmd "$jira_url/issues/$jira_prefix$1$addcomment" else $open_cmd "$jira_url/browse/$jira_prefix$1$addcomment" @@ -61,7 +64,7 @@ open_jira_issue () { jira_name () { if [[ -z "$1" ]]; then - if [[ "x${JIRA_NAME}" != "x" ]]; then + if [[ "${JIRA_NAME}" != "" ]]; then jira_name=${JIRA_NAME} else echo "JIRA_NAME not specified" -- cgit v1.2.3-70-g09d2 From dff03743efa3f49f4ba4b1214d97f9746bb1a0d4 Mon Sep 17 00:00:00 2001 From: Mohnish Jadwani Date: Tue, 7 Jul 2015 09:47:49 +0530 Subject: adds an alias to search for the rails routes that pattern match a string --- plugins/rails/rails.plugin.zsh | 1 + 1 file changed, 1 insertion(+) (limited to 'plugins') diff --git a/plugins/rails/rails.plugin.zsh b/plugins/rails/rails.plugin.zsh index 6824836fc..097578e23 100644 --- a/plugins/rails/rails.plugin.zsh +++ b/plugins/rails/rails.plugin.zsh @@ -58,6 +58,7 @@ alias rdmtc='rake db:migrate db:test:clone' alias rlc='rake log:clear' alias rn='rake notes' alias rr='rake routes' +alias rrg='rake routes | grep ' # legacy stuff alias sstat='thin --stats "/thin/stats" start' -- cgit v1.2.3-70-g09d2 From 750de22972bfa38003d38ce3a13f46bd7e41807d Mon Sep 17 00:00:00 2001 From: Headless Date: Tue, 7 Jul 2015 15:44:35 +0300 Subject: rails rake test --- plugins/rails/rails.plugin.zsh | 1 + 1 file changed, 1 insertion(+) (limited to 'plugins') diff --git a/plugins/rails/rails.plugin.zsh b/plugins/rails/rails.plugin.zsh index 6824836fc..4c250369b 100644 --- a/plugins/rails/rails.plugin.zsh +++ b/plugins/rails/rails.plugin.zsh @@ -58,6 +58,7 @@ alias rdmtc='rake db:migrate db:test:clone' alias rlc='rake log:clear' alias rn='rake notes' alias rr='rake routes' +alias rt='rake test' # legacy stuff alias sstat='thin --stats "/thin/stats" start' -- cgit v1.2.3-70-g09d2 From 88a30a3e2f3089556fe40c719f4cbed8426a144e Mon Sep 17 00:00:00 2001 From: Patryk Małek Date: Tue, 7 Jul 2015 18:50:23 +0200 Subject: Changing string comparison for more zsh-like --- plugins/jira/jira.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins') diff --git a/plugins/jira/jira.plugin.zsh b/plugins/jira/jira.plugin.zsh index a22e19363..042fcd7a4 100644 --- a/plugins/jira/jira.plugin.zsh +++ b/plugins/jira/jira.plugin.zsh @@ -54,7 +54,7 @@ open_jira_issue () { echo "Opening issue #$1" fi - if [[ "$JIRA_RAPID_BOARD" = "true" ]]; then + if [[ "$JIRA_RAPID_BOARD" == "true" ]]; then $open_cmd "$jira_url/issues/$jira_prefix$1$addcomment" else $open_cmd "$jira_url/browse/$jira_prefix$1$addcomment" -- cgit v1.2.3-70-g09d2 From 1e99168627eef4c61114cb0572047473b7cb56be Mon Sep 17 00:00:00 2001 From: Patryk Małek Date: Tue, 7 Jul 2015 19:56:22 +0200 Subject: Changing indents to be more consistent (2 spaces) --- plugins/jira/jira.plugin.zsh | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) (limited to 'plugins') diff --git a/plugins/jira/jira.plugin.zsh b/plugins/jira/jira.plugin.zsh index 042fcd7a4..769bf2367 100644 --- a/plugins/jira/jira.plugin.zsh +++ b/plugins/jira/jira.plugin.zsh @@ -76,24 +76,24 @@ jira_name () { } jira_query () { - verb="$1" - if [[ "${verb}" = "reported" ]]; then - lookup=reporter - preposition=by - elif [[ "${verb}" = "assigned" ]]; then - lookup=assignee - preposition=to - else - echo "not a valid lookup $verb" - return 1 - fi - shift 1 - jira_name $@ - if [[ $? = 1 ]]; then - return 1 - fi - echo "Browsing issues ${verb} ${preposition} ${jira_name}" - $open_cmd "${jira_url}/secure/IssueNavigator.jspa?reset=true&jqlQuery=${lookup}+%3D+%22${jira_name}%22+AND+resolution+%3D+unresolved+ORDER+BY+priority+DESC%2C+created+ASC" + verb="$1" + if [[ "${verb}" = "reported" ]]; then + lookup=reporter + preposition=by + elif [[ "${verb}" = "assigned" ]]; then + lookup=assignee + preposition=to + else + echo "not a valid lookup $verb" + return 1 + fi + shift 1 + jira_name $@ + if [[ $? = 1 ]]; then + return 1 + fi + echo "Browsing issues ${verb} ${preposition} ${jira_name}" + $open_cmd "${jira_url}/secure/IssueNavigator.jspa?reset=true&jqlQuery=${lookup}+%3D+%22${jira_name}%22+AND+resolution+%3D+unresolved+ORDER+BY+priority+DESC%2C+created+ASC" } alias jira='open_jira_issue' -- cgit v1.2.3-70-g09d2 From 37f45eb621b04a1286ac1667b7474111e6e0b4ce Mon Sep 17 00:00:00 2001 From: Patryk Małek Date: Tue, 7 Jul 2015 20:03:58 +0200 Subject: Making variables local in jira plugin --- plugins/jira/jira.plugin.zsh | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'plugins') diff --git a/plugins/jira/jira.plugin.zsh b/plugins/jira/jira.plugin.zsh index 769bf2367..7839e2a80 100644 --- a/plugins/jira/jira.plugin.zsh +++ b/plugins/jira/jira.plugin.zsh @@ -19,6 +19,7 @@ open_jira_issue () { open_cmd='xdg-open' fi + local jira_url if [ -f .jira-url ]; then jira_url=$(cat .jira-url) elif [ -f ~/.jira-url ]; then @@ -30,6 +31,7 @@ open_jira_issue () { return 1 fi + local jira_prefix if [ -f .jira-prefix ]; then jira_prefix=$(cat .jira-prefix) elif [ -f ~/.jira-prefix ]; then @@ -45,7 +47,7 @@ open_jira_issue () { $open_cmd "${jira_url}/secure/CreateIssue!default.jspa" elif [[ "$1" = "assigned" || "$1" = "reported" ]]; then jira_query $@ - else + else local addcomment='' if [[ "$2" == "m" ]]; then addcomment="#add-comment" @@ -53,11 +55,11 @@ open_jira_issue () { else echo "Opening issue #$1" fi - + if [[ "$JIRA_RAPID_BOARD" == "true" ]]; then - $open_cmd "$jira_url/issues/$jira_prefix$1$addcomment" + $open_cmd "$jira_url/issues/$jira_prefix$1$addcomment" else - $open_cmd "$jira_url/browse/$jira_prefix$1$addcomment" + $open_cmd "$jira_url/browse/$jira_prefix$1$addcomment" fi fi } @@ -76,7 +78,11 @@ jira_name () { } jira_query () { + local jira_name + local verb verb="$1" + local lookup + local preposition if [[ "${verb}" = "reported" ]]; then lookup=reporter preposition=by -- cgit v1.2.3-70-g09d2 From b1772c5333fcc43610ade75384d9cf87c8ccde61 Mon Sep 17 00:00:00 2001 From: Patryk Małek Date: Tue, 7 Jul 2015 20:07:13 +0200 Subject: More consistent curly braces variables --- plugins/jira/jira.plugin.zsh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'plugins') diff --git a/plugins/jira/jira.plugin.zsh b/plugins/jira/jira.plugin.zsh index 7839e2a80..566e1f1f4 100644 --- a/plugins/jira/jira.plugin.zsh +++ b/plugins/jira/jira.plugin.zsh @@ -57,9 +57,9 @@ open_jira_issue () { fi if [[ "$JIRA_RAPID_BOARD" == "true" ]]; then - $open_cmd "$jira_url/issues/$jira_prefix$1$addcomment" + $open_cmd "${jira_url}/issues/${jira_prefix}${1}${addcomment}" else - $open_cmd "$jira_url/browse/$jira_prefix$1$addcomment" + $open_cmd "${jira_url}/browse/${jira_prefix}${1}${addcomment}" fi fi } -- cgit v1.2.3-70-g09d2 From ad4675cb0a8f732abef7b9a2b3df2141afbf79aa Mon Sep 17 00:00:00 2001 From: Patryk Małek Date: Tue, 7 Jul 2015 20:26:00 +0200 Subject: Concise local variables declarations --- plugins/jira/jira.plugin.zsh | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'plugins') diff --git a/plugins/jira/jira.plugin.zsh b/plugins/jira/jira.plugin.zsh index 566e1f1f4..22984549b 100644 --- a/plugins/jira/jira.plugin.zsh +++ b/plugins/jira/jira.plugin.zsh @@ -78,11 +78,8 @@ jira_name () { } jira_query () { - local jira_name - local verb - verb="$1" - local lookup - local preposition + local verb="$1" + local jira_name lookup preposition if [[ "${verb}" = "reported" ]]; then lookup=reporter preposition=by -- cgit v1.2.3-70-g09d2 From 1e8196de8289a69268a9631ddf4d3b3519ade5c1 Mon Sep 17 00:00:00 2001 From: Takumi IINO Date: Wed, 8 Jul 2015 11:16:44 +0900 Subject: passing the first argument with double quote --- plugins/coffee/coffee.plugin.zsh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'plugins') diff --git a/plugins/coffee/coffee.plugin.zsh b/plugins/coffee/coffee.plugin.zsh index 1a7bedd87..4e98e0228 100644 --- a/plugins/coffee/coffee.plugin.zsh +++ b/plugins/coffee/coffee.plugin.zsh @@ -2,11 +2,11 @@ # compile a string of coffeescript and print to output cf () { - coffee -peb $1 + coffee -peb "$1" } # compile & copy to clipboard cfc () { - cf $1 | pbcopy + cf "$1" | pbcopy } # compile from pasteboard & print -- cgit v1.2.3-70-g09d2 From ffe8e5465cdf6b9c1bad34df3f826f34cfbb59f8 Mon Sep 17 00:00:00 2001 From: Paul Robertson Date: Thu, 9 Jul 2015 23:40:35 -0400 Subject: add '--help' to heroku commands --- plugins/heroku/_heroku | 1 + 1 file changed, 1 insertion(+) (limited to 'plugins') diff --git a/plugins/heroku/_heroku b/plugins/heroku/_heroku index bb2f7403f..fd72e530e 100644 --- a/plugins/heroku/_heroku +++ b/plugins/heroku/_heroku @@ -143,5 +143,6 @@ _arguments \ $_command_args \ '(--app)--app[the app name]' \ '(--remote)--remote[the remote name]' \ + '(--help)--help[help about the current command]' \ && return 0 -- cgit v1.2.3-70-g09d2 From ff8d799594d0fd127058455b194b27d00a323d68 Mon Sep 17 00:00:00 2001 From: Fabio Strozzi Date: Sun, 12 Jul 2015 17:01:34 +0200 Subject: Esc-esc now toggles sudo. Press esc-esc once to add sudo (normal behaviour), press it twice to remove it from the beginning of the line. --- plugins/sudo/sudo.plugin.zsh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'plugins') diff --git a/plugins/sudo/sudo.plugin.zsh b/plugins/sudo/sudo.plugin.zsh index e3ba39918..0ba8bed5b 100644 --- a/plugins/sudo/sudo.plugin.zsh +++ b/plugins/sudo/sudo.plugin.zsh @@ -14,7 +14,11 @@ sudo-command-line() { [[ -z $BUFFER ]] && zle up-history - [[ $BUFFER != sudo\ * ]] && LBUFFER="sudo $LBUFFER" + if [[ $BUFFER == sudo\ * ]]; then + LBUFFER="${LBUFFER#sudo }" + else + LBUFFER="sudo $LBUFFER" + fi } zle -N sudo-command-line # Defined shortcut keys: [Esc] [Esc] -- cgit v1.2.3-70-g09d2 From afa30572f522969e07b0f85f0cf0fe0e32dd8831 Mon Sep 17 00:00:00 2001 From: Andrew Stuart Date: Mon, 13 Jul 2015 13:08:18 -0700 Subject: Add jira_url_help --- plugins/jira/jira.plugin.zsh | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'plugins') diff --git a/plugins/jira/jira.plugin.zsh b/plugins/jira/jira.plugin.zsh index ca540c84c..f624648ae 100644 --- a/plugins/jira/jira.plugin.zsh +++ b/plugins/jira/jira.plugin.zsh @@ -25,7 +25,7 @@ open_jira_issue () { elif [[ "x$JIRA_URL" != "x" ]]; then jira_url=$JIRA_URL else - echo "JIRA url is not specified anywhere." + jira_url_help return 1 fi @@ -59,6 +59,16 @@ open_jira_issue () { fi } +jira_url_help() { + cat << EOF +JIRA url is not specified anywhere. +Valid options, in order of preference: + .jira-url file + $HOME/.jira-url file + JIRA_URL environment variable +EOF +} + jira_name () { if [[ -z "$1" ]]; then if [[ "x${JIRA_NAME}" != "x" ]]; then -- cgit v1.2.3-70-g09d2 From 7a13a407e92dc6780355f67018bb03da81a73b8f Mon Sep 17 00:00:00 2001 From: Roland Chernov Date: Sat, 18 Jul 2015 21:10:56 +0900 Subject: Added thefuck plugin https://github.com/nvbn/thefuck --- plugins/thefuck/thefuck.plugin.zsh | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 plugins/thefuck/thefuck.plugin.zsh (limited to 'plugins') diff --git a/plugins/thefuck/thefuck.plugin.zsh b/plugins/thefuck/thefuck.plugin.zsh new file mode 100644 index 000000000..81461d48e --- /dev/null +++ b/plugins/thefuck/thefuck.plugin.zsh @@ -0,0 +1,9 @@ +fuck-command-line() { + FUCK=$(thefuck $(fc -ln -1 | tail -n 1) 2> /dev/null) + [ -z $FUCK ] && echo -n -e "\a" && return + BUFFER=$FUCK + zle end-of-line +} +zle -N fuck-command-line +# Defined shortcut keys: [Esc] [Esc] +bindkey "\e\e" fuck-command-line -- cgit v1.2.3-70-g09d2 From cd2213a0304e7f0b8fdfbb02be96f57042e2744a Mon Sep 17 00:00:00 2001 From: Roland Chernov Date: Sat, 18 Jul 2015 21:17:51 +0900 Subject: Thefuck plugin README --- plugins/thefuck/README.md | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 plugins/thefuck/README.md (limited to 'plugins') diff --git a/plugins/thefuck/README.md b/plugins/thefuck/README.md new file mode 100644 index 000000000..981b5513e --- /dev/null +++ b/plugins/thefuck/README.md @@ -0,0 +1,6 @@ +# The Fuck + +[The Fuck](https://github.com/nvbn/thefuck) plugin — magnificent app which corrects your previous console command. + +## Usage +Press `ESC` twice to correct previous console command. -- cgit v1.2.3-70-g09d2 From f838b56591691ad999c8ad1202f04f88350e2d73 Mon Sep 17 00:00:00 2001 From: linux_china Date: Sun, 19 Jul 2015 11:44:42 +0800 Subject: spring boot plugin readme --- plugins/spring/README.md | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 plugins/spring/README.md (limited to 'plugins') diff --git a/plugins/spring/README.md b/plugins/spring/README.md new file mode 100644 index 000000000..62bfd8013 --- /dev/null +++ b/plugins/spring/README.md @@ -0,0 +1,25 @@ +# Spring Boot oh-my-zsh plugin +oh-my-zsh Spring Boot plugin + +## Spring Boot autocomplete plugin + +- Adds autocomplete options for all spring boot commands. + +## Manual Install + + $ cd ~/.oh-my-zsh/plugins + $ git clone git@github.com:linux-china/oh-my-zsh-spring-boot-plugin.git spring + +Adjust your .zshrc file and add spring to plugins=(...) + +## Tips + +* Install Spring Cloud plugin: spring install org.springframework.cloud:spring-cloud-cli:1.0.2.RELEASE + +## Reference + +* Spring Boot: http://projects.spring.io/spring-boot/ +* Spring Boot CLI: http://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#cli + +Maintainer : linux_china ([@linux_china](https://twitter.com/linux_china)) + -- cgit v1.2.3-70-g09d2 From b4a8cbf6a589a57572832714f0284e487719004a Mon Sep 17 00:00:00 2001 From: linux_china Date: Sun, 19 Jul 2015 11:44:51 +0800 Subject: spring boot plugin --- plugins/spring/_spring | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 plugins/spring/_spring (limited to 'plugins') diff --git a/plugins/spring/_spring b/plugins/spring/_spring new file mode 100644 index 000000000..93f19517d --- /dev/null +++ b/plugins/spring/_spring @@ -0,0 +1,29 @@ +#compdef spring 'spring' +#autoload + +_spring() { + + local cword + let cword=CURRENT-1 + + local hints + hints=() + + local reply + while read -r line; do + reply=`echo "$line" | awk '{printf $1 ":"; for (i=2; i Date: Sun, 19 Jul 2015 12:57:50 +0900 Subject: Added conflict note (thefuck plugin) --- plugins/thefuck/README.md | 3 +++ 1 file changed, 3 insertions(+) (limited to 'plugins') diff --git a/plugins/thefuck/README.md b/plugins/thefuck/README.md index 981b5513e..a9b7550d7 100644 --- a/plugins/thefuck/README.md +++ b/plugins/thefuck/README.md @@ -4,3 +4,6 @@ ## Usage Press `ESC` twice to correct previous console command. + +## Notes +`Esc`-`Esc` key binding conflicts with [sudo](https://github.com/robbyrussell/oh-my-zsh/tree/master/plugins/sudo) plugin. -- cgit v1.2.3-70-g09d2 From 0da9a4be25d0feb968b21645a0654ea499f0cc9d Mon Sep 17 00:00:00 2001 From: Cristian Măgherușan-Stanciu Date: Wed, 6 May 2015 18:40:03 +0200 Subject: fuck: added a basic plugin for https://github.com/nvbn/thefuck --- plugins/fuck/fuck.plugin.zsh | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 plugins/fuck/fuck.plugin.zsh (limited to 'plugins') diff --git a/plugins/fuck/fuck.plugin.zsh b/plugins/fuck/fuck.plugin.zsh new file mode 100644 index 000000000..1a3b474fc --- /dev/null +++ b/plugins/fuck/fuck.plugin.zsh @@ -0,0 +1,6 @@ +if [ $commands[thefuck] ]; then + alias fuck='eval $(thefuck $(fc -ln -1 | tail -n 1)); fc -R' + alias FUCK='fuck' +else + echo 'thefuck is not installed, you should "pip install thefuck" first' +fi -- cgit v1.2.3-70-g09d2 From 803e5dbb8464088a8d84509077bf6dce9ac26688 Mon Sep 17 00:00:00 2001 From: Cristian Măgherușan-Stanciu Date: Thu, 9 Jul 2015 17:41:43 +0200 Subject: improved the check for availability --- plugins/fuck/fuck.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins') diff --git a/plugins/fuck/fuck.plugin.zsh b/plugins/fuck/fuck.plugin.zsh index 1a3b474fc..cbf8c09ce 100644 --- a/plugins/fuck/fuck.plugin.zsh +++ b/plugins/fuck/fuck.plugin.zsh @@ -1,4 +1,4 @@ -if [ $commands[thefuck] ]; then +if [[ -n $commands[thefuck] ]]; then alias fuck='eval $(thefuck $(fc -ln -1 | tail -n 1)); fc -R' alias FUCK='fuck' else -- cgit v1.2.3-70-g09d2 From 8e8a13398e71b969dc39189c0fedcc4733a911df Mon Sep 17 00:00:00 2001 From: Black Roland Date: Wed, 22 Jul 2015 17:20:52 +0900 Subject: Thefuck: combined with @cristim plugin. Code formating --- plugins/fuck/fuck.plugin.zsh | 6 ------ plugins/thefuck/thefuck.plugin.zsh | 12 ++++++++++-- 2 files changed, 10 insertions(+), 8 deletions(-) delete mode 100644 plugins/fuck/fuck.plugin.zsh (limited to 'plugins') diff --git a/plugins/fuck/fuck.plugin.zsh b/plugins/fuck/fuck.plugin.zsh deleted file mode 100644 index cbf8c09ce..000000000 --- a/plugins/fuck/fuck.plugin.zsh +++ /dev/null @@ -1,6 +0,0 @@ -if [[ -n $commands[thefuck] ]]; then - alias fuck='eval $(thefuck $(fc -ln -1 | tail -n 1)); fc -R' - alias FUCK='fuck' -else - echo 'thefuck is not installed, you should "pip install thefuck" first' -fi diff --git a/plugins/thefuck/thefuck.plugin.zsh b/plugins/thefuck/thefuck.plugin.zsh index 81461d48e..86ec9901b 100644 --- a/plugins/thefuck/thefuck.plugin.zsh +++ b/plugins/thefuck/thefuck.plugin.zsh @@ -1,6 +1,14 @@ +if [[ -z $commands[thefuck] ]]; then + echo 'thefuck is not installed, you should "pip install thefuck" first' + return -1 +fi + +alias fuck='eval $(thefuck $(fc -ln -1 | tail -n 1)); fc -R' +alias FUCK='fuck' + fuck-command-line() { - FUCK=$(thefuck $(fc -ln -1 | tail -n 1) 2> /dev/null) - [ -z $FUCK ] && echo -n -e "\a" && return + FUCK="$(thefuck $(fc -ln -1 | tail -n 1) 2> /dev/null)" + [[ -z $FUCK ]] && echo -n -e "\a" && return BUFFER=$FUCK zle end-of-line } -- cgit v1.2.3-70-g09d2 From 54e27406dcc2fea55432595f9ec01502da8e4468 Mon Sep 17 00:00:00 2001 From: Roland Chernov Date: Thu, 23 Jul 2015 20:10:31 +0900 Subject: Thefuck: replaced static alias with `eval "$(thefuck-alias)"` --- plugins/thefuck/thefuck.plugin.zsh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'plugins') diff --git a/plugins/thefuck/thefuck.plugin.zsh b/plugins/thefuck/thefuck.plugin.zsh index 86ec9901b..10467d337 100644 --- a/plugins/thefuck/thefuck.plugin.zsh +++ b/plugins/thefuck/thefuck.plugin.zsh @@ -3,8 +3,8 @@ if [[ -z $commands[thefuck] ]]; then return -1 fi -alias fuck='eval $(thefuck $(fc -ln -1 | tail -n 1)); fc -R' -alias FUCK='fuck' +# Register alias +eval "$(thefuck-alias)" fuck-command-line() { FUCK="$(thefuck $(fc -ln -1 | tail -n 1) 2> /dev/null)" -- cgit v1.2.3-70-g09d2 From f534b4b321d5db4b3d42d3e2cf1f2b2af5bd3c64 Mon Sep 17 00:00:00 2001 From: Roland Chernov Date: Thu, 23 Jul 2015 20:54:51 +0900 Subject: Thefuck: fixed compability with latest version --- plugins/thefuck/thefuck.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins') diff --git a/plugins/thefuck/thefuck.plugin.zsh b/plugins/thefuck/thefuck.plugin.zsh index 10467d337..739bb0b9a 100644 --- a/plugins/thefuck/thefuck.plugin.zsh +++ b/plugins/thefuck/thefuck.plugin.zsh @@ -7,7 +7,7 @@ fi eval "$(thefuck-alias)" fuck-command-line() { - FUCK="$(thefuck $(fc -ln -1 | tail -n 1) 2> /dev/null)" + FUCK="$(THEFUCK_REQUIRE_CONFIRMATION=0 thefuck $(fc -ln -1 | tail -n 1) 2> /dev/null)" [[ -z $FUCK ]] && echo -n -e "\a" && return BUFFER=$FUCK zle end-of-line -- cgit v1.2.3-70-g09d2 From c83575da3fb103af55215835c9e4add2665fbc86 Mon Sep 17 00:00:00 2001 From: Jerry Ling Date: Wed, 29 Jul 2015 20:05:44 +0800 Subject: Add 'man' plugin. Inspired by sudo. But we have man-preview! --- plugins/man/man.zsh | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 plugins/man/man.zsh (limited to 'plugins') diff --git a/plugins/man/man.zsh b/plugins/man/man.zsh new file mode 100644 index 000000000..3490b0b61 --- /dev/null +++ b/plugins/man/man.zsh @@ -0,0 +1,27 @@ +# ------------------------------------------------------------------------------ +# Author +# ------ +# +# * Jerry Ling +# +# ------------------------------------------------------------------------------ +# Usgae +# ----- +# +# man will be inserted before the command +# +# ------------------------------------------------------------------------------ + +man-command-line() { + [[ -z $BUFFER ]] && zle up-history + [[ $BUFFER != man\ * ]] && LBUFFER="man $LBUFFER" +} +zle -N man-command-line +# Defined shortcut keys: [Esc]man +bindkey "\e"man man-command-line + + +# ------------------------------------------------------------------------------ +# Also, you might want to use man-preview included in 'osx' plugin +# just substitute "man" in the function with "man-preview" after you included OS X in +# the .zshrc \ No newline at end of file -- cgit v1.2.3-70-g09d2 From 2120b2e079dbcc887a13aaf976c04edaf10fb626 Mon Sep 17 00:00:00 2001 From: Andrew Stuart Date: Wed, 29 Jul 2015 13:58:22 -0700 Subject: Add escaped home --- plugins/jira/jira.plugin.zsh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'plugins') diff --git a/plugins/jira/jira.plugin.zsh b/plugins/jira/jira.plugin.zsh index f624648ae..ed1a1f471 100644 --- a/plugins/jira/jira.plugin.zsh +++ b/plugins/jira/jira.plugin.zsh @@ -62,9 +62,9 @@ open_jira_issue () { jira_url_help() { cat << EOF JIRA url is not specified anywhere. -Valid options, in order of preference: +Valid options, in order of precedence: .jira-url file - $HOME/.jira-url file + \$HOME/.jira-url file JIRA_URL environment variable EOF } -- cgit v1.2.3-70-g09d2 From a2b574bc9edc4f548ca7eb3a8116004be7252092 Mon Sep 17 00:00:00 2001 From: Matteo Giaccone Date: Thu, 30 Jul 2015 12:32:41 +0100 Subject: git plugin: make gclean safer, introduce gpristine --- plugins/git/git.plugin.zsh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'plugins') diff --git a/plugins/git/git.plugin.zsh b/plugins/git/git.plugin.zsh index cc6eb1031..52f8f7515 100644 --- a/plugins/git/git.plugin.zsh +++ b/plugins/git/git.plugin.zsh @@ -71,7 +71,8 @@ alias gcan!='git commit -v -a -s --no-edit --amend' alias gcb='git checkout -b' alias gcf='git config --list' alias gcl='git clone --recursive' -alias gclean='git reset --hard && git clean -dfx' +alias gclean='git clean -fd' +alias gpristine='git reset --hard && git clean -dfx' alias gcm='git checkout master' alias gcmsg='git commit -m' alias gco='git checkout' -- cgit v1.2.3-70-g09d2 From fb8c446ea4317c391321a29dc97677bc6fdeb0cf Mon Sep 17 00:00:00 2001 From: Roland Chernov Date: Thu, 30 Jul 2015 21:04:58 +0900 Subject: Thefuck: fix global variable assignment --- plugins/thefuck/thefuck.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins') diff --git a/plugins/thefuck/thefuck.plugin.zsh b/plugins/thefuck/thefuck.plugin.zsh index 739bb0b9a..8b1746e85 100644 --- a/plugins/thefuck/thefuck.plugin.zsh +++ b/plugins/thefuck/thefuck.plugin.zsh @@ -7,7 +7,7 @@ fi eval "$(thefuck-alias)" fuck-command-line() { - FUCK="$(THEFUCK_REQUIRE_CONFIRMATION=0 thefuck $(fc -ln -1 | tail -n 1) 2> /dev/null)" + local FUCK="$(THEFUCK_REQUIRE_CONFIRMATION=0 thefuck $(fc -ln -1 | tail -n 1) 2> /dev/null)" [[ -z $FUCK ]] && echo -n -e "\a" && return BUFFER=$FUCK zle end-of-line -- cgit v1.2.3-70-g09d2 From daa04bae867a12fbe8256432c3590869d8f359ea Mon Sep 17 00:00:00 2001 From: Kentaro Wada Date: Sat, 1 Aug 2015 03:11:58 +0900 Subject: gnu-utils: add findutils (find,xargs,locate) --- plugins/gnu-utils/gnu-utils.plugin.zsh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'plugins') diff --git a/plugins/gnu-utils/gnu-utils.plugin.zsh b/plugins/gnu-utils/gnu-utils.plugin.zsh index e59265d66..de95f7e6c 100644 --- a/plugins/gnu-utils/gnu-utils.plugin.zsh +++ b/plugins/gnu-utils/gnu-utils.plugin.zsh @@ -29,7 +29,10 @@ if [[ -x "${commands[gwhoami]}" ]]; then 'gunexpand' 'guniq' 'gunlink' 'guptime' 'gusers' 'gvdir' 'gwc' 'gwho' 'gwhoami' 'gyes') - # Not part of coreutils, installed separately. + # findutils + gcmds+=('gfind' 'gxargs' 'glocate') + + # Not part of either coreutils or findutils, installed separately. gcmds+=('gsed' 'gtar' 'gtime') for gcmd in "${gcmds[@]}"; do -- cgit v1.2.3-70-g09d2 From e1353fce3ccd88441f97b65adaa98e15a640ed33 Mon Sep 17 00:00:00 2001 From: Ahmed Hisham Ismail Date: Mon, 3 Aug 2015 22:06:33 +0200 Subject: Adds npmE alias Option to execute a command from node_modules folder --- plugins/npm/npm.plugin.zsh | 3 +++ 1 file changed, 3 insertions(+) (limited to 'plugins') diff --git a/plugins/npm/npm.plugin.zsh b/plugins/npm/npm.plugin.zsh index 68ec5fabd..6d7357622 100644 --- a/plugins/npm/npm.plugin.zsh +++ b/plugins/npm/npm.plugin.zsh @@ -12,3 +12,6 @@ alias npmS="npm i -S " # Install and save to dev-dependencies in your package.json # npmd is used by https://github.com/dominictarr/npmd alias npmD="npm i -D " +# Execute command from node_modules folder based on current directory +# i.e npmE gulp +alias npmE="'PATH=$(npm bin):$PATH'" -- cgit v1.2.3-70-g09d2 From 269ae84c9b2e9b9bff2c8af6973ac03ba38c7e44 Mon Sep 17 00:00:00 2001 From: Ahmed Hisham Ismail Date: Wed, 5 Aug 2015 02:49:20 +0200 Subject: Removes unnecessary single quotes --- plugins/npm/npm.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins') diff --git a/plugins/npm/npm.plugin.zsh b/plugins/npm/npm.plugin.zsh index 6d7357622..64ba93a18 100644 --- a/plugins/npm/npm.plugin.zsh +++ b/plugins/npm/npm.plugin.zsh @@ -14,4 +14,4 @@ alias npmS="npm i -S " alias npmD="npm i -D " # Execute command from node_modules folder based on current directory # i.e npmE gulp -alias npmE="'PATH=$(npm bin):$PATH'" +alias npmE="PATH=$(npm bin):$PATH" -- cgit v1.2.3-70-g09d2 From 720fb5b68e186feae24c48283ded7c41b41c73fb Mon Sep 17 00:00:00 2001 From: Manfred Touron Date: Tue, 9 Jun 2015 11:07:23 +0200 Subject: Support for 'scw' command (Scaleway CLI) --- plugins/scw/README.md | 7 ++ plugins/scw/_scw | 333 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 340 insertions(+) create mode 100644 plugins/scw/README.md create mode 100644 plugins/scw/_scw (limited to 'plugins') diff --git a/plugins/scw/README.md b/plugins/scw/README.md new file mode 100644 index 000000000..d2312c2e5 --- /dev/null +++ b/plugins/scw/README.md @@ -0,0 +1,7 @@ +## Scaleway CLI autocomplete plugin + +[scw](https://github.com/scaleway/scaleway-cli): Manage Bare Metal servers from Command Line (as easily as with Docker) + +- Adds autocomplete options for all `scw` commands. + +Maintainer : Manfred Touron ([@moul](https://github.com/moul)) diff --git a/plugins/scw/_scw b/plugins/scw/_scw new file mode 100644 index 000000000..f9fdf916e --- /dev/null +++ b/plugins/scw/_scw @@ -0,0 +1,333 @@ +#compdef scw +# +# zsh completion for scw (http://scaleway.com) +# +# Inspired by https://github.com/felixr/docker-zsh-completion + +__scw_get_servers() { + local expl + declare -a servers + servers=(${(f)"$(_call_program commands scw _completion servers-names)"}) + _describe -t servers "servers" servers +} + +__scw_stoppedservers() { + __scw_get_servers +} + +__scw_runningservers() { + __scw_get_servers +} + +__scw_servers () { + __scw_get_servers +} + +__scw_images () { + local expl + declare -a images + images=(${(f)"$(_call_program commands scw _completion images-names)"}) + _describe -t images "images" images +} + +__scw_images_and_snapshots () { + __scw_images + __scw_snapshots +} + +__scw_snapshots () { + local expl + declare -a snapshots + snapshots=(${(f)"$(_call_program commands scw _completion --prefix snapshots-names)"}) + _describe -t snapshots "snapshots" snapshots +} + +__scw_bootscripts () { + local expl + declare -a bootscripts + bootscripts=(${(f)"$(_call_program commands scw _completion bootscripts-names)"}) + _describe -t bootscripts "bootscripts" bootscripts +} + +__scw_tags() { + __scw_images +} + +__scw_repositories_with_tags() { + __scw_images +} + +__scw_search() { + # declare -a scwsearch + local cache_policy + zstyle -s ":completion:${curcontext}:" cache-policy cache_policy + if [[ -z "$cache_policy" ]]; then + zstyle ":completion:${curcontext}:" cache-policy __scw_caching_policy + fi + + local searchterm cachename + searchterm="${words[$CURRENT]%/}" + cachename=_scw-search-$searchterm + + local expl + local -a result + if ( [[ ${(P)+cachename} -eq 0 ]] || _cache_invalid ${cachename#_} ) \ + && ! _retrieve_cache ${cachename#_}; then + _message "Searching for ${searchterm}..." + result=(${${${(f)"$(_call_program commands scw search ${searchterm})"}%% *}[2,-1]}) + _store_cache ${cachename#_} result + fi + _wanted scwsearch expl 'available images' compadd -a result +} + +__scw_caching_policy() +{ + oldp=( "$1"(Nmh+1) ) # 1 hour + (( $#oldp )) +} + + +__scw_repositories () { + __scw_images +} + +__scw_commands () { + # local -a _scw_subcommands + local cache_policy + + zstyle -s ":completion:${curcontext}:" cache-policy cache_policy + if [[ -z "$cache_policy" ]]; then + zstyle ":completion:${curcontext}:" cache-policy __scw_caching_policy + fi + + if ( [[ ${+_scw_subcommands} -eq 0 ]] || _cache_invalid scw_subcommands) \ + && ! _retrieve_cache scw_subcommands; + then + local -a lines + lines=(${(f)"$(_call_program commands scw 2>&1)"}) + _scw_subcommands=(${${${lines[$((${lines[(i)Commands:]} + 1)),${lines[(I) *]}]}## #}/ ##/:}) + _scw_subcommands=($_scw_subcommands 'help:Show help for a command') + _store_cache scw_subcommands _scw_subcommands + fi + _describe -t scw-commands "scw command" _scw_subcommands +} + +__scw_subcommand () { + local -a _command_args + case "$words[1]" in + (attach) + _arguments \ + '--no-stdin[Do not attach stdin]' \ + ':servers:__scw_runningservers' + ;; + (commit) + _arguments \ + {-v,--volume=0}'[Volume slot]:volume: ' \ + ':server:__scw_servers' \ + ':repository:__scw_repositories_with_tags' + ;; + (cp) + _arguments \ + ':server:->server' \ + ':hostpath:_files' + case $state in + (server) + if compset -P '*:'; then + _files + else + __scw_servers -qS ":" + fi + ;; + esac + ;; + (exec) + local state ret + _arguments \ + {-T,--timeout=0}'[Set timeout values to seconds]' \ + {-w,--wait}'[Wait for SSH to be ready]' \ + ':servers:__scw_runningservers' \ + '*::command:->anycommand' && ret=0 + + case $state in + (anycommand) + shift 1 words + (( CURRENT-- )) + _normal + ;; + esac + + return ret + ;; + (history) + _arguments \ + '--no-trunc[Do not truncate output]' \ + {-q,--quiet}'[Only show numeric IDs]' \ + '*:images:__scw_images' + ;; + (images) + _arguments \ + {-a,--all}'[Show all images]' \ + '--no-trunc[Do not truncate output]' \ + {-q,--quiet}'[Only show numeric IDs]' \ + ':repository:__scw_repositories' + ;; + (info) + ;; + (inspect) + _arguments \ + {-f,--format=-}'[Format the output using the given go template]:template: ' \ + '*:servers:__scw_servers' + ;; + (kill) + _arguments \ + '*:servers:__scw_runningservers' + ;; + (login) + _arguments \ + {-o,--organization=-}'[Organization]:organization: ' \ + {-t,--token=-}'[Token]:token: ' \ + ':server: ' + ;; + (logout) + _arguments \ + ':server: ' + ;; + (logs) + _arguments \ + '*:servers:__scw_servers' + ;; + (port) + _arguments \ + '1:servers:__scw_runningservers' \ + '2:port:_ports' + ;; + (start) + _arguments \ + {-T,--timeout=0}'[Set timeout values to seconds]' \ + {-w,--wait}'[Wait for SSH to be ready]' \ + '*:servers:__scw_stoppedservers' + ;; + (rm) + _arguments \ + '*:servers:__scw_stoppedservers' + ;; + (rmi) + _arguments \ + '*:images:__scw_images' + ;; + (restart) + _arguments \ + '*:servers:__scw_runningservers' + ;; + (stop) + _arguments \ + {-t,--terminate}'[Stop and trash a server with its volumes]' \ + {-w,--wait}'[Synchronous stop. Wait for server to be stopped]' \ + '*:servers:__scw_runningservers' + ;; + (top) + _arguments \ + '1:servers:__scw_runningservers' \ + '(-)*:: :->ps-arguments' + case $state in + (ps-arguments) + _ps + ;; + esac + ;; + (ps) + _arguments \ + {-a,--all}'[Show all servers. Only running servers are shown by default]' \ + {-l,--latest}'[Show only the latest created server]' \ + '-n[Show n last created servers, include non-running one]:n:(1 5 10 25 50)' \ + '--no-trunc[Do not truncate output]' \ + {-q,--quiet}'[Only show numeric IDs]' + ;; + (tag) + _arguments \ + {-f,--force}'[force]'\ + ':image:__scw_images'\ + ':repository:__scw_repositories_with_tags' + ;; + (create|run) + _arguments \ + {-a,--attach}'[Attach to stdin, stdout or stderr]' \ + '*'{-e,--environment=-}'[Set environment variables]:environment variable: ' \ + '--name=-[Server name]:name: ' \ + '--bootscript=-[Assign a bootscript]:bootscript:__scw_bootscripts ' \ + '*-v[Bind mount a volume]:volume: '\ + '(-):images:__scw_images_and_snapshots' \ + '(-):command: _command_names -e' \ + '*::arguments: _normal' + + case $state in + (link) + if compset -P '*:'; then + _wanted alias expl 'Alias' compadd -E "" + else + __scw_runningservers -qS ":" + fi + ;; + esac + ;; + (rename) + _arguments \ + ':old name:__scw_servers' \ + ':new name: ' + ;; + (search) + _arguments \ + '--no-trunc[Do not truncate output]' \ + ':term: ' + ;; + (wait) + _arguments '*:servers:__scw_runningservers' + ;; + (help) + _arguments ':subcommand:__scw_commands' + ;; + (*) + _message 'Unknown sub command' + esac + +} + +_scw () { + # Support for subservices, which allows for `compdef _scw scw-shell=_scw_servers`. + # Based on /usr/share/zsh/functions/Completion/Unix/_git without support for `ret`. + if [[ $service != scw ]]; then + _call_function - _$service + return + fi + + local curcontext="$curcontext" state line + typeset -A opt_args + + _arguments -C \ + '-H[tcp://host:port to bind/connect to]:socket: ' \ + '(-): :->command' \ + '(-)*:: :->option-or-argument' + + if (( CURRENT == 1 )); then + + fi + case $state in + (command) + __scw_commands + ;; + (option-or-argument) + curcontext=${curcontext%:*:*}:scw-$words[1]: + __scw_subcommand + ;; + esac +} + +_scw "$@" + +# Local Variables: +# mode: Shell-Script +# sh-indentation: 4 +# indent-tabs-mode: nil +# sh-basic-offset: 4 +# End: +# vim: ft=zsh sw=4 ts=4 et -- cgit v1.2.3-70-g09d2 From c3fbe4d121d9edb8b34bfbe1aad45a1d81e9899e Mon Sep 17 00:00:00 2001 From: Andrew Robertson Date: Wed, 5 Aug 2015 19:51:05 +0100 Subject: Add support for Docker images from custom registries --- plugins/docker/_docker | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins') diff --git a/plugins/docker/_docker b/plugins/docker/_docker index 25f55beca..a82a31ad3 100644 --- a/plugins/docker/_docker +++ b/plugins/docker/_docker @@ -27,7 +27,7 @@ __docker_all_containers() { # output a selectable list of all docker images __docker_images() { declare -a img_cmd - img_cmd=($(docker images | awk 'NR>1{print $1}')) + img_cmd=($(docker images | awk 'NR>1{print $1}'| sed 's/:/\\:/g')) _describe 'images' img_cmd } -- cgit v1.2.3-70-g09d2 From dcd95dd2238bc1b3203306a2f66acc09080cfee6 Mon Sep 17 00:00:00 2001 From: Ahmed Hisham Ismail Date: Tue, 11 Aug 2015 02:56:49 +0200 Subject: Changes quotes so that path will be set appropriately on multiple runs --- plugins/npm/npm.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins') diff --git a/plugins/npm/npm.plugin.zsh b/plugins/npm/npm.plugin.zsh index 64ba93a18..595105d3c 100644 --- a/plugins/npm/npm.plugin.zsh +++ b/plugins/npm/npm.plugin.zsh @@ -14,4 +14,4 @@ alias npmS="npm i -S " alias npmD="npm i -D " # Execute command from node_modules folder based on current directory # i.e npmE gulp -alias npmE="PATH=$(npm bin):$PATH" +alias npmE='PATH="$(npm bin)":"$PATH"' -- cgit v1.2.3-70-g09d2 From 02383017268004c4873797c16a667389bead1b83 Mon Sep 17 00:00:00 2001 From: LE Manh Cuong Date: Fri, 14 Aug 2015 09:55:46 +0700 Subject: Emoji plugin - Fix wrong string comparison --- plugins/emoji/emoji-char-definitions.zsh | 9 +++++++++ plugins/emoji/update_emoji.pl | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) (limited to 'plugins') diff --git a/plugins/emoji/emoji-char-definitions.zsh b/plugins/emoji/emoji-char-definitions.zsh index 7d110603c..04693da05 100644 --- a/plugins/emoji/emoji-char-definitions.zsh +++ b/plugins/emoji/emoji-char-definitions.zsh @@ -7,8 +7,12 @@ # $emoji - which maps character names to Unicode characters # $emoji_flags - maps country names to Unicode flag characters using region indicators +# Main emoji typeset -gAH emoji +# National flags typeset -gAH emoji_flags +# Combining modifiers +typeset -gAH emoji_mod emoji[copyright_sign]=$'\U00A9' emoji[registered_sign]=$'\U00AE' @@ -448,10 +452,15 @@ emoji[badminton_racquet_and_shuttlecock]=$'\U1F3F8' emoji[bow_and_arrow]=$'\U1F3F9' emoji[amphora]=$'\U1F3FA' emoji[emoji_modifier_fitzpatrick_type_1_2]=$'\U1F3FB' +emoji_mod[emoji_modifier_fitzpatrick_type_1_2]=$'\U1F3FB' emoji[emoji_modifier_fitzpatrick_type_3]=$'\U1F3FC' +emoji_mod[emoji_modifier_fitzpatrick_type_3]=$'\U1F3FC' emoji[emoji_modifier_fitzpatrick_type_4]=$'\U1F3FD' +emoji_mod[emoji_modifier_fitzpatrick_type_4]=$'\U1F3FD' emoji[emoji_modifier_fitzpatrick_type_5]=$'\U1F3FE' +emoji_mod[emoji_modifier_fitzpatrick_type_5]=$'\U1F3FE' emoji[emoji_modifier_fitzpatrick_type_6]=$'\U1F3FF' +emoji_mod[emoji_modifier_fitzpatrick_type_6]=$'\U1F3FF' emoji[rat]=$'\U1F400' emoji[mouse]=$'\U1F401' emoji[ox]=$'\U1F402' diff --git a/plugins/emoji/update_emoji.pl b/plugins/emoji/update_emoji.pl index d90c6e316..04f3ce8e7 100644 --- a/plugins/emoji/update_emoji.pl +++ b/plugins/emoji/update_emoji.pl @@ -88,7 +88,7 @@ typeset -gAH emoji_mod } # Modifiers are included in both the main set and their separate map, # because they have a standalone representation as a color swatch. - if ( $modifier_status == "modifier" ) { + if ( $modifier_status eq "modifier" ) { $outfh->print("emoji_mod[$omz_name]=\$'$zsh_code'\n"); } } else { -- cgit v1.2.3-70-g09d2 From d20c111d78f52dfe81bc632532774d3715feb4e3 Mon Sep 17 00:00:00 2001 From: Chayoung You Date: Sat, 15 Aug 2015 15:19:02 +0900 Subject: rvm plugin: Fix `gems` to work with GNU sed Fix #1579. --- plugins/rvm/rvm.plugin.zsh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'plugins') diff --git a/plugins/rvm/rvm.plugin.zsh b/plugins/rvm/rvm.plugin.zsh index 234ac1642..53e809aaf 100644 --- a/plugins/rvm/rvm.plugin.zsh +++ b/plugins/rvm/rvm.plugin.zsh @@ -61,11 +61,11 @@ function gems { local current_ruby=`rvm-prompt i v p` local current_gemset=`rvm-prompt g` - gem list $@ | sed \ - -Ee "s/\([0-9, \.]+( .+)?\)/$fg[blue]&$reset_color/g" \ - -Ee "s|$(echo $rvm_path)|$fg[magenta]\$rvm_path$reset_color|g" \ - -Ee "s/$current_ruby@global/$fg[yellow]&$reset_color/g" \ - -Ee "s/$current_ruby$current_gemset$/$fg[green]&$reset_color/g" + gem list $@ | sed -E \ + -e "s/\([0-9, \.]+( .+)?\)/$fg[blue]&$reset_color/g" \ + -e "s|$(echo $rvm_path)|$fg[magenta]\$rvm_path$reset_color|g" \ + -e "s/$current_ruby@global/$fg[yellow]&$reset_color/g" \ + -e "s/$current_ruby$current_gemset$/$fg[green]&$reset_color/g" } function _rvm_completion { -- cgit v1.2.3-70-g09d2 From daedfcab510b01d566a2dff6bc94a9e91a563a18 Mon Sep 17 00:00:00 2001 From: Gabe Martin-Dempesy Date: Sat, 15 Aug 2015 12:54:46 -0700 Subject: reduce rbenv plugin load time by 150ms by removing additional brew call --- plugins/rbenv/rbenv.plugin.zsh | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'plugins') diff --git a/plugins/rbenv/rbenv.plugin.zsh b/plugins/rbenv/rbenv.plugin.zsh index 213e1beb0..ef5106f2d 100644 --- a/plugins/rbenv/rbenv.plugin.zsh +++ b/plugins/rbenv/rbenv.plugin.zsh @@ -2,14 +2,11 @@ _homebrew-installed() { type brew &> /dev/null } -_rbenv-from-homebrew-installed() { - brew --prefix rbenv &> /dev/null -} - FOUND_RBENV=0 rbenvdirs=("$HOME/.rbenv" "/usr/local/rbenv" "/opt/rbenv" "/usr/local/opt/rbenv") -if _homebrew-installed && _rbenv-from-homebrew-installed ; then - rbenvdirs=($(brew --prefix rbenv) "${rbenvdirs[@]}") +if _homebrew-installed && rbenv_homebrew_path=$(brew --prefix rbenv 2>/dev/null); then + rbenvdirs=($rbenv_homebrew_path "${rbenvdirs[@]}") + unset rbenv_homebrew_path fi for rbenvdir in "${rbenvdirs[@]}" ; do -- cgit v1.2.3-70-g09d2 From 88243b846adc61c3e34a60f4c0ae53e3eb8b9e93 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Sun, 16 Aug 2015 22:26:33 +0200 Subject: Use right variable name to avoid zero-length array This fixes the typographic error that always assigned an undefined array to `$names`, which made `$list_size` = 0 and triggered a divide by zero error on the next line. --- plugins/emoji/emoji.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins') diff --git a/plugins/emoji/emoji.plugin.zsh b/plugins/emoji/emoji.plugin.zsh index a98d0b714..adb11bb53 100644 --- a/plugins/emoji/emoji.plugin.zsh +++ b/plugins/emoji/emoji.plugin.zsh @@ -255,7 +255,7 @@ function random_emoji() { if [[ -z "$group" || "$group" == "all" ]]; then names=(${(k)emoji}) else - names=(${=emoji_groups[$group_name]}) + names=(${=emoji_groups[$group]}) fi local list_size=$#names local random_index=$(( ( RANDOM % $list_size ) + 1 )) -- cgit v1.2.3-70-g09d2 From c6a5f6efb434fa64f31b40f366e7fecae80758e6 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Sun, 16 Aug 2015 22:30:56 +0200 Subject: Check that list_size value is not zero before division --- plugins/emoji/emoji.plugin.zsh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'plugins') diff --git a/plugins/emoji/emoji.plugin.zsh b/plugins/emoji/emoji.plugin.zsh index adb11bb53..f2d169bf3 100644 --- a/plugins/emoji/emoji.plugin.zsh +++ b/plugins/emoji/emoji.plugin.zsh @@ -257,7 +257,8 @@ function random_emoji() { else names=(${=emoji_groups[$group]}) fi - local list_size=$#names + local list_size=${#names} + [[ $list_size -eq 0 ]] && return 1 local random_index=$(( ( RANDOM % $list_size ) + 1 )) local name=${names[$random_index]} echo ${emoji[$name]} -- cgit v1.2.3-70-g09d2 From 6443626a6beedc1135402e0fdd4646ba1e7ae35a Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Sat, 1 Aug 2015 18:06:36 +0200 Subject: Pull in latest version from olivierverdier/zsh-git-prompt --- plugins/git-prompt/git-prompt.plugin.zsh | 95 ++++++++++++++++++------ plugins/git-prompt/gitstatus.py | 123 +++++++++++++------------------ 2 files changed, 126 insertions(+), 92 deletions(-) (limited to 'plugins') diff --git a/plugins/git-prompt/git-prompt.plugin.zsh b/plugins/git-prompt/git-prompt.plugin.zsh index d868a5fe1..ccba22dc5 100644 --- a/plugins/git-prompt/git-prompt.plugin.zsh +++ b/plugins/git-prompt/git-prompt.plugin.zsh @@ -1,32 +1,34 @@ # ZSH Git Prompt Plugin from: # http://github.com/olivierverdier/zsh-git-prompt -# -export __GIT_PROMPT_DIR=$ZSH/plugins/git-prompt + +export __GIT_PROMPT_DIR=${0:A:h} + +export GIT_PROMPT_EXECUTABLE=${GIT_PROMPT_USE_PYTHON:-"python"} + +# Initialize colors. +autoload -U colors +colors # Allow for functions in the prompt. setopt PROMPT_SUBST -## Enable auto-execution of functions. -typeset -ga preexec_functions -typeset -ga precmd_functions -typeset -ga chpwd_functions +autoload -U add-zsh-hook -# Append git functions needed for prompt. -preexec_functions+='preexec_update_git_vars' -precmd_functions+='precmd_update_git_vars' -chpwd_functions+='chpwd_update_git_vars' +add-zsh-hook chpwd chpwd_update_git_vars +add-zsh-hook preexec preexec_update_git_vars +add-zsh-hook precmd precmd_update_git_vars ## Function definitions function preexec_update_git_vars() { case "$2" in - git*) + git*|hub*|gh*|stg*) __EXECUTED_GIT_COMMAND=1 ;; esac } function precmd_update_git_vars() { - if [ -n "$__EXECUTED_GIT_COMMAND" ]; then + if [ -n "$__EXECUTED_GIT_COMMAND" ] || [ ! -n "$ZSH_THEME_GIT_PROMPT_CACHE" ]; then update_current_git_vars unset __EXECUTED_GIT_COMMAND fi @@ -39,19 +41,68 @@ function chpwd_update_git_vars() { function update_current_git_vars() { unset __CURRENT_GIT_STATUS - local gitstatus="$__GIT_PROMPT_DIR/gitstatus.py" - _GIT_STATUS=`python ${gitstatus}` - __CURRENT_GIT_STATUS=("${(f)_GIT_STATUS}") + if [[ "$GIT_PROMPT_EXECUTABLE" == "python" ]]; then + local gitstatus="$__GIT_PROMPT_DIR/gitstatus.py" + _GIT_STATUS=`python ${gitstatus} 2>/dev/null` + fi + if [[ "$GIT_PROMPT_EXECUTABLE" == "haskell" ]]; then + local gitstatus="$__GIT_PROMPT_DIR/dist/build/gitstatus/gitstatus" + _GIT_STATUS=`${gitstatus}` + fi + __CURRENT_GIT_STATUS=("${(@s: :)_GIT_STATUS}") + GIT_BRANCH=$__CURRENT_GIT_STATUS[1] + GIT_AHEAD=$__CURRENT_GIT_STATUS[2] + GIT_BEHIND=$__CURRENT_GIT_STATUS[3] + GIT_STAGED=$__CURRENT_GIT_STATUS[4] + GIT_CONFLICTS=$__CURRENT_GIT_STATUS[5] + GIT_CHANGED=$__CURRENT_GIT_STATUS[6] + GIT_UNTRACKED=$__CURRENT_GIT_STATUS[7] } -function prompt_git_info() { + +git_super_status() { + precmd_update_git_vars if [ -n "$__CURRENT_GIT_STATUS" ]; then - echo "(%{${fg[red]}%}$__CURRENT_GIT_STATUS[1]%{${fg[default]}%}$__CURRENT_GIT_STATUS[2]%{${fg[magenta]}%}$__CURRENT_GIT_STATUS[3]%{${fg[default]}%})" - fi + STATUS="$ZSH_THEME_GIT_PROMPT_PREFIX$ZSH_THEME_GIT_PROMPT_BRANCH$GIT_BRANCH%{${reset_color}%}" + if [ "$GIT_BEHIND" -ne "0" ]; then + STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_BEHIND$GIT_BEHIND%{${reset_color}%}" + fi + if [ "$GIT_AHEAD" -ne "0" ]; then + STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_AHEAD$GIT_AHEAD%{${reset_color}%}" + fi + STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_SEPARATOR" + if [ "$GIT_STAGED" -ne "0" ]; then + STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_STAGED$GIT_STAGED%{${reset_color}%}" + fi + if [ "$GIT_CONFLICTS" -ne "0" ]; then + STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_CONFLICTS$GIT_CONFLICTS%{${reset_color}%}" + fi + if [ "$GIT_CHANGED" -ne "0" ]; then + STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_CHANGED$GIT_CHANGED%{${reset_color}%}" + fi + if [ "$GIT_UNTRACKED" -ne "0" ]; then + STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_UNTRACKED%{${reset_color}%}" + fi + if [ "$GIT_CHANGED" -eq "0" ] && [ "$GIT_CONFLICTS" -eq "0" ] && [ "$GIT_STAGED" -eq "0" ] && [ "$GIT_UNTRACKED" -eq "0" ]; then + STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_CLEAN" + fi + STATUS="$STATUS%{${reset_color}%}$ZSH_THEME_GIT_PROMPT_SUFFIX" + echo "$STATUS" + fi } +# Default values for the appearance of the prompt. Configure at will. +ZSH_THEME_GIT_PROMPT_PREFIX="(" +ZSH_THEME_GIT_PROMPT_SUFFIX=")" +ZSH_THEME_GIT_PROMPT_SEPARATOR="|" +ZSH_THEME_GIT_PROMPT_BRANCH="%{$fg_bold[magenta]%}" +ZSH_THEME_GIT_PROMPT_STAGED="%{$fg[red]%}%{●%G%}" +ZSH_THEME_GIT_PROMPT_CONFLICTS="%{$fg[red]%}%{✖%G%}" +ZSH_THEME_GIT_PROMPT_CHANGED="%{$fg[blue]%}%{✚%G%}" +ZSH_THEME_GIT_PROMPT_BEHIND="%{↓%G%}" +ZSH_THEME_GIT_PROMPT_AHEAD="%{↑%G%}" +ZSH_THEME_GIT_PROMPT_UNTRACKED="%{…%G%}" +ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg_bold[green]%}%{✔%G%}" + # Set the prompt. -#PROMPT='%B%m%~%b$(prompt_git_info) %# ' -# for a right prompt: -#RPROMPT='%b$(prompt_git_info)' -RPROMPT='$(prompt_git_info)' +RPROMPT='$(git_super_status)' diff --git a/plugins/git-prompt/gitstatus.py b/plugins/git-prompt/gitstatus.py index 256841432..d944fd4ed 100644 --- a/plugins/git-prompt/gitstatus.py +++ b/plugins/git-prompt/gitstatus.py @@ -1,82 +1,65 @@ #!/usr/bin/env python -# -*- coding: UTF-8 -*- -from subprocess import Popen, PIPE -import re - -# change those symbols to whatever you prefer -symbols = { - 'ahead of': '↑', - 'behind': '↓', - 'staged': '♦', - 'changed': '‣', - 'untracked': '…', - 'clean': '⚡', - 'unmerged': '≠', - 'sha1': ':' -} +from __future__ import print_function -output, error = Popen( - ['git', 'status'], stdout=PIPE, stderr=PIPE, universal_newlines=True).communicate() +# change this symbol to whatever you prefer +prehash = ':' -if error: - import sys - sys.exit(0) -lines = output.splitlines() +from subprocess import Popen, PIPE -behead_re = re.compile( - r"^# Your branch is (ahead of|behind) '(.*)' by (\d+) commit") -diverge_re = re.compile(r"^# and have (\d+) and (\d+) different") +import sys +gitsym = Popen(['git', 'symbolic-ref', 'HEAD'], stdout=PIPE, stderr=PIPE) +branch, error = gitsym.communicate() -status = '' -staged = re.compile(r'^# Changes to be committed:$', re.MULTILINE) -changed = re.compile(r'^# Changed but not updated:$', re.MULTILINE) -untracked = re.compile(r'^# Untracked files:$', re.MULTILINE) -unmerged = re.compile(r'^# Unmerged paths:$', re.MULTILINE) +error_string = error.decode('utf-8') +if 'fatal: Not a git repository' in error_string: + sys.exit(0) -def execute(*command): - out, err = Popen(stdout=PIPE, stderr=PIPE, *command).communicate() - if not err: - nb = len(out.splitlines()) - else: - nb = '?' - return nb +branch = branch.decode("utf-8").strip()[11:] -if staged.search(output): - nb = execute( - ['git', 'diff', '--staged', '--name-only', '--diff-filter=ACDMRT']) - status += '%s%s' % (symbols['staged'], nb) -if unmerged.search(output): - nb = execute(['git', 'diff', '--staged', '--name-only', '--diff-filter=U']) - status += '%s%s' % (symbols['unmerged'], nb) -if changed.search(output): - nb = execute(['git', 'diff', '--name-only', '--diff-filter=ACDMRT']) - status += '%s%s' % (symbols['changed'], nb) -if untracked.search(output): - status += symbols['untracked'] -if status == '': - status = symbols['clean'] +res, err = Popen(['git','diff','--name-status'], stdout=PIPE, stderr=PIPE).communicate() +err_string = err.decode('utf-8') +if 'fatal' in err_string: + sys.exit(0) +changed_files = [namestat[0] for namestat in res.decode("utf-8").splitlines()] +staged_files = [namestat[0] for namestat in Popen(['git','diff', '--staged','--name-status'], stdout=PIPE).communicate()[0].splitlines()] +nb_changed = len(changed_files) - changed_files.count('U') +nb_U = staged_files.count('U') +nb_staged = len(staged_files) - nb_U +staged = str(nb_staged) +conflicts = str(nb_U) +changed = str(nb_changed) +nb_untracked = len([0 for status in Popen(['git','status','--porcelain',],stdout=PIPE).communicate()[0].decode("utf-8").splitlines() if status.startswith('??')]) +untracked = str(nb_untracked) -remote = '' +ahead, behind = 0,0 -bline = lines[0] -if bline.find('Not currently on any branch') != -1: - branch = symbols['sha1'] + Popen([ - 'git', - 'rev-parse', - '--short', - 'HEAD'], stdout=PIPE).communicate()[0][:-1] +if not branch: # not on any branch + branch = prehash + Popen(['git','rev-parse','--short','HEAD'], stdout=PIPE).communicate()[0].decode("utf-8")[:-1] else: - branch = bline.split(' ')[-1] - bstatusline = lines[1] - match = behead_re.match(bstatusline) - if match: - remote = symbols[match.groups()[0]] - remote += match.groups()[2] - elif lines[2:]: - div_match = diverge_re.match(lines[2]) - if div_match: - remote = "{behind}{1}{ahead of}{0}".format( - *div_match.groups(), **symbols) + remote_name = Popen(['git','config','branch.%s.remote' % branch], stdout=PIPE).communicate()[0].decode("utf-8").strip() + if remote_name: + merge_name = Popen(['git','config','branch.%s.merge' % branch], stdout=PIPE).communicate()[0].decode("utf-8").strip() + if remote_name == '.': # local + remote_ref = merge_name + else: + remote_ref = 'refs/remotes/%s/%s' % (remote_name, merge_name[11:]) + revgit = Popen(['git', 'rev-list', '--left-right', '%s...HEAD' % remote_ref],stdout=PIPE, stderr=PIPE) + revlist = revgit.communicate()[0] + if revgit.poll(): # fallback to local + revlist = Popen(['git', 'rev-list', '--left-right', '%s...HEAD' % merge_name],stdout=PIPE, stderr=PIPE).communicate()[0] + behead = revlist.decode("utf-8").splitlines() + ahead = len([x for x in behead if x[0]=='>']) + behind = len(behead) - ahead + +out = ' '.join([ + branch, + str(ahead), + str(behind), + staged, + conflicts, + changed, + untracked, + ]) +print(out, end='') -print('\n'.join([branch, remote, status])) -- cgit v1.2.3-70-g09d2 From 5642014ff1b718df04d803b7b0457b9872b2b4f2 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Sat, 1 Aug 2015 18:13:46 +0200 Subject: Pull in simplified version from @wkentaro This version uses `git status --porcelain` instead of making multiple calls to `git status`. --- plugins/git-prompt/gitstatus.py | 80 +++++++++++++++++++++-------------------- 1 file changed, 42 insertions(+), 38 deletions(-) (limited to 'plugins') diff --git a/plugins/git-prompt/gitstatus.py b/plugins/git-prompt/gitstatus.py index d944fd4ed..1065b3cb5 100644 --- a/plugins/git-prompt/gitstatus.py +++ b/plugins/git-prompt/gitstatus.py @@ -4,6 +4,7 @@ from __future__ import print_function # change this symbol to whatever you prefer prehash = ':' +import subprocess from subprocess import Popen, PIPE import sys @@ -13,53 +14,56 @@ branch, error = gitsym.communicate() error_string = error.decode('utf-8') if 'fatal: Not a git repository' in error_string: - sys.exit(0) + sys.exit(0) branch = branch.decode("utf-8").strip()[11:] -res, err = Popen(['git','diff','--name-status'], stdout=PIPE, stderr=PIPE).communicate() -err_string = err.decode('utf-8') -if 'fatal' in err_string: - sys.exit(0) -changed_files = [namestat[0] for namestat in res.decode("utf-8").splitlines()] -staged_files = [namestat[0] for namestat in Popen(['git','diff', '--staged','--name-status'], stdout=PIPE).communicate()[0].splitlines()] -nb_changed = len(changed_files) - changed_files.count('U') -nb_U = staged_files.count('U') -nb_staged = len(staged_files) - nb_U -staged = str(nb_staged) -conflicts = str(nb_U) -changed = str(nb_changed) -nb_untracked = len([0 for status in Popen(['git','status','--porcelain',],stdout=PIPE).communicate()[0].decode("utf-8").splitlines() if status.startswith('??')]) -untracked = str(nb_untracked) +# Get git status (staged, change, conflicts and untracked) +try: + res = subprocess.check_output(['git', 'status', '--porcelain']) +except subprocess.CalledProcessError: + sys.exit(0) +status = [(st[0], st[1], st[2:]) for st in res.splitlines()] +untracked, staged, changed, conflicts = [], [], [], [] +for st in status: + if st[0] == '?' and st[1] == '?': + untracked.append(st) + else: + if st[1] == 'M': + changed.append(st) + if st[0] == 'U': + conflicts.append(st) + elif st[0] != ' ': + staged.append(st) ahead, behind = 0,0 if not branch: # not on any branch - branch = prehash + Popen(['git','rev-parse','--short','HEAD'], stdout=PIPE).communicate()[0].decode("utf-8")[:-1] + branch = prehash + Popen(['git','rev-parse','--short','HEAD'], stdout=PIPE).communicate()[0].decode("utf-8")[:-1] else: - remote_name = Popen(['git','config','branch.%s.remote' % branch], stdout=PIPE).communicate()[0].decode("utf-8").strip() - if remote_name: - merge_name = Popen(['git','config','branch.%s.merge' % branch], stdout=PIPE).communicate()[0].decode("utf-8").strip() - if remote_name == '.': # local - remote_ref = merge_name - else: - remote_ref = 'refs/remotes/%s/%s' % (remote_name, merge_name[11:]) - revgit = Popen(['git', 'rev-list', '--left-right', '%s...HEAD' % remote_ref],stdout=PIPE, stderr=PIPE) - revlist = revgit.communicate()[0] - if revgit.poll(): # fallback to local - revlist = Popen(['git', 'rev-list', '--left-right', '%s...HEAD' % merge_name],stdout=PIPE, stderr=PIPE).communicate()[0] - behead = revlist.decode("utf-8").splitlines() - ahead = len([x for x in behead if x[0]=='>']) - behind = len(behead) - ahead + remote_name = Popen(['git','config','branch.%s.remote' % branch], stdout=PIPE).communicate()[0].decode("utf-8").strip() + if remote_name: + merge_name = Popen(['git','config','branch.%s.merge' % branch], stdout=PIPE).communicate()[0].decode("utf-8").strip() + if remote_name == '.': # local + remote_ref = merge_name + else: + remote_ref = 'refs/remotes/%s/%s' % (remote_name, merge_name[11:]) + revgit = Popen(['git', 'rev-list', '--left-right', '%s...HEAD' % remote_ref],stdout=PIPE, stderr=PIPE) + revlist = revgit.communicate()[0] + if revgit.poll(): # fallback to local + revlist = Popen(['git', 'rev-list', '--left-right', '%s...HEAD' % merge_name],stdout=PIPE, stderr=PIPE).communicate()[0] + behead = revlist.decode("utf-8").splitlines() + ahead = len([x for x in behead if x[0]=='>']) + behind = len(behead) - ahead out = ' '.join([ - branch, - str(ahead), - str(behind), - staged, - conflicts, - changed, - untracked, - ]) + branch, + str(ahead), + str(behind), + str(len(staged)), + str(len(conflicts)), + str(len(changed)), + str(len(untracked)), +]) print(out, end='') -- cgit v1.2.3-70-g09d2 From 1d133ff11fe187ee7255637d51165013b4e6a738 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Sat, 1 Aug 2015 18:26:18 +0200 Subject: Cleanup the rest of gitstatus.py --- plugins/git-prompt/gitstatus.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'plugins') diff --git a/plugins/git-prompt/gitstatus.py b/plugins/git-prompt/gitstatus.py index 1065b3cb5..903ad474d 100644 --- a/plugins/git-prompt/gitstatus.py +++ b/plugins/git-prompt/gitstatus.py @@ -4,16 +4,13 @@ from __future__ import print_function # change this symbol to whatever you prefer prehash = ':' +import sys import subprocess from subprocess import Popen, PIPE -import sys -gitsym = Popen(['git', 'symbolic-ref', 'HEAD'], stdout=PIPE, stderr=PIPE) -branch, error = gitsym.communicate() - -error_string = error.decode('utf-8') +branch, error = Popen(['git', 'symbolic-ref', 'HEAD'], stdout=PIPE, stderr=PIPE).communicate() -if 'fatal: Not a git repository' in error_string: +if 'fatal: Not a git repository' in error.decode('utf-8'): sys.exit(0) branch = branch.decode("utf-8").strip()[11:] -- cgit v1.2.3-70-g09d2 From 6ff53d173b374e5ebbdff141059c71e4e14aa62e Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Sat, 1 Aug 2015 18:09:20 +0200 Subject: Cleanup of git-prompt plugin file --- plugins/git-prompt/git-prompt.plugin.zsh | 110 +++++++++++++------------------ 1 file changed, 47 insertions(+), 63 deletions(-) (limited to 'plugins') diff --git a/plugins/git-prompt/git-prompt.plugin.zsh b/plugins/git-prompt/git-prompt.plugin.zsh index ccba22dc5..5175bf70f 100644 --- a/plugins/git-prompt/git-prompt.plugin.zsh +++ b/plugins/git-prompt/git-prompt.plugin.zsh @@ -1,24 +1,13 @@ # ZSH Git Prompt Plugin from: # http://github.com/olivierverdier/zsh-git-prompt -export __GIT_PROMPT_DIR=${0:A:h} +__GIT_PROMPT_DIR="${0:A:h}" -export GIT_PROMPT_EXECUTABLE=${GIT_PROMPT_USE_PYTHON:-"python"} - -# Initialize colors. -autoload -U colors -colors - -# Allow for functions in the prompt. -setopt PROMPT_SUBST - -autoload -U add-zsh-hook - -add-zsh-hook chpwd chpwd_update_git_vars -add-zsh-hook preexec preexec_update_git_vars -add-zsh-hook precmd precmd_update_git_vars +## Hook function definitions +function chpwd_update_git_vars() { + update_current_git_vars +} -## Function definitions function preexec_update_git_vars() { case "$2" in git*|hub*|gh*|stg*) @@ -34,64 +23,59 @@ function precmd_update_git_vars() { fi } -function chpwd_update_git_vars() { - update_current_git_vars -} +chpwd_functions+=(chpwd_update_git_vars) +precmd_functions+=(precmd_update_git_vars) +preexec_functions+=(preexec_update_git_vars) + +## Function definitions function update_current_git_vars() { unset __CURRENT_GIT_STATUS - if [[ "$GIT_PROMPT_EXECUTABLE" == "python" ]]; then - local gitstatus="$__GIT_PROMPT_DIR/gitstatus.py" - _GIT_STATUS=`python ${gitstatus} 2>/dev/null` - fi - if [[ "$GIT_PROMPT_EXECUTABLE" == "haskell" ]]; then - local gitstatus="$__GIT_PROMPT_DIR/dist/build/gitstatus/gitstatus" - _GIT_STATUS=`${gitstatus}` - fi + local gitstatus="$__GIT_PROMPT_DIR/gitstatus.py" + _GIT_STATUS=$(python ${gitstatus} 2>/dev/null) __CURRENT_GIT_STATUS=("${(@s: :)_GIT_STATUS}") - GIT_BRANCH=$__CURRENT_GIT_STATUS[1] - GIT_AHEAD=$__CURRENT_GIT_STATUS[2] - GIT_BEHIND=$__CURRENT_GIT_STATUS[3] - GIT_STAGED=$__CURRENT_GIT_STATUS[4] - GIT_CONFLICTS=$__CURRENT_GIT_STATUS[5] - GIT_CHANGED=$__CURRENT_GIT_STATUS[6] - GIT_UNTRACKED=$__CURRENT_GIT_STATUS[7] + GIT_BRANCH=$__CURRENT_GIT_STATUS[1] + GIT_AHEAD=$__CURRENT_GIT_STATUS[2] + GIT_BEHIND=$__CURRENT_GIT_STATUS[3] + GIT_STAGED=$__CURRENT_GIT_STATUS[4] + GIT_CONFLICTS=$__CURRENT_GIT_STATUS[5] + GIT_CHANGED=$__CURRENT_GIT_STATUS[6] + GIT_UNTRACKED=$__CURRENT_GIT_STATUS[7] } - git_super_status() { - precmd_update_git_vars + precmd_update_git_vars if [ -n "$__CURRENT_GIT_STATUS" ]; then - STATUS="$ZSH_THEME_GIT_PROMPT_PREFIX$ZSH_THEME_GIT_PROMPT_BRANCH$GIT_BRANCH%{${reset_color}%}" - if [ "$GIT_BEHIND" -ne "0" ]; then - STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_BEHIND$GIT_BEHIND%{${reset_color}%}" - fi - if [ "$GIT_AHEAD" -ne "0" ]; then - STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_AHEAD$GIT_AHEAD%{${reset_color}%}" - fi - STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_SEPARATOR" - if [ "$GIT_STAGED" -ne "0" ]; then - STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_STAGED$GIT_STAGED%{${reset_color}%}" - fi - if [ "$GIT_CONFLICTS" -ne "0" ]; then - STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_CONFLICTS$GIT_CONFLICTS%{${reset_color}%}" - fi - if [ "$GIT_CHANGED" -ne "0" ]; then - STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_CHANGED$GIT_CHANGED%{${reset_color}%}" - fi - if [ "$GIT_UNTRACKED" -ne "0" ]; then - STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_UNTRACKED%{${reset_color}%}" - fi - if [ "$GIT_CHANGED" -eq "0" ] && [ "$GIT_CONFLICTS" -eq "0" ] && [ "$GIT_STAGED" -eq "0" ] && [ "$GIT_UNTRACKED" -eq "0" ]; then - STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_CLEAN" - fi - STATUS="$STATUS%{${reset_color}%}$ZSH_THEME_GIT_PROMPT_SUFFIX" - echo "$STATUS" - fi + STATUS="$ZSH_THEME_GIT_PROMPT_PREFIX$ZSH_THEME_GIT_PROMPT_BRANCH$GIT_BRANCH%{${reset_color}%}" + if [ "$GIT_BEHIND" -ne "0" ]; then + STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_BEHIND$GIT_BEHIND%{${reset_color}%}" + fi + if [ "$GIT_AHEAD" -ne "0" ]; then + STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_AHEAD$GIT_AHEAD%{${reset_color}%}" + fi + STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_SEPARATOR" + if [ "$GIT_STAGED" -ne "0" ]; then + STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_STAGED$GIT_STAGED%{${reset_color}%}" + fi + if [ "$GIT_CONFLICTS" -ne "0" ]; then + STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_CONFLICTS$GIT_CONFLICTS%{${reset_color}%}" + fi + if [ "$GIT_CHANGED" -ne "0" ]; then + STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_CHANGED$GIT_CHANGED%{${reset_color}%}" + fi + if [ "$GIT_UNTRACKED" -ne "0" ]; then + STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_UNTRACKED%{${reset_color}%}" + fi + if [ "$GIT_CHANGED" -eq "0" ] && [ "$GIT_CONFLICTS" -eq "0" ] && [ "$GIT_STAGED" -eq "0" ] && [ "$GIT_UNTRACKED" -eq "0" ]; then + STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_CLEAN" + fi + STATUS="$STATUS%{${reset_color}%}$ZSH_THEME_GIT_PROMPT_SUFFIX" + echo "$STATUS" + fi } -# Default values for the appearance of the prompt. Configure at will. +# Default values for the appearance of the prompt. ZSH_THEME_GIT_PROMPT_PREFIX="(" ZSH_THEME_GIT_PROMPT_SUFFIX=")" ZSH_THEME_GIT_PROMPT_SEPARATOR="|" -- cgit v1.2.3-70-g09d2 From 94007f7db2d47f3e13e4aac878f0e780a479f628 Mon Sep 17 00:00:00 2001 From: Kentaro Wada Date: Sun, 2 Aug 2015 08:50:56 +0900 Subject: git-prompt: collect all git status information by one cmd This commit uses the `git status --porcelain -b` format to gather the number of ahead and behind commits related to the remote branch. --- plugins/git-prompt/gitstatus.py | 61 +++++++++++++++++++---------------------- 1 file changed, 28 insertions(+), 33 deletions(-) (limited to 'plugins') diff --git a/plugins/git-prompt/gitstatus.py b/plugins/git-prompt/gitstatus.py index 903ad474d..2f02e5fcc 100644 --- a/plugins/git-prompt/gitstatus.py +++ b/plugins/git-prompt/gitstatus.py @@ -5,25 +5,40 @@ from __future__ import print_function prehash = ':' import sys -import subprocess from subprocess import Popen, PIPE -branch, error = Popen(['git', 'symbolic-ref', 'HEAD'], stdout=PIPE, stderr=PIPE).communicate() -if 'fatal: Not a git repository' in error.decode('utf-8'): - sys.exit(0) +# `git status --porcelain -b` can collect all information +# branch, remote_branch, untracked, staged, changed, conflicts, ahead, behind +po = Popen(['git', 'status', '--porcelain', '-b'], stdout=PIPE, stderr=PIPE) +stdout, sterr = po.communicate() +if po.returncode != 0: + sys.exit(0) # Not a git repository -branch = branch.decode("utf-8").strip()[11:] - -# Get git status (staged, change, conflicts and untracked) -try: - res = subprocess.check_output(['git', 'status', '--porcelain']) -except subprocess.CalledProcessError: - sys.exit(0) -status = [(st[0], st[1], st[2:]) for st in res.splitlines()] +# collect git status information untracked, staged, changed, conflicts = [], [], [], [] +ahead, behind = 0, 0 +status = [(line[0], line[1], line[2:]) for line in stdout.splitlines()] for st in status: - if st[0] == '?' and st[1] == '?': + if st[0] == '#' and st[1] == '#': + if len(st[2].strip().split('...')) == 1: + branch = st[2].strip() + else: + # current and remote branch info + branch, rest = st[2].strip().split('...') + if len(rest.split(' ')) == 1: + # remote_branch = rest.split(' ')[0] + pass + else: + # ahead or behind + divergence = ' '.join(rest.split(' ')[1:]) + divergence = divergence.lstrip('[').rstrip(']') + for div in divergence.split(', '): + if 'ahead' in div: + ahead = int(div[len('ahead '):].strip()) + elif 'behind' in div: + behind = int(div[len('behind '):].strip()) + elif st[0] == '?' and st[1] == '?': untracked.append(st) else: if st[1] == 'M': @@ -33,26 +48,6 @@ for st in status: elif st[0] != ' ': staged.append(st) -ahead, behind = 0,0 - -if not branch: # not on any branch - branch = prehash + Popen(['git','rev-parse','--short','HEAD'], stdout=PIPE).communicate()[0].decode("utf-8")[:-1] -else: - remote_name = Popen(['git','config','branch.%s.remote' % branch], stdout=PIPE).communicate()[0].decode("utf-8").strip() - if remote_name: - merge_name = Popen(['git','config','branch.%s.merge' % branch], stdout=PIPE).communicate()[0].decode("utf-8").strip() - if remote_name == '.': # local - remote_ref = merge_name - else: - remote_ref = 'refs/remotes/%s/%s' % (remote_name, merge_name[11:]) - revgit = Popen(['git', 'rev-list', '--left-right', '%s...HEAD' % remote_ref],stdout=PIPE, stderr=PIPE) - revlist = revgit.communicate()[0] - if revgit.poll(): # fallback to local - revlist = Popen(['git', 'rev-list', '--left-right', '%s...HEAD' % merge_name],stdout=PIPE, stderr=PIPE).communicate()[0] - behead = revlist.decode("utf-8").splitlines() - ahead = len([x for x in behead if x[0]=='>']) - behind = len(behead) - ahead - out = ' '.join([ branch, str(ahead), -- cgit v1.2.3-70-g09d2 From 30bed07e9c9480d1e563d29da5747ce427f58d8d Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Tue, 4 Aug 2015 16:34:03 +0200 Subject: Parse UTF-8 output from git status --- plugins/git-prompt/gitstatus.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'plugins') diff --git a/plugins/git-prompt/gitstatus.py b/plugins/git-prompt/gitstatus.py index 2f02e5fcc..8790f3a3c 100644 --- a/plugins/git-prompt/gitstatus.py +++ b/plugins/git-prompt/gitstatus.py @@ -18,7 +18,7 @@ if po.returncode != 0: # collect git status information untracked, staged, changed, conflicts = [], [], [], [] ahead, behind = 0, 0 -status = [(line[0], line[1], line[2:]) for line in stdout.splitlines()] +status = [(line[0], line[1], line[2:]) for line in stdout.decode('utf-8').splitlines()] for st in status: if st[0] == '#' and st[1] == '#': if len(st[2].strip().split('...')) == 1: @@ -58,4 +58,3 @@ out = ' '.join([ str(len(untracked)), ]) print(out, end='') - -- cgit v1.2.3-70-g09d2 From 45473c3a81410735dac7fe0a1df33ad95fd3f2e5 Mon Sep 17 00:00:00 2001 From: Kentaro Wada Date: Tue, 11 Aug 2015 12:04:51 +0900 Subject: Fix for initial or detached status branch info --- plugins/git-prompt/gitstatus.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'plugins') diff --git a/plugins/git-prompt/gitstatus.py b/plugins/git-prompt/gitstatus.py index 8790f3a3c..59feadc39 100644 --- a/plugins/git-prompt/gitstatus.py +++ b/plugins/git-prompt/gitstatus.py @@ -5,6 +5,8 @@ from __future__ import print_function prehash = ':' import sys +import re +import subprocess from subprocess import Popen, PIPE @@ -21,8 +23,13 @@ ahead, behind = 0, 0 status = [(line[0], line[1], line[2:]) for line in stdout.decode('utf-8').splitlines()] for st in status: if st[0] == '#' and st[1] == '#': - if len(st[2].strip().split('...')) == 1: + if re.search('Initial commit on', st[2]): + branch = st[2].split(' ')[-1] + elif len(st[2].strip().split('...')) == 1: branch = st[2].strip() + if branch == 'HEAD (no branch)': + cmd = ['git', 'log', '-1', '--format="%h"'] + branch = subprocess.check_output(cmd).strip().strip('"') else: # current and remote branch info branch, rest = st[2].strip().split('...') -- cgit v1.2.3-70-g09d2 From 3c698743fa4265ab2b70b880e12f957792669438 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Tue, 11 Aug 2015 11:29:05 +0200 Subject: Clean up gitstatus.py --- plugins/git-prompt/gitstatus.py | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) (limited to 'plugins') diff --git a/plugins/git-prompt/gitstatus.py b/plugins/git-prompt/gitstatus.py index 59feadc39..1beae541a 100644 --- a/plugins/git-prompt/gitstatus.py +++ b/plugins/git-prompt/gitstatus.py @@ -1,18 +1,14 @@ #!/usr/bin/env python from __future__ import print_function -# change this symbol to whatever you prefer -prehash = ':' - import sys import re -import subprocess -from subprocess import Popen, PIPE +from subprocess import Popen, PIPE, check_output -# `git status --porcelain -b` can collect all information +# `git status --porcelain --branch` can collect all information # branch, remote_branch, untracked, staged, changed, conflicts, ahead, behind -po = Popen(['git', 'status', '--porcelain', '-b'], stdout=PIPE, stderr=PIPE) +po = Popen(['git', 'status', '--porcelain', '--branch'], stdout=PIPE, stderr=PIPE) stdout, sterr = po.communicate() if po.returncode != 0: sys.exit(0) # Not a git repository @@ -25,11 +21,10 @@ for st in status: if st[0] == '#' and st[1] == '#': if re.search('Initial commit on', st[2]): branch = st[2].split(' ')[-1] + elif re.search('no branch', st[2]): + branch = check_output(['git', 'rev-parse', '--short', 'HEAD']).decode('utf-8').strip() elif len(st[2].strip().split('...')) == 1: branch = st[2].strip() - if branch == 'HEAD (no branch)': - cmd = ['git', 'log', '-1', '--format="%h"'] - branch = subprocess.check_output(cmd).strip().strip('"') else: # current and remote branch info branch, rest = st[2].strip().split('...') -- cgit v1.2.3-70-g09d2 From be667a24b0dc6a42a3e5368727366449b09633d1 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Mon, 17 Aug 2015 01:05:37 +0200 Subject: Remove obsolete comment --- plugins/emoji/emoji.plugin.zsh | 2 -- 1 file changed, 2 deletions(-) (limited to 'plugins') diff --git a/plugins/emoji/emoji.plugin.zsh b/plugins/emoji/emoji.plugin.zsh index f2d169bf3..7876f1c89 100644 --- a/plugins/emoji/emoji.plugin.zsh +++ b/plugins/emoji/emoji.plugin.zsh @@ -76,8 +76,6 @@ emoji_skintone[6]=$'\U1F3FF' # These are stored in a single associative array, $emoji_groups, to avoid cluttering up the global # namespace, and to allow adding additional group definitions at run time. # The keys are the group names, and the values are whitespace-separated lists of emoji character names. -# -# These extra local arrays are used to allow more convenient formatting of the source code. emoji_groups[fruits]=" tomato -- cgit v1.2.3-70-g09d2 From 3f83331c71b9dd8b1065c4e7a58223cd7d5be421 Mon Sep 17 00:00:00 2001 From: Mohnish Jadwani Date: Mon, 17 Aug 2015 06:23:58 +0530 Subject: removes a trailing white space --- plugins/rails/rails.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins') diff --git a/plugins/rails/rails.plugin.zsh b/plugins/rails/rails.plugin.zsh index 097578e23..c4ad595e7 100644 --- a/plugins/rails/rails.plugin.zsh +++ b/plugins/rails/rails.plugin.zsh @@ -58,7 +58,7 @@ alias rdmtc='rake db:migrate db:test:clone' alias rlc='rake log:clear' alias rn='rake notes' alias rr='rake routes' -alias rrg='rake routes | grep ' +alias rrg='rake routes | grep' # legacy stuff alias sstat='thin --stats "/thin/stats" start' -- cgit v1.2.3-70-g09d2 From c4ba3065a1e9beb76f2f0ac64f3436b5448576b2 Mon Sep 17 00:00:00 2001 From: Kentaro Wada Date: Mon, 17 Aug 2015 18:22:27 +0900 Subject: Show tag name when detached status if possible --- plugins/git-prompt/gitstatus.py | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) (limited to 'plugins') diff --git a/plugins/git-prompt/gitstatus.py b/plugins/git-prompt/gitstatus.py index 1beae541a..a8eb8284b 100644 --- a/plugins/git-prompt/gitstatus.py +++ b/plugins/git-prompt/gitstatus.py @@ -3,9 +3,31 @@ from __future__ import print_function import sys import re +import shlex from subprocess import Popen, PIPE, check_output +def get_tagname_or_hash(): + """return tagname if exists else hash""" + cmd = 'git log -1 --format="%h%d"' + output = check_output(shlex.split(cmd)).decode('utf-8').strip() + hash_, tagname = None, None + # get hash + m = re.search('\(.*\)$', output) + if m: + hash_ = output[:m.start()-1] + # get tagname + m = re.search('tag: .*[,\)]', output) + if m: + tagname = 'tags/' + output[m.start()+len('tag: '): m.end()-1] + + if tagname: + return tagname + elif hash_: + return hash_ + return None + + # `git status --porcelain --branch` can collect all information # branch, remote_branch, untracked, staged, changed, conflicts, ahead, behind po = Popen(['git', 'status', '--porcelain', '--branch'], stdout=PIPE, stderr=PIPE) @@ -21,8 +43,8 @@ for st in status: if st[0] == '#' and st[1] == '#': if re.search('Initial commit on', st[2]): branch = st[2].split(' ')[-1] - elif re.search('no branch', st[2]): - branch = check_output(['git', 'rev-parse', '--short', 'HEAD']).decode('utf-8').strip() + elif re.search('no branch', st[2]): # detached status + branch = get_tagname_or_hash() elif len(st[2].strip().split('...')) == 1: branch = st[2].strip() else: -- cgit v1.2.3-70-g09d2 From 96c34cebae5da3a52e7da0d61188c1f9822a9c2e Mon Sep 17 00:00:00 2001 From: Andrew Janke Date: Sun, 9 Aug 2015 16:37:12 -0400 Subject: Add a deprecation comment. --- lib/functions.zsh | 2 -- plugins/terminalapp/terminalapp.plugin.zsh | 6 ++++++ 2 files changed, 6 insertions(+), 2 deletions(-) create mode 100644 plugins/terminalapp/terminalapp.plugin.zsh (limited to 'plugins') diff --git a/lib/functions.zsh b/lib/functions.zsh index 5c1a5a283..2a962669c 100644 --- a/lib/functions.zsh +++ b/lib/functions.zsh @@ -176,7 +176,6 @@ function omz_urldecode { emulate -L zsh local encoded_url=$1 - echo -e input $1 # Work bytewise, since URLs escape UTF-8 octets local caller_encoding=$langinfo[CODESET] local LC_ALL=C @@ -188,7 +187,6 @@ function omz_urldecode { tmp=${tmp:gs/\\/\\\\/} # Handle %-escapes by turning them into `\xXX` printf escapes tmp=${tmp:gs/%/\\x/} - echo -E "before decode $tmp" local decoded eval "decoded=\$'$tmp'" diff --git a/plugins/terminalapp/terminalapp.plugin.zsh b/plugins/terminalapp/terminalapp.plugin.zsh new file mode 100644 index 000000000..7c0c278b9 --- /dev/null +++ b/plugins/terminalapp/terminalapp.plugin.zsh @@ -0,0 +1,6 @@ +# This file is intentionally empty. +# +# The terminalapp plugin is deprecated and may be removed in a future release. +# Its functionality has been folded in to the core lib/termsupport.zsh, which +# is loaded for all users. You can remove terminalapp from your $plugins list +# once all your systems are updated to the current version of Oh My Zsh. -- cgit v1.2.3-70-g09d2 From 7cf892ecaa86f064aa3f78b9d5bee3b7db208ca4 Mon Sep 17 00:00:00 2001 From: Andrew Janke Date: Tue, 18 Aug 2015 04:46:52 -0400 Subject: Add dashboard support and default-action configuration. Some refactoring. --- plugins/jira/jira.plugin.zsh | 118 ++++++++++++++++++++++++------------------- 1 file changed, 66 insertions(+), 52 deletions(-) (limited to 'plugins') diff --git a/plugins/jira/jira.plugin.zsh b/plugins/jira/jira.plugin.zsh index 842dff5c7..a10feec3e 100644 --- a/plugins/jira/jira.plugin.zsh +++ b/plugins/jira/jira.plugin.zsh @@ -1,61 +1,88 @@ -# To use: add a .jira-url file in the base of your project -# You can also set JIRA_URL in your .zshrc or put .jira-url in your home directory -# .jira-url in the current directory takes precedence. The same goes with .jira-prefix -# and JIRA_PREFIX. +# CLI support for JIRA interaction # -# If you use Rapid Board, set: -#JIRA_RAPID_BOARD="true" -# in you .zshrc +# Setup: +# Add a .jira-url file in the base of your project +# You can also set $JIRA_URL in your .zshrc or put .jira-url in your home directory +# A .jira-url in the current directory takes precedence. +# The same goes with .jira-prefix and $JIRA_PREFIX. # -# Setup: cd to/my/project -# echo "https://name.jira.com" >> .jira-url -# Usage: jira # opens a new issue -# jira ABC-123 # Opens an existing issue -open_jira_issue () { - if [ -f .jira-url ]; then +# For example: +# cd to/my/project +# echo "https://name.jira.com" >> .jira-url +# +# Variables: +# $JIRA_RAPID_BOARD - set to "true" if you use Rapid Board +# $JIRA_DEFAULT_ACTION - action to do when `jira` is called witn no args +# defaults to "new" +# $JIRA_NAME - Your JIRA username. Used as default for assigned/reported +# $JIRA_PREFIX - Prefix added to issue ID arguments +# +# +# Usage: +# jira # Performs the default action +# jira new # opens a new issue +# jira reported [username] +# jira assigned [username] +# jira dashboard +# jira ABC-123 # Opens an existing issue +# jira ABC-123 m # Opens an existing issue for adding a comment + +: ${JIRA_DEFAULT_ACTION:=new} + +function jira() { + local action=${1:=$JIRA_DEFAULT_ACTION} + + local jira_url jira_prefix + if [[ -f .jira-url ]]; then jira_url=$(cat .jira-url) - elif [ -f ~/.jira-url ]; then + elif [[ -f ~/.jira-url ]]; then jira_url=$(cat ~/.jira-url) - elif [[ "${JIRA_URL}" != "" ]]; then + elif [[ -n "${JIRA_URL}" ]]; then jira_url=${JIRA_URL} else jira_url_help return 1 fi - local jira_prefix - if [ -f .jira-prefix ]; then + if [[ -f .jira-prefix ]]; then jira_prefix=$(cat .jira-prefix) - elif [ -f ~/.jira-prefix ]; then + elif [[ -f ~/.jira-prefix ]]; then jira_prefix=$(cat ~/.jira-prefix) - elif [[ "${JIRA_PREFIX}" != "" ]]; then + elif [[ -n "${JIRA_PREFIX}" ]]; then jira_prefix=${JIRA_PREFIX} else jira_prefix="" fi - if [ -z "$1" ]; then + + if [[ $action == "new" ]]; then echo "Opening new issue" open_command "${jira_url}/secure/CreateIssue!default.jspa" - elif [[ "$1" = "assigned" || "$1" = "reported" ]]; then + elif [[ "$action" == "assigned" || "$action" == "reported" ]]; then jira_query $@ + elif [[ "$action" == "dashboard" ]]; then + echo "Opening dashboard" + open_command "${jira_url}/secure/Dashboard.jspa" else - local addcomment='' + # Anything that doesn't match a special action is considered an issue name + local issue_arg=$action + local issue="${jira_prefix}${issue_arg}" + local url_fragment='' if [[ "$2" == "m" ]]; then - addcomment="#add-comment" - echo "Add comment to issue #$1" + url_fragment="#add-comment" + echo "Add comment to issue #$issue" else - echo "Opening issue #$1" + echo "Opening issue #$issue" fi if [[ "$JIRA_RAPID_BOARD" == "true" ]]; then - open_command "${jira_url}/issues/${jira_prefix}${1}${addcomment}" + open_command "${jira_url}/issues/${issue}${url_fragment}" else - open_command "${jira_url}/browse/${jira_prefix}${1}${addcomment}" + open_command "${jira_url}/browse/${issue}${url_fragment}" fi fi } -jira_url_help() { +function jira_url_help() { cat << EOF JIRA url is not specified anywhere. Valid options, in order of precedence: @@ -65,40 +92,27 @@ Valid options, in order of precedence: EOF } -jira_name () { - if [[ -z "$1" ]]; then - if [[ "${JIRA_NAME}" != "" ]]; then - jira_name=${JIRA_NAME} - else - echo "JIRA_NAME not specified" - return 1 - fi - else - jira_name=$@ - fi -} - -jira_query () { +function jira_query() { local verb="$1" - local jira_name lookup preposition - if [[ "${verb}" = "reported" ]]; then + local jira_name lookup preposition query + if [[ "${verb}" == "reported" ]]; then lookup=reporter preposition=by - elif [[ "${verb}" = "assigned" ]]; then + elif [[ "${verb}" == "assigned" ]]; then lookup=assignee preposition=to else - echo "not a valid lookup $verb" + echo "not a valid lookup: $verb" >&2 return 1 fi - shift 1 - jira_name $@ - if [[ $? = 1 ]]; then + jira_name=${2:=$JIRA_NAME} + if [[ -z $jira_name ]]; then + echo "JIRA_NAME not specified" >&2 return 1 fi + echo "Browsing issues ${verb} ${preposition} ${jira_name}" - open_command "${jira_url}/secure/IssueNavigator.jspa?reset=true&jqlQuery=${lookup}+%3D+%22${jira_name}%22+AND+resolution+%3D+unresolved+ORDER+BY+priority+DESC%2C+created+ASC" + query="${lookup}+%3D+%22${jira_name}%22+AND+resolution+%3D+unresolved+ORDER+BY+priority+DESC%2C+created+ASC" + open_command "${jira_url}/secure/IssueNavigator.jspa?reset=true&jqlQuery=${query}" } -alias jira='open_jira_issue' - -- cgit v1.2.3-70-g09d2 From dc42e8d488d7b7b5285e71947940c7d6fb19355b Mon Sep 17 00:00:00 2001 From: Andrew Janke Date: Tue, 18 Aug 2015 05:05:54 -0400 Subject: jira: add completion --- plugins/jira/_jira | 21 +++++++++++++++++++++ plugins/jira/jira.plugin.zsh | 8 ++++---- 2 files changed, 25 insertions(+), 4 deletions(-) create mode 100644 plugins/jira/_jira (limited to 'plugins') diff --git a/plugins/jira/_jira b/plugins/jira/_jira new file mode 100644 index 000000000..b0ea658e2 --- /dev/null +++ b/plugins/jira/_jira @@ -0,0 +1,21 @@ +#compdef jira +#autoload + +local -a _1st_arguments +_1st_arguments=( + 'new:create a new issue' + 'dashboard:open the dashboard' + 'reported:search for issues reported by a user' + 'assigned:search for issues assigned to a user' +) + +_arguments -C \ + ':command:->command' \ + '*::options:->options' + +case $state in + (command) + _describe -t commands "jira subcommand" _1st_arguments + return + ;; +esac diff --git a/plugins/jira/jira.plugin.zsh b/plugins/jira/jira.plugin.zsh index a10feec3e..89559767f 100644 --- a/plugins/jira/jira.plugin.zsh +++ b/plugins/jira/jira.plugin.zsh @@ -40,7 +40,7 @@ function jira() { elif [[ -n "${JIRA_URL}" ]]; then jira_url=${JIRA_URL} else - jira_url_help + _jira_url_help return 1 fi @@ -59,7 +59,7 @@ function jira() { echo "Opening new issue" open_command "${jira_url}/secure/CreateIssue!default.jspa" elif [[ "$action" == "assigned" || "$action" == "reported" ]]; then - jira_query $@ + _jira_query $@ elif [[ "$action" == "dashboard" ]]; then echo "Opening dashboard" open_command "${jira_url}/secure/Dashboard.jspa" @@ -82,7 +82,7 @@ function jira() { fi } -function jira_url_help() { +function _jira_url_help() { cat << EOF JIRA url is not specified anywhere. Valid options, in order of precedence: @@ -92,7 +92,7 @@ Valid options, in order of precedence: EOF } -function jira_query() { +function _jira_query() { local verb="$1" local jira_name lookup preposition query if [[ "${verb}" == "reported" ]]; then -- cgit v1.2.3-70-g09d2 From a9daea17d89ae2b7d30dc6e184566ca8104e63d2 Mon Sep 17 00:00:00 2001 From: fgibaux Date: Tue, 18 Aug 2015 14:19:40 +0200 Subject: plugin symfony2 sf2.7 compatibility fix with symfony 2.7 command group titles are listed as commands. this commit prevents it. --- plugins/symfony2/symfony2.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins') diff --git a/plugins/symfony2/symfony2.plugin.zsh b/plugins/symfony2/symfony2.plugin.zsh index e94280ed0..98a2321db 100644 --- a/plugins/symfony2/symfony2.plugin.zsh +++ b/plugins/symfony2/symfony2.plugin.zsh @@ -5,7 +5,7 @@ _symfony_console () { } _symfony2_get_command_list () { - `_symfony_console` --no-ansi | sed "1,/Available commands/d" | awk '/^ ?[a-z]+/ { print $1 }' + `_symfony_console` --no-ansi | sed "1,/Available commands/d" | awk '/^ ?[^ ]+ / { print $1 }' } _symfony2 () { -- cgit v1.2.3-70-g09d2 From 7c31c7a96391e80bdd6ebdb6579751f4d44d6ac4 Mon Sep 17 00:00:00 2001 From: Tim O'Brien Date: Wed, 19 Aug 2015 22:33:41 -0700 Subject: Bring bgnotify plugin up to date with t413/zsh-background-notify Changes include: - time format now shows h/m/s (only when needed!) - adds hooks only for interactive connections - adds specific kde support (via kdialog) - adds click-action for OS X terminals --- plugins/bgnotify/bgnotify.plugin.zsh | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-) (limited to 'plugins') diff --git a/plugins/bgnotify/bgnotify.plugin.zsh b/plugins/bgnotify/bgnotify.plugin.zsh index b70b42f98..f6dd3886c 100755 --- a/plugins/bgnotify/bgnotify.plugin.zsh +++ b/plugins/bgnotify/bgnotify.plugin.zsh @@ -11,31 +11,38 @@ autoload -Uz add-zsh-hook || { print "can't add zsh hook!"; return } ## definitions ## -if ! (type bgnotify_formatted | grep -q 'function'); then - function bgnotify_formatted { - ## exit_status, command, elapsed_time - [ $1 -eq 0 ] && title="#win (took $3 s)" || title="#fail (took $3 s)" - bgnotify "$title" "$2" +if ! (type bgnotify_formatted | grep -q 'function'); then ## allow custom function override + function bgnotify_formatted { ## args: (exit_status, command, elapsed_seconds) + elapsed="$(( $3 % 60 ))s" + (( $3 >= 60 )) && elapsed="$((( $3 % 3600) / 60 ))m $elapsed" + (( $3 >= 3600 )) && elapsed="$(( $3 / 3600 ))h $elapsed" + [ $1 -eq 0 ] && bgnotify "#win (took $elapsed)" "$2" || bgnotify "#fail (took $elapsed)" "$2" } fi currentWindowId () { if hash osascript 2>/dev/null; then #osx osascript -e 'tell application (path to frontmost application as text) to id of front window' 2&> /dev/null || echo "0" - elif hash notify-send 2>/dev/null; then #ubuntu! - xprop -root | awk '/NET_ACTIVE_WINDOW/ { print $5; exit }' + elif (hash notify-send 2>/dev/null || hash kdialog 2>/dev/null); then #ubuntu! + xprop -root 2> /dev/null | awk '/NET_ACTIVE_WINDOW/{print $5;exit} END{exit !$5}' || echo "0" else echo $EPOCHSECONDS #fallback for windows fi } -bgnotify () { +bgnotify () { ## args: (title, subtitle) if hash terminal-notifier 2>/dev/null; then #osx - terminal-notifier -message "$2" -title "$1" + [[ "$TERM_PROGRAM" == 'iTerm.app' ]] && term_id='com.googlecode.iterm2' || + [[ "$TERM_PROGRAM" == 'Apple_Terminal' ]] && term_id='com.apple.terminal'; + ## now call terminal-notifier, (hopefully with $term_id!) + [ -z "$term_id" ] && terminal-notifier -message "$2" -title "$1" >/dev/null || + terminal-notifier -message "$2" -title "$1" -activate "$term_id" -sender "$term_id" >/dev/null elif hash growlnotify 2>/dev/null; then #osx growl growlnotify -m "$1" "$2" - elif hash notify-send 2>/dev/null; then #ubuntu! + elif hash notify-send 2>/dev/null; then #ubuntu gnome! notify-send "$1" "$2" + elif hash kdialog 2>/dev/null; then #ubuntu kde! + kdialog -title "$1" --passivepopup "$2" 5 elif hash notifu 2>/dev/null; then #cygwyn support! notifu /m "$2" /p "$1" fi @@ -46,7 +53,7 @@ bgnotify () { bgnotify_begin() { bgnotify_timestamp=$EPOCHSECONDS - bgnotify_lastcmd=$1 + bgnotify_lastcmd="$1" bgnotify_windowid=$(currentWindowId) } @@ -63,5 +70,8 @@ bgnotify_end() { bgnotify_timestamp=0 #reset it to 0! } -add-zsh-hook preexec bgnotify_begin -add-zsh-hook precmd bgnotify_end +## only enable if a local (non-ssh) connection +if [ -z "$SSH_CLIENT" ] && [ -z "$SSH_TTY" ]; then + add-zsh-hook preexec bgnotify_begin + add-zsh-hook precmd bgnotify_end +fi -- cgit v1.2.3-70-g09d2 From 1aeebf60a0dd09ba13a08ae0b81d1d44cad7d15c Mon Sep 17 00:00:00 2001 From: 章正中 Date: Fri, 21 Aug 2015 14:28:03 +0800 Subject: Update link --- plugins/vundle/vundle.plugin.zsh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'plugins') diff --git a/plugins/vundle/vundle.plugin.zsh b/plugins/vundle/vundle.plugin.zsh index fa1911477..0f071597a 100644 --- a/plugins/vundle/vundle.plugin.zsh +++ b/plugins/vundle/vundle.plugin.zsh @@ -1,13 +1,13 @@ function vundle-init () { - if [ ! -d ~/.vim/bundle/vundle/ ] + if [ ! -d ~/.vim/bundle/Vundle.vim/ ] then - mkdir -p ~/.vim/bundle/vundle/ + mkdir -p ~/.vim/bundle/Vundle.vim/ fi - if [ ! -d ~/.vim/bundle/vundle/.git ] && [ ! -f ~/.vim/bundle/vundle/.git ] + if [ ! -d ~/.vim/bundle/Vundle.vim/.git ] && [ ! -f ~/.vim/bundle/Vundle.vim/.git ] then - git clone http://github.com/gmarik/vundle.git ~/.vim/bundle/vundle - echo "\n\tRead about vim configuration for vundle at https://github.com/gmarik/vundle\n" + git clone git://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim + echo "\n\tRead about vim configuration for vundle at https://github.com/VundleVim/Vundle.vim\n" fi } -- cgit v1.2.3-70-g09d2 From aaf5c8f43f6eee141b9ea4b85b4e1097db4a1770 Mon Sep 17 00:00:00 2001 From: Philippe Loctaux Date: Fri, 21 Aug 2015 16:05:54 +0200 Subject: added apt-get autoremove in ubuntu plugin I use that command a lot of times, and there's no shortcut for that. Now it does :) --- plugins/ubuntu/ubuntu.plugin.zsh | 3 +++ 1 file changed, 3 insertions(+) (limited to 'plugins') diff --git a/plugins/ubuntu/ubuntu.plugin.zsh b/plugins/ubuntu/ubuntu.plugin.zsh index 0211d3374..a1a5016c7 100644 --- a/plugins/ubuntu/ubuntu.plugin.zsh +++ b/plugins/ubuntu/ubuntu.plugin.zsh @@ -3,6 +3,7 @@ # https://github.com/dbb # https://github.com/Mappleconfusers # Nicolas Jonas nextgenthemes.com +# https://github.com/loctauxphilippe # # Debian, Ubuntu and friends related zsh aliases and functions for zsh @@ -38,6 +39,7 @@ alias agu='sudo apt-get update' # ad alias agud='sudo apt-get update && sudo apt-get dist-upgrade' #adu alias agug='sudo apt-get upgrade' # ag alias aguu='sudo apt-get update && sudo apt-get upgrade' #adg +alias agar='sudo apt-get autoremove' compdef _ag ag='sudo apt-get' compdef _aga aga='sudo apt-get autoclean' @@ -51,6 +53,7 @@ compdef _agu agu='sudo apt-get update' compdef _agud agud='sudo apt-get update && sudo apt-get dist-upgrade' compdef _agug agug='sudo apt-get upgrade' compdef _aguu aguu='sudo apt-get update && sudo apt-get upgrade' +compdef _agar agar='sudo apt-get autoremove' # Remove ALL kernel images and headers EXCEPT the one in use alias kclean='sudo aptitude remove -P ?and(~i~nlinux-(ima|hea) \ -- cgit v1.2.3-70-g09d2 From 76f4871d4e65a8d114055c765ed026ebadd5079d Mon Sep 17 00:00:00 2001 From: Dawid Ferenczy Date: Tue, 25 Aug 2015 18:07:47 +0200 Subject: Added missing commands to Vagrant plugin, updated commands description --- plugins/vagrant/_vagrant | 36 ++++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 14 deletions(-) (limited to 'plugins') diff --git a/plugins/vagrant/_vagrant b/plugins/vagrant/_vagrant index 76f80b0d7..764f89545 100644 --- a/plugins/vagrant/_vagrant +++ b/plugins/vagrant/_vagrant @@ -1,4 +1,4 @@ -#compdef vagrant +#compdef vagrant #autoload # vagrant zsh completion @@ -6,37 +6,45 @@ local -a _1st_arguments _1st_arguments=( 'box:Box commands' - 'connect:Connects to a shared, remote Vagrant environment' + 'connect:Connects to a remotely shared Vagrant environment' 'destroy:Destroys the vagrant environment' - 'docker-logs:Shows Docker logs' - 'docker-run:Run one-off commands against a Docker container' + 'docker-logs:Outputs the logs from the Docker container' + 'docker-run:Run a one-off command in the context of a container' 'global-status:Reports the status of all active Vagrant environments on the system' 'halt:Halts the currently running vagrant environment' + 'help:Shows the help for a subcommand' 'init:[box_name] [box_url] Initializes current folder for Vagrant usage' + 'list-commands:Outputs all available Vagrant subcommands, even non-primary ones' 'login:Authenticates against a Vagrant Cloud server to access protected boxes' 'package:Packages a vagrant environment for distribution' 'plugin:Plugin commands' 'provision:Run the provisioner' + 'push:Deploys code in this environment to a configured destination' + 'rdp:Connects to machine via RDP' 'reload:Reload the vagrant environment' 'resume:Resumes a suspend vagrant environment' - 'share:Shares the Vagrant environment and allows remote access' + 'rsync:Syncs rsync synced folders to remote machine' + 'rsync-auto:Syncs rsync synced folders automatically when files change' + 'share:Shares your Vagrant environment with anyone in the world' 'ssh:SSH into the currently running environment' - 'ssh-config:outputs .ssh/config valid syntax for connecting to this environment via ssh' + 'ssh-config:Outputs .ssh/config valid syntax for connecting to this environment via ssh' 'status:Shows the status of the current Vagrant environment' 'suspend:Suspends the currently running vagrant environment' 'up:Creates the vagrant environment' - 'version:Prints the currently installed Vagrant version and checks for new updates' + 'version:Prints current and latest Vagrant version' '--help:[TASK] Describe available tasks or one specific task' '--version:Prints the Vagrant version information' ) local -a _box_arguments _box_arguments=( - 'add:NAME URI Add a box to the system' - 'help:COMMAND Describe subcommands or one specific subcommand' + 'add:ADDRESS Adds a box to the system' + 'help:COMMAND List subcommands' 'list:Lists all installed boxes' - 'remove:NAME Remove a box from the system' - 'repackage:NAME Repackage an installed box into a `.box` file.' + 'outdated:Checks if a box has newer version' + 'remove:NAME Removes a box from the system' + 'repackage:NAME PROVIDER VERSION Repackages an installed box into a `.box` file' + 'update:Updates box to a newer version, if available' ) __task_list () @@ -78,7 +86,7 @@ __vagrant-box () (options) case $line[1] in (repackage|remove) - _arguments ':feature:__box_list' + _arguments ':feature:__box_list' ;; esac ;; @@ -107,14 +115,14 @@ case $state in (options) case $line[1] in (help) - _arguments ':feature:__task_list' + _arguments ':feature:__task_list' ;; (box) __vagrant-box ;; (up|provision|package|destroy|reload|ssh|ssh-config|halt|resume|status) - _arguments ':feature:__vm_list' + _arguments ':feature:__vm_list' esac ;; esac -- cgit v1.2.3-70-g09d2 From 1bf5c587a5183f111538bf0879fbc75892988b8e Mon Sep 17 00:00:00 2001 From: Hans Chen Date: Tue, 25 Aug 2015 17:05:28 -0400 Subject: Update autojump plugin for latest brew installation --- plugins/autojump/autojump.plugin.zsh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'plugins') diff --git a/plugins/autojump/autojump.plugin.zsh b/plugins/autojump/autojump.plugin.zsh index 4cf036401..c05c699e1 100644 --- a/plugins/autojump/autojump.plugin.zsh +++ b/plugins/autojump/autojump.plugin.zsh @@ -15,7 +15,7 @@ if [ $commands[autojump] ]; then # check if autojump is installed . /usr/local/share/autojump/autojump.zsh elif [ -f /opt/local/etc/profile.d/autojump.zsh ]; then # mac os x with ports . /opt/local/etc/profile.d/autojump.zsh - elif [ $commands[brew] -a -f `brew --prefix`/etc/autojump.zsh ]; then # mac os x with brew - . `brew --prefix`/etc/autojump.zsh + elif [ $commands[brew] -a -f `brew --prefix`/etc/autojump.sh ]; then # mac os x with brew + . `brew --prefix`/etc/autojump.sh fi fi -- cgit v1.2.3-70-g09d2 From a127c4f88e9807c9d5ac58f5424dfc479370c227 Mon Sep 17 00:00:00 2001 From: Niccolò Maggioni Date: Wed, 26 Aug 2015 10:48:01 +0200 Subject: 'ip' command compatibility and much quicker external IP detection --- plugins/systemadmin/systemadmin.plugin.zsh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'plugins') diff --git a/plugins/systemadmin/systemadmin.plugin.zsh b/plugins/systemadmin/systemadmin.plugin.zsh index 4ae70dfa7..f6641b273 100644 --- a/plugins/systemadmin/systemadmin.plugin.zsh +++ b/plugins/systemadmin/systemadmin.plugin.zsh @@ -140,12 +140,16 @@ d0() { # gather external ip address geteip() { - curl http://ifconfig.me + echo "$(curl -s -S http://ipecho.net/plain)" } # determine local IP address getip() { - ifconfig | grep 'inet addr:'| grep -v '127.0.0.1' | cut -d: -f2 | awk '{ print $1}' + if [ "$(which ip)" != "" ]; then + ip addr | grep "inet " | grep -v '127.0.0.1' | awk '{print $2}' + else + ifconfig | grep 'inet addr:'| grep -v '127.0.0.1' | cut -d: -f2 | awk '{ print $1}' + fi } # Clear zombie processes -- cgit v1.2.3-70-g09d2 From 058bbe4f02be67102871d82de6aa194e6b865cf8 Mon Sep 17 00:00:00 2001 From: Niccolò Maggioni Date: Wed, 26 Aug 2015 10:54:08 +0200 Subject: General compatibility --- plugins/systemadmin/systemadmin.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins') diff --git a/plugins/systemadmin/systemadmin.plugin.zsh b/plugins/systemadmin/systemadmin.plugin.zsh index f6641b273..5618ba8f1 100644 --- a/plugins/systemadmin/systemadmin.plugin.zsh +++ b/plugins/systemadmin/systemadmin.plugin.zsh @@ -145,7 +145,7 @@ geteip() { # determine local IP address getip() { - if [ "$(which ip)" != "" ]; then + if [ $(hash | grep '^ip=') ]; then ip addr | grep "inet " | grep -v '127.0.0.1' | awk '{print $2}' else ifconfig | grep 'inet addr:'| grep -v '127.0.0.1' | cut -d: -f2 | awk '{ print $1}' -- cgit v1.2.3-70-g09d2 From 241be2d28b41293f163c4be75bb122975c2eacd9 Mon Sep 17 00:00:00 2001 From: Robin Daugherty Date: Wed, 26 Aug 2015 13:24:59 -0400 Subject: Fix rand-quote failure when site is unreachable This plugin was designed so that if there is any failure, it will simply call itself recursively. Which means that if you were working offline, if `quote` was called in your `.zshrc`, you would be unable to open a new terminal session. I fixed this by allowing the plugin to output nothing if a quote could not be fetched. --- plugins/rand-quote/rand-quote.plugin.zsh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'plugins') diff --git a/plugins/rand-quote/rand-quote.plugin.zsh b/plugins/rand-quote/rand-quote.plugin.zsh index c3bf6234e..3c9722a73 100644 --- a/plugins/rand-quote/rand-quote.plugin.zsh +++ b/plugins/rand-quote/rand-quote.plugin.zsh @@ -18,8 +18,8 @@ if [[ -x `which curl` ]]; then W=$(echo "$Q" | sed -e 's/.*\/quotes\///g' -e 's/<.*//g' -e 's/.*">//g') if [ "$W" -a "$TXT" ]; then echo "${WHO_COLOR}${W}${COLON_COLOR}: ${TEXT_COLOR}“${TXT}”${END_COLOR}" - else - quote + # else + # quote fi } #quote -- cgit v1.2.3-70-g09d2 From 96aefd2b98e5a646573a0ad6394f6ca0276facf1 Mon Sep 17 00:00:00 2001 From: Robin Daugherty Date: Wed, 26 Aug 2015 14:12:38 -0400 Subject: Remove code, not comment it out Gaaah. --- plugins/rand-quote/rand-quote.plugin.zsh | 2 -- 1 file changed, 2 deletions(-) (limited to 'plugins') diff --git a/plugins/rand-quote/rand-quote.plugin.zsh b/plugins/rand-quote/rand-quote.plugin.zsh index 3c9722a73..8f345d9aa 100644 --- a/plugins/rand-quote/rand-quote.plugin.zsh +++ b/plugins/rand-quote/rand-quote.plugin.zsh @@ -18,8 +18,6 @@ if [[ -x `which curl` ]]; then W=$(echo "$Q" | sed -e 's/.*\/quotes\///g' -e 's/<.*//g' -e 's/.*">//g') if [ "$W" -a "$TXT" ]; then echo "${WHO_COLOR}${W}${COLON_COLOR}: ${TEXT_COLOR}“${TXT}”${END_COLOR}" - # else - # quote fi } #quote -- cgit v1.2.3-70-g09d2 From d923cebdb34c373597d6f11a0e57e4b73f9f53f4 Mon Sep 17 00:00:00 2001 From: Niccolò Maggioni Date: Thu, 27 Aug 2015 11:34:53 +0200 Subject: Updated with @mcornella suggestions --- plugins/systemadmin/systemadmin.plugin.zsh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'plugins') diff --git a/plugins/systemadmin/systemadmin.plugin.zsh b/plugins/systemadmin/systemadmin.plugin.zsh index 5618ba8f1..8c2633355 100644 --- a/plugins/systemadmin/systemadmin.plugin.zsh +++ b/plugins/systemadmin/systemadmin.plugin.zsh @@ -140,12 +140,12 @@ d0() { # gather external ip address geteip() { - echo "$(curl -s -S http://ipecho.net/plain)" + curl -s -S https://icanhazip.com } # determine local IP address getip() { - if [ $(hash | grep '^ip=') ]; then + if (( ${+commands[ip]} )); then ip addr | grep "inet " | grep -v '127.0.0.1' | awk '{print $2}' else ifconfig | grep 'inet addr:'| grep -v '127.0.0.1' | cut -d: -f2 | awk '{ print $1}' -- cgit v1.2.3-70-g09d2 From 0a2c31fb60ab9870f3a2090eba10d0bdbcc9a3b9 Mon Sep 17 00:00:00 2001 From: MoonFruit Date: Fri, 28 Aug 2015 10:46:45 +0800 Subject: Remove redundant semicolon Remove redundant semicolon to make tab() works better in ITerm 2. --- plugins/osx/osx.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins') diff --git a/plugins/osx/osx.plugin.zsh b/plugins/osx/osx.plugin.zsh index a6e3a83e6..390960fdc 100644 --- a/plugins/osx/osx.plugin.zsh +++ b/plugins/osx/osx.plugin.zsh @@ -6,7 +6,7 @@ # ------------------------------------------------------------------------------ function tab() { - local command="cd \\\"$PWD\\\"; clear; " + local command="cd \\\"$PWD\\\"; clear" (( $# > 0 )) && command="${command}; $*" the_app=$( -- cgit v1.2.3-70-g09d2 From acf6039ff391cd868814d5df714fb26339f1009b Mon Sep 17 00:00:00 2001 From: cxbig Date: Sat, 29 Aug 2015 01:35:41 +0200 Subject: improved alias conflict between git flow & git fetch --- plugins/git-flow/git-flow.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins') diff --git a/plugins/git-flow/git-flow.plugin.zsh b/plugins/git-flow/git-flow.plugin.zsh index 4357c0895..444440bcb 100644 --- a/plugins/git-flow/git-flow.plugin.zsh +++ b/plugins/git-flow/git-flow.plugin.zsh @@ -21,7 +21,7 @@ # #Alias -alias gf='git flow' +alias gfl='git flow' alias gcd='git checkout develop' alias gch='git checkout hotfix' alias gcr='git checkout release' -- cgit v1.2.3-70-g09d2 From 0a80889848ccb3ada94dd2fdb793a01a268f7a16 Mon Sep 17 00:00:00 2001 From: Will Mendes Date: Sat, 29 Aug 2015 11:48:28 -0300 Subject: Frontend-search: add search in npm website --- plugins/frontend-search/README.md | 2 ++ plugins/frontend-search/_frontend-search.sh | 4 ++++ plugins/frontend-search/frontend-search.plugin.zsh | 7 ++++++- 3 files changed, 12 insertions(+), 1 deletion(-) (limited to 'plugins') diff --git a/plugins/frontend-search/README.md b/plugins/frontend-search/README.md index 801d450f3..b8e96ea4a 100644 --- a/plugins/frontend-search/README.md +++ b/plugins/frontend-search/README.md @@ -43,6 +43,7 @@ The search content are * `reactjs &as_sitesearch=facebook.github.io/react>` * `emberjs ` * `stackoverflow ` +* `npmjs ` ## Aliases ## @@ -69,6 +70,7 @@ There are a few aliases presented as well: * `reactjs` A shorthand for `frontend reactjs` * `emberjs` A shorthand for `frontend emberjs` * `stackoverflow` A shorthand for `frontend stackoverflow` +* `npmjs` A shorthand for `frontend npmjs` ## Author diff --git a/plugins/frontend-search/_frontend-search.sh b/plugins/frontend-search/_frontend-search.sh index 252f21570..b12f829a1 100644 --- a/plugins/frontend-search/_frontend-search.sh +++ b/plugins/frontend-search/_frontend-search.sh @@ -37,6 +37,7 @@ function _frontend() { 'reactjs: Search in React website' 'emberjs: Search in Ember website' 'stackoverflow: Search in StackOverflow website' + 'npmjs: Search in NPMJS website' ) _arguments -C \ @@ -110,6 +111,9 @@ function _frontend() { stackoverflow) _describe -t points "Warp points" frontend_points && ret=0 ;; + npmjs) + _describe -t points "Warp points" frontend_points && ret=0 + ;; esac ;; esac diff --git a/plugins/frontend-search/frontend-search.plugin.zsh b/plugins/frontend-search/frontend-search.plugin.zsh index f7485621b..e47735a60 100644 --- a/plugins/frontend-search/frontend-search.plugin.zsh +++ b/plugins/frontend-search/frontend-search.plugin.zsh @@ -9,7 +9,7 @@ function frontend() { fi # check whether the search engine is supported - if [[ ! $1 =~ '(jquery|mdn|compass|html5please|caniuse|aurajs|dartlang|qunit|fontello|bootsnipp|cssflow|codepen|unheap|bem|smacss|angularjs|reactjs|emberjs|stackoverflow)' ]]; + if [[ ! $1 =~ '(jquery|mdn|compass|html5please|caniuse|aurajs|dartlang|qunit|fontello|bootsnipp|cssflow|codepen|unheap|bem|smacss|angularjs|reactjs|emberjs|stackoverflow|npmjs)' ]]; then echo "Search valid search content $1 not supported." echo "Valid contents: (formats 'frontend ' or '')" @@ -33,6 +33,7 @@ function frontend() { echo "* reactjs" echo "* emberjs" echo "* stackoverflow" + echo "* npmjs" echo "" return 1 @@ -99,6 +100,9 @@ function frontend() { "stackoverflow") url="${url}stackoverflow.com" url="${url}/search?q=$2" ;; + "npmjs") + url="${url}www.npmjs.com" + url="${url}/search?q=$2" ;; *) echo "INVALID PARAM!" return ;; esac @@ -148,3 +152,4 @@ alias emberjs='frontend emberjs' # search websites alias stackoverflow='frontend stackoverflow' +alias npmjs='frontend npmjs' -- cgit v1.2.3-70-g09d2 From 022a060ec754f3ed54cb62acc3370310bfe71a50 Mon Sep 17 00:00:00 2001 From: kyleheyne Date: Mon, 31 Aug 2015 17:36:41 -0400 Subject: thefuck-alias -> thefuck --alias Per warning message. --- plugins/thefuck/thefuck.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins') diff --git a/plugins/thefuck/thefuck.plugin.zsh b/plugins/thefuck/thefuck.plugin.zsh index 8b1746e85..765e2b9a5 100644 --- a/plugins/thefuck/thefuck.plugin.zsh +++ b/plugins/thefuck/thefuck.plugin.zsh @@ -4,7 +4,7 @@ if [[ -z $commands[thefuck] ]]; then fi # Register alias -eval "$(thefuck-alias)" +eval "$(thefuck --alias)" fuck-command-line() { local FUCK="$(THEFUCK_REQUIRE_CONFIRMATION=0 thefuck $(fc -ln -1 | tail -n 1) 2> /dev/null)" -- cgit v1.2.3-70-g09d2 From 7f64092361472e12de85f945884445e0e2274846 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Tue, 1 Sep 2015 19:07:49 +0200 Subject: [vim-interaction plugin] Escaping special chars in file names and simplifying code. --- plugins/vim-interaction/vim-interaction.plugin.zsh | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) (limited to 'plugins') diff --git a/plugins/vim-interaction/vim-interaction.plugin.zsh b/plugins/vim-interaction/vim-interaction.plugin.zsh index b0b9414cd..b774be342 100644 --- a/plugins/vim-interaction/vim-interaction.plugin.zsh +++ b/plugins/vim-interaction/vim-interaction.plugin.zsh @@ -4,17 +4,6 @@ # Derek Wyatt (derek@{myfirstnamemylastname}.org # -function resolveFile -{ - if [ -f "$1" ]; then - echo $(readlink -f "$1") - elif [[ "${1#/}" == "$1" ]]; then - echo "$PWD/$1" - else - echo $1 - fi -} - function callvim { if [[ $# == 0 ]]; then @@ -48,13 +37,10 @@ EOH if [[ ${before#:} != $before && ${before%} == $before ]]; then before="$before" fi - local files="" - for f in $@ - do - files="$files $(resolveFile $f)" - done - if [[ -n $files ]]; then - files=':args! '"$files" + local files + if [[ $# -gt 0 ]]; then + # absolute path of files resolving symlinks (:A) and quoting special chars (:q) + files=':args! '"${@:A:q}" fi cmd="$before$files$after" gvim --remote-send "$cmd" -- cgit v1.2.3-70-g09d2 From f1472f1f6462d391a14ec80157365500f7a11b3f Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Sun, 30 Aug 2015 00:09:15 +0200 Subject: Simplify frontend-search function with assoc array Also adds the lodash URL (which was missing) and uses https on those websites that support it. --- plugins/frontend-search/frontend-search.plugin.zsh | 100 +++++++-------------- 1 file changed, 32 insertions(+), 68 deletions(-) (limited to 'plugins') diff --git a/plugins/frontend-search/frontend-search.plugin.zsh b/plugins/frontend-search/frontend-search.plugin.zsh index e47735a60..3afc3336d 100644 --- a/plugins/frontend-search/frontend-search.plugin.zsh +++ b/plugins/frontend-search/frontend-search.plugin.zsh @@ -1,6 +1,33 @@ # frontend from terminal function frontend() { + emulate -L zsh + + # define search content URLS + typeset -A urls + urls=( + angularjs 'https://google.com/search?as_sitesearch=angularjs.org&as_q=' + aurajs 'http://aurajs.com/api/#stq=' + bem 'https://google.com/search?as_sitesearch=bem.info&as_q=' + bootsnipp 'http://bootsnipp.com/search?q=' + caniuse 'http://caniuse.com/#search=' + codepen 'http://codepen.io/search?q=' + compass 'http://compass-style.org/search?q=' + cssflow 'http://www.cssflow.com/search?q=' + dartlang 'https://api.dartlang.org/apidocs/channels/stable/dartdoc-viewer/dart:' + emberjs 'http://emberjs.com/api/#stp=1&stq=' + fontello 'http://fontello.com/#search=' + html5please 'http://html5please.com/#' + jquery 'https://api.jquery.com/?s=' + lodash 'https://devdocs.io/lodash/index#' + mdn 'https://developer.mozilla.org/search?q=' + npmjs 'https://www.npmjs.com/search?q=' + qunit 'https://api.qunitjs.com/?s=' + reactjs 'https://google.com/search?as_sitesearch=facebook.github.io/react&as_q=' + smacss 'https://google.com/search?as_sitesearch=smacss.com&as_q=' + stackoverflow 'http://stackoverflow.com/search?q=' + unheap 'http://www.unheap.com/?s=' + ) # no keyword provided, simply show how call methods if [[ $# -le 1 ]]; then @@ -9,7 +36,7 @@ function frontend() { fi # check whether the search engine is supported - if [[ ! $1 =~ '(jquery|mdn|compass|html5please|caniuse|aurajs|dartlang|qunit|fontello|bootsnipp|cssflow|codepen|unheap|bem|smacss|angularjs|reactjs|emberjs|stackoverflow|npmjs)' ]]; + if [[ -z "$urls[$1]" ]]; then then echo "Search valid search content $1 not supported." echo "Valid contents: (formats 'frontend ' or '')" @@ -39,73 +66,10 @@ function frontend() { return 1 fi - local url="http://" - local query="" - - case "$1" in - "jquery") - url="${url}api.jquery.com" - url="${url}/?s=$2" ;; - "mdn") - url="${url}developer.mozilla.org" - url="${url}/search?q=$2" ;; - "compass") - url="${url}compass-style.org" - url="${url}/search?q=$2" ;; - "html5please") - url="${url}html5please.com" - url="${url}/#$2" ;; - "caniuse") - url="${url}caniuse.com" - url="${url}/#search=$2" ;; - "aurajs") - url="${url}aurajs.com" - url="${url}/api/#stq=$2" ;; - "dartlang") - url="${url}api.dartlang.org/apidocs/channels/stable/dartdoc-viewer" - url="${url}/dart-$2" ;; - "qunit") - url="${url}api.qunitjs.com" - url="${url}/?s=$2" ;; - "fontello") - url="${url}fontello.com" - url="${url}/#search=$2" ;; - "bootsnipp") - url="${url}bootsnipp.com" - url="${url}/search?q=$2" ;; - "cssflow") - url="${url}cssflow.com" - url="${url}/search?q=$2" ;; - "codepen") - url="${url}codepen.io" - url="${url}/search?q=$2" ;; - "unheap") - url="${url}www.unheap.com" - url="${url}/?s=$2" ;; - "bem") - url="${url}google.com" - url="${url}/search?as_q=$2&as_sitesearch=bem.info" ;; - "smacss") - url="${url}google.com" - url="${url}/search?as_q=$2&as_sitesearch=smacss.com" ;; - "angularjs") - url="${url}google.com" - url="${url}/search?as_q=$2&as_sitesearch=angularjs.org" ;; - "reactjs") - url="${url}google.com" - url="${url}/search?as_q=$2&as_sitesearch=facebook.github.io/react" ;; - "emberjs") - url="${url}emberjs.com" - url="${url}/api/#stq=$2&stp=1" ;; - "stackoverflow") - url="${url}stackoverflow.com" - url="${url}/search?q=$2" ;; - "npmjs") - url="${url}www.npmjs.com" - url="${url}/search?q=$2" ;; - *) echo "INVALID PARAM!" - return ;; - esac + # build search url: + # join arguments passed with '+', then append to search engine URL + # TODO substitute for proper urlencode method + url="${urls[$1]}${(j:+:)@[2,-1]}" echo "$url" -- cgit v1.2.3-70-g09d2 From ff706f3ef8fd632d93e2c347d32c62f15b17c25c Mon Sep 17 00:00:00 2001 From: willmendesneto Date: Thu, 3 Jul 2014 22:53:00 -0300 Subject: Add "help" method in "frontend-search" plugin --- plugins/frontend-search/README.md | 9 +++++++- plugins/frontend-search/frontend-search.plugin.zsh | 26 ++++++++++++++++++++-- 2 files changed, 32 insertions(+), 3 deletions(-) (limited to 'plugins') diff --git a/plugins/frontend-search/README.md b/plugins/frontend-search/README.md index b8e96ea4a..bf8a4bc08 100644 --- a/plugins/frontend-search/README.md +++ b/plugins/frontend-search/README.md @@ -17,9 +17,16 @@ plugins=( ... frontend-search) ## Commands ## -All command searches are accept only in format +All command searches are accept only in formats * `frontend ` +* ` ` + +For more informations, please run help command (are similars) + +* `frontend -h` +* `frontend --help` +* `frontend help` The search content are diff --git a/plugins/frontend-search/frontend-search.plugin.zsh b/plugins/frontend-search/frontend-search.plugin.zsh index 3afc3336d..08930ddcd 100644 --- a/plugins/frontend-search/frontend-search.plugin.zsh +++ b/plugins/frontend-search/frontend-search.plugin.zsh @@ -29,14 +29,36 @@ function frontend() { unheap 'http://www.unheap.com/?s=' ) + # show help for commands list + if [[ $1 =~ '(help|--help|-h)' ]] + then + echo "Usage:" + echo "\n\tfrontend \n\t\n\tfrontend " + echo "" + echo "Where is one of:" + echo "jquery, mdn, compass, html5please, caniuse, aurajs, dartlang, qunit, fontello," + echo "bootsnipp, cssflow, codepen, unheap, bem, smacss, angularjs, reactjs, emberjs" + echo "help" + echo "" + echo "Where is a term to search in allowed repositories" + echo "" + echo "frontend --help show plugin help" + echo "frontend -h show plugin help" + echo "" + echo "It is allowed to directly access all search contents." + echo "" + return 1 + fi + # no keyword provided, simply show how call methods - if [[ $# -le 1 ]]; then + if [[ $# -le 1 ]] + then echo "Please provide a search-content and a search-term for app.\nEx:\nfrontend \n" return 1 fi # check whether the search engine is supported - if [[ -z "$urls[$1]" ]]; then + if [[ -z "$urls[$1]" ]] then echo "Search valid search content $1 not supported." echo "Valid contents: (formats 'frontend ' or '')" -- cgit v1.2.3-70-g09d2 From 663ac56d54d252b9de7c76346bd64a14340a51f7 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Mon, 31 Aug 2015 18:49:05 +0200 Subject: Prettify frontend help output and clean up logic --- plugins/frontend-search/frontend-search.plugin.zsh | 79 +++++++--------------- 1 file changed, 24 insertions(+), 55 deletions(-) (limited to 'plugins') diff --git a/plugins/frontend-search/frontend-search.plugin.zsh b/plugins/frontend-search/frontend-search.plugin.zsh index 08930ddcd..6eb1fed2b 100644 --- a/plugins/frontend-search/frontend-search.plugin.zsh +++ b/plugins/frontend-search/frontend-search.plugin.zsh @@ -1,9 +1,7 @@ -# frontend from terminal - function frontend() { emulate -L zsh - # define search content URLS + # define search context URLS typeset -A urls urls=( angularjs 'https://google.com/search?as_sitesearch=angularjs.org&as_q=' @@ -29,74 +27,45 @@ function frontend() { unheap 'http://www.unheap.com/?s=' ) - # show help for commands list - if [[ $1 =~ '(help|--help|-h)' ]] + # show help for command list + if [[ $# -lt 2 ]] then - echo "Usage:" - echo "\n\tfrontend \n\t\n\tfrontend " - echo "" - echo "Where is one of:" - echo "jquery, mdn, compass, html5please, caniuse, aurajs, dartlang, qunit, fontello," - echo "bootsnipp, cssflow, codepen, unheap, bem, smacss, angularjs, reactjs, emberjs" - echo "help" - echo "" - echo "Where is a term to search in allowed repositories" - echo "" - echo "frontend --help show plugin help" - echo "frontend -h show plugin help" - echo "" - echo "It is allowed to directly access all search contents." - echo "" + print -P "Usage: frontend %Ucontext%u %Uterm%u [...%Umore%u] (or just: %Ucontext%u %Uterm%u [...%Umore%u])" + print -P "" + print -P "%Uterm%u and what follows is what will be searched for in the %Ucontext%u website," + print -P "and %Ucontext%u is one of the following:" + print -P "" + print -P " angularjs, aurajs, bem, bootsnipp, caniuse, codepen, compass, cssflow," + print -P " dartlang, emberjs, fontello, html5please, jquery, lodash, mdn, npmjs," + print -P " qunit, reactjs, smacss, stackoverflow, unheap" + print -P "" + print -P "For example: frontend npmjs mocha (or just: npmjs mocha)." + print -P "" return 1 fi - # no keyword provided, simply show how call methods - if [[ $# -le 1 ]] - then - echo "Please provide a search-content and a search-term for app.\nEx:\nfrontend \n" - return 1 - fi - - # check whether the search engine is supported + # check whether the search context is supported if [[ -z "$urls[$1]" ]] then - echo "Search valid search content $1 not supported." - echo "Valid contents: (formats 'frontend ' or '')" - echo "* jquery" - echo "* mdn" - echo "* compass" - echo "* html5please" - echo "* caniuse" - echo "* aurajs" - echo "* dartlang" - echo "* lodash" - echo "* qunit" - echo "* fontello" - echo "* bootsnipp" - echo "* cssflow" - echo "* codepen" - echo "* unheap" - echo "* bem" - echo "* smacss" - echo "* angularjs" - echo "* reactjs" - echo "* emberjs" - echo "* stackoverflow" - echo "* npmjs" + echo "Search context \"$1\" currently not supported." + echo "" + echo "Valid contexts are:" + echo "" + echo " angularjs, aurajs, bem, bootsnipp, caniuse, codepen, compass, cssflow, " + echo " dartlang, emberjs, fontello, html5please, jquery, lodash, mdn, npmjs, " + echo " qunit, reactjs, smacss, stackoverflow, unheap" echo "" - return 1 fi # build search url: - # join arguments passed with '+', then append to search engine URL + # join arguments passed with '+', then append to search context URL # TODO substitute for proper urlencode method url="${urls[$1]}${(j:+:)@[2,-1]}" - echo "$url" + echo "Opening $url ..." open_command "$url" - } # javascript -- cgit v1.2.3-70-g09d2 From d982e1200f1f14fa4487a45c8af4e18834092ebd Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Mon, 31 Aug 2015 19:12:05 +0200 Subject: Reorder alias definitions --- plugins/frontend-search/frontend-search.plugin.zsh | 63 ++++++++-------------- 1 file changed, 22 insertions(+), 41 deletions(-) (limited to 'plugins') diff --git a/plugins/frontend-search/frontend-search.plugin.zsh b/plugins/frontend-search/frontend-search.plugin.zsh index 6eb1fed2b..2fd5416b3 100644 --- a/plugins/frontend-search/frontend-search.plugin.zsh +++ b/plugins/frontend-search/frontend-search.plugin.zsh @@ -1,3 +1,25 @@ +alias angularjs='frontend angularjs' +alias aurajs='frontend aurajs' +alias bem='frontend bem' +alias bootsnipp='frontend bootsnipp' +alias caniuse='frontend caniuse' +alias codepen='frontend codepen' +alias compass='frontend compass' +alias cssflow='frontend cssflow' +alias dartlang='frontend dartlang' +alias emberjs='frontend emberjs' +alias fontello='frontend fontello' +alias html5please='frontend html5please' +alias jquery='frontend jquery' +alias lodash='frontend lodash' +alias mdn='frontend mdn' +alias npmjs='frontend npmjs' +alias qunit='frontend qunit' +alias reactjs='frontend reactjs' +alias smacss='frontend smacss' +alias stackoverflow='frontend stackoverflow' +alias unheap='frontend unheap' + function frontend() { emulate -L zsh @@ -67,44 +89,3 @@ function frontend() { open_command "$url" } - -# javascript -alias jquery='frontend jquery' -alias mdn='frontend mdn' - -# pre processors frameworks -alias compassdoc='frontend compass' - -# important links -alias html5please='frontend html5please' -alias caniuse='frontend caniuse' - -# components and libraries -alias aurajs='frontend aurajs' -alias dartlang='frontend dartlang' -alias lodash='frontend lodash' - -#tests -alias qunit='frontend qunit' - -#fonts -alias fontello='frontend fontello' - -# snippets -alias bootsnipp='frontend bootsnipp' -alias cssflow='frontend cssflow' -alias codepen='frontend codepen' -alias unheap='frontend unheap' - -# css architecture -alias bem='frontend bem' -alias smacss='frontend smacss' - -# frameworks -alias angularjs='frontend angularjs' -alias reactjs='frontend reactjs' -alias emberjs='frontend emberjs' - -# search websites -alias stackoverflow='frontend stackoverflow' -alias npmjs='frontend npmjs' -- cgit v1.2.3-70-g09d2 From c481c62bc996cfe22417621dfd96c4267eb1e740 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Mon, 31 Aug 2015 19:17:16 +0200 Subject: Refactor and clear up README file --- plugins/frontend-search/README.md | 121 +++++++++++++++----------------------- 1 file changed, 48 insertions(+), 73 deletions(-) (limited to 'plugins') diff --git a/plugins/frontend-search/README.md b/plugins/frontend-search/README.md index bf8a4bc08..d0bc5589f 100644 --- a/plugins/frontend-search/README.md +++ b/plugins/frontend-search/README.md @@ -1,83 +1,60 @@ -## Rationale ## +## Introduction ## -> Searches for your Frontend contents more easier +> Searches for your frontend web development made easier -## Instalation ## +## Installation ## +Open your `~/.zshrc` file and enable the `frontend-search` plugin: -Open your `.zshrc` file and load `frontend-search` plugin +```zsh + +plugins=( ... frontend-search) -```bash -... -plugins=( ... frontend-search) -... ``` -## Commands ## - -All command searches are accept only in formats - -* `frontend ` -* ` ` - -For more informations, please run help command (are similars) - -* `frontend -h` -* `frontend --help` -* `frontend help` - -The search content are - -* `jquery ` -* `mdn ` -* `compass ` -* `html5please ` -* `caniuse ` -* `aurajs ` -* `dartlang ` -* `lodash ` -* `qunit ` -* `fontello ` -* `bootsnipp ` -* `cssflow ` -* `codepen ` -* `unheap ` -* `bem &as_sitesearch=bem.info>` -* `smacss &as_sitesearch=smacss.com>` -* `angularjs &as_sitesearch=angularjs.org>` -* `reactjs &as_sitesearch=facebook.github.io/react>` -* `emberjs ` -* `stackoverflow ` -* `npmjs ` - - -## Aliases ## - -There are a few aliases presented as well: - -* `jquery` A shorthand for `frontend jquery` -* `mdn` A shorthand for `frontend mdn` -* `compass` A shorthand for `frontend compass` -* `html5please` A shorthand for `frontend html5please` -* `caniuse` A shorthand for `frontend caniuse` -* `aurajs` A shorthand for `frontend aurajs` -* `dartlang` A shorthand for `frontend dartlang` -* `lodash` A shorthand for `frontend lodash` -* `qunit` A shorthand for `frontend qunit` -* `fontello` A shorthand for `frontend fontello` -* `bootsnipp` A shorthand for `frontend bootsnipp` -* `cssflow` A shorthand for `frontend cssflow` -* `codepen` A shorthand for `frontend codepen` -* `unheap` A shorthand for `frontend unheap` -* `bem` A shorthand for `frontend bem` -* `smacss` A shorthand for `frontend smacss` -* `angularjs` A shorthand for `frontend angularjs` -* `reactjs` A shorthand for `frontend reactjs` -* `emberjs` A shorthand for `frontend emberjs` -* `stackoverflow` A shorthand for `frontend stackoverflow` -* `npmjs` A shorthand for `frontend npmjs` +## Usage ## + +You can use the frontend-search plugin in these two forms: + +* `frontend [more terms if you want]` +* ` [more terms if you want]` + +For example, these two are equivalent: + +```zsh +$ frontend angularjs dependency injection +$ angularjs dependency injection +``` + +Available search contexts are: + +| context | URL | +|---------------|--------------------------------------------------------------------------| +| angularjs | `https://google.com/search?as_sitesearch=angularjs.org&as_q=` | +| aurajs | `http://aurajs.com/api/#stq=` | +| bem | `https://google.com/search?as_sitesearch=bem.info&as_q=` | +| bootsnipp | `http://bootsnipp.com/search?q=` | +| caniuse | `http://caniuse.com/#search=` | +| codepen | `http://codepen.io/search?q=` | +| compass | `http://compass-style.org/search?q=` | +| cssflow | `http://www.cssflow.com/search?q=` | +| dartlang | `https://api.dartlang.org/apidocs/channels/stable/dartdoc-viewer/dart:` | +| emberjs | `http://emberjs.com/api/#stp=1&stq=` | +| fontello | `http://fontello.com/#search=` | +| html5please | `http://html5please.com/#` | +| jquery | `https://api.jquery.com/?s=` | +| lodash | `https://devdocs.io/lodash/index#` | +| mdn | `https://developer.mozilla.org/search?q=` | +| npmjs | `https://www.npmjs.com/search?q=` | +| qunit | `https://api.qunitjs.com/?s=` | +| reactjs | `https://google.com/search?as_sitesearch=facebook.github.io/react&as_q=` | +| smacss | `https://google.com/search?as_sitesearch=smacss.com&as_q=` | +| stackoverflow | `http://stackoverflow.com/search?q=` | +| unheap | `http://www.unheap.com/?s=` | + +If you want to have another context, open an Issue and tell us! ## Author @@ -86,5 +63,3 @@ There are a few aliases presented as well: + + + - -New features comming soon. -- cgit v1.2.3-70-g09d2 From b08431ff7431528f0e9dc49ceb199be2226266dc Mon Sep 17 00:00:00 2001 From: Andy Blyler Date: Tue, 1 Sep 2015 23:08:41 -0400 Subject: Add codeclimate autocomplete plugin --- plugins/codeclimate/_codeclimate | 82 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 plugins/codeclimate/_codeclimate (limited to 'plugins') diff --git a/plugins/codeclimate/_codeclimate b/plugins/codeclimate/_codeclimate new file mode 100644 index 000000000..fd2536a34 --- /dev/null +++ b/plugins/codeclimate/_codeclimate @@ -0,0 +1,82 @@ +#compdef codeclimate + +_codeclimate_all_engines() { + engines_all=(`codeclimate engines:list | tail -n +2 | gawk '{ print $2 }' | gawk -F: '{ print $1 }'`) +} + +_codeclimate_installed_engines() { + _codeclimate_all_engines + + engines_installed=() + + if [ -e .codeclimate.yml ] + then + for engine in $engines_all + do + if grep -q $engine ".codeclimate.yml" + then + engines_installed+=$engine + fi + done + fi +} + +_codeclimate_not_installed_engines() { + _codeclimate_all_engines + + engines_not_installed=() + + if [ -e .codeclimate.yml ] + then + for engine in $engines_all + do + if ! grep -q $engine ".codeclimate.yml" + then + engines_not_installed+=$engine + fi + done + fi +} + +local curcontext="$curcontext" state line ret=1 +local expl +local -a engines_all engines_installed engines_not_installed + +_arguments \ + '1: :->cmds' \ + '*:: :->args' && ret=0 + +case $state in + cmds) + _values "bundle command" \ + "analyze[Analyze all relevant files in the current working directory]" \ + "console[Start an interactive session providing access to the classes within the CLI]" \ + "engines\:disable[Prevents the engine from being used in this project]" \ + "engines\:enable[This engine will be run the next time your project is analyzed]" \ + "engines\:install[Compares the list of engines in your .codeclimate.yml file to those that are currently installed, then installs any missing engines]" \ + "engines\:list[Lists all available engines in the Code Climate Docker Hub]" \ + "engines\:remove[Removes an engine from your .codeclimate.yml file]" \ + "help[Displays a list of commands that can be passed to the Code Climate CLI]" \ + "init[Generates a new .codeclimate.yml file in the current working directory]" \ + "validate-config[Validates the .codeclimate.yml file in the current working directory]" \ + "version[Displays the current version of the Code Climate CLI]" + ret=0 + ;; + args) + case $line[1] in + engines:enable) + _codeclimate_not_installed_engines + _wanted engines_not_installed expl 'not installed engines' compadd -a engines_not_installed ;; + engines:disable|engines:remove) + _codeclimate_installed_engines + _wanted engines_installed expl 'installed engines' compadd -a engines_installed ;; + analyze) + _arguments \ + '-f:Output Format:(text json)' + ret=0 + ;; + esac + ;; +esac + +return ret -- cgit v1.2.3-70-g09d2 From ef4a31563075aa0c0453219fcb66eb3941f2d515 Mon Sep 17 00:00:00 2001 From: Eric Bottard Date: Tue, 3 Mar 2015 18:28:32 +0100 Subject: Fix invocation of gradlew --- plugins/gradle/gradle.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins') diff --git a/plugins/gradle/gradle.plugin.zsh b/plugins/gradle/gradle.plugin.zsh index 6f634d1ba..97941756d 100644 --- a/plugins/gradle/gradle.plugin.zsh +++ b/plugins/gradle/gradle.plugin.zsh @@ -82,7 +82,7 @@ _gradlew_tasks () { if [ in_gradle ]; then _gradle_arguments if _gradle_does_task_list_need_generating; then - gradlew tasks --all | grep "^[ ]*[a-zA-Z0-9:]*\ -\ " | sed "s/ - .*$//" | sed "s/[\ ]*//" > .gradletasknamecache + ./gradlew tasks --all | grep "^[ ]*[a-zA-Z0-9:]*\ -\ " | sed "s/ - .*$//" | sed "s/[\ ]*//" > .gradletasknamecache fi compadd -X "==== Gradlew Tasks ====" `cat .gradletasknamecache` fi -- cgit v1.2.3-70-g09d2 From 6d7c39a2aef023ac887f0cadbe0035706838c859 Mon Sep 17 00:00:00 2001 From: Michele Bologna Date: Wed, 2 Sep 2015 20:57:04 +0200 Subject: Added fancy-ctrl-z plugin Use Ctrl-Z to switch back to Vim I frequently need to execute random command in my shell. To achieve it I pause Vim by pressing Ctrl-z, type command and press fg to switch back to Vim. The fg part really hurts me. I just wanted to hit Ctrl-z once again to get back to Vim. I could not find a solution, so I developed one on my own that works wonderfully with ZSH. Source: http://sheerun.net/2014/03/21/how-to-boost-your-vim-productivity/ --- plugins/fancy-ctrl-z/fancy-ctrl-z.plugin.zsh | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 plugins/fancy-ctrl-z/fancy-ctrl-z.plugin.zsh (limited to 'plugins') diff --git a/plugins/fancy-ctrl-z/fancy-ctrl-z.plugin.zsh b/plugins/fancy-ctrl-z/fancy-ctrl-z.plugin.zsh new file mode 100644 index 000000000..d4e41b71f --- /dev/null +++ b/plugins/fancy-ctrl-z/fancy-ctrl-z.plugin.zsh @@ -0,0 +1,21 @@ +# Use Ctrl-Z to switch back to Vim +# I frequently need to execute random command in my shell. To achieve it I pause +# Vim by pressing Ctrl-z, type command and press fg to switch back to Vim. +# The fg part really hurt sme. I just wanted to hit Ctrl-z once again to get back +# to Vim. I could not find a solution, so I developed one on my own that +# works wonderfully with ZSH +# +# Source: http://sheerun.net/2014/03/21/how-to-boost-your-vim-productivity/ + +fancy-ctrl-z () { + if [[ $#BUFFER -eq 0 ]]; then + BUFFER="fg" + zle accept-line + else + zle push-input + zle clear-screen + fi +} +zle -N fancy-ctrl-z +bindkey '^Z' fancy-ctrl-z + -- cgit v1.2.3-70-g09d2 From 9a7b2d7ffb6def1b1009b3c4a21d33af22a74234 Mon Sep 17 00:00:00 2001 From: Michele Bologna Date: Thu, 3 Sep 2015 08:55:03 +0200 Subject: Moved comments and credits from source to README --- plugins/fancy-ctrl-z/README.md | 14 ++++++++++++++ plugins/fancy-ctrl-z/fancy-ctrl-z.plugin.zsh | 9 --------- 2 files changed, 14 insertions(+), 9 deletions(-) create mode 100644 plugins/fancy-ctrl-z/README.md (limited to 'plugins') diff --git a/plugins/fancy-ctrl-z/README.md b/plugins/fancy-ctrl-z/README.md new file mode 100644 index 000000000..a7670fa2c --- /dev/null +++ b/plugins/fancy-ctrl-z/README.md @@ -0,0 +1,14 @@ +# Use Ctrl-Z to switch back to Vim + +I frequently need to execute random command in my shell. To achieve it I pause +Vim by pressing Ctrl-z, type command and press fg to switch back to Vim. +The fg part really hurt sme. I just wanted to hit Ctrl-z once again to get back +to Vim. I could not find a solution, so I developed one on my own that +works wonderfully with ZSH + +Source: http://sheerun.net/2014/03/21/how-to-boost-your-vim-productivity/ + +Credits: +- original idea by @sheerun +- added to OMZ by @mbologna + diff --git a/plugins/fancy-ctrl-z/fancy-ctrl-z.plugin.zsh b/plugins/fancy-ctrl-z/fancy-ctrl-z.plugin.zsh index d4e41b71f..8ab297913 100644 --- a/plugins/fancy-ctrl-z/fancy-ctrl-z.plugin.zsh +++ b/plugins/fancy-ctrl-z/fancy-ctrl-z.plugin.zsh @@ -1,12 +1,3 @@ -# Use Ctrl-Z to switch back to Vim -# I frequently need to execute random command in my shell. To achieve it I pause -# Vim by pressing Ctrl-z, type command and press fg to switch back to Vim. -# The fg part really hurt sme. I just wanted to hit Ctrl-z once again to get back -# to Vim. I could not find a solution, so I developed one on my own that -# works wonderfully with ZSH -# -# Source: http://sheerun.net/2014/03/21/how-to-boost-your-vim-productivity/ - fancy-ctrl-z () { if [[ $#BUFFER -eq 0 ]]; then BUFFER="fg" -- cgit v1.2.3-70-g09d2 From c7d782f1ab2488ff0e44c2d72d9b81ea24b3195c Mon Sep 17 00:00:00 2001 From: Pablo Cantero Date: Thu, 3 Sep 2015 13:39:41 -0300 Subject: Add the update from @mtwentyman https://github.com/phstc/dotfiles/pull/1 to make it work for older versions of capistrano --- plugins/capistrano/_capistrano | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins') diff --git a/plugins/capistrano/_capistrano b/plugins/capistrano/_capistrano index c181b55ca..e6e71ffcc 100644 --- a/plugins/capistrano/_capistrano +++ b/plugins/capistrano/_capistrano @@ -14,7 +14,7 @@ _arguments -C \ _cap_tasks() { if [[ -f config/deploy.rb || -f Capfile ]]; then if [[ ! -f .cap_tasks~ ]]; then - shipit -v --tasks | awk '{command=$2; $1=$2=$3=""; gsub(/^[ \t\r\n]+/, "", $0); gsub(":", "\\:", command); print command"["$0"]"}' > .cap_tasks~ + shipit -v --tasks | sed 's/\(\[\)\(.*\)\(\]\)/\2:/' | awk '{command=$2; $1=$2=$3=""; gsub(/^[ \t\r\n]+/, "", $0); gsub(":", "\\:", command); print command"["$0"]"}' > .cap_tasks~ fi OLD_IFS=$IFS -- cgit v1.2.3-70-g09d2 From 7a63ccabf662138777a43d014a1a0ab5d8f86ab0 Mon Sep 17 00:00:00 2001 From: Alexey V Zapparov Date: Fri, 4 Sep 2015 21:18:32 +0200 Subject: Fix aws plugin RPROMPT pollution --- plugins/aws/aws.plugin.zsh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'plugins') diff --git a/plugins/aws/aws.plugin.zsh b/plugins/aws/aws.plugin.zsh index 7246db9f0..d31052f83 100644 --- a/plugins/aws/aws.plugin.zsh +++ b/plugins/aws/aws.plugin.zsh @@ -11,11 +11,16 @@ export AWS_HOME=~/.aws function agp { echo $AWS_DEFAULT_PROFILE } + function asp { + local rprompt=${RPROMPT//} + export AWS_DEFAULT_PROFILE=$1 export AWS_PROFILE=$1 - export RPROMPT="$RPROMPT" + + export RPROMPT="$rprompt" } + function aws_profiles { reply=($(grep profile $AWS_HOME/config|sed -e 's/.*profile \([a-zA-Z0-9_-]*\).*/\1/')) } -- cgit v1.2.3-70-g09d2 From 75844fe1a1c9bfc84270b593cc0357fd1c356d87 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Mon, 10 Aug 2015 01:45:11 +0200 Subject: Put relevant documentation into README file --- plugins/taskwarrior/README.md | 13 +++++++++++++ plugins/taskwarrior/taskwarrior.plugin.zsh | 14 -------------- 2 files changed, 13 insertions(+), 14 deletions(-) create mode 100644 plugins/taskwarrior/README.md (limited to 'plugins') diff --git a/plugins/taskwarrior/README.md b/plugins/taskwarrior/README.md new file mode 100644 index 000000000..053151e78 --- /dev/null +++ b/plugins/taskwarrior/README.md @@ -0,0 +1,13 @@ +# taskwarrior + +This plugin adds smart tab completion for [TaskWarrior](http://taskwarrior.org/). +It uses the zsh tab completion script (`_task`) shipped with TaskWarrior for the +completion definitions. + +The latest version pulled in from the official project is of January 1st, 2015. + + +## Examples + +Typing `task [TAB]` will give you a list of commands, `task 66[TAB]` shows a +list of available modifications for that task, etcetera. diff --git a/plugins/taskwarrior/taskwarrior.plugin.zsh b/plugins/taskwarrior/taskwarrior.plugin.zsh index 5d1e6ffea..ab885943f 100644 --- a/plugins/taskwarrior/taskwarrior.plugin.zsh +++ b/plugins/taskwarrior/taskwarrior.plugin.zsh @@ -1,17 +1,3 @@ -################################################################################ -# Author: Pete Clark -# Email: pete[dot]clark[at]gmail[dot]com -# Version: 0.1 (05/24/2011) -# License: WTFPL -# -# This oh-my-zsh plugin adds smart tab completion for -# TaskWarrior. It uses the zsh tab completion -# script (_task) distributed with TaskWarrior for the completion definitions. -# -# Typing task [tabtab] will give you a list of current tasks, task 66[tabtab] -# gives a list of available modifications for that task, etc. -################################################################################ - zstyle ':completion:*:*:task:*' verbose yes zstyle ':completion:*:*:task:*:descriptions' format '%U%B%d%b%u' -- cgit v1.2.3-70-g09d2 From 38d25a335999753093011f93699725c865f73360 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Fri, 14 Aug 2015 20:43:11 +0200 Subject: Update taskwarrior completion to latest version (Jul 26 2015) See relevant commit at: https://git.tasktools.org/projects/TM/repos/task/commits/3158883dc4d251 --- plugins/taskwarrior/_task | 312 +++++++++++++++++++++++++--------------------- 1 file changed, 173 insertions(+), 139 deletions(-) (limited to 'plugins') diff --git a/plugins/taskwarrior/_task b/plugins/taskwarrior/_task index 5cc253152..afa30d45a 100644 --- a/plugins/taskwarrior/_task +++ b/plugins/taskwarrior/_task @@ -1,9 +1,6 @@ #compdef task -# zsh completion for taskwarrior # -# taskwarrior - a command line task list manager. -# -# Copyright 2010 - 2011 Johannes Schlatow +# Copyright 2010 - 2015 Johannes Schlatow # Copyright 2009 P.C. Shyamshankar # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -30,31 +27,40 @@ typeset -g _task_cmds _task_projects _task_tags _task_config _task_modifiers _task_projects=($(task _projects)) _task_tags=($(task _tags)) _task_ids=($(task _ids)) +_task_zshids=( ${(f)"$(task _zshids)"} ) _task_config=($(task _config)) _task_columns=($(task _columns)) _task_modifiers=( - 'before' \ - 'after' \ - 'none' \ - 'any' \ - 'is' \ - 'isnt' \ - 'has' \ - 'hasnt' \ - 'startswith' \ - 'endswith' \ - 'word' \ - 'noword' + 'before' \ + 'after' \ + 'none' \ + 'any' \ + 'is' \ + 'isnt' \ + 'has' \ + 'hasnt' \ + 'startswith' \ + 'endswith' \ + 'word' \ + 'noword' ) _task_conjunctions=( - 'and' \ - 'or' \ - 'xor' \ - '\)' - '\(' + 'and' \ + 'or' \ + 'xor' \ + '\)' \ + '\(' \ + '<' \ + '<=' \ + '=' \ + '!=' \ + '>=' \ + '>' ) -_task_cmds=($(task _commands)) -_task_zshcmds=( ${(f)"$(task _zshcommands)"} ) +_task_cmds=($(task _commands; task _aliases)) +_task_zshcmds=( ${(f)"$(task _zshcommands)"} sentinel:sentinel:sentinel ) + +_task_aliases=($(task _aliases)) _task() { _arguments -s -S \ @@ -68,110 +74,130 @@ word=$'[^\0]#\0' # priorities local -a task_priorities _regex_words values 'task priorities' \ - 'H:High' \ - 'M:Middle' \ - 'L:Low' + 'H:High' \ + 'M:Middle' \ + 'L:Low' task_priorities=("$reply[@]") # projects local -a task_projects task_projects=( - /"$word"/ - ":values:task projects:compadd -a _task_projects" + /"$word"/ + ":values:task projects:compadd -a _task_projects" ) local -a _task_dates _regex_words values 'task dates' \ - 'tod*ay:Today' \ - 'yes*terday:Yesterday' \ - 'tom*orrow:Tomorrow' \ - 'sow:Start of week' \ - 'soww:Start of work week' \ - 'socw:Start of calendar week' \ - 'som:Start of month' \ - 'soy:Start of year' \ - 'eow:End of week' \ - 'eoww:End of work week' \ - 'eocw:End of calendar week' \ - 'eom:End of month' \ - 'eoy:End of year' \ - 'mon:Monday' \ - 'tue:Tuesday'\ - 'wed:Wednesday' \ - 'thu:Thursday' \ - 'fri:Friday' \ - 'sat:Saturday' \ - 'sun:Sunday' + 'tod*ay:Today' \ + 'yes*terday:Yesterday' \ + 'tom*orrow:Tomorrow' \ + 'sow:Start of week' \ + 'soww:Start of work week' \ + 'socw:Start of calendar week' \ + 'som:Start of month' \ + 'soq:Start of quarter' \ + 'soy:Start of year' \ + 'eow:End of week' \ + 'eoww:End of work week' \ + 'eocw:End of calendar week' \ + 'eom:End of month' \ + 'eoq:End of quarter' \ + 'eoy:End of year' \ + 'mon:Monday' \ + 'tue:Tuesday'\ + 'wed:Wednesday' \ + 'thu:Thursday' \ + 'fri:Friday' \ + 'sat:Saturday' \ + 'sun:Sunday' \ + 'good*friday:Good Friday' \ + 'easter:Easter' \ + 'eastermonday:Easter Monday' \ + 'ascension:Ascension' \ + 'pentecost:Pentecost' \ + 'midsommar:Midsommar' \ + 'midsommarafton:Midsommarafton' \ + 'later:Later' \ + 'someday:Some Day' _task_dates=("$reply[@]") local -a _task_reldates _regex_words values 'task reldates' \ - 'hrs:n hours' \ - 'day:n days' \ - '1st:first' \ - '2nd:second' \ - '3rd:third' \ - 'th:4th, 5th, etc.' \ - 'wks:weeks' + 'hrs:n hours' \ + 'day:n days' \ + '1st:first' \ + '2nd:second' \ + '3rd:third' \ + 'th:4th, 5th, etc.' \ + 'wks:weeks' _task_reldates=("$reply[@]") task_dates=( - \( "$_task_dates[@]" \| + \( "$_task_dates[@]" \| \( /$'[0-9][0-9]#'/- \( "$_task_reldates[@]" \) \) - \) + \) ) +local -a task_zshids +_regex_words values 'task IDs' $_task_zshids +task_zshids=("$reply[@]") + _regex_words values 'task frequencies' \ - 'daily:Every day' \ - 'day:Every day' \ - 'weekdays:Every day skipping weekend days' \ - 'weekly:Every week' \ - 'biweekly:Every two weeks' \ - 'fortnight:Every two weeks' \ -+ 'monthly:Every month' \ - 'quarterly:Every three months' \ - 'semiannual:Every six months' \ - 'annual:Every year' \ - 'yearly:Every year' \ - 'biannual:Every two years' \ - 'biyearly:Every two years' + 'daily:Every day' \ + 'day:Every day' \ + 'weekdays:Every day skipping weekend days' \ + 'weekly:Every week' \ + 'biweekly:Every two weeks' \ + 'fortnight:Every two weeks' \ + 'monthly:Every month' \ + 'quarterly:Every three months' \ + 'semiannual:Every six months' \ + 'annual:Every year' \ + 'yearly:Every year' \ + 'biannual:Every two years' \ + 'biyearly:Every two years' _task_freqs=("$reply[@]") local -a _task_frequencies _regex_words values 'task frequencies' \ - 'd:days' \ - 'w:weeks' \ - 'q:quarters' \ - 'y:years' + 'd:days' \ + 'w:weeks' \ + 'q:quarters' \ + 'y:years' _task_frequencies=("$reply[@]") task_freqs=( - \( "$_task_freqs[@]" \| + \( "$_task_freqs[@]" \| \( /$'[0-9][0-9]#'/- \( "$_task_frequencies[@]" \) \) - \) + \) ) # attributes local -a task_attributes _regex_words -t ':' default 'task attributes' \ - 'pro*ject:Project name:$task_projects' \ - 'du*e:Due date:$task_dates' \ - 'wa*it:Date until task becomes pending:$task_dates' \ - 're*cur:Recurrence frequency:$task_freqs' \ - 'pri*ority:priority:$task_priorities' \ - 'un*til:Recurrence end date:$task_dates' \ - 'fg:Foreground color' \ - 'bg:Background color' \ - 'li*mit:Desired number of rows in report' + 'des*cription:Task description text' \ + 'status:Status of task - pending, completed, deleted, waiting' \ + 'pro*ject:Project name:$task_projects' \ + 'pri*ority:priority:$task_priorities' \ + 'du*e:Due date:$task_dates' \ + 're*cur:Recurrence frequency:$task_freqs' \ + 'un*til:Expiration date:$task_dates' \ + 'li*mit:Desired number of rows in report' \ + 'wa*it:Date until task becomes pending:$task_dates' \ + 'ent*ry:Date task was created:$task_dates' \ + 'end:Date task was completed/deleted:$task_dates' \ + 'st*art:Date task was started:$task_dates' \ + 'sc*heduled:Date task is scheduled to start:$task_dates' \ + 'dep*ends:Other tasks that this task depends upon:$task_zshids' task_attributes=("$reply[@]") args=( - \( "$task_attributes[@]" \| - \( /'(project|due|wait|recur|priority|until|fg|bg|limit).'/- \( /$'[^:]#:'/ ":default:modifiers:compadd -S ':' -a _task_modifiers" \) \) \| - \( /'(rc).'/- \( /$'[^:]#:'/ ":arguments:config:compadd -S ':' -a _task_config" \) \) \| - \( /'(+|-)'/- \( /"$word"/ ":values:remove tag:compadd -a _task_tags" \) \) \| - \( /"$word"/ \) - \) \# + \( "$task_attributes[@]" \| + \( /'(project|description|status|entry|end|start|scheduled|depends|due|wait|recur|priority|until|limit).'/- \( /$'[^:]#:'/ ":default:modifiers:compadd -S ':' -a _task_modifiers" \) \) \| + \( /'(rc).'/- \( /$'[^:]#:'/ ":arguments:config:compadd -S ':' -a _task_config" \) \) \| + \( /'(+|-)'/- \( /"$word"/ ":values:remove tag:compadd -a _task_tags" \) \) \| + \( /"$word"/ \) + \) \# ) _regex_arguments _task_attributes "${args[@]}" @@ -180,43 +206,50 @@ _regex_arguments _task_attributes "${args[@]}" # filter completion (( $+functions[_task_filter] )) || _task_filter() { - _task_attributes "$@" - - # TODO complete conjunctions only if the previous word is a filter expression, i.e. attribute, ID, any non-command - _describe -t default 'task conjunctions' _task_conjunctions -} - -# merge completion -(( $+functions[_task_merge] )) || -_task_merge() { - # TODO match URIs in .taskrc - _files -} - -# push completion -(( $+functions[_task_push] )) || -_task_push() { - # TODO match URIs in .taskrc - _files -} + _task_attributes "$@" -# pull completion -(( $+functions[_task_pull] )) || -_task_pull() { - # TODO match URIs in .taskrc - _files + # TODO complete conjunctions only if the previous word is a filter expression, i.e. attribute, ID, any non-command + _describe -t default 'task conjunctions' _task_conjunctions } # execute completion (( $+functions[_task_execute] )) || _task_execute() { - _files + _files } # id-only completion (( $+functions[_task_id] )) || _task_id() { - _describe -t values 'task IDs' _task_zshids + _describe -t values 'task IDs' _task_zshids +} + +# subcommand-only function +(( $+functions[_task_subcommands] )) || +_task_subcommands() { + local -a subcommands + local _zshcmd + local cmd category desc + local lastcategory='' + # The list is sorted by category, in the right order. + for _zshcmd in "$_task_zshcmds[@]"; do + # Parse out the three fields + cmd=${_zshcmd%%:*} + category=${${_zshcmd#*:}%%:*} + desc=${_zshcmd#*:*:} + + # Present each category as soon as the first entry in the *next* category + # is seen. + if [[ $category != $lastcategory && -n $lastcategory ]]; then + _describe -t ${lastcategory}-commands "task ${lastcategory} command" subcommands + subcommands=() + fi + + # Log the subcommand; we will process it in some future iteration. + subcommands+=( "$cmd:$desc" ) + + lastcategory=$category + done } ## first level completion => task sub-command completion @@ -224,27 +257,28 @@ _task_id() { _task_default() { local cmd ret=1 - integer i=1 - while (( i < $#words )) - do - cmd="${_task_cmds[(r)$words[$i]]}" - if (( $#cmd )); then - _call_function ret _task_${cmd} || - _call_function ret _task_filter || - _message "No command remaining." - return ret - fi - (( i++ )) - done - - # update IDs - _task_zshids=( ${(f)"$(task _zshids)"} ) - - _describe -t commands 'task command' _task_zshcmds - _describe -t values 'task IDs' _task_zshids - _call_function ret _task_filter - - return ret + integer i=1 + while (( i < $#words )) + do + cmd="${_task_cmds[(r)$words[$i]]}" + if (( $#cmd )); then + _call_function ret _task_${cmd} || + _call_function ret _task_filter || + _message "No command remaining." + return ret + fi + (( i++ )) + done + + # update IDs + _task_zshids=( ${(f)"$(task _zshids)"} ) + + _task_subcommands + _describe -t tasks 'task IDs' _task_zshids + _describe -t aliases 'task aliases' _task_aliases + _call_function ret _task_filter + + return ret } -_task +_task "$@" -- cgit v1.2.3-70-g09d2 From cbdad588e65f4205fcdc4e34e97b04fa7fdb5457 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Fri, 7 Aug 2015 18:56:57 +0200 Subject: Use zsh globbing instead of ls + grep in xc function Uses zsh arrays and globbing to find .xcworkspace and .xcodeproj files. --- plugins/xcode/xcode.plugin.zsh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'plugins') diff --git a/plugins/xcode/xcode.plugin.zsh b/plugins/xcode/xcode.plugin.zsh index 1d1205b80..4aa6bfc9b 100644 --- a/plugins/xcode/xcode.plugin.zsh +++ b/plugins/xcode/xcode.plugin.zsh @@ -1,12 +1,12 @@ #xc function courtesy of http://gist.github.com/subdigital/5420709 function xc { - xcode_proj=`ls | grep "\.xc" | sort -r | head -1` - if [[ `echo -n $xcode_proj | wc -m` == 0 ]] - then + local xcode_proj + xcode_proj=(*.{xcworkspace,xcodeproj}(N)) + if [[ ${#xcode_proj} -eq 0 ]]; then echo "No xcworkspace/xcodeproj file found in the current directory." else - echo "Found $xcode_proj" - open "$xcode_proj" + echo "Found ${xcode_proj[1]}" + open "${xcode_proj[1]}" fi } -- cgit v1.2.3-70-g09d2 From 6a830f39b68300cf86504f1c60d9ab77c09b7971 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Fri, 4 Sep 2015 01:43:48 +0200 Subject: Return error if no xcode files where found --- plugins/xcode/xcode.plugin.zsh | 2 ++ 1 file changed, 2 insertions(+) (limited to 'plugins') diff --git a/plugins/xcode/xcode.plugin.zsh b/plugins/xcode/xcode.plugin.zsh index 4aa6bfc9b..274bd92e4 100644 --- a/plugins/xcode/xcode.plugin.zsh +++ b/plugins/xcode/xcode.plugin.zsh @@ -2,8 +2,10 @@ function xc { local xcode_proj xcode_proj=(*.{xcworkspace,xcodeproj}(N)) + if [[ ${#xcode_proj} -eq 0 ]]; then echo "No xcworkspace/xcodeproj file found in the current directory." + return 1 else echo "Found ${xcode_proj[1]}" open "${xcode_proj[1]}" -- cgit v1.2.3-70-g09d2 From 24bdd8e29a344f0282b842f89a4a10f145344939 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Fri, 7 Aug 2015 19:04:26 +0200 Subject: Replace xcsel function with just an alias --- plugins/xcode/xcode.plugin.zsh | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'plugins') diff --git a/plugins/xcode/xcode.plugin.zsh b/plugins/xcode/xcode.plugin.zsh index 274bd92e4..059c78fd5 100644 --- a/plugins/xcode/xcode.plugin.zsh +++ b/plugins/xcode/xcode.plugin.zsh @@ -12,10 +12,7 @@ function xc { fi } -function xcsel { - sudo xcode-select --switch "$*" -} - +alias xcsel='sudo xcode-select --switch' alias xcb='xcodebuild' alias xcp='xcode-select --print-path' alias xcdd='rm -rf ~/Library/Developer/Xcode/DerivedData/*' -- cgit v1.2.3-70-g09d2 From ec3694c788d2b32eb1735687cf89b057d4ca4d4d Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Fri, 4 Sep 2015 22:08:57 +0200 Subject: Make simulator dependant of currently active dev directory This also gets rid of `xcode-select` command-not-found errors. --- plugins/xcode/xcode.plugin.zsh | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'plugins') diff --git a/plugins/xcode/xcode.plugin.zsh b/plugins/xcode/xcode.plugin.zsh index 059c78fd5..f80de36d5 100644 --- a/plugins/xcode/xcode.plugin.zsh +++ b/plugins/xcode/xcode.plugin.zsh @@ -17,8 +17,15 @@ alias xcb='xcodebuild' alias xcp='xcode-select --print-path' alias xcdd='rm -rf ~/Library/Developer/Xcode/DerivedData/*' -if [[ -d $(xcode-select -p)/Platforms/iPhoneSimulator.platform/Developer/Applications/iPhone\ Simulator.app ]]; then - alias simulator='open $(xcode-select -p)/Platforms/iPhoneSimulator.platform/Developer/Applications/iPhone\ Simulator.app' -else - alias simulator='open $(xcode-select -p)/Applications/iOS\ Simulator.app' -fi +function simulator { + local devfolder + devfolder="$(xcode-select -p)" + + # Xcode ≤ 5.x + if [[ -d "${devfolder}/Platforms/iPhoneSimulator.platform/Developer/Applications/iPhone Simulator.app" ]]; then + open "${devfolder}/Platforms/iPhoneSimulator.platform/Developer/Applications/iPhone Simulator.app" + # Xcode ≥ 6.x + else + open "${devfolder}/Applications/iOS Simulator.app" + fi +} -- cgit v1.2.3-70-g09d2 From d95589d4e43d3a6288b8a66492c17d12c4e4eca0 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Sat, 5 Sep 2015 23:17:38 +0200 Subject: Add README for the xcode plugin --- plugins/xcode/README.md | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 plugins/xcode/README.md (limited to 'plugins') diff --git a/plugins/xcode/README.md b/plugins/xcode/README.md new file mode 100644 index 000000000..b8efef38c --- /dev/null +++ b/plugins/xcode/README.md @@ -0,0 +1,31 @@ +# Xcode + +## Description + +This plugin provides a few utilities that can help you on your daily use of Xcode and iOS development. + +To start using it, add the `xcode` plugin to your `plugins` array: + +```zsh +plugins=(... xcode) +``` + + +## Aliases + +| Alias | Description | Command | +|-------|---------------------------------------|------------------------------------------------| +| xcsel | Change active developer directory | sudo xcode-select --switch | +| xcp | Show currently active dev. directory | xcode-select --print-path | +| xcb | Build Xcode projects and workspaces | xcodebuild | +| xcdd | Purge all temporary build information | rm -rf ~/Library/Developer/Xcode/DerivedData/* | + + +## Functions + +- **`xc`**: + Open one of the `.xcworkspace` and `.xcodeproj` files that it can find in the current working directory. + Returns 1 if it didn't find any relevant files. + +- **`simulator`**: + Open the iOS Simulator from your command line, dependant on whichever is the active developer directory for Xcode. -- cgit v1.2.3-70-g09d2 From 5584aa05c7c94949665f024ad0d88b8162654cb9 Mon Sep 17 00:00:00 2001 From: Andrew Janke Date: Fri, 4 Sep 2015 17:17:16 -0400 Subject: xcode: add version-based xcselv() --- plugins/xcode/xcode.plugin.zsh | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'plugins') diff --git a/plugins/xcode/xcode.plugin.zsh b/plugins/xcode/xcode.plugin.zsh index f80de36d5..b3058ceff 100644 --- a/plugins/xcode/xcode.plugin.zsh +++ b/plugins/xcode/xcode.plugin.zsh @@ -17,6 +17,35 @@ alias xcb='xcodebuild' alias xcp='xcode-select --print-path' alias xcdd='rm -rf ~/Library/Developer/Xcode/DerivedData/*' + +# "XCode-SELect by Version" - select Xcode by just version number +# Uses naming convention: +# - different versions of Xcode are named Xcode-.app or stored +# in a folder named Xcode- +# - the special version name "-" refers to the "default" Xcode.app with no suffix +function xcselv { + emulate -L zsh + local version=$1 + local apps_dirs apps_dir apps app + apps_dirs=( $HOME/Applications /Applications ) + for apps_dir ($apps_dirs); do + if [[ $version == "-" ]]; then + apps=( $apps_dir/Xcode.app $apps_dir/Xcode/Xcode.app ) + else + apps=( $apps_dir/Xcode-$version.app $apps_dir/Xcode-$version/Xcode.app ) + fi + for app ($apps); do + if [[ -e "$app" ]]; then + echo "selecting Xcode $version: $app" + xcsel "$app" + return + fi + done + done + echo "xcselv: Xcode version $version not found" + return 1 +} + function simulator { local devfolder devfolder="$(xcode-select -p)" -- cgit v1.2.3-70-g09d2 From 213f46a296bd76031eb6a2fa66c72efeb912481d Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Mon, 7 Sep 2015 12:08:50 +0200 Subject: Add xcselv documentation in the README --- plugins/xcode/README.md | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'plugins') diff --git a/plugins/xcode/README.md b/plugins/xcode/README.md index b8efef38c..362940b93 100644 --- a/plugins/xcode/README.md +++ b/plugins/xcode/README.md @@ -13,12 +13,13 @@ plugins=(... xcode) ## Aliases -| Alias | Description | Command | -|-------|---------------------------------------|------------------------------------------------| -| xcsel | Change active developer directory | sudo xcode-select --switch | -| xcp | Show currently active dev. directory | xcode-select --print-path | -| xcb | Build Xcode projects and workspaces | xcodebuild | -| xcdd | Purge all temporary build information | rm -rf ~/Library/Developer/Xcode/DerivedData/* | +| Alias | Description | Command | +|-------|------------------------------------------|------------------------------------------------| +| xcb | Build Xcode projects and workspaces | xcodebuild | +| xcdd | Purge all temporary build information | rm -rf ~/Library/Developer/Xcode/DerivedData/* | +| xcp | Show currently selected Xcode directory | xcode-select --print-path | +| xcsel | Select different Xcode directory by path | sudo xcode-select --switch | + ## Functions @@ -29,3 +30,6 @@ plugins=(... xcode) - **`simulator`**: Open the iOS Simulator from your command line, dependant on whichever is the active developer directory for Xcode. + +- **`xcselv`**: + Select different Xcode by version. Example: `xcselv 6.2` -- cgit v1.2.3-70-g09d2 From 82ae41ca4cf4fac253294f17b33b0c718755ffc5 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Mon, 7 Sep 2015 12:09:08 +0200 Subject: Reorder xcode plugin file --- plugins/xcode/xcode.plugin.zsh | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'plugins') diff --git a/plugins/xcode/xcode.plugin.zsh b/plugins/xcode/xcode.plugin.zsh index b3058ceff..1f547470d 100644 --- a/plugins/xcode/xcode.plugin.zsh +++ b/plugins/xcode/xcode.plugin.zsh @@ -1,4 +1,10 @@ -#xc function courtesy of http://gist.github.com/subdigital/5420709 +alias xcb='xcodebuild' +alias xcdd='rm -rf ~/Library/Developer/Xcode/DerivedData/*' +alias xcp='xcode-select --print-path' +alias xcsel='sudo xcode-select --switch' + +# original author: @subdigital +# source: http://gist.github.com/subdigital/5420709 function xc { local xcode_proj xcode_proj=(*.{xcworkspace,xcodeproj}(N)) @@ -12,12 +18,6 @@ function xc { fi } -alias xcsel='sudo xcode-select --switch' -alias xcb='xcodebuild' -alias xcp='xcode-select --print-path' -alias xcdd='rm -rf ~/Library/Developer/Xcode/DerivedData/*' - - # "XCode-SELect by Version" - select Xcode by just version number # Uses naming convention: # - different versions of Xcode are named Xcode-.app or stored -- cgit v1.2.3-70-g09d2 From 6170fa41d975d40f462a14ca69612270ae9ddb9b Mon Sep 17 00:00:00 2001 From: Michele Bologna Date: Wed, 9 Sep 2015 11:42:56 +0200 Subject: Added fedora plugin, based on dnf/yum plugin --- plugins/fedora/README.md | 3 +++ plugins/fedora/fedora.plugin.zsh | 16 ++++++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 plugins/fedora/README.md create mode 100644 plugins/fedora/fedora.plugin.zsh (limited to 'plugins') diff --git a/plugins/fedora/README.md b/plugins/fedora/README.md new file mode 100644 index 000000000..f384b0ffd --- /dev/null +++ b/plugins/fedora/README.md @@ -0,0 +1,3 @@ +This is a plugin based on yum plugin, but using dnf as main frontend +(from Fedora 22 onwards, yum is deprecated in favor of dnf). + diff --git a/plugins/fedora/fedora.plugin.zsh b/plugins/fedora/fedora.plugin.zsh new file mode 100644 index 000000000..eddc3627b --- /dev/null +++ b/plugins/fedora/fedora.plugin.zsh @@ -0,0 +1,16 @@ +## Aliases + +alias dnfs="dnf search" # search package +alias dnfp="dnf info" # show package info +alias dnfl="dnf list" # list packages +alias dnfgl="dnf grouplist" # list package groups +alias dnfli="dnf list installed" # print all installed packages +alias dnfmc="dnf makecache" # rebuilds the dnf package list + +alias dnfu="sudo dnf upgrade" # upgrade packages +alias dnfi="sudo dnf install" # install package +alias dnfgi="sudo dnf groupinstall" # install package group +alias dnfr="sudo dnf remove" # remove package +alias dnfgr="sudo dnf groupremove" # remove pagage group +alias dnfrl="sudo dnf remove --remove-leaves" # remove package and leaves +alias dnfc="sudo dnf clean all" # clean cache -- cgit v1.2.3-70-g09d2 From 9e9b790fe1e3150b36bb1e01b432f5b38e52b512 Mon Sep 17 00:00:00 2001 From: Ilia Choly Date: Tue, 8 Sep 2015 17:34:39 -0400 Subject: golang: improve go doc completion --- plugins/golang/golang.plugin.zsh | 36 +++++++++++++++++++++++++----------- plugins/golang/templates/package.txt | 29 +++++++++++++++++++++++++++++ plugins/golang/templates/search.txt | 0 3 files changed, 54 insertions(+), 11 deletions(-) create mode 100644 plugins/golang/templates/package.txt create mode 100644 plugins/golang/templates/search.txt (limited to 'plugins') diff --git a/plugins/golang/golang.plugin.zsh b/plugins/golang/golang.plugin.zsh index 900fc630d..4e6ca0a99 100644 --- a/plugins/golang/golang.plugin.zsh +++ b/plugins/golang/golang.plugin.zsh @@ -54,23 +54,37 @@ __go_tool_complete() { '-installsuffix[suffix to add to package directory]:suffix' '-tags[list of build tags to consider satisfied]:tags' ) - __go_list() { - local expl importpaths - declare -a importpaths - importpaths=($(go list ${words[$CURRENT]}... 2>/dev/null)) - _wanted importpaths expl 'import paths' compadd "$@" - "${importpaths[@]}" + __go_packages() { + _path_files -W "$(go env GOROOT)/src" -/ + _path_files -W "$(go env GOPATH)/src" -/ + } + __go_identifiers() { + compadd $(godoc -templates $ZSH/plugins/golang/templates ${words[-2]} 2> /dev/null) } case ${words[2]} in - clean|doc) - _arguments -s -w : '*:importpaths:__go_list' + doc) + _arguments -s -w \ + "-c[symbol matching honors case (paths not affected)]" \ + "-cmd[show symbols with package docs even if package is a command]" \ + "-u[show unexported symbols as well as exported]" \ + "2:importpaths:__go_packages" \ + ":next identifiers:__go_identifiers" + ;; + clean) + _arguments -s -w \ + "-i[remove the corresponding installed archive or binary (what 'go install' would create)]" \ + "-n[print the remove commands it would execute, but not run them]" \ + "-r[apply recursively to all the dependencies of the packages named by the import paths]" \ + "-x[print remove commands as it executes them]" \ + "*:importpaths:__go_packages" ;; fix|fmt|list|vet) - _alternative ':importpaths:__go_list' ':files:_path_files -g "*.go"' + _alternative ':importpaths:__go_packages' ':files:_path_files -g "*.go"' ;; install) _arguments -s -w : ${build_flags[@]} \ "-v[show package names]" \ - '*:importpaths:__go_list' + '*:importpaths:__go_packages' ;; get) _arguments -s -w : \ @@ -81,7 +95,7 @@ __go_tool_complete() { ${build_flags[@]} \ "-v[show package names]" \ "-o[output file]:file:_files" \ - "*:args:{ _alternative ':importpaths:__go_list' ':files:_path_files -g \"*.go\"' }" + "*:args:{ _alternative ':importpaths:__go_packages' ':files:_path_files -g \"*.go\"' }" ;; test) _arguments -s -w : \ @@ -103,7 +117,7 @@ __go_tool_complete() { "-cpuprofile[write CPU profile to file]:file:_files" \ "-memprofile[write heap profile to file]:file:_files" \ "-memprofilerate[set heap profiling rate]:number" \ - "*:args:{ _alternative ':importpaths:__go_list' ':files:_path_files -g \"*.go\"' }" + "*:args:{ _alternative ':importpaths:__go_packages' ':files:_path_files -g \"*.go\"' }" ;; help) _values "${commands[@]}" \ diff --git a/plugins/golang/templates/package.txt b/plugins/golang/templates/package.txt new file mode 100644 index 000000000..2b75cce35 --- /dev/null +++ b/plugins/golang/templates/package.txt @@ -0,0 +1,29 @@ +{{with .PDoc}}{{/* + +Constants +--------------------------------------- + +*/}}{{with .Consts}}{{range .}}{{range .Names}}{{.}} {{end}}{{end}}{{end}}{{/* + +Variables +--------------------------------------- + +*/}}{{with .Vars}}{{range .}}{{range .Names}}{{.}} {{end}}{{end}}{{end}}{{/* + +Functions +--------------------------------------- + +*/}}{{with .Funcs}}{{range .}}{{ .Name }} {{end}}{{end}}{{/* + +Types +--------------------------------------- + +*/}}{{with .Types}}{{range .}}{{ $TypeName := .Name }}{{ $TypeName }} {{/* + +*/}}{{range .Methods}}{{ $TypeName }}.{{.Name}} {{end}}{{/* + +*/}}{{range .Funcs}}{{.Name}} {{end}}{{/* + +*/}}{{range .Consts}}{{range .Names}}{{.}} {{end}}{{end}}{{/* + +*/}}{{range .Vars}}{{range .Names}}{{.}} {{end}}{{end}}{{end}}{{end}}{{end}} diff --git a/plugins/golang/templates/search.txt b/plugins/golang/templates/search.txt new file mode 100644 index 000000000..e69de29bb -- cgit v1.2.3-70-g09d2 From 953e4d892631f93e31cfdfb72199fb8f413c6b49 Mon Sep 17 00:00:00 2001 From: Ben Klein Date: Thu, 10 Sep 2015 22:19:53 -0400 Subject: Make Linux compatible Just an if/else to determine if we're OSX or Linux and alias `at` appropriately. --- plugins/atom/atom.plugin.zsh | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) (limited to 'plugins') diff --git a/plugins/atom/atom.plugin.zsh b/plugins/atom/atom.plugin.zsh index 9adb9031a..ec1a114ed 100644 --- a/plugins/atom/atom.plugin.zsh +++ b/plugins/atom/atom.plugin.zsh @@ -1,14 +1,22 @@ -local _atom_paths > /dev/null 2>&1 -_atom_paths=( - "$HOME/Applications/Atom.app" - "/Applications/Atom.app" -) +# Gets OS Type +unamestr=$(uname -s) -for _atom_path in $_atom_paths; do - if [[ -a $_atom_path ]]; then - alias at="open -a '$_atom_path'" - break - fi -done +# If OSX +if [[ "$unamestr" == 'Darwin' ]]; then + local _atom_paths > /dev/null 2>&1 + _atom_paths=( + "$HOME/Applications/Atom.app" + "/Applications/Atom.app" + ) -alias att='at .' + for _atom_path in $_atom_paths; do + if [[ -a $_atom_path ]]; then + alias at="open -a '$_atom_path'" + break + fi + done +# If Linux +elif [[ "$unamestr" == 'Linux' ]]; then + # Alerts the user if 'atom' is not a found command. + type atom >/dev/null 2>&1 && alias at="atom" || { echo >&2 "You have enabled the atom oh-my-zsh plugin on Linux, but atom is not a recognized command. Please make sure you have it installed before using this plugin."; } +fi -- cgit v1.2.3-70-g09d2 From dca429557aef7b700ae2f1088115a707af78a31b Mon Sep 17 00:00:00 2001 From: Ben Klein Date: Thu, 10 Sep 2015 22:22:00 -0400 Subject: Make Readme much clearer and explain edits. Also added some examples, but those should be mostly self-explanatory. --- plugins/atom/README.md | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'plugins') diff --git a/plugins/atom/README.md b/plugins/atom/README.md index 75d77a0ac..6350c647b 100644 --- a/plugins/atom/README.md +++ b/plugins/atom/README.md @@ -1,6 +1,8 @@ ## atom -Plugin for Atom, a cross platform text and code editor, available for Linux, Mac OS X, and Windows. +This plugin makes "at" a useful function for invoking the Atom Editor. + +Originally by Github user [aforty](https://github.com/aforty) for OSX, modified to alias 'at' to 'atom' for Linux, since atom already works on the terminal for Linux, and calling 'at' in a non-OSX environment should still work. ### Requirements @@ -10,8 +12,12 @@ Plugin for Atom, a cross platform text and code editor, available for Linux, Mac * If `at` command is called without an argument, launch Atom - * If `at` is passed a directory, `cd` to it and open it in Atom + * If `at` is passed a directory, open it in Atom * If `at` is passed a file, open it in Atom - * if `att` command is called, it is equivalent to `at .`, opening the current folder in Atom +### Examples + + * Open the current dir in atom: `at .` + * Open another dir in atom: `at path/to/folder` + * Open a file: `at filename.extension` -- cgit v1.2.3-70-g09d2 From 36fea45bfc564c667007421a643df38c02235c8b Mon Sep 17 00:00:00 2001 From: Andrew Janke Date: Fri, 11 Sep 2015 03:11:01 -0400 Subject: svn plugin: urldecode repo info The repo location reported by `svn` is a URL. If you don't decode it before using it a prompt, the `%` sequences will be misinterpreted by prompt expansion and give screwy results. Fixes #2233 --- plugins/svn/svn.plugin.zsh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'plugins') diff --git a/plugins/svn/svn.plugin.zsh b/plugins/svn/svn.plugin.zsh index 9f7a4c6eb..816055afe 100644 --- a/plugins/svn/svn.plugin.zsh +++ b/plugins/svn/svn.plugin.zsh @@ -1,16 +1,17 @@ # vim:ft=zsh ts=2 sw=2 sts=2 # function svn_prompt_info() { + local _DISPLAY if in_svn; then if [ "x$SVN_SHOW_BRANCH" = "xtrue" ]; then unset SVN_SHOW_BRANCH _DISPLAY=$(svn_get_branch_name) else _DISPLAY=$(svn_get_repo_name) + _DISPLAY=$(omz_urldecode "${_DISPLAY}") fi echo "$ZSH_PROMPT_BASE_COLOR$ZSH_THEME_SVN_PROMPT_PREFIX\ $ZSH_THEME_REPO_NAME_COLOR$_DISPLAY$ZSH_PROMPT_BASE_COLOR$ZSH_THEME_SVN_PROMPT_SUFFIX$ZSH_PROMPT_BASE_COLOR$(svn_dirty)$(svn_dirty_pwd)$ZSH_PROMPT_BASE_COLOR" - unset _DISPLAY fi } @@ -30,7 +31,7 @@ function svn_get_repo_name() { } function svn_get_branch_name() { - _DISPLAY=$( + local _DISPLAY=$( svn info 2> /dev/null | \ awk -F/ \ '/^URL:/ { \ @@ -49,7 +50,6 @@ function svn_get_branch_name() { else echo $_DISPLAY fi - unset _DISPLAY } function svn_get_rev_nr() { @@ -60,7 +60,7 @@ function svn_get_rev_nr() { function svn_dirty_choose() { if in_svn; then - root=`svn info 2> /dev/null | sed -n 's/^Working Copy Root Path: //p'` + local root=`svn info 2> /dev/null | sed -n 's/^Working Copy Root Path: //p'` if $(svn status $root 2> /dev/null | command grep -Eq '^\s*[ACDIM!?L]'); then # Grep exits with 0 when "One or more lines were selected", return "dirty". echo $1 @@ -77,7 +77,7 @@ function svn_dirty() { function svn_dirty_choose_pwd () { if in_svn; then - root=$PWD + local root=$PWD if $(svn status $root 2> /dev/null | command grep -Eq '^\s*[ACDIM!?L]'); then # Grep exits with 0 when "One or more lines were selected", return "dirty". echo $1 -- cgit v1.2.3-70-g09d2 From 22287d0153047cf5d5872d294202d9ce35e8eac8 Mon Sep 17 00:00:00 2001 From: Ilia Choly Date: Fri, 11 Sep 2015 12:20:26 -0400 Subject: handle multiple paths in GOPATH --- plugins/golang/golang.plugin.zsh | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'plugins') diff --git a/plugins/golang/golang.plugin.zsh b/plugins/golang/golang.plugin.zsh index 4e6ca0a99..1ce3cea58 100644 --- a/plugins/golang/golang.plugin.zsh +++ b/plugins/golang/golang.plugin.zsh @@ -55,8 +55,13 @@ __go_tool_complete() { '-tags[list of build tags to consider satisfied]:tags' ) __go_packages() { - _path_files -W "$(go env GOROOT)/src" -/ - _path_files -W "$(go env GOPATH)/src" -/ + local gopaths + declare -a gopaths + gopaths=("${(s/:/)$(go env GOPATH)}") + gopaths+=("$(go env GOROOT)") + for p in $gopaths; do + _path_files -W "$p/src" -/ + done } __go_identifiers() { compadd $(godoc -templates $ZSH/plugins/golang/templates ${words[-2]} 2> /dev/null) -- cgit v1.2.3-70-g09d2 From 6642a99fac11dd4e10869566f1d38761f1e8746c Mon Sep 17 00:00:00 2001 From: Andrew Janke Date: Thu, 10 Sep 2015 01:48:24 -0400 Subject: xcode: extend xcselv to list versions and do completion --- plugins/xcode/README.md | 65 +++++++++++++++--- plugins/xcode/_xcselv | 19 ++++++ plugins/xcode/xcode.plugin.zsh | 151 +++++++++++++++++++++++++++++++++++++---- 3 files changed, 214 insertions(+), 21 deletions(-) create mode 100644 plugins/xcode/_xcselv (limited to 'plugins') diff --git a/plugins/xcode/README.md b/plugins/xcode/README.md index 362940b93..15e657859 100644 --- a/plugins/xcode/README.md +++ b/plugins/xcode/README.md @@ -4,7 +4,7 @@ This plugin provides a few utilities that can help you on your daily use of Xcode and iOS development. -To start using it, add the `xcode` plugin to your `plugins` array: +To start using it, add the `xcode` plugin to your `plugins` array in `~/.zshrc`: ```zsh plugins=(... xcode) @@ -24,12 +24,61 @@ plugins=(... xcode) ## Functions -- **`xc`**: - Open one of the `.xcworkspace` and `.xcodeproj` files that it can find in the current working directory. - Returns 1 if it didn't find any relevant files. +### `xc` -- **`simulator`**: - Open the iOS Simulator from your command line, dependant on whichever is the active developer directory for Xcode. +Opens the current directory in Xcode as an Xcode project. This will open one of the `.xcworkspace` and `.xcodeproj` files that it can find in the current working directory. +Returns 1 if it didn't find any relevant files. -- **`xcselv`**: - Select different Xcode by version. Example: `xcselv 6.2` +### `simulator` + +Opens the iOS Simulator from your command line, dependent on whichever is the active developer directory for Xcode. (That is, it respects the `xcsel` setting.) + +### `xcselv` + +Selects different Xcode installations by version name. This is like `xcsel`, except it takes just a version name as an argument instead of the full path to the Xcode installation. Uses the naming conventions described below. + +* `xcselv ` selects a version + * Example: `xcselv 6.2` +* `xcselv default` selects the default unversioned `Applications/Xcode.app` +* `xcselv` with no argument lists the available Xcode versions in a human-readable format +* `xcselv -l` lists the installed Xcode versions +* `xcselv -L` lists the installed Xcode versions in a short version-name-only format +* `xcselv -p` prints info about the active Xcode version +* `xcselv -h` prints a help message + +The option parsing for `xcselv` is naive. Options may not be combined, and only the first option is recognized. + +## Multiple Xcode Versions + +The `xcselv` command provides support for switching between different Xcode installations using just a version number. Different Xcode versions are identified by file naming conventions. + +### Versioned Xcode Naming Conventions + +Apple does not seem to explicitly define or provide tooling support for a naming convention or other organizational mechanism for managing versioned Xcode installations. Apple seems to have released beta versions with both `Xcode.app` and `Xcode-.app` style names in the past, and both styles show up in forum and blog discussions. + +We've adopted the following naming convention: + +* Versioned Xcode installations are identified by the name `Xcode-` or `Xcode`. +* The `-` separating `"Xcode"` and the version name is optional, and may be replaced by a space. +* The versioned name may be applied to the `Xcode.app` itself, or a subdirectory underneath `Applications/` containing it. +* You cannot version both the `Xcode.app` filename itself and the containing subfolder. +* Thus, all of the following are equivalent. + * `Applications/Xcode-.app` + * `Applications/Xcode-/Xcode.app` + * `Applications/Xcode.app` + * `Applications/Xcode .app` + * `Applications/Xcode /Xcode.app` +* Both the system `/Applications/` and user `$HOME/Applications/` directories are searched. + * The user's `$HOME/Applications/` takes precedence over `/Applications` for a given version. + * If multiple naming variants within the same `Applications/` folder indicate the same version (for example, `Xcode-3.2.1.app`, `Xcode3.2.1.app`, and `Xcode-3.2.1/Xcode.app`), the precedence order is unspecified and implementation-dependent. +* The `` may be any string that is valid in a filename. +* The special version name `"default"` refers to the "default" unversioned Xcode at `Applications/Xcode.app` (in either `/Applications/` or `$HOME/Applications/`). +* Version names may not start with ``"-"`` or whitespace. + +The restrictions on the naming convention may need to be tightened in the future. In particular, if there are other well-known applications whose names begin with the string `"Xcode"`, the strings allowed for `` may need to be restricted to avoid colliding with other applications. If there's evidence that one of these naming techniques is strongly favored either in practice or by Apple, we may tighten the naming convention to favor it. + +## Caveats + +Using `xcsel` or `xcselv` to select an Xcode that is installed under your `$HOME` may break things for other users, depending on your system setup. We let you do this anyway because some people run OS X as effectively single-user, or have open permissions so this will work. You could also use `$DEVELOPER_DIR` as an alternative to `xcsel` that is scoped to the current user or session, instead of a global setting. + +This does not verify that the version name in the Xcode filename matches the actual version of that binary. It is the user's responsibility to get the names right. diff --git a/plugins/xcode/_xcselv b/plugins/xcode/_xcselv new file mode 100644 index 000000000..f9861d54b --- /dev/null +++ b/plugins/xcode/_xcselv @@ -0,0 +1,19 @@ +#compdef xcselv +#autoload + +function _xcselv_compl_list_versions() { + _omz_xcode_list_versions short +} + +_arguments \ + '(-l -L -p)-h[prints a help message]' \ + '(-L -p -h)-l[lists installed Xcode versions]' \ + '(-l -p -h)-L[lists installed Xcode versions (long form)]' \ + '(-h -l -L)-p[prints active Xcode version]' \ + && ret=0 + +local _xcode_versions +_xcode_versions=($(_xcselv_compl_list_versions)) +_describe -t _xcode_versions 'version' _xcode_versions + +return 1 diff --git a/plugins/xcode/xcode.plugin.zsh b/plugins/xcode/xcode.plugin.zsh index 1f547470d..b63a857a7 100644 --- a/plugins/xcode/xcode.plugin.zsh +++ b/plugins/xcode/xcode.plugin.zsh @@ -22,28 +22,153 @@ function xc { # Uses naming convention: # - different versions of Xcode are named Xcode-.app or stored # in a folder named Xcode- -# - the special version name "-" refers to the "default" Xcode.app with no suffix +# - the special version name "default" refers to the "default" Xcode.app with no suffix function xcselv { emulate -L zsh + if [[ $# == 0 ]]; then + echo "xcselv: error: no option or argument given" >&2 + echo "xcselv: see 'xcselv -h' for help" >&2 + return 1 + elif [[ $1 == "-p" ]]; then + _omz_xcode_print_active_version + return + elif [[ $1 == "-l" ]]; then + _omz_xcode_list_versions + return + elif [[ $1 == "-L" ]]; then + _omz_xcode_list_versions short + return + elif [[ $1 == "-h" ]]; then + _omz_xcode_print_xcselv_usage + return 0 + elif [[ $1 == -* && $1 != "-" ]]; then + echo "xcselv: error: unrecognized option: $1" >&2 + echo "xcselv: see 'xcselv -h' for help" >&2 + return 1 + fi + # Main case: "xcselv " to select a version local version=$1 - local apps_dirs apps_dir apps app - apps_dirs=( $HOME/Applications /Applications ) - for apps_dir ($apps_dirs); do - if [[ $version == "-" ]]; then - apps=( $apps_dir/Xcode.app $apps_dir/Xcode/Xcode.app ) + local -A xcode_versions + _omz_xcode_locate_versions + if [[ -z ${xcode_versions[$version]} ]]; then + echo "xcselv: error: Xcode version '$version' not found" >&2 + return 1 + fi + app="${xcode_versions[$version]}" + echo "selecting Xcode $version: $app" + xcsel "$app" +} + +function _omz_xcode_print_xcselv_usage { + cat << EOF >&2 +Usage: + xcselv + xcselv [options] + +Options: + set the active Xcode version + -h print this help message and exit + -p print the active Xcode version + -l list installed Xcode versions (long human-readable form) + -L list installed Xcode versions (short form, version names only) +EOF +} + +# Parses the Xcode version from a filename based on our conventions +# Only meaningful when called from other _omz_xcode functions +function _omz_xcode_parse_versioned_file { + local file=$1 + local basename=${app:t} + local dir=${app:h} + local parent=${dir:t} + #echo "parent=$parent basename=$basename verstr=$verstr ver=$ver" >&2 + local verstr + if [[ $parent == Xcode* ]]; then + if [[ $basename == "Xcode.app" ]]; then + # "Xcode-/Xcode.app" format + verstr=$parent else - apps=( $apps_dir/Xcode-$version.app $apps_dir/Xcode-$version/Xcode.app ) + # Both file and parent dir are versioned. Reject. + return 1; fi + elif [[ $basename == Xcode*.app ]]; then + # "Xcode-.app" format + verstr=${basename:r} + else + # Invalid naming pattern + return 1; + fi + + local ver=${verstr#Xcode} + ver=${ver#[- ]} + if [[ -z $ver ]]; then + # Unversioned "default" installation location + ver="default" + fi + print -- "$ver" +} + +# Print the active version, using xcselv's notion of versions +function _omz_xcode_print_active_version { + emulate -L zsh + local -A xcode_versions + local versions version active_path + _omz_xcode_locate_versions + active_path=$(xcode-select -p) + active_path=${active_path%%/Contents/Developer*} + versions=(${(kni)xcode_versions}) + for version ($versions); do + if [[ "${xcode_versions[$version]}" == $active_path ]]; then + printf "%s (%s)\n" $version $active_path + return + fi + done + printf "%s (%s)\n" "" $active_path +} + +# Locates all the installed versions of Xcode on this system, for this +# plugin's internal use. +# Populates the $xcode_versions associative array variable +# Caller should local-ize $xcode_versions with `local -A xcode_versions` +function _omz_xcode_locate_versions { + emulate -L zsh + local -a app_dirs + local app_dir apps app xcode_ver + # In increasing precedence order: + app_dirs=(/Applications $HOME/Applications) + for app_dir ($app_dirs); do + apps=( $app_dir/Xcode*.app(N) $app_dir/Xcode*/Xcode.app(N) ) for app ($apps); do - if [[ -e "$app" ]]; then - echo "selecting Xcode $version: $app" - xcsel "$app" - return + xcode_ver=$(_omz_xcode_parse_versioned_file $app) + if [[ $? != 0 ]]; then + continue fi + xcode_versions[$xcode_ver]=$app done done - echo "xcselv: Xcode version $version not found" - return 1 +} + +function _omz_xcode_list_versions { + emulate -L zsh + local -A xcode_versions + _omz_xcode_locate_versions + local width=1 width_i versions do_short=0 + if [[ $1 == "short" ]]; then + do_short=1 + fi + versions=(${(kni)xcode_versions}) + for version ($versions); do + if [[ $#version > $width ]]; then + width=$#version; + fi + done + for version ($versions); do + if [[ $do_short == 1 ]]; then + printf "%s\n" $version + else + printf "%-${width}s -> %s\n" "$version" "${xcode_versions[$version]}" + fi + done } function simulator { -- cgit v1.2.3-70-g09d2 From c9af79fcad9af8e4f2fd102336e7b0ffc1df0336 Mon Sep 17 00:00:00 2001 From: Andrew Janke Date: Fri, 11 Sep 2015 18:37:39 -0400 Subject: jira: add README, "emulate -L zsh", add "dumpconfig" action (The "dumpconfig" action is for verifying the configuration behavior against what's documented in the README now.) add "error" to some of the error messages --- plugins/jira/README.md | 64 ++++++++++++++++++++++++++++++++++++++++++++ plugins/jira/_jira | 1 + plugins/jira/jira.plugin.zsh | 44 ++++++++++-------------------- 3 files changed, 79 insertions(+), 30 deletions(-) create mode 100644 plugins/jira/README.md (limited to 'plugins') diff --git a/plugins/jira/README.md b/plugins/jira/README.md new file mode 100644 index 000000000..efb8a743a --- /dev/null +++ b/plugins/jira/README.md @@ -0,0 +1,64 @@ +# Jira plugin # + +CLI support for JIRA interaction + +## Description ## + +This plugin provides command line tools for interacting with Atlassian's [JIRA](https://www.atlassian.com/software/jira) bug tracking software. + +The interaction is all done through the web. No local installation of JIRA is necessary. + +In this document, "JIRA" refers to the JIRA issue tracking server, and `jira` refers to the command this plugin supplies. + +## Usage ## + +This plugin supplies one command, `jira`, through which all its features are exposed. Most forms of this command open a JIRA page in your web browser. + +``` +jira # performs the default action + +jira new # opens a new issue +jira dashboard # opens your JIRA dashboard +jira reported [username] # queries for issues reported by a user +jira assigned [username] # queries for issues assigned to a user +jira ABC-123 # opens an existing issue +jira ABC-123 m # opens an existing issue for adding a comment +``` + +#### Debugging usage #### + +These calling forms are for developers' use, and may change at any time. + +``` +jira dumpconfig # displays the effective configuration +``` + +## Setup ## + +The URL for your JIRA instance is set by `$JIRA_URL` or a `.jira_url` file. + +Add a `.jira-url` file in the base of your project. You can also set `$JIRA_URL` in your `~/.zshrc` or put a `.jira-url` in your home directory. A `.jira-url` in the current directory takes precedence, so you can make per-project customizations. + +The same goes with `.jira-prefix` and `$JIRA_PREFIX`. These control the prefix added to all issue IDs, which differentiates projects within a JIRA instance. + +For example: + +``` +cd to/my/project +echo "https://jira.atlassian.com" >> .jira-url +``` + +(Note: The current implementation only looks in the current directory for `.jira-url` and `.jira-prefix`, not up the path, so if you are in a subdirectory of your project, it will fall back to your default JIRA URL. This will probably change in the future though.) + +### Variables ### + +* `$JIRA_URL` - Your JIRA instance's URL +* `$JIRA_NAME` - Your JIRA username; used as the default user for `assigned`/`reported` searches +* `$JIRA_PREFIX` - Prefix added to issue ID arguments +* `$JIRA_RAPID_BOARD` - Set to `true` if you use Rapid Board +* `$JIRA_DEFAULT_ACTION` - Action to do when `jira` is called with no arguments; defaults to "new" + + +### Browser ### + +Your default web browser, as determined by how `open_command` handles `http://` URLs, is used for interacting with the JIRA instance. If you change your system's URL handler associations, it will change the browser that `jira` uses. diff --git a/plugins/jira/_jira b/plugins/jira/_jira index b0ea658e2..03fe6a499 100644 --- a/plugins/jira/_jira +++ b/plugins/jira/_jira @@ -7,6 +7,7 @@ _1st_arguments=( 'dashboard:open the dashboard' 'reported:search for issues reported by a user' 'assigned:search for issues assigned to a user' + 'dumpconfig:display effective jira configuration' ) _arguments -C \ diff --git a/plugins/jira/jira.plugin.zsh b/plugins/jira/jira.plugin.zsh index 89559767f..341e23ec0 100644 --- a/plugins/jira/jira.plugin.zsh +++ b/plugins/jira/jira.plugin.zsh @@ -1,35 +1,11 @@ # CLI support for JIRA interaction # -# Setup: -# Add a .jira-url file in the base of your project -# You can also set $JIRA_URL in your .zshrc or put .jira-url in your home directory -# A .jira-url in the current directory takes precedence. -# The same goes with .jira-prefix and $JIRA_PREFIX. -# -# For example: -# cd to/my/project -# echo "https://name.jira.com" >> .jira-url -# -# Variables: -# $JIRA_RAPID_BOARD - set to "true" if you use Rapid Board -# $JIRA_DEFAULT_ACTION - action to do when `jira` is called witn no args -# defaults to "new" -# $JIRA_NAME - Your JIRA username. Used as default for assigned/reported -# $JIRA_PREFIX - Prefix added to issue ID arguments -# -# -# Usage: -# jira # Performs the default action -# jira new # opens a new issue -# jira reported [username] -# jira assigned [username] -# jira dashboard -# jira ABC-123 # Opens an existing issue -# jira ABC-123 m # Opens an existing issue for adding a comment +# See README.md for details : ${JIRA_DEFAULT_ACTION:=new} function jira() { + emulate -L zsh local action=${1:=$JIRA_DEFAULT_ACTION} local jira_url jira_prefix @@ -63,6 +39,12 @@ function jira() { elif [[ "$action" == "dashboard" ]]; then echo "Opening dashboard" open_command "${jira_url}/secure/Dashboard.jspa" + elif [[ "$action" == "dumpconfig" ]]; then + echo "JIRA_URL=$jira_url" + echo "JIRA_PREFIX=$jira_prefix" + echo "JIRA_NAME=$JIRA_NAME" + echo "JIRA_RAPID_BOARD=$JIRA_RAPID_BOARD" + echo "JIRA_DEFAULT_ACTION=$JIRA_DEFAULT_ACTION" else # Anything that doesn't match a special action is considered an issue name local issue_arg=$action @@ -84,15 +66,17 @@ function jira() { function _jira_url_help() { cat << EOF -JIRA url is not specified anywhere. +error: JIRA URL is not specified anywhere. + Valid options, in order of precedence: .jira-url file \$HOME/.jira-url file - JIRA_URL environment variable + \$JIRA_URL environment variable EOF } function _jira_query() { + emulate -L zsh local verb="$1" local jira_name lookup preposition query if [[ "${verb}" == "reported" ]]; then @@ -102,12 +86,12 @@ function _jira_query() { lookup=assignee preposition=to else - echo "not a valid lookup: $verb" >&2 + echo "error: not a valid lookup: $verb" >&2 return 1 fi jira_name=${2:=$JIRA_NAME} if [[ -z $jira_name ]]; then - echo "JIRA_NAME not specified" >&2 + echo "error: JIRA_NAME not specified" >&2 return 1 fi -- cgit v1.2.3-70-g09d2 From 797e1f9a64c0d2775723bb28c76745b327f86d56 Mon Sep 17 00:00:00 2001 From: Tim O'Brien Date: Mon, 14 Sep 2015 15:32:50 -0700 Subject: [plugins/bgnotify] fix for iTerm2 notification clicks --- plugins/bgnotify/bgnotify.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins') diff --git a/plugins/bgnotify/bgnotify.plugin.zsh b/plugins/bgnotify/bgnotify.plugin.zsh index f6dd3886c..459f5214e 100755 --- a/plugins/bgnotify/bgnotify.plugin.zsh +++ b/plugins/bgnotify/bgnotify.plugin.zsh @@ -32,7 +32,7 @@ currentWindowId () { bgnotify () { ## args: (title, subtitle) if hash terminal-notifier 2>/dev/null; then #osx - [[ "$TERM_PROGRAM" == 'iTerm.app' ]] && term_id='com.googlecode.iterm2' || + [[ "$TERM_PROGRAM" == 'iTerm.app' ]] && term_id='com.googlecode.iterm2'; [[ "$TERM_PROGRAM" == 'Apple_Terminal' ]] && term_id='com.apple.terminal'; ## now call terminal-notifier, (hopefully with $term_id!) [ -z "$term_id" ] && terminal-notifier -message "$2" -title "$1" >/dev/null || -- cgit v1.2.3-70-g09d2 From a8a8bc3967fc7b6906bd03c8f893a206ebc055f5 Mon Sep 17 00:00:00 2001 From: Daniel Stankevich Date: Wed, 16 Sep 2015 17:18:27 +1000 Subject: Add simple Stack commands list --- plugins/stack/stack.plugin.zsh | 49 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 plugins/stack/stack.plugin.zsh (limited to 'plugins') diff --git a/plugins/stack/stack.plugin.zsh b/plugins/stack/stack.plugin.zsh new file mode 100644 index 000000000..7cc256394 --- /dev/null +++ b/plugins/stack/stack.plugin.zsh @@ -0,0 +1,49 @@ +function stack_sandbox_info() { + stack_files=(*.stack(N)) + if [ $#stack_files -gt 0 ]; then + if [ -f stack.sandbox.config ]; then + echo "%{$fg[green]%}sandboxed%{$reset_color%}" + else + echo "%{$fg[red]%}not sandboxed%{$reset_color%}" + fi + fi +} + +function _stack_commands() { + local ret=1 state + _arguments ':subcommand:->subcommand' && ret=0 + + case $state in + subcommand) + subcommands=( + "build:Build the project(s) in this directory/configuration" + "install:Build executables and install to a user path" + "test:Build and test the project(s) in this directory/configuration" + "bench:Build and benchmark the project(s) in this directory/configuration" + "haddock:Generate haddocks for the project(s) in this directory/configuration" + "new:Create a brand new project" + "init:Initialize a stack project based on one or more stack packages" + "solver:Use a dependency solver to try and determine missing extra-deps" + "setup:Get the appropriate ghc for your project" + "path:Print out handy path information" + "unpack:Unpack one or more packages locally" + "update:Update the package index" + "upgrade:Upgrade to the latest stack (experimental)" + "upload:Upload a package to Hackage" + "dot:Visualize your project's dependency graph using Graphviz dot" + "exec:Execute a command" + "ghc:Run ghc" + "ghci:Run ghci in the context of project(s)" + "ide:Run ide-backend-client with the correct arguments" + "runghc:Run runghc" + "clean:Clean the local packages" + "docker:Subcommands specific to Docker use" + ) + _describe -t subcommands 'stack subcommands' subcommands && ret=0 + esac + + return ret +} + +compdef _stack_commands stack + -- cgit v1.2.3-70-g09d2 From bb10ad0a13f0dfc1d716ea023d4fc806a4e167d0 Mon Sep 17 00:00:00 2001 From: Daniel Stankevich Date: Wed, 16 Sep 2015 17:25:39 +1000 Subject: Remove unnecessary sandbox fn --- plugins/stack/stack.plugin.zsh | 12 ------------ 1 file changed, 12 deletions(-) (limited to 'plugins') diff --git a/plugins/stack/stack.plugin.zsh b/plugins/stack/stack.plugin.zsh index 7cc256394..a149208d0 100644 --- a/plugins/stack/stack.plugin.zsh +++ b/plugins/stack/stack.plugin.zsh @@ -1,14 +1,3 @@ -function stack_sandbox_info() { - stack_files=(*.stack(N)) - if [ $#stack_files -gt 0 ]; then - if [ -f stack.sandbox.config ]; then - echo "%{$fg[green]%}sandboxed%{$reset_color%}" - else - echo "%{$fg[red]%}not sandboxed%{$reset_color%}" - fi - fi -} - function _stack_commands() { local ret=1 state _arguments ':subcommand:->subcommand' && ret=0 @@ -46,4 +35,3 @@ function _stack_commands() { } compdef _stack_commands stack - -- cgit v1.2.3-70-g09d2 From 8c5b9481622759d2081e0b28faef64a39200f122 Mon Sep 17 00:00:00 2001 From: Henrik Hodne Date: Wed, 16 Sep 2015 15:28:08 +0200 Subject: chruby: donʼt try to execute .sh files before loading MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/chruby/chruby.plugin.zsh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'plugins') diff --git a/plugins/chruby/chruby.plugin.zsh b/plugins/chruby/chruby.plugin.zsh index b461b0c9b..5be6528b0 100644 --- a/plugins/chruby/chruby.plugin.zsh +++ b/plugins/chruby/chruby.plugin.zsh @@ -45,11 +45,11 @@ _source_from_omz_settings() { zstyle -s :omz:plugins:chruby path _chruby_path zstyle -s :omz:plugins:chruby auto _chruby_auto - if ${_chruby_path} && [[ -r ${_chruby_path} ]]; then + if [[ -r ${_chruby_path} ]]; then source ${_chruby_path} fi - if ${_chruby_auto} && [[ -r ${_chruby_auto} ]]; then + if [[ -r ${_chruby_auto} ]]; then source ${_chruby_auto} fi } -- cgit v1.2.3-70-g09d2 From dce052dac00f83dae364358cdc6c24ed3486e9ea Mon Sep 17 00:00:00 2001 From: Alexis Hildebrandt Date: Fri, 18 Sep 2015 14:24:46 +0200 Subject: Add emotty plugin which displays an emoji for the current $TTY. --- plugins/emotty/emotty.plugin.zsh | 43 ++++++++++++++++++++++++++ plugins/emotty/emotty_emoji_set.zsh | 24 +++++++++++++++ plugins/emotty/emotty_floral_set.zsh | 18 +++++++++++ plugins/emotty/emotty_love_set.zsh | 34 ++++++++++++++++++++ plugins/emotty/emotty_nature_set.zsh | 58 +++++++++++++++++++++++++++++++++++ plugins/emotty/emotty_stellar_set.zsh | 25 +++++++++++++++ plugins/emotty/emotty_zodiac_set.zsh | 29 ++++++++++++++++++ 7 files changed, 231 insertions(+) create mode 100644 plugins/emotty/emotty.plugin.zsh create mode 100644 plugins/emotty/emotty_emoji_set.zsh create mode 100644 plugins/emotty/emotty_floral_set.zsh create mode 100644 plugins/emotty/emotty_love_set.zsh create mode 100644 plugins/emotty/emotty_nature_set.zsh create mode 100644 plugins/emotty/emotty_stellar_set.zsh create mode 100644 plugins/emotty/emotty_zodiac_set.zsh (limited to 'plugins') diff --git a/plugins/emotty/emotty.plugin.zsh b/plugins/emotty/emotty.plugin.zsh new file mode 100644 index 000000000..b32dd1a4c --- /dev/null +++ b/plugins/emotty/emotty.plugin.zsh @@ -0,0 +1,43 @@ +# ------------------------------------------------------------------------------ +# FILE: emotty.plugin.zsh +# DESCRIPTION: Return an emoji for the current $TTY number. +# AUTHOR: Alexis Hildebrandt (afh[at]surryhill.net) +# VERSION: 1.0.0 +# DEPENDS: emoji plugin +# +# There are different sets of emoji characters available, to choose a different +# set export emotty_set to the name of the set you would like to use, e.g.: +# % export emotty_set=nature +# ------------------------------------------------------------------------------ + +typeset -gAH _emotty_sets +local _emotty_plugin_dir="${0:h}" +source "$_emotty_plugin_dir/emotty_stellar_set.zsh" +source "$_emotty_plugin_dir/emotty_floral_set.zsh" +source "$_emotty_plugin_dir/emotty_zodiac_set.zsh" +source "$_emotty_plugin_dir/emotty_nature_set.zsh" +source "$_emotty_plugin_dir/emotty_emoji_set.zsh" +source "$_emotty_plugin_dir/emotty_love_set.zsh" +unset _emotty_plugin_dir + +emotty_default_set=emoji + +function emotty() { + # Use emotty set defined by user, fallback to default + local emotty=${_emotty_sets[${emotty_set:-$emotty_default_set}]} + # Parse $TTY number, normalizing it to an emotty set index + (( tty = (${TTY##/dev/ttys} % ${#${=emotty}}) + 1 )) + local character_name=${${=emotty}[tty]} + echo "${emoji[${character_name}]}${emoji2[emoji_style]}" +} + +function display_emotty() { + local name=$1 + for i in ${=_emotty_sets[$name]}; do + printf "${emoji[$i]}${emoji2[emoji_style]} " + done + print + for i in ${=_emotty_sets[$name]}; do + print "${emoji[$i]}${emoji2[emoji_style]} = $i" + done +} diff --git a/plugins/emotty/emotty_emoji_set.zsh b/plugins/emotty/emotty_emoji_set.zsh new file mode 100644 index 000000000..00e317131 --- /dev/null +++ b/plugins/emotty/emotty_emoji_set.zsh @@ -0,0 +1,24 @@ +#!/usr/bin/env zsh +# vim:ft=zsh ts=2 sw=2 sts=2 + +_emotty_sets[emoji]=" + crystal_ball + ghost + jack_o_lantern + see_no_evil_monkey + hear_no_evil_monkey + speak_no_evil_monkey + smiling_cat_face_with_open_mouth + extraterrestrial_alien + rocket + billiards + bomb + pill + japanese_symbol_for_beginner + direct_hit + cyclone + diamond_shape_with_a_dot_inside + sparkle + eight_spoked_asterisk + eight_pointed_black_star + " diff --git a/plugins/emotty/emotty_floral_set.zsh b/plugins/emotty/emotty_floral_set.zsh new file mode 100644 index 000000000..f761feae6 --- /dev/null +++ b/plugins/emotty/emotty_floral_set.zsh @@ -0,0 +1,18 @@ +#!/usr/bin/env zsh +# vim:ft=zsh ts=2 sw=2 sts=2 + +_emotty_sets[floral]=" + hibiscus + cherry_blossom + blossom + sunflower + bouquet + tulip + rose + four_leaf_clover + seedling + herb + palm_tree + evergreen_tree + deciduous_tree + " diff --git a/plugins/emotty/emotty_love_set.zsh b/plugins/emotty/emotty_love_set.zsh new file mode 100644 index 000000000..8f19e6902 --- /dev/null +++ b/plugins/emotty/emotty_love_set.zsh @@ -0,0 +1,34 @@ +#!/usr/bin/env zsh +# vim:ft=zsh ts=2 sw=2 sts=2 + +# Note: The heavy_black_heart emoji requires $emoji2[emoji_style] +# to be rendered as the emoji red heart. +_emotty_sets[love]=" + green_heart + blue_heart + purple_heart + yellow_heart + heavy_black_heart + broken_heart + heart_with_arrow + heart_with_ribbon + sparkling_heart + two_hearts + revolving_hearts + growing_heart + beating_heart + heart_decoration + couple_with_heart + kiss + man_and_woman_holding_hands + two_women_holding_hands + two_men_holding_hands + kiss_mark + smiling_face_with_heart_shaped_eyes + kissing_face + face_throwing_a_kiss + kissing_face_with_smiling_eyes + kissing_face_with_closed_eyes + smiling_cat_face_with_heart_shaped_eyes + kissing_cat_face_with_closed_eyes + " diff --git a/plugins/emotty/emotty_nature_set.zsh b/plugins/emotty/emotty_nature_set.zsh new file mode 100644 index 000000000..8dab4c1ba --- /dev/null +++ b/plugins/emotty/emotty_nature_set.zsh @@ -0,0 +1,58 @@ +#!/usr/bin/env zsh +# vim:ft=zsh ts=2 sw=2 sts=2 + +_emotty_sets[nature]=" + mouse_face + hamster_face + rabbit_face + dog_face + cat_face + tiger_face + bear_face + monkey_face + koala + panda_face + chicken + baby_chick + bird + penguin + cow_face + pig_face + frog_face + boar + wolf_face + horse_face + snail + bug + ant + honeybee + lady_beetle + spouting_whale + dolphin + octopus + fish + tropical_fish + snake + turtle + lemon + tangerine + peach + mushroom + tomato + strawberry + red_apple + cherries + grapes + aubergine + watermelon + banana + pineapple + melon + pear + green_apple + ear_of_maize + sunflower + seedling + herb + four_leaf_clover + " diff --git a/plugins/emotty/emotty_stellar_set.zsh b/plugins/emotty/emotty_stellar_set.zsh new file mode 100644 index 000000000..8e7e61068 --- /dev/null +++ b/plugins/emotty/emotty_stellar_set.zsh @@ -0,0 +1,25 @@ +#!/usr/bin/env zsh +# vim:ft=zsh ts=2 sw=2 sts=2 + +# NOTE: The following emoji show as $'character' in the title +# white_medium_star +# sparkles +# dizzy_symbol + +_emotty_sets[stellar]=" + full_moon_symbol + waning_gibbous_moon_symbol + waning_crescent_moon_symbol + last_quarter_moon_symbol + new_moon_symbol + new_moon_with_face + waxing_crescent_moon_symbol + first_quarter_moon_symbol + waxing_gibbous_moon_symbol + full_moon_with_face + sun_with_face + glowing_star + crescent_moon + first_quarter_moon_with_face + last_quarter_moon_with_face + " diff --git a/plugins/emotty/emotty_zodiac_set.zsh b/plugins/emotty/emotty_zodiac_set.zsh new file mode 100644 index 000000000..bde6e3d2e --- /dev/null +++ b/plugins/emotty/emotty_zodiac_set.zsh @@ -0,0 +1,29 @@ +#!/usr/bin/env zsh +# vim:ft=zsh ts=2 sw=2 sts=2 + +_emotty_sets[zodiac]=" + aries + taurus + gemini + cancer + leo + virgo + libra + scorpius + sagittarius + capricorn + aquarius + pisces + rat + ox + tiger + rabbit + dragon + snake + horse + goat + monkey + rooster + dog + pig + " -- cgit v1.2.3-70-g09d2 From f8502965e491d341829e565e221d7848588d6798 Mon Sep 17 00:00:00 2001 From: Ramses Ladlani Date: Mon, 21 Sep 2015 09:18:43 +0200 Subject: Added cygwin support to atom plugin --- plugins/atom/atom.plugin.zsh | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) (limited to 'plugins') diff --git a/plugins/atom/atom.plugin.zsh b/plugins/atom/atom.plugin.zsh index ec1a114ed..2711cf0e8 100644 --- a/plugins/atom/atom.plugin.zsh +++ b/plugins/atom/atom.plugin.zsh @@ -1,8 +1,5 @@ -# Gets OS Type -unamestr=$(uname -s) - -# If OSX -if [[ "$unamestr" == 'Darwin' ]]; then +case $OSTYPE in +darwin*) local _atom_paths > /dev/null 2>&1 _atom_paths=( "$HOME/Applications/Atom.app" @@ -15,8 +12,26 @@ if [[ "$unamestr" == 'Darwin' ]]; then break fi done -# If Linux -elif [[ "$unamestr" == 'Linux' ]]; then + ;; +cygwin) + local _atom_path > /dev/null 2>&1 + + _atom_path=${LOCALAPPDATA}/atom/bin/atom + + if [[ -a $_atom_path ]]; then + cyg_open_atom() + { + if [[ -n $1 ]]; then + ${_atom_path} `cygpath -w -a $1` + else + ${_atom_path} + fi + } + + alias at=cyg_open_atom + fi + ;; +linux*) # Alerts the user if 'atom' is not a found command. type atom >/dev/null 2>&1 && alias at="atom" || { echo >&2 "You have enabled the atom oh-my-zsh plugin on Linux, but atom is not a recognized command. Please make sure you have it installed before using this plugin."; } -fi +esac -- cgit v1.2.3-70-g09d2 From 1bb2715b22a08d3ae24d99550acd531c872a26cd Mon Sep 17 00:00:00 2001 From: Michael SALIHI Date: Mon, 21 Sep 2015 13:17:45 +0200 Subject: Fix capistrano problem when generating autocompletion --- plugins/capistrano/_capistrano | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins') diff --git a/plugins/capistrano/_capistrano b/plugins/capistrano/_capistrano index e6e71ffcc..c19c20b7a 100644 --- a/plugins/capistrano/_capistrano +++ b/plugins/capistrano/_capistrano @@ -14,7 +14,7 @@ _arguments -C \ _cap_tasks() { if [[ -f config/deploy.rb || -f Capfile ]]; then if [[ ! -f .cap_tasks~ ]]; then - shipit -v --tasks | sed 's/\(\[\)\(.*\)\(\]\)/\2:/' | awk '{command=$2; $1=$2=$3=""; gsub(/^[ \t\r\n]+/, "", $0); gsub(":", "\\:", command); print command"["$0"]"}' > .cap_tasks~ + shipit --tasks | sed 's/\(\[\)\(.*\)\(\]\)/\2:/' | awk '{command=$2; $1=$2=$3=""; gsub(/^[ \t\r\n]+/, "", $0); gsub(":", "\\:", command); print command"["$0"]"}' > .cap_tasks~ fi OLD_IFS=$IFS -- cgit v1.2.3-70-g09d2 From a746e6010ae2b260213f081789eaff01865f5664 Mon Sep 17 00:00:00 2001 From: Andy Bateman Date: Mon, 14 Sep 2015 19:27:41 +1200 Subject: Update osx.plugin.zsh Added function to display the song you're currently listening to in iTunes Fixed indent Indentation on line 169 was squiffy Fixed spelling Removed unnecessary wording to make function more succinct. Highlighting of Artist and Track Changed the highlighting of the Track and Artist in yellow to make use of Prompt Expansion Colors --- plugins/osx/osx.plugin.zsh | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'plugins') diff --git a/plugins/osx/osx.plugin.zsh b/plugins/osx/osx.plugin.zsh index 390960fdc..044276c1c 100644 --- a/plugins/osx/osx.plugin.zsh +++ b/plugins/osx/osx.plugin.zsh @@ -161,6 +161,15 @@ function itunes() { vol) opt="set sound volume to $1" #$1 Due to the shift ;; + playing) + local state=`osascript -e 'tell application "iTunes" to player state as string'` + if [ "$state" = "playing" ]; then + currenttrack=`osascript -e 'tell application "iTunes" to name of current track as string'` + currentartist=`osascript -e 'tell application "iTunes" to artist of current track as string'` + echo "Listening to %F{yellow}$currenttrack%f by %F{yellow}$currentartist%f"; + fi + return 0 + ;; shuf|shuff|shuffle) # The shuffle property of current playlist can't be changed in iTunes 12, # so this workaround uses AppleScript to simulate user input instead. @@ -199,6 +208,7 @@ EOF echo "\tnext|previous\tplay next or previous track" echo "\tshuf|shuffle [on|off|toggle]\tSet shuffled playback. Default: toggle. Note: toggle doesn't support the MiniPlayer." echo "\tvol\tSet the volume, takes an argument from 0 to 100" + echo "\tplaying\tShow what song is currently playing in iTunes." echo "\thelp\tshow this message and exit" return 0 ;; -- cgit v1.2.3-70-g09d2 From 29db0e0119aba4f317ac320ed5089b82142bcb10 Mon Sep 17 00:00:00 2001 From: Andy Bateman Date: Thu, 17 Sep 2015 13:48:30 +1200 Subject: Fixed colourisation of Now Playing function --- plugins/osx/osx.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins') diff --git a/plugins/osx/osx.plugin.zsh b/plugins/osx/osx.plugin.zsh index 044276c1c..f1b437189 100644 --- a/plugins/osx/osx.plugin.zsh +++ b/plugins/osx/osx.plugin.zsh @@ -166,7 +166,7 @@ function itunes() { if [ "$state" = "playing" ]; then currenttrack=`osascript -e 'tell application "iTunes" to name of current track as string'` currentartist=`osascript -e 'tell application "iTunes" to artist of current track as string'` - echo "Listening to %F{yellow}$currenttrack%f by %F{yellow}$currentartist%f"; + print -P "Listening to %F{yellow}$currenttrack%f by %F{yellow}$currentartist%f"; fi return 0 ;; -- cgit v1.2.3-70-g09d2 From 9f2acdc445f05e6556cf6180a1edd52b6939bbcc Mon Sep 17 00:00:00 2001 From: Andy Bateman Date: Thu, 17 Sep 2015 18:28:48 +1200 Subject: You can now use 'itunes status' as well as 'itunes playing' to show current track --- plugins/osx/osx.plugin.zsh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'plugins') diff --git a/plugins/osx/osx.plugin.zsh b/plugins/osx/osx.plugin.zsh index f1b437189..859e08da5 100644 --- a/plugins/osx/osx.plugin.zsh +++ b/plugins/osx/osx.plugin.zsh @@ -161,9 +161,9 @@ function itunes() { vol) opt="set sound volume to $1" #$1 Due to the shift ;; - playing) + playing|status) local state=`osascript -e 'tell application "iTunes" to player state as string'` - if [ "$state" = "playing" ]; then + if [[ "$state" = "playing" ]]; then currenttrack=`osascript -e 'tell application "iTunes" to name of current track as string'` currentartist=`osascript -e 'tell application "iTunes" to artist of current track as string'` print -P "Listening to %F{yellow}$currenttrack%f by %F{yellow}$currentartist%f"; -- cgit v1.2.3-70-g09d2 From 993e09cc6b6127be92afe072f5957e4e9e72367f Mon Sep 17 00:00:00 2001 From: Andy Bateman Date: Thu, 17 Sep 2015 19:12:35 +1200 Subject: Added function for 'itunes playing' to display state when not playing --- plugins/osx/osx.plugin.zsh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'plugins') diff --git a/plugins/osx/osx.plugin.zsh b/plugins/osx/osx.plugin.zsh index 859e08da5..9413f5056 100644 --- a/plugins/osx/osx.plugin.zsh +++ b/plugins/osx/osx.plugin.zsh @@ -167,6 +167,8 @@ function itunes() { currenttrack=`osascript -e 'tell application "iTunes" to name of current track as string'` currentartist=`osascript -e 'tell application "iTunes" to artist of current track as string'` print -P "Listening to %F{yellow}$currenttrack%f by %F{yellow}$currentartist%f"; + else + print "iTunes is" $state; fi return 0 ;; @@ -208,7 +210,7 @@ EOF echo "\tnext|previous\tplay next or previous track" echo "\tshuf|shuffle [on|off|toggle]\tSet shuffled playback. Default: toggle. Note: toggle doesn't support the MiniPlayer." echo "\tvol\tSet the volume, takes an argument from 0 to 100" - echo "\tplaying\tShow what song is currently playing in iTunes." + echo "\tplaying|status\tShow what song is currently playing in iTunes." echo "\thelp\tshow this message and exit" return 0 ;; -- cgit v1.2.3-70-g09d2 From 326c2b08593e9b02da149dcc0d3c5cf99b21d3a2 Mon Sep 17 00:00:00 2001 From: Andy Bateman Date: Sun, 20 Sep 2015 08:46:45 +1200 Subject: Replaced the use of 'print' with 'echo' in order to sanitise track and artist names Fixed indentation Fixed indentation --- plugins/osx/osx.plugin.zsh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'plugins') diff --git a/plugins/osx/osx.plugin.zsh b/plugins/osx/osx.plugin.zsh index 9413f5056..86778363b 100644 --- a/plugins/osx/osx.plugin.zsh +++ b/plugins/osx/osx.plugin.zsh @@ -166,9 +166,9 @@ function itunes() { if [[ "$state" = "playing" ]]; then currenttrack=`osascript -e 'tell application "iTunes" to name of current track as string'` currentartist=`osascript -e 'tell application "iTunes" to artist of current track as string'` - print -P "Listening to %F{yellow}$currenttrack%f by %F{yellow}$currentartist%f"; + echo -E "Listening to $fg[yellow]$currenttrack$reset_color by $fg[yellow]$currentartist$reset_color"; else - print "iTunes is" $state; + echo "iTunes is" $state; fi return 0 ;; -- cgit v1.2.3-70-g09d2 From e957ae41354d6892170e327df3be8a5913f41e78 Mon Sep 17 00:00:00 2001 From: Alexander Frolov Date: Wed, 23 Sep 2015 09:54:22 +0300 Subject: Update README.md --- plugins/vi-mode/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'plugins') diff --git a/plugins/vi-mode/README.md b/plugins/vi-mode/README.md index 03e67cca2..8519a5592 100644 --- a/plugins/vi-mode/README.md +++ b/plugins/vi-mode/README.md @@ -61,8 +61,8 @@ Insertion Delete and Insert ----------------- -- `ctrl-h` : While in *Insert mode*: delete character after the cursor -- `ctrl-w` : While in *Insert mode*: delete word after the cursor +- `ctrl-h` : While in *Insert mode*: delete character before the cursor +- `ctrl-w` : While in *Insert mode*: delete word before the cursor - `d{motion}` : Delete text that {motion} moves over - `dd` : Delete line - `D` : Delete characters under the cursor until the end of the line -- cgit v1.2.3-70-g09d2 From 8e74f7c1aa44b5f74cf4ede49562f0586a562347 Mon Sep 17 00:00:00 2001 From: Michael SALIHI Date: Thu, 24 Sep 2015 02:22:50 +0200 Subject: Add alias for print latest tag name --- plugins/git/git.plugin.zsh | 1 + 1 file changed, 1 insertion(+) (limited to 'plugins') diff --git a/plugins/git/git.plugin.zsh b/plugins/git/git.plugin.zsh index bbee13ab8..4f2745038 100644 --- a/plugins/git/git.plugin.zsh +++ b/plugins/git/git.plugin.zsh @@ -84,6 +84,7 @@ 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' gdv() { git diff -w "$@" | view - } compdef _git gdv=git-diff -- cgit v1.2.3-70-g09d2 From 07f08aa731e73bfa27a4e89b96ce991af5175848 Mon Sep 17 00:00:00 2001 From: Tyler Charlesworth Date: Thu, 24 Sep 2015 01:25:22 -0700 Subject: Adds Cygwin support --- plugins/sublime/sublime.plugin.zsh | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'plugins') diff --git a/plugins/sublime/sublime.plugin.zsh b/plugins/sublime/sublime.plugin.zsh index 4b93c1580..62c6df8f8 100644 --- a/plugins/sublime/sublime.plugin.zsh +++ b/plugins/sublime/sublime.plugin.zsh @@ -1,5 +1,3 @@ -# Sublime Text 2 Aliases - if [[ $('uname') == 'Linux' ]]; then local _sublime_linux_paths > /dev/null 2>&1 _sublime_linux_paths=( @@ -33,7 +31,6 @@ elif [[ "$OSTYPE" = darwin* ]]; then "$HOME/Applications/Sublime Text 3.app/Contents/SharedSupport/bin/subl" "$HOME/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl" ) - for _sublime_path in $_sublime_darwin_paths; do if [[ -a $_sublime_path ]]; then subl () { "$_sublime_path" $* } @@ -43,4 +40,18 @@ elif [[ "$OSTYPE" = darwin* ]]; then done fi +elif [[ "$OSTYPE" = 'cygwin' ]]; then + local _sublime_cygwin_paths > /dev/null 2>&1 + _sublime_cygwin_paths=( + "$(cygpath $ProgramW6432/Sublime\ Text\ 2)/sublime_text.exe" + "$(cygpath $ProgramW6432/Sublime\ Text\ 3)/sublime_text.exe" + ) + for _sublime_path in $_sublime_cygwin_paths; do + if [[ -a $_sublime_path ]]; then + subl () { "$_sublime_path" $* } + alias st=subl + break + fi + done + alias stt='st .' -- cgit v1.2.3-70-g09d2 From 0c0450b3035cd4e9fd3f2c07469b933a4d1aa78f Mon Sep 17 00:00:00 2001 From: Aleksandar Vidakovic Date: Thu, 24 Sep 2015 11:51:15 +0100 Subject: Accept single and double quotes in Gulp plugin --- plugins/gulp/gulp.plugin.zsh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'plugins') diff --git a/plugins/gulp/gulp.plugin.zsh b/plugins/gulp/gulp.plugin.zsh index 6017c7b60..8e11a444f 100644 --- a/plugins/gulp/gulp.plugin.zsh +++ b/plugins/gulp/gulp.plugin.zsh @@ -20,10 +20,10 @@ # in the current directory. # function $$gulp_completion() { - compls=$(grep -Eo "gulp.task\(('(([a-zA-Z0-9]|-)*)',)" gulpfile.js 2>/dev/null | grep -Eo "'(([a-zA-Z0-9]|-)*)'" | sed s/"'"//g | sort) + compls=$(grep -Eo "gulp.task\((['\"](([a-zA-Z0-9]|-)*)['\"],)" gulpfile.js 2>/dev/null | grep -Eo "['\"](([a-zA-Z0-9]|-)*)['\"]" | sed s/"['\"]"//g | sort)" completions=(${=compls}) compadd -- $completions } -compdef $$gulp_completion gulp \ No newline at end of file +compdef $$gulp_completion gulp -- cgit v1.2.3-70-g09d2 From 17088c6431271fe9fd9fa5cdfd56ff2addab5fd5 Mon Sep 17 00:00:00 2001 From: Piotr Gaczkowski Date: Fri, 25 Sep 2015 22:45:45 +0200 Subject: Fix invalid test expression. --- plugins/chruby/chruby.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins') diff --git a/plugins/chruby/chruby.plugin.zsh b/plugins/chruby/chruby.plugin.zsh index 5be6528b0..164b4319f 100644 --- a/plugins/chruby/chruby.plugin.zsh +++ b/plugins/chruby/chruby.plugin.zsh @@ -24,7 +24,7 @@ _homebrew-installed() { } _chruby-from-homebrew-installed() { - [ -r $(brew --prefix chruby)] &> /dev/null + [ -r $(brew --prefix chruby) ] &> /dev/null } _ruby-build_installed() { -- cgit v1.2.3-70-g09d2