From 16ae4e127f6af2f8f3332025ce46d45ab5bcadac Mon Sep 17 00:00:00 2001 From: Pablo Cantero Date: Sun, 26 Jan 2014 10:18:04 -0200 Subject: [PATCH 01/88] 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 diff --git a/plugins/capistrano/_capistrano b/plugins/capistrano/_capistrano index 3cadf3d5..7a74b373 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 00000000..9a4a2cc3 --- /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 +} From c9fbfc9f48b25c724265e06f0bce8d737c7ea13b Mon Sep 17 00:00:00 2001 From: Pablo Cantero Date: Fri, 4 Apr 2014 21:20:01 -0300 Subject: [PATCH 02/88] Uses `shipit` instead of `xcap` --- plugins/capistrano/_capistrano | 6 +++--- plugins/capistrano/capistrano.plugin.zsh | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/plugins/capistrano/_capistrano b/plugins/capistrano/_capistrano index 7a74b373..c181b55c 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 9a4a2cc3..c85eb474 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 $* From f516b7c7f5e630ab04d31e5f7da5f443b21f173f Mon Sep 17 00:00:00 2001 From: drm00 Date: Fri, 25 Apr 2014 14:15:14 +0200 Subject: [PATCH 03/88] add check for colored ls on openbsd. (retry of #2225) --- lib/theme-and-appearance.zsh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/theme-and-appearance.zsh b/lib/theme-and-appearance.zsh index 0353f9db..2c6d4912 100644 --- a/lib/theme-and-appearance.zsh +++ b/lib/theme-and-appearance.zsh @@ -12,8 +12,11 @@ then # otherwise, leave ls as is, because NetBSD's ls doesn't support -G gls --color -d . &>/dev/null 2>&1 && alias ls='gls --color=tty' elif [[ "$(uname -s)" == "OpenBSD" ]]; then - # On OpenBSD, test if "colorls" is installed (this one supports colors); - # otherwise, leave ls as is, because OpenBSD's ls doesn't support -G + # On OpenBSD, "gls" (ls from GNU coreutils) and "colorls" (ls from base, + # with color and multibyte support) are available from ports. "colorls" + # will be installed on purpose and can't be pulled in by installing + # coreutils, so prefer it to "gls". + gls --color -d . &>/dev/null 2>&1 && alias ls='gls --color=tty' colorls -G -d . &>/dev/null 2>&1 && alias ls='colorls -G' else ls --color -d . &>/dev/null 2>&1 && alias ls='ls --color=tty' || alias ls='ls -G' From 20edd5f6de221dcf4ae818c0fa91c5121afbbf0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20K=C3=B6nig?= Date: Mon, 1 Sep 2014 15:12:36 +0200 Subject: [PATCH 04/88] gulp.js plugin --- gulp/gulp.plugin.zsh | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 gulp/gulp.plugin.zsh diff --git a/gulp/gulp.plugin.zsh b/gulp/gulp.plugin.zsh new file mode 100644 index 00000000..6017c7b6 --- /dev/null +++ b/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 From 8f9a72aa7b6d23f82b027a28ffe3f3f6cec8c863 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20K=C3=B6nig?= Date: Thu, 18 Sep 2014 19:55:44 +0200 Subject: [PATCH 05/88] Moved plugin. --- {gulp => plugins/gulp}/gulp.plugin.zsh | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {gulp => plugins/gulp}/gulp.plugin.zsh (100%) diff --git a/gulp/gulp.plugin.zsh b/plugins/gulp/gulp.plugin.zsh similarity index 100% rename from gulp/gulp.plugin.zsh rename to plugins/gulp/gulp.plugin.zsh From 0c77e4ba6f52642d7f94e6cd72c869ad2e47c62f Mon Sep 17 00:00:00 2001 From: spacewander Date: Mon, 15 Dec 2014 12:41:22 +0800 Subject: [PATCH 06/88] update git-extras plugin --- plugins/git-extras/git-extras.plugin.zsh | 198 ++++++++++++++--------- 1 file changed, 122 insertions(+), 76 deletions(-) diff --git a/plugins/git-extras/git-extras.plugin.zsh b/plugins/git-extras/git-extras.plugin.zsh index 8419166a..d91c1af8 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,6 +100,35 @@ __git_author_names() { _wanted author-names expl author-name compadd $* - $author_names } +# subcommands + +_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-changelog() { _arguments \ @@ -99,11 +136,6 @@ _git-changelog() { } -_git-effort() { - _arguments \ - '--above[ignore file with less than x commits]' \ -} - _git-contrib() { _arguments \ @@ -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 +_git-squash() { + _arguments \ + ':branch-name:__git_branch_names' +} - _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-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' \ - 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' \ + extras:'git-extras' \ + feature:'create a feature branch' \ + 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' \ - setup:'setup a git repository' \ - 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' \ + 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' \ + undo:'remove the latest commit' \ + unlock:'unlock a file excluded from version control' From a9e97e5d2da90cf3e2b4575888fe585972ebcc74 Mon Sep 17 00:00:00 2001 From: Andrew Janke Date: Sat, 14 Feb 2015 19:05:27 -0500 Subject: [PATCH 07/88] 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 diff --git a/lib/termsupport.zsh b/lib/termsupport.zsh index e1c2e2f9..da74dfdb 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 -precmd_functions+=(omz_termsupport_cwd) +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" + } + + # 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 6e47ee18..00000000 --- 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 From 3a18c33f17fb73ead87f3c532b3f5c21ea192e10 Mon Sep 17 00:00:00 2001 From: Andrew Janke Date: Sat, 14 Feb 2015 20:30:03 -0500 Subject: [PATCH 08/88] In termsupport, use LC_CTYPE instead of LANG to enable byte-by-byte text processing. LANG doesn't seem to actually work. --- lib/termsupport.zsh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/termsupport.zsh b/lib/termsupport.zsh index da74dfdb..9ff8a811 100644 --- a/lib/termsupport.zsh +++ b/lib/termsupport.zsh @@ -65,8 +65,8 @@ if [[ "$TERM_PROGRAM" == "Apple_Terminal" ]] && [[ -z "$INSIDE_EMACS" ]]; then # Percent-encode the pathname. local URL_PATH='' { - # Use LANG=C to process text byte-by-byte. - local i ch hexch LANG=C + # Use LC_CTYPE=C to process text byte-by-byte. + local i ch hexch LC_CTYPE=C for ((i = 1; i <= ${#PWD}; ++i)); do ch="$PWD[i]" if [[ "$ch" =~ [/._~A-Za-z0-9-] ]]; then From 702ff1ca9167455d2df385790e9023f758d5fc33 Mon Sep 17 00:00:00 2001 From: Andrew Janke Date: Tue, 17 Feb 2015 00:49:53 -0500 Subject: [PATCH 09/88] Add support for non-UTF-8 encodings in caller's locale. --- lib/termsupport.zsh | 73 +++++++++++++++++++++++++++++---------------- 1 file changed, 48 insertions(+), 25 deletions(-) diff --git a/lib/termsupport.zsh b/lib/termsupport.zsh index 9ff8a811..70b54301 100644 --- a/lib/termsupport.zsh +++ b/lib/termsupport.zsh @@ -55,35 +55,58 @@ preexec_functions+=(omz_termsupport_preexec) # Keep Apple Terminal.app's current working directory updated # Based on this answer: http://superuser.com/a/315029 +# With extra fixes to handle multibyte chars and non-UTF-8 locales if [[ "$TERM_PROGRAM" == "Apple_Terminal" ]] && [[ -z "$INSIDE_EMACS" ]]; then + + # URL-encodes a string + # Outputs the encoded string on stdout + # Returns nonzero if encoding failed + function _omz_urlencode() { + local url_str='' + { + local str=$1 + + # URLs must use UTF-8 encoding; convert if required + local encoding=${LC_CTYPE/*./} + if [[ $encoding != UTF-8 ]]; then + str=$(iconv -f $encoding -t UTF-8) + if [[ $? != 0 ]]; then + echo "Error converting string from $encoding to UTF-8" >&2 + return 1 + fi + fi + + # Use LC_CTYPE=C to process text byte-by-byte + local i ch hexch LC_CTYPE=C + for ((i = 1; i <= ${#str}; ++i)); do + ch="$str[i]" + if [[ "$ch" =~ [/._~A-Za-z0-9-] ]]; then + url_str+="$ch" + else + hexch=$(printf "%02X" "'$ch") + url_str+="%$hexch" + fi + done + echo $url_str + } + } + # 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. + # 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 LC_CTYPE=C to process text byte-by-byte. - local i ch hexch LC_CTYPE=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 - } + # Percent-encode the pathname. + local URL_PATH=$(_omz_urlencode $PWD) + [[ $? != 0 ]] && return 1 + local PWD_URL="file://$HOST$URL_PATH" + # Undocumented Terminal.app-specific control sequence + printf '\e]7;%s\a' $PWD_URL + } - local PWD_URL="file://$HOST$URL_PATH" - printf '\e]7;%s\a' "$PWD_URL" - } - - # 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 + # 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 From 187cf07c9148d5d6dda9b8ac1b453bd6e39ea550 Mon Sep 17 00:00:00 2001 From: Andrew Janke Date: Tue, 17 Feb 2015 00:54:54 -0500 Subject: [PATCH 10/88] For unspecified encodings, assume it's UTF-8 or compatible (e.g. ASCII) and muddle through without character encoding conversion. --- lib/termsupport.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/termsupport.zsh b/lib/termsupport.zsh index 70b54301..ef9f0e5f 100644 --- a/lib/termsupport.zsh +++ b/lib/termsupport.zsh @@ -69,7 +69,7 @@ if [[ "$TERM_PROGRAM" == "Apple_Terminal" ]] && [[ -z "$INSIDE_EMACS" ]]; then # URLs must use UTF-8 encoding; convert if required local encoding=${LC_CTYPE/*./} - if [[ $encoding != UTF-8 ]]; then + if [[ -n $encoding && $encoding != UTF-8 ]]; then str=$(iconv -f $encoding -t UTF-8) if [[ $? != 0 ]]; then echo "Error converting string from $encoding to UTF-8" >&2 From cb37c934c0e1083897b501e5b8a85340e3b7e470 Mon Sep 17 00:00:00 2001 From: Andrew Janke Date: Sat, 21 Feb 2015 16:00:40 -0500 Subject: [PATCH 11/88] Remove unnecessary braces. --- lib/termsupport.zsh | 44 +++++++++++++++++++++----------------------- 1 file changed, 21 insertions(+), 23 deletions(-) diff --git a/lib/termsupport.zsh b/lib/termsupport.zsh index ef9f0e5f..7cb3791e 100644 --- a/lib/termsupport.zsh +++ b/lib/termsupport.zsh @@ -63,33 +63,31 @@ if [[ "$TERM_PROGRAM" == "Apple_Terminal" ]] && [[ -z "$INSIDE_EMACS" ]]; then # Outputs the encoded string on stdout # Returns nonzero if encoding failed function _omz_urlencode() { + local str=$1 local url_str='' - { - local str=$1 - # URLs must use UTF-8 encoding; convert if required - local encoding=${LC_CTYPE/*./} - if [[ -n $encoding && $encoding != UTF-8 ]]; then - str=$(iconv -f $encoding -t UTF-8) - if [[ $? != 0 ]]; then - echo "Error converting string from $encoding to UTF-8" >&2 - return 1 - fi + # URLs must use UTF-8 encoding; convert if required + local encoding=${LC_CTYPE/*./} + if [[ -n $encoding && $encoding != UTF-8 ]]; then + str=$(iconv -f $encoding -t UTF-8) + if [[ $? != 0 ]]; then + echo "Error converting string from $encoding to UTF-8" >&2 + return 1 fi + fi - # Use LC_CTYPE=C to process text byte-by-byte - local i ch hexch LC_CTYPE=C - for ((i = 1; i <= ${#str}; ++i)); do - ch="$str[i]" - if [[ "$ch" =~ [/._~A-Za-z0-9-] ]]; then - url_str+="$ch" - else - hexch=$(printf "%02X" "'$ch") - url_str+="%$hexch" - fi - done - echo $url_str - } + # Use LC_CTYPE=C to process text byte-by-byte + local i ch hexch LC_CTYPE=C + for ((i = 1; i <= ${#str}; ++i)); do + ch="$str[i]" + if [[ "$ch" =~ [/._~A-Za-z0-9-] ]]; then + url_str+="$ch" + else + hexch=$(printf "%02X" "'$ch") + url_str+="%$hexch" + fi + done + echo $url_str } # Emits the control sequence to notify Terminal.app of the cwd From 88f42b6132adedff7557170168416d575569b56e Mon Sep 17 00:00:00 2001 From: Andrew Janke Date: Sat, 21 Feb 2015 16:25:28 -0500 Subject: [PATCH 12/88] Add support for variant "utf8" locale suffix spelling. Fix dumb bug in iconv call that would cause it to hang. --- lib/termsupport.zsh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/termsupport.zsh b/lib/termsupport.zsh index 7cb3791e..52622f5a 100644 --- a/lib/termsupport.zsh +++ b/lib/termsupport.zsh @@ -64,12 +64,12 @@ if [[ "$TERM_PROGRAM" == "Apple_Terminal" ]] && [[ -z "$INSIDE_EMACS" ]]; then # Returns nonzero if encoding failed function _omz_urlencode() { local str=$1 - local url_str='' + local url_str="" # URLs must use UTF-8 encoding; convert if required local encoding=${LC_CTYPE/*./} - if [[ -n $encoding && $encoding != UTF-8 ]]; then - str=$(iconv -f $encoding -t UTF-8) + if [[ -n $encoding && $encoding != UTF-8 && $encoding != utf8 ]]; then + str=$(echo $str | iconv -f $encoding -t UTF-8) if [[ $? != 0 ]]; then echo "Error converting string from $encoding to UTF-8" >&2 return 1 From ea6adc5a0a3332e541a812a2da0e94c73e2102da Mon Sep 17 00:00:00 2001 From: Andrew Janke Date: Fri, 29 May 2015 22:59:07 -0400 Subject: [PATCH 13/88] Add omz_diagnostic_dump() to help with bug reports. --- lib/diagnostics.zsh | 280 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 280 insertions(+) create mode 100644 lib/diagnostics.zsh diff --git a/lib/diagnostics.zsh b/lib/diagnostics.zsh new file mode 100644 index 00000000..cca13f4e --- /dev/null +++ b/lib/diagnostics.zsh @@ -0,0 +1,280 @@ +# diagnostics.zsh +# +# Diagnostic and debugging support for oh-my-zsh + +# omz_diagnostic_dump() +# +# Author: Andrew Janke +# +# Usage: +# +# omz_diagnostic_dump [-v] [-V] [file] +# +# NOTE: This is a work in progress. Its interface and behavior are going to change, +# and probably in non-back-compatible ways. +# +# Outputs a bunch of information about the state and configuration of +# oh-my-zsh, zsh, and the user's system. This is intended to provide a +# bunch of context for diagnosing your own or a third party's problems, and to +# be suitable for posting to public bug reports. +# +# The output is human-readable and its format may change over time. It is not +# suitable for parsing. All the output is in one single file so it can be posted +# as a gist or bug comment on GitHub. GitHub doesn't support attaching tarballs +# or other files to bugs; otherwise, this would probably have an option to produce +# tarballs that contain copies of the config and customization files instead of +# catting them all in to one file. +# +# This is intended to be widely portable, and run anywhere that oh-my-zsh does. +# Feel free to report any portability issues as bugs. +# +# This is written in a defensive style so it still works (and can detect) cases when +# basic functionality like echo and which have been redefined. In particular, almost +# everything is invoked with "builtin" or "command", to work in the face of user +# redefinitions. +# +# OPTIONS +# +# [file] Specifies the output file. If not given, a file in the current directory +# is selected automatically. +# +# -v Increase the verbosity of the dump output. May be specified multiple times. +# Verbosity levels: +# 0 - Basic info, shell state, omz configuration, git state +# 1 - (default) Adds key binding info and configuration file contents +# 2 - Adds zcompdump file contents +# +# -V Reduce the verbosity of the dump output. May be specified multiple times. +# +# TODO: +# * Multi-file capture +# * Add automatic gist uploading +# * Consider whether to move default output file location to TMPDIR. More robust +# but less user friendly. +# +function omz_diagnostic_dump() { + emulate -L zsh + + local thisfcn=omz_diagnostic_dump + local -A opts + local opt_verbose opt_noverbose opt_outfile + local timestamp=$(date +%Y%m%d-%H%M%S) + local outfile=omz_diagdump_$timestamp.txt + builtin zparseopts -A opts -D -- "v+=opt_verbose" "V+=opt_noverbose" + local verbose n_verbose=${#opt_verbose} n_noverbose=${#opt_noverbose} + (( verbose = 1 + n_verbose - n_noverbose )) + + if [[ ${#*} > 0 ]]; then + opt_outfile=$1 + fi + if [[ ${#*} > 1 ]]; then + builtin echo "$thisfcn: error: too many arguments" >&2 + return 1 + fi + if [[ -n "$opt_outfile" ]]; then + outfile="$opt_outfile" + fi + + # Always write directly to a file so terminal escape sequences are + # captured cleanly + _omz_diag_dump_one_big_text &> "$outfile" + if [[ $? != 0 ]]; then + builtin echo "$thisfcn: error while creating diagnostic dump; see $outfile for details" + fi + + builtin echo + builtin echo Diagnostic dump file created at: "$outfile" + builtin echo + builtin echo To share this with OMZ developers, post it as a gist on GitHub + builtin echo at "https://gist.github.com" and share the link to the gist. + builtin echo + builtin echo "WARNING: This dump file contains all your zsh and omz configuration files," + builtin echo "so don't share it publicly if there's sensitive information in them." + builtin echo + +} + +function _omz_diag_dump_one_big_text() { + local program programs progfile md5 + + builtin echo oh-my-zsh diagnostic dump + builtin echo + + # Basic system and zsh information + command date + command uname -a + builtin echo OSTYPE=$OSTYPE + command zsh --version + builtin echo User: $USER + builtin echo + + # Installed programs + programs=(sh zsh ksh bash sed cat grep find git posh) + for program in $programs; do + local md5_str="" md5="" link_str="" extra_str="" + progfile=$(builtin which $program) + if [[ $? == 0 ]]; then + if [[ -e $progfile ]]; then + if builtin whence md5 &>/dev/null; then + extra_str+=" $(md5 -q $progfile)" + fi + if [[ -h "$progfile" ]]; then + extra_str+=" ( -> ${file:A} )" + fi + fi + builtin printf '%-9s %-20s %s\n' "$program is" "$progfile" "$extra_str" + else + builtin echo "$program: not found" + fi + done + builtin echo + builtin echo Versions: + builtin echo "zsh: $(zsh --version)" + builtin echo "bash: $(bash --version | command grep bash)" + builtin echo "git: $(git --version)" + builtin echo "grep: $(grep --version)" + builtin echo + + # Core command definitions + _omz_diag_dump_check_core_commands || return 1 + builtin echo + + # ZSH Process state + builtin echo Process state: + builtin echo pwd: $PWD + if builtin whence pstree &>/dev/null; then + builtin echo Process tree for this shell: + pstree -p $$ + else + ps -fT + fi + builtin set | command grep -a '^\(ZSH\|plugins\|TERM\|LC_\|LANG\|precmd\|chpwd\|preexec\|FPATH\|TTY\|DISPLAY\|PATH\)\|OMZ' + builtin echo + #TODO: Should this include `env` instead of or in addition to `export`? + builtin echo Exported: + builtin echo $(builtin export | command sed 's/=.*//') + builtin echo + builtin echo Locale: + command locale + builtin echo + + # Zsh configuration + builtin echo Zsh configuration: + builtin echo setopt: $(builtin setopt) + builtin echo + + # Oh-my-zsh installation + builtin echo oh-my-zsh installation: + command ls -ld ~/.z* + command ls -ld ~/.oh* + builtin echo + builtin echo oh-my-zsh git state: + (cd $ZSH && builtin echo "HEAD: $(git rev-parse HEAD)" && git remote -v && git status | command grep "[^[:space:]]") + if [[ $verbose -ge 1 ]]; then + (cd $ZSH && git reflog --date=default | command grep pull) + fi + builtin echo + if [[ -e $ZSH_CUSTOM ]]; then + local custom_dir=$ZSH_CUSTOM + if [[ -h $custom_dir ]]; then + custom_dir=$(cd $custom_dir && pwd -P) + fi + builtin echo "oh-my-zsh custom dir:" + builtin echo " $ZSH_CUSTOM ($custom_dir)" + (cd ${custom_dir:h} && command find ${custom_dir:t} -name .git -prune -o -print) + builtin echo + fi + + # Key binding and terminal info + if [[ $verbose -ge 1 ]]; then + builtin echo "bindkey:" + builtin bindkey + builtin echo + builtin echo "infocmp:" + command infocmp + builtin echo + fi + + # Configuration file info + local zdotdir=${ZDOTDIR:-$HOME} + builtin echo "Zsh configuration files:" + local cfgfile cfgfiles + cfgfiles=( /etc/zshenv /etc/zprofile /etc/zshrc /etc/zlogin /etc/zlogout + $zdotdir/.zshenv $zdotdir/.zprofile $zdotdir/.zshrc $zdotdir/.zlogin $zdotdir/.zlogout ) + command ls -lad $cfgfiles 2>&1 + builtin echo + if [[ $verbose -ge 1 ]]; then + for cfgfile in $cfgfiles; do + _omz_diag_dump_echo_file_w_header $cfgfile + done + fi + builtin echo "Zsh compdump files:" + local dumpfile dumpfiles + command ls -lad $zdotdir/.zcompdump* + dumpfiles=( $zdotdir/.zcompdump*(N) ) + if [[ $verbose -ge 2 ]]; then + for dumpfile in $dumpfiles; do + _omz_diag_dump_echo_file_w_header $dumpfile + done + fi + +} + +function _omz_diag_dump_check_core_commands() { + builtin echo "Core command check:" + local redefined name builtins externals + redefined=() + # All the zsh non-module builtin commands + # These are taken from the zsh reference manual for 5.0.2 + # Commands from modules should not be included. + # (For back-compatibility, if any of these are newish, they should be removed, + # or at least made conditional on the version of the current running zsh.) + # "history" is also excluded because OMZ is known to redefine that + builtins=( alias autoload bg bindkey break builtin bye cd chdir command + comparguments compcall compctl compdescribe compfiles compgroups compquote comptags + comptry compvalues continue declare dirs disable disown echo echotc echoti emulate + enable eval exec exit export false fc fg float functions getln getopts hash + integer jobs kill let limit local log logout noglob popd print printf + pushd pushln pwd r read readonly rehash return sched set setopt shift + source suspend test times trap true ttyctl type typeset ulimit umask unalias + unfunction unhash unlimit unset unsetopt vared wait whence where which zcompile + zle zmodload zparseopts zregexparse zstyle ) + builtins_fatal=( builtin command local ) + externals=( zsh ) + for name in $builtins; do + if [[ $(builtin whence -w $name) != "$name: builtin" ]]; then + builtin echo "builtin '$name' has been redefined" + builtin which $name + redefined+=$name + fi + done + for name in $externals; do + if [[ $(builtin whence -w $name) != "$name: command" ]]; then + builtin echo "command '$name' has been redefined" + builtin which $name + redefined+=$name + fi + done + + if [[ -n "$redefined" ]]; then + builtin echo "SOME CORE COMMANDS HAVE BEEN REDEFINED: $redefined" + else + builtin echo "All core commands are defined normally" + fi + +} + +function _omz_diag_dump_echo_file_w_header() { + local file=$1 + if [[ ( -f $file || -h $file ) ]]; then + builtin echo "========== $file ==========" + if [[ -h $file ]]; then + builtin echo "========== ( => ${file:A} ) ==========" + fi + command cat $file + builtin echo "========== end $file ==========" + builtin echo + fi +} + + From 82c1288cb25b1567b4d17f33a75192de1b9f4634 Mon Sep 17 00:00:00 2001 From: Andrew Janke Date: Sat, 6 Jun 2015 01:19:29 -0400 Subject: [PATCH 14/88] Include some bash rc files; improve formatting; more version info --- lib/diagnostics.zsh | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/lib/diagnostics.zsh b/lib/diagnostics.zsh index cca13f4e..7991b64c 100644 --- a/lib/diagnostics.zsh +++ b/lib/diagnostics.zsh @@ -104,12 +104,12 @@ function _omz_diag_dump_one_big_text() { command date command uname -a builtin echo OSTYPE=$OSTYPE - command zsh --version + builtin echo ZSH_VERSION=$ZSH_VERSION builtin echo User: $USER builtin echo # Installed programs - programs=(sh zsh ksh bash sed cat grep find git posh) + programs=(sh zsh ksh bash sed cat grep ls find git posh) for program in $programs; do local md5_str="" md5="" link_str="" extra_str="" progfile=$(builtin which $program) @@ -119,7 +119,7 @@ function _omz_diag_dump_one_big_text() { extra_str+=" $(md5 -q $progfile)" fi if [[ -h "$progfile" ]]; then - extra_str+=" ( -> ${file:A} )" + extra_str+=" ( -> ${progfile:A} )" fi fi builtin printf '%-9s %-20s %s\n' "$program is" "$progfile" "$extra_str" @@ -128,8 +128,9 @@ function _omz_diag_dump_one_big_text() { fi done builtin echo - builtin echo Versions: + builtin echo Command Versions: builtin echo "zsh: $(zsh --version)" + builtin echo "this zsh session: $ZSH_VERSION" builtin echo "bash: $(bash --version | command grep bash)" builtin echo "git: $(git --version)" builtin echo "grep: $(grep --version)" @@ -199,8 +200,12 @@ function _omz_diag_dump_one_big_text() { local zdotdir=${ZDOTDIR:-$HOME} builtin echo "Zsh configuration files:" local cfgfile cfgfiles + # Some files for bash that zsh does not use are intentionally included + # to help with diagnosing behavior differences between bash and zsh cfgfiles=( /etc/zshenv /etc/zprofile /etc/zshrc /etc/zlogin /etc/zlogout - $zdotdir/.zshenv $zdotdir/.zprofile $zdotdir/.zshrc $zdotdir/.zlogin $zdotdir/.zlogout ) + $zdotdir/.zshenv $zdotdir/.zprofile $zdotdir/.zshrc $zdotdir/.zlogin $zdotdir/.zlogout + ~/.zsh-pre-oh-my-zsh + /etc/bashrc /etc/profile ~/.bashrc ~/.profile ~/.bash_profile ~/.bash_logout ) command ls -lad $cfgfiles 2>&1 builtin echo if [[ $verbose -ge 1 ]]; then @@ -208,6 +213,7 @@ function _omz_diag_dump_one_big_text() { _omz_diag_dump_echo_file_w_header $cfgfile done fi + builtin echo builtin echo "Zsh compdump files:" local dumpfile dumpfiles command ls -lad $zdotdir/.zcompdump* @@ -274,6 +280,12 @@ function _omz_diag_dump_echo_file_w_header() { command cat $file builtin echo "========== end $file ==========" builtin echo + elif [[ -d $file ]]; then + builtin echo "File '$file' is a directory" + elif [[ ! -e $file ]]; then + builtin echo "File '$file' does not exist" + else + command ls -lad "$file" fi } From afadb5a7fba061bc1b6da1df3b00e20ede4a5cba Mon Sep 17 00:00:00 2001 From: Andrew Janke Date: Sat, 6 Jun 2015 11:04:14 -0400 Subject: [PATCH 15/88] diagnostics: add zstyle state to output --- lib/diagnostics.zsh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/diagnostics.zsh b/lib/diagnostics.zsh index 7991b64c..6dede066 100644 --- a/lib/diagnostics.zsh +++ b/lib/diagnostics.zsh @@ -163,6 +163,9 @@ function _omz_diag_dump_one_big_text() { builtin echo Zsh configuration: builtin echo setopt: $(builtin setopt) builtin echo + builtin echo zstyle: + builtin zstyle + builtin echo # Oh-my-zsh installation builtin echo oh-my-zsh installation: From af68165207ea757e303fdbab365ac9e3f11c8530 Mon Sep 17 00:00:00 2001 From: Andrew Janke Date: Sat, 6 Jun 2015 11:50:05 -0400 Subject: [PATCH 16/88] Fix name of backed-up zshrc --- lib/diagnostics.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/diagnostics.zsh b/lib/diagnostics.zsh index 6dede066..023ba42b 100644 --- a/lib/diagnostics.zsh +++ b/lib/diagnostics.zsh @@ -207,7 +207,7 @@ function _omz_diag_dump_one_big_text() { # to help with diagnosing behavior differences between bash and zsh cfgfiles=( /etc/zshenv /etc/zprofile /etc/zshrc /etc/zlogin /etc/zlogout $zdotdir/.zshenv $zdotdir/.zprofile $zdotdir/.zshrc $zdotdir/.zlogin $zdotdir/.zlogout - ~/.zsh-pre-oh-my-zsh + ~/.zsh.pre-oh-my-zsh /etc/bashrc /etc/profile ~/.bashrc ~/.profile ~/.bash_profile ~/.bash_logout ) command ls -lad $cfgfiles 2>&1 builtin echo From 01e355fb1e5dc3982efeecee699a96254f3f44e6 Mon Sep 17 00:00:00 2001 From: Michele Bologna Date: Wed, 20 May 2015 17:36:46 +0200 Subject: [PATCH 17/88] In addition to the already existing variables ZSH_THEME_GIT_PROMPT for behind, ahead and diverged remote, I added ZSH_THEME_GIT_PROMPT_EQUAL_REMOTE. --- lib/git.zsh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/git.zsh b/lib/git.zsh index caa7e632..baf86371 100644 --- a/lib/git.zsh +++ b/lib/git.zsh @@ -36,7 +36,10 @@ git_remote_status() { ahead=$(command git rev-list ${hook_com[branch]}@{upstream}..HEAD 2>/dev/null | wc -l) behind=$(command git rev-list HEAD..${hook_com[branch]}@{upstream} 2>/dev/null | wc -l) - if [ $ahead -gt 0 ] && [ $behind -eq 0 ] + if [ $ahead -eq 0 ] && [ $behind -eq 0 ] + then + echo "$ZSH_THEME_GIT_PROMPT_EQUAL_REMOTE" + elif [ $ahead -gt 0 ] && [ $behind -eq 0 ] then git_remote_status="$ZSH_THEME_GIT_PROMPT_AHEAD_REMOTE" git_remote_status_detailed="$ZSH_THEME_GIT_PROMPT_AHEAD_REMOTE_COLOR$ZSH_THEME_GIT_PROMPT_AHEAD_REMOTE$((ahead))%{$reset_color%}" From 68b792bbb67958c726dd8ebe9cfe12f5e463d160 Mon Sep 17 00:00:00 2001 From: Michele Bologna Date: Tue, 16 Jun 2015 10:48:24 +0200 Subject: [PATCH 18/88] Change to use omz git_prompt* functions Removed references for official git __git_ps1() functions. Change to use omz function git_prompt* functions like: - git_prompt_info() -> branch name - git_prompt_status() -> check if untracked, modified, added, stashed file are in the current git repo - git_remote_status() -> check if current repo is ahead, behind, or diverged. These functions returns string automatically added to your PS1; these are customizable via exporting ZSH_THEME_GIT_PROMPT* --- themes/michelebologna.zsh-theme | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/themes/michelebologna.zsh-theme b/themes/michelebologna.zsh-theme index fec24387..110e3f20 100644 --- a/themes/michelebologna.zsh-theme +++ b/themes/michelebologna.zsh-theme @@ -59,16 +59,17 @@ ZSH_THEME_GIT_PROMPT_PREFIX="" ZSH_THEME_GIT_PROMPT_SUFFIX="" ZSH_THEME_GIT_PROMPT_DIRTY="" ZSH_THEME_GIT_PROMPT_CLEAN="" -ZSH_THEME_GIT_PROMPT_UNTRACKED="%%" -ZSH_THEME_GIT_PROMPT_MODIFIED="*" -ZSH_THEME_GIT_PROMPT_ADDED="+" -ZSH_THEME_GIT_PROMPT_STASHED="$" -ZSH_THEME_GIT_PROMPT_EQUAL_REMOTE="=" +ZSH_THEME_GIT_PROMPT_UNTRACKED="$blue%%" +ZSH_THEME_GIT_PROMPT_MODIFIED="$red*" +ZSH_THEME_GIT_PROMPT_ADDED="$green+" +ZSH_THEME_GIT_PROMPT_STASHED="$blue$" +ZSH_THEME_GIT_PROMPT_EQUAL_REMOTE="$green=" ZSH_THEME_GIT_PROMPT_AHEAD_REMOTE=">" ZSH_THEME_GIT_PROMPT_BEHIND_REMOTE="<" -ZSH_THEME_GIT_PROMPT_DIVERGED_REMOTE="<>" +ZSH_THEME_GIT_PROMPT_DIVERGED_REMOTE="$red<>" PROMPT='$username_output$hostname_output:$current_dir_output%1(j. [$jobs_bg].)' -PROMPT+='$(__git_ps1)' +GIT_PROMPT='$(out=$(git_prompt_info)$(git_prompt_status)$(git_remote_status);if [[ -n $out ]]; then printf %s " $white($green$out$white)$reset";fi)' +PROMPT+="$GIT_PROMPT" PROMPT+=" $last_command_output%#$reset " RPROMPT='' From 4cd281ba1be0d8a2e44f96bdb1f2a98b15f54c47 Mon Sep 17 00:00:00 2001 From: Andrew Janke Date: Thu, 25 Jun 2015 20:13:59 -0400 Subject: [PATCH 19/88] agnoster: Define Powerline chars with escape sequence, and use same character on all platforms. Add clarifying comments. This makes everything consistent with the current Powerline-patched fonts definitions. --- themes/agnoster.zsh-theme | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/themes/agnoster.zsh-theme b/themes/agnoster.zsh-theme index 3a0c58b8..3e454a0a 100644 --- a/themes/agnoster.zsh-theme +++ b/themes/agnoster.zsh-theme @@ -7,6 +7,9 @@ # # In order for this theme to render correctly, you will need a # [Powerline-patched font](https://github.com/Lokaltog/powerline-fonts). +# Make sure you have a recent version: the code points that Powerline +# uses changed in 2012, and older versions will display incorrectly, +# in confusing ways. # # In addition, I recommend the # [Solarized theme](https://github.com/altercation/solarized/) and, if you're @@ -27,12 +30,19 @@ CURRENT_BG='NONE' -# Fix odd char on mac -if [[ `uname` == 'Darwin' ]]; then - SEGMENT_SEPARATOR='\ue0b0' -else - SEGMENT_SEPARATOR='' -fi +# Special Powerline characters + +# NOTE: This segment separator character is correct. In 2012, Powerline changed +# the code points they use for their special characters. This is the new code point. +# If this is not working for you, you probably have an old version of the +# Powerline-patched fonts installed. Download and install the new version. +# Do not submit PRs to change this unless you have reviewed the Powerline code point +# history and have new information. +# This is defined using a Unicode escape sequence so it is unambiguously readable, regardless of +# what font the user is viewing this source code in. Do not replace the +# escape sequence with a single literal character. +SEGMENT_SEPARATOR='\ue0b0' #  + # Begin a segment # Takes two arguments, background and foreground. Both can be omitted, @@ -73,6 +83,7 @@ prompt_context() { # Git: branch/detached head, dirty status prompt_git() { + local PL_BRANCH_CHAR='\ue0a0' #  local ref dirty mode repo_path repo_path=$(git rev-parse --git-dir 2>/dev/null) @@ -104,7 +115,7 @@ prompt_git() { zstyle ':vcs_info:*' formats ' %u%c' zstyle ':vcs_info:*' actionformats ' %u%c' vcs_info - echo -n "${ref/refs\/heads\// }${vcs_info_msg_0_%% }${mode}" + echo -n "${ref/refs\/heads\//$PL_BRANCH_CHAR }${vcs_info_msg_0_%% }${mode}" fi } From 689b5ab3c8c8bf30ee63cafb8401d7d95e41f359 Mon Sep 17 00:00:00 2001 From: Andrew Janke Date: Fri, 26 Jun 2015 01:48:17 -0400 Subject: [PATCH 20/88] 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(-) diff --git a/plugins/osx/osx.plugin.zsh b/plugins/osx/osx.plugin.zsh index a6e3a83e..2cbb9597 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() { From 9813ff5f24c6ce8409490d7ef8b8c4458f2a6a66 Mon Sep 17 00:00:00 2001 From: Andrew Janke Date: Sun, 28 Jun 2015 16:54:04 -0400 Subject: [PATCH 21/88] omz_diagnostic_dump: Add umask and $fpath listing. This helps catch issues with compinit and insecure directories. --- lib/diagnostics.zsh | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/diagnostics.zsh b/lib/diagnostics.zsh index 023ba42b..f5f15dea 100644 --- a/lib/diagnostics.zsh +++ b/lib/diagnostics.zsh @@ -106,6 +106,7 @@ function _omz_diag_dump_one_big_text() { builtin echo OSTYPE=$OSTYPE builtin echo ZSH_VERSION=$ZSH_VERSION builtin echo User: $USER + builtin echo umask: $(umask) builtin echo # Installed programs @@ -159,13 +160,19 @@ function _omz_diag_dump_one_big_text() { command locale builtin echo - # Zsh configuration + # Zsh installation and configuration builtin echo Zsh configuration: builtin echo setopt: $(builtin setopt) builtin echo builtin echo zstyle: builtin zstyle builtin echo + builtin echo 'compaudit output:' + compaudit + builtin echo + builtin echo '$fpath directories:' + command ls -lad $fpath + builtin echo # Oh-my-zsh installation builtin echo oh-my-zsh installation: @@ -195,7 +202,7 @@ function _omz_diag_dump_one_big_text() { builtin bindkey builtin echo builtin echo "infocmp:" - command infocmp + command infocmp -L builtin echo fi From c82deedc97f7578fa0a8a2dd3c8b598a166bfd04 Mon Sep 17 00:00:00 2001 From: Andrew Janke Date: Fri, 3 Jul 2015 01:44:47 -0400 Subject: [PATCH 22/88] agnoster: Protect Unicode esape sequences with local LC_* settings --- themes/agnoster.zsh-theme | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/themes/agnoster.zsh-theme b/themes/agnoster.zsh-theme index 3e454a0a..6444dfa6 100644 --- a/themes/agnoster.zsh-theme +++ b/themes/agnoster.zsh-theme @@ -32,17 +32,19 @@ CURRENT_BG='NONE' # Special Powerline characters -# NOTE: This segment separator character is correct. In 2012, Powerline changed -# the code points they use for their special characters. This is the new code point. -# If this is not working for you, you probably have an old version of the -# Powerline-patched fonts installed. Download and install the new version. -# Do not submit PRs to change this unless you have reviewed the Powerline code point -# history and have new information. -# This is defined using a Unicode escape sequence so it is unambiguously readable, regardless of -# what font the user is viewing this source code in. Do not replace the -# escape sequence with a single literal character. -SEGMENT_SEPARATOR='\ue0b0' #  - +() { + local LC_ALL="" LC_CTYPE="en_US.UTF-8" + # NOTE: This segment separator character is correct. In 2012, Powerline changed + # the code points they use for their special characters. This is the new code point. + # If this is not working for you, you probably have an old version of the + # Powerline-patched fonts installed. Download and install the new version. + # Do not submit PRs to change this unless you have reviewed the Powerline code point + # history and have new information. + # This is defined using a Unicode escape sequence so it is unambiguously readable, regardless of + # what font the user is viewing this source code in. Do not replace the + # escape sequence with a single literal character. + SEGMENT_SEPARATOR=$'\ue0b0' #  +} # Begin a segment # Takes two arguments, background and foreground. Both can be omitted, @@ -83,7 +85,12 @@ prompt_context() { # Git: branch/detached head, dirty status prompt_git() { - local PL_BRANCH_CHAR='\ue0a0' #  + + local PL_BRANCH_CHAR + () { + local LC_ALL="" LC_CTYPE="en_US.UTF-8" + PL_BRANCH_CHAR=$'\ue0a0' #  + } local ref dirty mode repo_path repo_path=$(git rev-parse --git-dir 2>/dev/null) From 19ea867a3a5cc118fd84560275db05354a4aed0b Mon Sep 17 00:00:00 2001 From: Andrew Janke Date: Tue, 3 Mar 2015 21:13:46 -0500 Subject: [PATCH 23/88] install.sh: use portable printf instead of echo --- tools/install.sh | 47 +++++++++++++++++++++++++++++------------------ 1 file changed, 29 insertions(+), 18 deletions(-) diff --git a/tools/install.sh b/tools/install.sh index c83a6f23..ff2e3e91 100755 --- a/tools/install.sh +++ b/tools/install.sh @@ -1,52 +1,63 @@ set -e +BLUE="\033[0;34m" +GREEN="\033[0;32m" +YELLOW="\033[0;33m" +NOCOLOR="\033[0m" + if [ ! -n "$ZSH" ]; then ZSH=~/.oh-my-zsh fi if [ -d "$ZSH" ]; then - echo "\033[0;33mYou already have Oh My Zsh installed.\033[0m You'll need to remove $ZSH if you want to install" + printf "${YELLOW}You already have Oh My Zsh installed.${NOCOLOR} You'll need to remove $ZSH if you want to install\n" exit fi -echo "\033[0;34mCloning Oh My Zsh...\033[0m" +printf "${BLUE}Cloning Oh My Zsh...${NOCOLOR}\n" hash git >/dev/null 2>&1 && env git clone --depth=1 https://github.com/robbyrussell/oh-my-zsh.git $ZSH || { - echo "git not installed" + printf "git not installed\n" exit } -echo "\033[0;34mLooking for an existing zsh config...\033[0m" +printf "${BLUE}Looking for an existing zsh config...${NOCOLOR}\n" if [ -f ~/.zshrc ] || [ -h ~/.zshrc ]; then - echo "\033[0;33mFound ~/.zshrc.\033[0m \033[0;32mBacking up to ~/.zshrc.pre-oh-my-zsh\033[0m"; + printf "${YELLOW}Found ~/.zshrc.${NOCOLOR} ${GREEN}Backing up to ~/.zshrc.pre-oh-my-zsh${NOCOLOR}\n"; mv ~/.zshrc ~/.zshrc.pre-oh-my-zsh; fi -echo "\033[0;34mUsing the Oh My Zsh template file and adding it to ~/.zshrc\033[0m" +printf "${BLUE}Using the Oh My Zsh template file and adding it to ~/.zshrc${NOCOLOR}\n" cp $ZSH/templates/zshrc.zsh-template ~/.zshrc sed -i -e "/^export ZSH=/ c\\ export ZSH=$ZSH " ~/.zshrc -echo "\033[0;34mCopying your current PATH and adding it to the end of ~/.zshrc for you.\033[0m" +printf "${BLUE}Copying your current PATH and adding it to the end of ~/.zshrc for you.${NOCOLOR}\n" sed -i -e "/export PATH=/ c\\ export PATH=\"$PATH\" " ~/.zshrc TEST_CURRENT_SHELL=$(expr "$SHELL" : '.*/\(.*\)') if [ "$TEST_CURRENT_SHELL" != "zsh" ]; then - echo "\033[0;34mTime to change your default shell to zsh!\033[0m" + printf "${BLUE}Time to change your default shell to zsh!${NOCOLOR}\n" chsh -s $(grep /zsh$ /etc/shells | tail -1) fi unset TEST_CURRENT_SHELL -echo "\033[0;32m"' __ __ '"\033[0m" -echo "\033[0;32m"' ____ / /_ ____ ___ __ __ ____ _____/ /_ '"\033[0m" -echo "\033[0;32m"' / __ \/ __ \ / __ `__ \/ / / / /_ / / ___/ __ \ '"\033[0m" -echo "\033[0;32m"'/ /_/ / / / / / / / / / / /_/ / / /_(__ ) / / / '"\033[0m" -echo "\033[0;32m"'\____/_/ /_/ /_/ /_/ /_/\__, / /___/____/_/ /_/ '"\033[0m" -echo "\033[0;32m"' /____/ ....is now installed!'"\033[0m" -echo "\n\n \033[0;32mPlease look over the ~/.zshrc file to select plugins, themes, and options.\033[0m" -echo "\n\n \033[0;32mp.s. Follow us at http://twitter.com/ohmyzsh.\033[0m" -echo "\n\n \033[0;32mp.p.s. Get stickers and t-shirts at http://shop.planetargon.com.\033[0m" +printf "${GREEN}" +echo ' __ __ ' +echo ' ____ / /_ ____ ___ __ __ ____ _____/ /_ ' +echo ' / __ \/ __ \ / __ `__ \/ / / / /_ / / ___/ __ \ ' +echo '/ /_/ / / / / / / / / / / /_/ / / /_(__ ) / / / ' +echo '\____/_/ /_/ /_/ /_/ /_/\__, / /___/____/_/ /_/ ' +echo ' /____/ ....is now installed!' +echo '' +echo '' +echo 'Please look over the ~/.zshrc file to select plugins, themes, and options.' +echo '' +echo 'p.s. Follow us at http://twitter.com/ohmyzsh.' +echo '' +echo 'p.p.s. Get stickers and t-shirts at http://shop.planetargon.com.' +echo '' +printf "${NOCOLOR}" env zsh -. ~/.zshrc From 8cf610089d97cf1abbd5cf3e0fb28d63b4c25f51 Mon Sep 17 00:00:00 2001 From: Andrew Janke Date: Mon, 6 Jul 2015 20:18:32 -0400 Subject: [PATCH 24/88] installer: use terminfo for portable escape sequences Do not use terminal visual effects if not connected to a terminal. --- tools/install.sh | 39 +++++++++++++++++++++++++++------------ tools/upgrade.sh | 43 ++++++++++++++++++++++++++++++++----------- 2 files changed, 59 insertions(+), 23 deletions(-) diff --git a/tools/install.sh b/tools/install.sh index ff2e3e91..8ff1219b 100755 --- a/tools/install.sh +++ b/tools/install.sh @@ -1,45 +1,60 @@ set -e -BLUE="\033[0;34m" -GREEN="\033[0;32m" -YELLOW="\033[0;33m" -NOCOLOR="\033[0m" +# Use colors, but only if connected to a terminal, and that terminal +# supports them. +ncolors=$(tput colors) +if [ -t 1 ] && [ -n "$ncolors" ] && [ "$ncolors" -ge 8 ]; then + RED=="$(tput setaf 1)" + GREEN="$(tput setaf 2)" + YELLOW="$(tput setaf 3)" + BLUE="$(tput setaf 4)" + BOLD="$(tput bold)" + NORMAL="$(tput sgr0)" +else + RED="" + GREEN="" + YELLOW="" + BLUE="" + BOLD="" + NORMAL="" +fi if [ ! -n "$ZSH" ]; then ZSH=~/.oh-my-zsh fi if [ -d "$ZSH" ]; then - printf "${YELLOW}You already have Oh My Zsh installed.${NOCOLOR} You'll need to remove $ZSH if you want to install\n" + printf "${YELLOW}You already have Oh My Zsh installed.${NORMAL}\n" + printf "You'll need to remove $ZSH if you want to re-install.\n" exit fi -printf "${BLUE}Cloning Oh My Zsh...${NOCOLOR}\n" +printf "${BLUE}Cloning Oh My Zsh...${NORMAL}\n" hash git >/dev/null 2>&1 && env git clone --depth=1 https://github.com/robbyrussell/oh-my-zsh.git $ZSH || { printf "git not installed\n" exit } -printf "${BLUE}Looking for an existing zsh config...${NOCOLOR}\n" +printf "${BLUE}Looking for an existing zsh config...${NORMAL}\n" if [ -f ~/.zshrc ] || [ -h ~/.zshrc ]; then - printf "${YELLOW}Found ~/.zshrc.${NOCOLOR} ${GREEN}Backing up to ~/.zshrc.pre-oh-my-zsh${NOCOLOR}\n"; + printf "${YELLOW}Found ~/.zshrc.${NORMAL} ${GREEN}Backing up to ~/.zshrc.pre-oh-my-zsh${NORMAL}\n"; mv ~/.zshrc ~/.zshrc.pre-oh-my-zsh; fi -printf "${BLUE}Using the Oh My Zsh template file and adding it to ~/.zshrc${NOCOLOR}\n" +printf "${BLUE}Using the Oh My Zsh template file and adding it to ~/.zshrc${NORMAL}\n" cp $ZSH/templates/zshrc.zsh-template ~/.zshrc sed -i -e "/^export ZSH=/ c\\ export ZSH=$ZSH " ~/.zshrc -printf "${BLUE}Copying your current PATH and adding it to the end of ~/.zshrc for you.${NOCOLOR}\n" +printf "${BLUE}Copying your current PATH and adding it to the end of ~/.zshrc for you.${NORMAL}\n" sed -i -e "/export PATH=/ c\\ export PATH=\"$PATH\" " ~/.zshrc TEST_CURRENT_SHELL=$(expr "$SHELL" : '.*/\(.*\)') if [ "$TEST_CURRENT_SHELL" != "zsh" ]; then - printf "${BLUE}Time to change your default shell to zsh!${NOCOLOR}\n" + printf "${BLUE}Time to change your default shell to zsh!${NORMAL}\n" chsh -s $(grep /zsh$ /etc/shells | tail -1) fi unset TEST_CURRENT_SHELL @@ -59,5 +74,5 @@ echo 'p.s. Follow us at http://twitter.com/ohmyzsh.' echo '' echo 'p.p.s. Get stickers and t-shirts at http://shop.planetargon.com.' echo '' -printf "${NOCOLOR}" +printf "${NORMAL}" env zsh diff --git a/tools/upgrade.sh b/tools/upgrade.sh index 5f0a81f1..4929054c 100644 --- a/tools/upgrade.sh +++ b/tools/upgrade.sh @@ -1,16 +1,37 @@ -printf '\033[0;34m%s\033[0m\n' "Upgrading Oh My Zsh" + +# Use colors, but only if connected to a terminal, and that terminal +# supports them. +ncolors=$(tput colors) +if [ -t 1 ] && [ -n "$ncolors" ] && [ "$ncolors" -ge 8 ]; then + RED=="$(tput setaf 1)" + GREEN="$(tput setaf 2)" + YELLOW="$(tput setaf 3)" + BLUE="$(tput setaf 4)" + BOLD="$(tput bold)" + NORMAL="$(tput sgr0)" +else + RED="" + GREEN="" + YELLOW="" + BLUE="" + BOLD="" + NORMAL="" +fi + +printf "${BLUE}%s${NORMAL}\n" "Upgrading Oh My Zsh" cd "$ZSH" if git pull --rebase --stat origin master then - printf '\033[0;32m%s\033[0m\n' ' __ __ ' - printf '\033[0;32m%s\033[0m\n' ' ____ / /_ ____ ___ __ __ ____ _____/ /_ ' - printf '\033[0;32m%s\033[0m\n' ' / __ \/ __ \ / __ `__ \/ / / / /_ / / ___/ __ \ ' - printf '\033[0;32m%s\033[0m\n' '/ /_/ / / / / / / / / / / /_/ / / /_(__ ) / / / ' - printf '\033[0;32m%s\033[0m\n' '\____/_/ /_/ /_/ /_/ /_/\__, / /___/____/_/ /_/ ' - printf '\033[0;32m%s\033[0m\n' ' /____/ ' - printf '\033[0;34m%s\033[0m\n' 'Hooray! Oh My Zsh has been updated and/or is at the current version.' - printf '\033[0;34m%s\033[1m%s\033[0m\n' 'To keep up on the latest news and updates, follow us on twitter: ' 'http://twitter.com/ohmyzsh' - printf '\033[0;34m%s\033[1m%s\033[0m\n' 'Get your Oh My Zsh swag at: ' 'http://shop.planetargon.com/' + printf '%s' "$GREEN" + printf '%s\n' ' __ __ ' + printf '%s\n' ' ____ / /_ ____ ___ __ __ ____ _____/ /_ ' + printf '%s\n' ' / __ \/ __ \ / __ `__ \/ / / / /_ / / ___/ __ \ ' + printf '%s\n' '/ /_/ / / / / / / / / / / /_/ / / /_(__ ) / / / ' + printf '%s\n' '\____/_/ /_/ /_/ /_/ /_/\__, / /___/____/_/ /_/ ' + printf '%s\n' ' /____/ ' + printf "${BLUE}%s\n" "Hooray! Oh My Zsh has been updated and/or is at the current version." + printf "${BLUE}${BOLD}%s${NORMAL}\n" "To keep up on the latest news and updates, follow us on twitter: http://twitter.com/ohmyzsh" + printf "${BLUE}${BOLD}%s${NORMAL}\n" "Get your Oh My Zsh swag at: http://shop.planetargon.com/" else - printf '\033[0;31m%s\033[0m\n' 'There was an error updating. Try again later?' + printf "${RED}%s${NORMAL}\n" 'There was an error updating. Try again later?' fi From dff03743efa3f49f4ba4b1214d97f9746bb1a0d4 Mon Sep 17 00:00:00 2001 From: Mohnish Jadwani Date: Tue, 7 Jul 2015 09:47:49 +0530 Subject: [PATCH 25/88] 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(+) diff --git a/plugins/rails/rails.plugin.zsh b/plugins/rails/rails.plugin.zsh index 6824836f..097578e2 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' From 750de22972bfa38003d38ce3a13f46bd7e41807d Mon Sep 17 00:00:00 2001 From: Headless Date: Tue, 7 Jul 2015 15:44:35 +0300 Subject: [PATCH 26/88] rails rake test --- plugins/rails/rails.plugin.zsh | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/rails/rails.plugin.zsh b/plugins/rails/rails.plugin.zsh index 6824836f..4c250369 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' From 1e8196de8289a69268a9631ddf4d3b3519ade5c1 Mon Sep 17 00:00:00 2001 From: Takumi IINO Date: Wed, 8 Jul 2015 11:16:44 +0900 Subject: [PATCH 27/88] passing the first argument with double quote --- plugins/coffee/coffee.plugin.zsh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/coffee/coffee.plugin.zsh b/plugins/coffee/coffee.plugin.zsh index 1a7bedd8..4e98e022 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 From bca720fa9549f7fe4687acd1aaf91720428657e9 Mon Sep 17 00:00:00 2001 From: Andrew Janke Date: Thu, 9 Jul 2015 20:50:57 -0400 Subject: [PATCH 28/88] diagnostics: include detailed OS version info if possible --- lib/diagnostics.zsh | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/lib/diagnostics.zsh b/lib/diagnostics.zsh index f5f15dea..53c6548d 100644 --- a/lib/diagnostics.zsh +++ b/lib/diagnostics.zsh @@ -55,6 +55,8 @@ function omz_diagnostic_dump() { emulate -L zsh + builtin echo "Generating diagnostic dump; please be patient..." + local thisfcn=omz_diagnostic_dump local -A opts local opt_verbose opt_noverbose opt_outfile @@ -108,6 +110,8 @@ function _omz_diag_dump_one_big_text() { builtin echo User: $USER builtin echo umask: $(umask) builtin echo + _omz_diag_dump_os_specific_version + builtin echo # Installed programs programs=(sh zsh ksh bash sed cat grep ls find git posh) @@ -299,4 +303,28 @@ function _omz_diag_dump_echo_file_w_header() { fi } +function _omz_diag_dump_os_specific_version() { + local osname osver version_file version_files + case "$OSTYPE" in + darwin*) + osname=$(command sw_vers -productName) + osver=$(command sw_vers -productVersion) + builtin echo "OS Version: $osname $osver build $(sw_vers -buildVersion)" + ;; + cygwin) + command systeminfo | command grep "^OS Name\|^OS Version" + ;; + esac + + if builtin which lsb_release >/dev/null; then + builtin echo "OS Release: $(command lsb_release -s -d)" + fi + + version_files=( /etc/*-release(N) /etc/*-version(N) /etc/*_version(N) ) + for version_file in $version_files; do + builtin echo "$version_file:" + command cat "$version_file" + builtin echo + done +} From dcb175d4309a41723ebeb561a8089115d9e7126b Mon Sep 17 00:00:00 2001 From: leycec Date: Sat, 11 Jul 2015 01:20:23 -0400 Subject: [PATCH 29/88] Insecure completion handler added. A new "lib/compfix.zsh" script defining a new handle_completion_insecurities() function has been added, which handles insecure completion directories by notifying users of said insecurities and moving away all existing completion caches to a temporary directory. While intended to be called at startup, this function is generally callable at any time (e.g., for testing). --- lib/compfix.zsh | 60 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 lib/compfix.zsh diff --git a/lib/compfix.zsh b/lib/compfix.zsh new file mode 100644 index 00000000..208aaadb --- /dev/null +++ b/lib/compfix.zsh @@ -0,0 +1,60 @@ +# Handle completions insecurities (i.e., completion-dependent directories with +# insecure ownership or permissions) by: +# +# * Human-readably notifying the user of these insecurities. +# * Moving away all existing completion caches to a temporary directory. Since +# any of these caches may have been generated from insecure directories, they +# are all suspect now. Failing to do so typically causes subsequent compinit() +# calls to fail with "command not found: compdef" errors. (That's bad.) +function handle_completion_insecurities() { + # List of the absolute paths of all unique insecure directories, split on + # newline from compaudit()'s output resembling: + # + # There are insecure directories: + # /usr/share/zsh/site-functions + # /usr/share/zsh/5.0.6/functions + # /usr/share/zsh + # /usr/share/zsh/5.0.6 + # + # Since the ignorable first line is printed to stderr and thus not captured, + # stderr is squelched to prevent this output from leaking to the user. + local -aU insecure_dirs + insecure_dirs=( ${(f@):-"$(compaudit 2>/dev/null)"} ) + + # If no such directories exist, get us out of here. + if (( ! ${#insecure_dirs} )); then + print "[oh-my-zsh] No insecure completion-dependent directories detected." + return + fi + + # List ownership and permissions of all insecure directories. + print "[oh-my-zsh] Insecure completion-dependent directories detected:" + ls -ld "${(@)insecure_dirs}" + print "[oh-my-zsh] For safety, completions will be disabled until you manually fix all" + print "[oh-my-zsh] insecure directory permissions and ownership and restart oh-my-zsh." + print "[oh-my-zsh] See the above list for directories with group or other writability.\n" + + # Locally enable the "NULL_GLOB" option, thus removing unmatched filename + # globs from argument lists *AND* printing no warning when doing so. Failing + # to do so prints an unreadable warning if no completion caches exist below. + setopt local_options null_glob + + # List of the absolute paths of all unique existing completion caches. + local -aU zcompdump_files + zcompdump_files=( "${ZSH_COMPDUMP}"(.) "${ZDOTDIR:-${HOME}}"/.zcompdump* ) + + # Move such caches to a temporary directory. + if (( ${#zcompdump_files} )); then + # Absolute path of the directory to which such files will be moved. + local ZSH_ZCOMPDUMP_BAD_DIR="${ZSH_CACHE_DIR}/zcompdump-bad" + + # List such files first. + print "[oh-my-zsh] Insecure completion caches also detected:" + ls -l "${(@)zcompdump_files}" + + # For safety, move rather than permanently remove such files. + print "[oh-my-zsh] Moving to \"${ZSH_ZCOMPDUMP_BAD_DIR}/\"...\n" + mkdir -p "${ZSH_ZCOMPDUMP_BAD_DIR}" + mv "${(@)zcompdump_files}" "${ZSH_ZCOMPDUMP_BAD_DIR}/" + fi +} From ff8d799594d0fd127058455b194b27d00a323d68 Mon Sep 17 00:00:00 2001 From: Fabio Strozzi Date: Sun, 12 Jul 2015 17:01:34 +0200 Subject: [PATCH 30/88] 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(-) diff --git a/plugins/sudo/sudo.plugin.zsh b/plugins/sudo/sudo.plugin.zsh index e3ba3991..0ba8bed5 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] From 46d13384db11634257aa803fc1e05f1ac6e10a1b Mon Sep 17 00:00:00 2001 From: Hongxin Liang Date: Mon, 13 Jul 2015 18:43:00 +0200 Subject: [PATCH 31/88] [theme] Fix color problem of steeef theme steeef theme sets colors depending on $TERM, however if %F is used, it must be closed by %f instead of %{$reset_color%}. Further on, all %f directives have been replaced by %F and color support of current TERM is checked more properly. --- themes/steeef.zsh-theme | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/themes/steeef.zsh-theme b/themes/steeef.zsh-theme index 13728ca9..13dc3ad2 100644 --- a/themes/steeef.zsh-theme +++ b/themes/steeef.zsh-theme @@ -10,7 +10,7 @@ export VIRTUAL_ENV_DISABLE_PROMPT=1 function virtualenv_info { - [ $VIRTUAL_ENV ] && echo '('$fg[blue]`basename $VIRTUAL_ENV`%{$reset_color%}') ' + [ $VIRTUAL_ENV ] && echo '('%F{blue}`basename $VIRTUAL_ENV`%f') ' } PR_GIT_UPDATE=1 @@ -20,18 +20,18 @@ autoload -U add-zsh-hook autoload -Uz vcs_info #use extended color pallete if available -if [[ $TERM = *256color* || $TERM = *rxvt* ]]; then +if [[ $terminfo[colors] -ge 256 ]]; then turquoise="%F{81}" orange="%F{166}" purple="%F{135}" hotpink="%F{161}" limegreen="%F{118}" else - turquoise="$fg[cyan]" - orange="$fg[yellow]" - purple="$fg[magenta]" - hotpink="$fg[red]" - limegreen="$fg[green]" + turquoise="%F{cyan}" + orange="%F{yellow}" + purple="%F{magenta}" + hotpink="%F{red}" + limegreen="%F{green}" fi # enable VCS systems you use @@ -48,7 +48,7 @@ zstyle ':vcs_info:*:prompt:*' check-for-changes true # %a - action (e.g. rebase-i) # %R - repository path # %S - path in the repository -PR_RST="%{${reset_color}%}" +PR_RST="%f" FMT_BRANCH="(%{$turquoise%}%b%u%c${PR_RST})" FMT_ACTION="(%{$limegreen%}%a${PR_RST})" FMT_UNSTAGED="%{$orange%}●" @@ -96,5 +96,5 @@ function steeef_precmd { add-zsh-hook precmd steeef_precmd PROMPT=$' -%{$purple%}%n%{$reset_color%} at %{$orange%}%m%{$reset_color%} in %{$limegreen%}%~%{$reset_color%} $vcs_info_msg_0_$(virtualenv_info)%{$reset_color%} +%{$purple%}%n${PR_RST} at %{$orange%}%m${PR_RST} in %{$limegreen%}%~${PR_RST} $vcs_info_msg_0_$(virtualenv_info) $ ' From 5a1dd14f13bfef9ca8d0d1b9683aea2b5b4e3ec9 Mon Sep 17 00:00:00 2001 From: Sharky Date: Sun, 19 Jul 2015 11:50:43 -0500 Subject: [PATCH 32/88] removed incorrect Devanagari conjunct symbol at end of Om --- themes/dogenpunk.zsh-theme | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/themes/dogenpunk.zsh-theme b/themes/dogenpunk.zsh-theme index 0bd38acc..ea3f1b96 100644 --- a/themes/dogenpunk.zsh-theme +++ b/themes/dogenpunk.zsh-theme @@ -3,7 +3,7 @@ MODE_INDICATOR="%{$fg_bold[red]%}❮%{$reset_color%}%{$fg[red]%}❮❮%{$reset_color%}" local return_status="%{$fg[red]%}%(?..⏎)%{$reset_color%}" -PROMPT='%{$fg[blue]%}%m%{$reset_color%}%{$fg_bold[white]%} ओम् %{$reset_color%}%{$fg[cyan]%}%~:%{$reset_color%}$(git_time_since_commit)$(git_prompt_info) +PROMPT='%{$fg[blue]%}%m%{$reset_color%}%{$fg_bold[white]%} ओम %{$reset_color%}%{$fg[cyan]%}%~:%{$reset_color%}$(git_time_since_commit)$(git_prompt_info) %{$fg[red]%}%!%{$reset_color%} $(prompt_char) ' ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg_bold[green]%}git%{$reset_color%}@%{$bg[white]%}%{$fg[black]%}" From cacc6c34b72ecb4593d05b66d891cf4f075e69f2 Mon Sep 17 00:00:00 2001 From: Sharky Date: Sun, 19 Jul 2015 12:33:37 -0500 Subject: [PATCH 33/88] replaced Om spelling so letters would not overlap --- themes/dogenpunk.zsh-theme | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/themes/dogenpunk.zsh-theme b/themes/dogenpunk.zsh-theme index ea3f1b96..d6719281 100644 --- a/themes/dogenpunk.zsh-theme +++ b/themes/dogenpunk.zsh-theme @@ -3,7 +3,7 @@ MODE_INDICATOR="%{$fg_bold[red]%}❮%{$reset_color%}%{$fg[red]%}❮❮%{$reset_color%}" local return_status="%{$fg[red]%}%(?..⏎)%{$reset_color%}" -PROMPT='%{$fg[blue]%}%m%{$reset_color%}%{$fg_bold[white]%} ओम %{$reset_color%}%{$fg[cyan]%}%~:%{$reset_color%}$(git_time_since_commit)$(git_prompt_info) +PROMPT='%{$fg[blue]%}%m%{$reset_color%}%{$fg_bold[white]%} ॐ %{$reset_color%}%{$fg[cyan]%}%~:%{$reset_color%}$(git_time_since_commit)$(git_prompt_info) %{$fg[red]%}%!%{$reset_color%} $(prompt_char) ' ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg_bold[green]%}git%{$reset_color%}@%{$bg[white]%}%{$fg[black]%}" From cb55161470e051e520bad388c20e32d43cfca973 Mon Sep 17 00:00:00 2001 From: leycec Date: Tue, 12 May 2015 19:27:51 -0400 Subject: [PATCH 34/88] Completion insecurities handled on startup. Completion-dependent directories with insecure permissions or ownership (e.g., group or other writability) are now detected, reported, and sanitized on OMZ startup rather than unsafely ignored -- which resulted in effectively empty completion caches and obscure compdef() errors resembling "compdef: unknown command or service: git". This fixes long-standing issues #630, #3356, and #3455 and related Babun issues 159, 281, and 322 -- and probably numerous other duplicates. --- oh-my-zsh.sh | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/oh-my-zsh.sh b/oh-my-zsh.sh index ec64c240..9dde78ca 100644 --- a/oh-my-zsh.sh +++ b/oh-my-zsh.sh @@ -8,6 +8,9 @@ fi # add a function path fpath=($ZSH/functions $ZSH/completions $fpath) +# Load all stock functions (from $fpath files) called below. +autoload -U compaudit compinit + # Set ZSH_CUSTOM to the path where your custom config files # and plugins exists, or else we will use the default custom/ if [[ -z "$ZSH_CUSTOM" ]]; then @@ -64,9 +67,14 @@ if [ -z "$ZSH_COMPDUMP" ]; then ZSH_COMPDUMP="${ZDOTDIR:-${HOME}}/.zcompdump-${SHORT_HOST}-${ZSH_VERSION}" fi -# Load and run compinit -autoload -U compinit -compinit -i -d "${ZSH_COMPDUMP}" +# If completion insecurities exist, warn the user without enabling completions. +if ! compaudit &>/dev/null; then + # This function resides in the "lib/compfix.zsh" script sourced above. + handle_completion_insecurities +# Else, enable and cache completions to the desired file. +else + compinit -d "${ZSH_COMPDUMP}" +fi # Load all of the plugins that were defined in ~/.zshrc for plugin ($plugins); do From da395c583770b466b5ba83c37d313a7b1c0024c9 Mon Sep 17 00:00:00 2001 From: leycec Date: Sat, 11 Jul 2015 00:52:54 -0400 Subject: [PATCH 35/88] Secure umask enforced during installation. For safety, a umask of 022 prohibiting both group and other writability is now enforced during OMZ installation. In theory, this should reduce the likelihood of subsequent compinit() failures due to insecure directory permissions under all platforms except for default Cygwin installations (in which Windows ACLs override POSIX umasks). --- tools/install.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tools/install.sh b/tools/install.sh index c83a6f23..405f461e 100755 --- a/tools/install.sh +++ b/tools/install.sh @@ -9,6 +9,13 @@ if [ -d "$ZSH" ]; then exit fi +# Prevent the cloned repository from having insecure permissions. Failing to do +# so causes compinit() calls to fail with "command not found: compdef" errors +# for users with insecure umasks (e.g., "002", allowing group writability). Note +# that this will be ignored under Cygwin by default, as Windows ACLs take +# precedence over umasks except for filesystems mounted with option "noacl". +umask g-w,o-w + echo "\033[0;34mCloning Oh My Zsh...\033[0m" hash git >/dev/null 2>&1 && env git clone --depth=1 https://github.com/robbyrussell/oh-my-zsh.git $ZSH || { echo "git not installed" From e8caf22beb8cde69f097382a75f6d1a247625030 Mon Sep 17 00:00:00 2001 From: leycec Date: Sat, 11 Jul 2015 00:54:36 -0400 Subject: [PATCH 36/88] Cygwin-specific "chsh" installation issue fixed. Installation previously assumed the existence of a "chsh" command in the current ${PATH}. Since Cygwin does *NOT* provide this command, installation now tests for the existence of this command before attempting to run it. --- tools/install.sh | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/tools/install.sh b/tools/install.sh index 405f461e..f5836fdf 100755 --- a/tools/install.sh +++ b/tools/install.sh @@ -39,12 +39,17 @@ sed -i -e "/export PATH=/ c\\ export PATH=\"$PATH\" " ~/.zshrc -TEST_CURRENT_SHELL=$(expr "$SHELL" : '.*/\(.*\)') -if [ "$TEST_CURRENT_SHELL" != "zsh" ]; then +# If this user's login shell is not already "zsh", attempt to switch. +if [ "$(expr "$SHELL" : '.*/\(.*\)')" != "zsh" ]; then + # If this platform provides a "chsh" command (not Cygwin), do it, man! + if hash chsh >/dev/null 2>&1; then echo "\033[0;34mTime to change your default shell to zsh!\033[0m" chsh -s $(grep /zsh$ /etc/shells | tail -1) + # Else, suggest the user do so manually. + else + echo "\033[0;34mPlease manually change your default shell to zsh!\033[0m" + fi fi -unset TEST_CURRENT_SHELL echo "\033[0;32m"' __ __ '"\033[0m" echo "\033[0;32m"' ____ / /_ ____ ___ __ __ ____ _____/ /_ '"\033[0m" From fa254458688acf0bede8567b2bb5793a9ed944d6 Mon Sep 17 00:00:00 2001 From: Andrew Janke Date: Wed, 22 Jul 2015 12:59:39 -0400 Subject: [PATCH 37/88] diagnostics: include output file name in dump output --- lib/diagnostics.zsh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/diagnostics.zsh b/lib/diagnostics.zsh index 53c6548d..f3823911 100644 --- a/lib/diagnostics.zsh +++ b/lib/diagnostics.zsh @@ -101,7 +101,9 @@ function _omz_diag_dump_one_big_text() { builtin echo oh-my-zsh diagnostic dump builtin echo - + builtin echo $outfile + builtin echo + # Basic system and zsh information command date command uname -a From b875df8970a67d02eef74f1aad0b60f42fedb356 Mon Sep 17 00:00:00 2001 From: Brian Degenhardt Date: Mon, 27 Jul 2015 14:19:23 -0700 Subject: [PATCH 38/88] agnoster: speed up git prompt Problem On detached-refs, the git prompt is very slow because it uses a command to output all refs, which takes 32s on the twitter internal git repo. Solution Use git-rev-parse instead of git-show-ref to only output the head ref. Runtime drops to 0.03 seconds. Note Interestingly, git-rev-parse isn't slow without the --head arguement so I'll probably be cooking up a patch for the git team to speed this up eventually, but it's still pointless to sigpipe git as it walks the filesystem. --- themes/agnoster.zsh-theme | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/themes/agnoster.zsh-theme b/themes/agnoster.zsh-theme index 3a0c58b8..ee0c2afb 100644 --- a/themes/agnoster.zsh-theme +++ b/themes/agnoster.zsh-theme @@ -78,7 +78,7 @@ prompt_git() { if $(git rev-parse --is-inside-work-tree >/dev/null 2>&1); then dirty=$(parse_git_dirty) - ref=$(git symbolic-ref HEAD 2> /dev/null) || ref="➦ $(git show-ref --head -s --abbrev |head -n1 2> /dev/null)" + ref=$(git symbolic-ref HEAD 2> /dev/null) || ref="➦ $(git rev-parse --short HEAD 2> /dev/null)" if [[ -n $dirty ]]; then prompt_segment yellow black else From daa04bae867a12fbe8256432c3590869d8f359ea Mon Sep 17 00:00:00 2001 From: Kentaro Wada Date: Sat, 1 Aug 2015 03:11:58 +0900 Subject: [PATCH 39/88] gnu-utils: add findutils (find,xargs,locate) --- plugins/gnu-utils/gnu-utils.plugin.zsh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/plugins/gnu-utils/gnu-utils.plugin.zsh b/plugins/gnu-utils/gnu-utils.plugin.zsh index e59265d6..de95f7e6 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 From e1353fce3ccd88441f97b65adaa98e15a640ed33 Mon Sep 17 00:00:00 2001 From: Ahmed Hisham Ismail Date: Mon, 3 Aug 2015 22:06:33 +0200 Subject: [PATCH 40/88] Adds npmE alias Option to execute a command from node_modules folder --- plugins/npm/npm.plugin.zsh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/plugins/npm/npm.plugin.zsh b/plugins/npm/npm.plugin.zsh index 68ec5fab..6d735762 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'" From 269ae84c9b2e9b9bff2c8af6973ac03ba38c7e44 Mon Sep 17 00:00:00 2001 From: Ahmed Hisham Ismail Date: Wed, 5 Aug 2015 02:49:20 +0200 Subject: [PATCH 41/88] Removes unnecessary single quotes --- plugins/npm/npm.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/npm/npm.plugin.zsh b/plugins/npm/npm.plugin.zsh index 6d735762..64ba93a1 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" From 720fb5b68e186feae24c48283ded7c41b41c73fb Mon Sep 17 00:00:00 2001 From: Manfred Touron Date: Tue, 9 Jun 2015 11:07:23 +0200 Subject: [PATCH 42/88] 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 diff --git a/plugins/scw/README.md b/plugins/scw/README.md new file mode 100644 index 00000000..d2312c2e --- /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 00000000..f9fdf916 --- /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 From 14b4ba83c35c34f4a1f3a69c9967f502ee2d6528 Mon Sep 17 00:00:00 2001 From: Andrew Janke Date: Sun, 9 Aug 2015 16:28:47 -0400 Subject: [PATCH 43/88] Move urlencode/urldecode functions to core lib --- lib/functions.zsh | 134 ++++++++++++++++++++++++++++++++++++++++++++ lib/termsupport.zsh | 33 +---------- 2 files changed, 135 insertions(+), 32 deletions(-) diff --git a/lib/functions.zsh b/lib/functions.zsh index 17f5f9cb..5c1a5a28 100644 --- a/lib/functions.zsh +++ b/lib/functions.zsh @@ -73,3 +73,137 @@ function env_default() { env | grep -q "^$1=" && return 0 export "$1=$2" && return 3 } + + +# Required for $langinfo +zmodload zsh/langinfo + +# URL-encode a string +# +# Encodes a string using RFC 2396 URL-encoding (%-escaped). +# See: https://www.ietf.org/rfc/rfc2396.txt +# +# By default, reserved characters and unreserved "mark" characters are +# not escaped by this function. This allows the common usage of passing +# an entire URL in, and encoding just special characters in it, with +# the expectation that reserved and mark characters are used appropriately. +# The -r and -m options turn on escaping of the reserved and mark characters, +# respectively, which allows arbitrary strings to be fully escaped for +# embedding inside URLs, where reserved characters might be misinterpreted. +# +# Prints the encoded string on stdout. +# Returns nonzero if encoding failed. +# +# Usage: +# omz_urlencode [-r] [-m] +# +# -r causes reserved characters (;/?:@&=+$,) to be escaped +# +# -m causes "mark" characters (_.!~*''()-) to be escaped +# +# -P causes spaces to be encoded as '%20' instead of '+' +function omz_urlencode() { + emulate -L zsh + zparseopts -D -E -a opts r m P + + local in_str=$1 + local url_str="" + local spaces_as_plus + if [[ -z $opts[(r)-P] ]]; then spaces_as_plus=1; fi + local str="$in_str" + + # URLs must use UTF-8 encoding; convert str to UTF-8 if required + local encoding=$langinfo[CODESET] + local safe_encodings + safe_encodings=(UTF-8 utf8 US-ASCII) + if [[ -z ${safe_encodings[(r)$encoding]} ]]; then + str=$(echo -E "$str" | iconv -f $encoding -t UTF-8) + if [[ $? != 0 ]]; then + echo "Error converting string from $encoding to UTF-8" >&2 + return 1 + fi + fi + + # Use LC_CTYPE=C to process text byte-by-byte + local i byte ord LC_ALL=C + export LC_ALL + local reserved=';/?:@&=+$,' + local mark='_.!~*''()-' + local dont_escape="[A-Za-z0-9" + if [[ -z $opts[(r)-r] ]]; then + dont_escape+=$reserved + fi + # $mark must be last because of the "-" + if [[ -z $opts[(r)-m] ]]; then + dont_escape+=$mark + fi + dont_escape+="]" + + # Implemented to use a single printf call and avoid subshells in the loop, + # for performance (primarily on Windows). + local url_str="" + for (( i = 1; i <= ${#str}; ++i )); do + byte="$str[i]" + if [[ "$byte" =~ "$dont_escape" ]]; then + url_str+="$byte" + else + if [[ "$byte" == " " && -n $spaces_as_plus ]]; then + url_str+="+" + else + ord=$(( [##16] #byte )) + url_str+="%$ord" + fi + fi + done + echo -E "$url_str" +} + +# URL-decode a string +# +# Decodes a RFC 2396 URL-encoded (%-escaped) string. +# This decodes the '+' and '%' escapes in the input string, and leaves +# other characters unchanged. Does not enforce that the input is a +# valid URL-encoded string. This is a convenience to allow callers to +# pass in a full URL or similar strings and decode them for human +# presentation. +# +# Outputs the encoded string on stdout. +# Returns nonzero if encoding failed. +# +# Usage: +# omz_urldecode - prints decoded string followed by a newline +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 + export LC_ALL + + # Change + back to ' ' + local tmp=${encoded_url:gs/+/ /} + # Protect other escapes to pass through the printf unchanged + 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'" + + # Now we have a UTF-8 encoded string in the variable. We need to re-encode + # it if caller is in a non-UTF-8 locale. + local safe_encodings + safe_encodings=(UTF-8 utf8 US-ASCII) + if [[ -z ${safe_encodings[(r)$caller_encoding]} ]]; then + decoded=$(echo -E "$decoded" | iconv -f UTF-8 -t $caller_encoding) + if [[ $? != 0 ]]; then + echo "Error converting string from UTF-8 to $caller_encoding" >&2 + return 1 + fi + fi + + echo -E "$decoded" +} + diff --git a/lib/termsupport.zsh b/lib/termsupport.zsh index 52622f5a..726cdce4 100644 --- a/lib/termsupport.zsh +++ b/lib/termsupport.zsh @@ -59,44 +59,13 @@ preexec_functions+=(omz_termsupport_preexec) if [[ "$TERM_PROGRAM" == "Apple_Terminal" ]] && [[ -z "$INSIDE_EMACS" ]]; then - # URL-encodes a string - # Outputs the encoded string on stdout - # Returns nonzero if encoding failed - function _omz_urlencode() { - local str=$1 - local url_str="" - - # URLs must use UTF-8 encoding; convert if required - local encoding=${LC_CTYPE/*./} - if [[ -n $encoding && $encoding != UTF-8 && $encoding != utf8 ]]; then - str=$(echo $str | iconv -f $encoding -t UTF-8) - if [[ $? != 0 ]]; then - echo "Error converting string from $encoding to UTF-8" >&2 - return 1 - fi - fi - - # Use LC_CTYPE=C to process text byte-by-byte - local i ch hexch LC_CTYPE=C - for ((i = 1; i <= ${#str}; ++i)); do - ch="$str[i]" - if [[ "$ch" =~ [/._~A-Za-z0-9-] ]]; then - url_str+="$ch" - else - hexch=$(printf "%02X" "'$ch") - url_str+="%$hexch" - fi - done - echo $url_str - } - # 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=$(_omz_urlencode $PWD) + local URL_PATH=$(omz_urlencode -P $PWD) [[ $? != 0 ]] && return 1 local PWD_URL="file://$HOST$URL_PATH" # Undocumented Terminal.app-specific control sequence From dcd95dd2238bc1b3203306a2f66acc09080cfee6 Mon Sep 17 00:00:00 2001 From: Ahmed Hisham Ismail Date: Tue, 11 Aug 2015 02:56:49 +0200 Subject: [PATCH 44/88] 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(-) diff --git a/plugins/npm/npm.plugin.zsh b/plugins/npm/npm.plugin.zsh index 64ba93a1..595105d3 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"' From 3f83331c71b9dd8b1065c4e7a58223cd7d5be421 Mon Sep 17 00:00:00 2001 From: Mohnish Jadwani Date: Mon, 17 Aug 2015 06:23:58 +0530 Subject: [PATCH 45/88] removes a trailing white space --- plugins/rails/rails.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/rails/rails.plugin.zsh b/plugins/rails/rails.plugin.zsh index 097578e2..c4ad595e 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' From c66c3aef8126bf943b2746afb6a9c2a536990db5 Mon Sep 17 00:00:00 2001 From: Fice-T Date: Sun, 16 Aug 2015 22:36:32 -0600 Subject: [PATCH 46/88] Fix graphical bug in cypher theme when return status is non-zero - When the previous command's return status is non-zero and the prompt is redrawn, graphical errors sometimes arise due to the fg{red} not being escaped. --- themes/cypher.zsh-theme | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/themes/cypher.zsh-theme b/themes/cypher.zsh-theme index 45df53d2..6e6b78ee 100644 --- a/themes/cypher.zsh-theme +++ b/themes/cypher.zsh-theme @@ -1,4 +1,4 @@ # Based on evan's prompt # Shows the exit status of the last command if non-zero # Uses "#" instead of "»" when running with elevated privileges -PROMPT="%m %{${fg_bold[red]}%}:: %{${fg[green]}%}%3~%(0?. . ${fg[red]}%? )%{${fg[blue]}%}»%{${reset_color}%} " +PROMPT="%m %{${fg_bold[red]}%}:: %{${fg[green]}%}%3~%(0?. . %{${fg[red]}%}%? )%{${fg[blue]}%}»%{${reset_color}%} " From 96c34cebae5da3a52e7da0d61188c1f9822a9c2e Mon Sep 17 00:00:00 2001 From: Andrew Janke Date: Sun, 9 Aug 2015 16:37:12 -0400 Subject: [PATCH 47/88] 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 diff --git a/lib/functions.zsh b/lib/functions.zsh index 5c1a5a28..2a962669 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 00000000..7c0c278b --- /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. From 47d19cc56425aa7c550d845726111ee8bd9520d1 Mon Sep 17 00:00:00 2001 From: Andrew Janke Date: Mon, 17 Aug 2015 20:55:41 -0400 Subject: [PATCH 48/88] Add defensive `emulate -L zsh` to termsupport functions --- lib/termsupport.zsh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/termsupport.zsh b/lib/termsupport.zsh index 726cdce4..ff61d532 100644 --- a/lib/termsupport.zsh +++ b/lib/termsupport.zsh @@ -7,6 +7,7 @@ # (In screen, only short_tab_title is used) # Limited support for Apple Terminal (Terminal can't set window and tab separately) function title { + emulate -L zsh [[ "$EMACS" == *term* ]] && return # if $2 is unset use $1 as default @@ -26,6 +27,7 @@ ZSH_THEME_TERM_TITLE_IDLE="%n@%m: %~" # Runs before showing the prompt function omz_termsupport_precmd { + emulate -L zsh if [[ $DISABLE_AUTO_TITLE == true ]]; then return fi @@ -35,11 +37,11 @@ function omz_termsupport_precmd { # Runs before executing the command function omz_termsupport_preexec { + emulate -L zsh if [[ $DISABLE_AUTO_TITLE == true ]]; then return fi - emulate -L zsh setopt extended_glob # cmd name only, or if this is sudo or ssh, the next cmd @@ -61,6 +63,7 @@ if [[ "$TERM_PROGRAM" == "Apple_Terminal" ]] && [[ -z "$INSIDE_EMACS" ]]; then # Emits the control sequence to notify Terminal.app of the cwd function update_terminalapp_cwd() { + emulate -L zsh # Identify the directory using a "file:" scheme URL, including # the host name to disambiguate local vs. remote paths. From 7c31c7a96391e80bdd6ebdb6579751f4d44d6ac4 Mon Sep 17 00:00:00 2001 From: Tim O'Brien Date: Wed, 19 Aug 2015 22:33:41 -0700 Subject: [PATCH 49/88] 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(-) diff --git a/plugins/bgnotify/bgnotify.plugin.zsh b/plugins/bgnotify/bgnotify.plugin.zsh index b70b42f9..f6dd3886 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 From 76f4871d4e65a8d114055c765ed026ebadd5079d Mon Sep 17 00:00:00 2001 From: Dawid Ferenczy Date: Tue, 25 Aug 2015 18:07:47 +0200 Subject: [PATCH 50/88] Added missing commands to Vagrant plugin, updated commands description --- plugins/vagrant/_vagrant | 36 ++++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/plugins/vagrant/_vagrant b/plugins/vagrant/_vagrant index 76f80b0d..764f8954 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 From fe92ea98e0633784508e85d6b756b1c3f667b2a4 Mon Sep 17 00:00:00 2001 From: Andrew Janke Date: Tue, 18 Aug 2015 03:01:21 -0400 Subject: [PATCH 51/88] installer: switch twitter link to https --- tools/install.sh | 4 ++-- tools/upgrade.sh | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/install.sh b/tools/install.sh index 8ff1219b..beec750c 100755 --- a/tools/install.sh +++ b/tools/install.sh @@ -4,7 +4,7 @@ set -e # supports them. ncolors=$(tput colors) if [ -t 1 ] && [ -n "$ncolors" ] && [ "$ncolors" -ge 8 ]; then - RED=="$(tput setaf 1)" + RED="$(tput setaf 1)" GREEN="$(tput setaf 2)" YELLOW="$(tput setaf 3)" BLUE="$(tput setaf 4)" @@ -70,7 +70,7 @@ echo '' echo '' echo 'Please look over the ~/.zshrc file to select plugins, themes, and options.' echo '' -echo 'p.s. Follow us at http://twitter.com/ohmyzsh.' +echo 'p.s. Follow us at https://twitter.com/ohmyzsh.' echo '' echo 'p.p.s. Get stickers and t-shirts at http://shop.planetargon.com.' echo '' diff --git a/tools/upgrade.sh b/tools/upgrade.sh index 4929054c..59b38011 100644 --- a/tools/upgrade.sh +++ b/tools/upgrade.sh @@ -30,7 +30,7 @@ then printf '%s\n' '\____/_/ /_/ /_/ /_/ /_/\__, / /___/____/_/ /_/ ' printf '%s\n' ' /____/ ' printf "${BLUE}%s\n" "Hooray! Oh My Zsh has been updated and/or is at the current version." - printf "${BLUE}${BOLD}%s${NORMAL}\n" "To keep up on the latest news and updates, follow us on twitter: http://twitter.com/ohmyzsh" + printf "${BLUE}${BOLD}%s${NORMAL}\n" "To keep up on the latest news and updates, follow us on twitter: https://twitter.com/ohmyzsh" printf "${BLUE}${BOLD}%s${NORMAL}\n" "Get your Oh My Zsh swag at: http://shop.planetargon.com/" else printf "${RED}%s${NORMAL}\n" 'There was an error updating. Try again later?' From 7f64092361472e12de85f945884445e0e2274846 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Tue, 1 Sep 2015 19:07:49 +0200 Subject: [PATCH 52/88] [vim-interaction plugin] Escaping special chars in file names and simplifying code. --- .../vim-interaction.plugin.zsh | 22 ++++--------------- 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/plugins/vim-interaction/vim-interaction.plugin.zsh b/plugins/vim-interaction/vim-interaction.plugin.zsh index b0b9414c..b774be34 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" From b08431ff7431528f0e9dc49ceb199be2226266dc Mon Sep 17 00:00:00 2001 From: Andy Blyler Date: Tue, 1 Sep 2015 23:08:41 -0400 Subject: [PATCH 53/88] Add codeclimate autocomplete plugin --- plugins/codeclimate/_codeclimate | 82 ++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 plugins/codeclimate/_codeclimate diff --git a/plugins/codeclimate/_codeclimate b/plugins/codeclimate/_codeclimate new file mode 100644 index 00000000..fd2536a3 --- /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 From ef4a31563075aa0c0453219fcb66eb3941f2d515 Mon Sep 17 00:00:00 2001 From: Eric Bottard Date: Tue, 3 Mar 2015 18:28:32 +0100 Subject: [PATCH 54/88] Fix invocation of gradlew --- plugins/gradle/gradle.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/gradle/gradle.plugin.zsh b/plugins/gradle/gradle.plugin.zsh index 6f634d1b..97941756 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 From 6d7c39a2aef023ac887f0cadbe0035706838c859 Mon Sep 17 00:00:00 2001 From: Michele Bologna Date: Wed, 2 Sep 2015 20:57:04 +0200 Subject: [PATCH 55/88] 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 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 00000000..d4e41b71 --- /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 + From bec496f0534560dd32d9986b1cb99d25a1fbd819 Mon Sep 17 00:00:00 2001 From: bronzdoc Date: Wed, 2 Sep 2015 16:57:13 -0600 Subject: [PATCH 56/88] Display rvm-prompt output. --- themes/amuse.zsh-theme | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/themes/amuse.zsh-theme b/themes/amuse.zsh-theme index 548f6d39..60761b5c 100644 --- a/themes/amuse.zsh-theme +++ b/themes/amuse.zsh-theme @@ -18,4 +18,11 @@ ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[red]%}!" ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg[green]%}?" ZSH_THEME_GIT_PROMPT_CLEAN="" -RPROMPT='%{$fg_bold[red]%}$(rbenv_version)%{$reset_color%}' +if [ -e ~/.rvm/bin/rvm-prompt ]; then + RPROMPT='%{$fg_bold[red]%}‹$(~/.rvm/bin/rvm-prompt i v)›%{$reset_color%}' +else + if which rbenv &> /dev/null; then + RPROMPT='%{$fg_bold[red]%}$(rbenv_version)%{$reset_color%}' + fi +fi + From 9a7b2d7ffb6def1b1009b3c4a21d33af22a74234 Mon Sep 17 00:00:00 2001 From: Michele Bologna Date: Thu, 3 Sep 2015 08:55:03 +0200 Subject: [PATCH 57/88] 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 diff --git a/plugins/fancy-ctrl-z/README.md b/plugins/fancy-ctrl-z/README.md new file mode 100644 index 00000000..a7670fa2 --- /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 d4e41b71..8ab29791 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" From c7d782f1ab2488ff0e44c2d72d9b81ea24b3195c Mon Sep 17 00:00:00 2001 From: Pablo Cantero Date: Thu, 3 Sep 2015 13:39:41 -0300 Subject: [PATCH 58/88] 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(-) diff --git a/plugins/capistrano/_capistrano b/plugins/capistrano/_capistrano index c181b55c..e6e71ffc 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 From d009f24ac395b815287ad10db1b78b1cd9e1cf54 Mon Sep 17 00:00:00 2001 From: Andrew Janke Date: Wed, 1 Jul 2015 10:33:08 -0400 Subject: [PATCH 59/88] gnzh theme: fix "eval" and related problems. Switch to normal zsh %F/%f prompt escapes to avoid "eval" and extra variables. Wrap whole thing in anonymous function so the existing `local` statements actually work. Then switch '...' to eager "..." so stuff actually works with local variables. And local-ize the remaining variables that are used only in prompt construction. --- themes/gnzh.zsh-theme | 57 ++++++++++++++++++++----------------------- 1 file changed, 27 insertions(+), 30 deletions(-) diff --git a/themes/gnzh.zsh-theme b/themes/gnzh.zsh-theme index ab154c1e..04b0450a 100644 --- a/themes/gnzh.zsh-theme +++ b/themes/gnzh.zsh-theme @@ -1,53 +1,50 @@ # ZSH Theme - Preview: http://dl.dropbox.com/u/4109351/pics/gnzh-zsh-theme.png # Based on bira theme -# load some modules -autoload -U zsh/terminfo # Used in the colour alias below setopt prompt_subst -# make some aliases for the colours: (could use normal escape sequences too) -for color in RED GREEN YELLOW BLUE MAGENTA CYAN WHITE; do - eval PR_$color='%{$fg[${(L)color}]%}' -done -eval PR_NO_COLOR="%{$terminfo[sgr0]%}" -eval PR_BOLD="%{$terminfo[bold]%}" +() { + +local PR_USER PR_USER_OP PR_PROMPT PR_HOST # Check the UID if [[ $UID -ne 0 ]]; then # normal user - eval PR_USER='${PR_GREEN}%n${PR_NO_COLOR}' - eval PR_USER_OP='${PR_GREEN}%#${PR_NO_COLOR}' - local PR_PROMPT='$PR_NO_COLOR➤ $PR_NO_COLOR' + PR_USER='%F{green}%n%f' + PR_USER_OP='%F{green}%#%f' + PR_PROMPT='%f➤ %f' else # root - eval PR_USER='${PR_RED}%n${PR_NO_COLOR}' - eval PR_USER_OP='${PR_RED}%#${PR_NO_COLOR}' - local PR_PROMPT='$PR_RED➤ $PR_NO_COLOR' + PR_USER='%F{red}%n%f' + PR_USER_OP='%F{red}%#%f' + PR_PROMPT='%F{red}➤ %f' fi # Check if we are on SSH or not if [[ -n "$SSH_CLIENT" || -n "$SSH2_CLIENT" ]]; then - eval PR_HOST='${PR_YELLOW}%M${PR_NO_COLOR}' #SSH + PR_HOST='%F{red}%M%f' # SSH else - eval PR_HOST='${PR_GREEN}%M${PR_NO_COLOR}' # no SSH + PR_HOST='%F{green}%M%f' # no SSH fi -local return_code="%(?..%{$PR_RED%}%? ↵%{$PR_NO_COLOR%})" -local user_host='${PR_USER}${PR_CYAN}@${PR_HOST}' -local current_dir='%{$PR_BOLD$PR_BLUE%}%~%{$PR_NO_COLOR%}' +local return_code="%(?..%F{red}%? ↵%f)" + +local user_host="${PR_USER}%F{cyan}@${PR_HOST}" +local current_dir="%B%F{blue}%~%f%b" local rvm_ruby='' -if ${HOME}/.rvm/bin/rvm-prompt &> /dev/null; then # detect local user rvm installation - rvm_ruby='%{$PR_RED%}‹$(${HOME}/.rvm/bin/rvm-prompt i v g s)›%{$PR_NO_COLOR%}' -elif which rvm-prompt &> /dev/null; then # detect sysem-wide rvm installation - rvm_ruby='%{$PR_RED%}‹$(rvm-prompt i v g s)›%{$PR_NO_COLOR%}' -elif which rbenv &> /dev/null; then # detect Simple Ruby Version management - rvm_ruby='%{$PR_RED%}‹$(rbenv version | sed -e "s/ (set.*$//")›%{$PR_NO_COLOR%}' +if ${HOME}/.rvm/bin/rvm-prompt &> /dev/null; then # detect user-local rvm installation + rvm_ruby='%F{red}‹$(${HOME}/.rvm/bin/rvm-prompt i v g s)›%f' +elif which rvm-prompt &> /dev/null; then # detect system-wide rvm installation + rvm_ruby='%F{red}‹$(rvm-prompt i v g s)›%f' +elif which rbenv &> /dev/null; then # detect Simple Ruby Version Management + rvm_ruby='%F{red}‹$(rbenv version | sed -e "s/ (set.*$//")›%f' fi -local git_branch='$(git_prompt_info)%{$PR_NO_COLOR%}' +local git_branch='$(git_prompt_info)' -#PROMPT="${user_host} ${current_dir} ${rvm_ruby} ${git_branch}$PR_PROMPT " PROMPT="╭─${user_host} ${current_dir} ${rvm_ruby} ${git_branch} ╰─$PR_PROMPT " -RPS1="${return_code}" +RPROMPT="${return_code}" -ZSH_THEME_GIT_PROMPT_PREFIX="%{$PR_YELLOW%}‹" -ZSH_THEME_GIT_PROMPT_SUFFIX="› %{$PR_NO_COLOR%}" +ZSH_THEME_GIT_PROMPT_PREFIX="%F{yellow}‹" +ZSH_THEME_GIT_PROMPT_SUFFIX="› %f" + +} From 46ddd88fe056ee84064536ce9b34f86bba6b53ca Mon Sep 17 00:00:00 2001 From: Andrew Janke Date: Fri, 4 Sep 2015 14:13:00 -0400 Subject: [PATCH 60/88] diagnostics: switch to shasum, filter sysinfo using lines shasum seems more widely available than md5/md5sum, and we don't have to worry about dealing with the different signatures and output formats of md5 and md5sum then. sysinfo outputs localized message labels, so we can't just grep for "OS Type". But OS is the first thing it outputs, so we can probably just grab those lines by line number. Switched to doing that. --- lib/diagnostics.zsh | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/diagnostics.zsh b/lib/diagnostics.zsh index f3823911..afc33829 100644 --- a/lib/diagnostics.zsh +++ b/lib/diagnostics.zsh @@ -117,13 +117,16 @@ function _omz_diag_dump_one_big_text() { # Installed programs programs=(sh zsh ksh bash sed cat grep ls find git posh) + local progfile="" extra_str="" sha_str="" for program in $programs; do - local md5_str="" md5="" link_str="" extra_str="" + extra_str="" sha_str="" progfile=$(builtin which $program) if [[ $? == 0 ]]; then if [[ -e $progfile ]]; then - if builtin whence md5 &>/dev/null; then - extra_str+=" $(md5 -q $progfile)" + if builtin whence shasum &>/dev/null; then + sha_str=($(command shasum $progfile)) + sha_str=$sha_str[1] + extra_str+=" SHA $sha_str" fi if [[ -h "$progfile" ]]; then extra_str+=" ( -> ${progfile:A} )" @@ -314,7 +317,7 @@ function _omz_diag_dump_os_specific_version() { builtin echo "OS Version: $osname $osver build $(sw_vers -buildVersion)" ;; cygwin) - command systeminfo | command grep "^OS Name\|^OS Version" + command systeminfo | command head -4 | command tail -2 ;; esac From 7a63ccabf662138777a43d014a1a0ab5d8f86ab0 Mon Sep 17 00:00:00 2001 From: Alexey V Zapparov Date: Fri, 4 Sep 2015 21:18:32 +0200 Subject: [PATCH 61/88] Fix aws plugin RPROMPT pollution --- plugins/aws/aws.plugin.zsh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/plugins/aws/aws.plugin.zsh b/plugins/aws/aws.plugin.zsh index 7246db9f..d31052f8 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/')) } From 3976e040350bd9ac9423252b97dee28d3762adc2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Wed, 19 Aug 2015 09:03:43 +0200 Subject: [PATCH 62/88] Use proper if comparison --- lib/completion.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/completion.zsh b/lib/completion.zsh index 452c0dfe..e848ea2d 100644 --- a/lib/completion.zsh +++ b/lib/completion.zsh @@ -58,7 +58,7 @@ zstyle ':completion:*:*:*:users' ignored-patterns \ # ... unless we really want to. zstyle '*' single-ignored show -if [ "x$COMPLETION_WAITING_DOTS" = "xtrue" ]; then +if [[ $COMPLETION_WAITING_DOTS = true ]]; then expand-or-complete-with-dots() { echo -n "\e[31m......\e[0m" zle expand-or-complete From 6a8d406eaa715814dc5a6df08960d1fe62e5c066 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Sun, 16 Aug 2015 22:19:59 +0200 Subject: [PATCH 63/88] Use prompt expansion sequence to color red the output This makes it clearer and possibly more portable for different platforms. --- lib/completion.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/completion.zsh b/lib/completion.zsh index e848ea2d..81250d9e 100644 --- a/lib/completion.zsh +++ b/lib/completion.zsh @@ -60,7 +60,7 @@ zstyle '*' single-ignored show if [[ $COMPLETION_WAITING_DOTS = true ]]; then expand-or-complete-with-dots() { - echo -n "\e[31m......\e[0m" + print -Pn "%{%F{red}......%f%}" zle expand-or-complete zle redisplay } From b42efeb87ebdcb89510b8ffbcf210494f194109e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Sat, 22 Aug 2015 21:21:41 +0200 Subject: [PATCH 64/88] Switch off line wrapping in case dots occupy extra line This commit uses the (hopefully) standard rmam and smam escape sequences which toggle off and on line wrapping respectively. This is so that extra dots that don't fit the current line won't be displayed in the next line, which would in turn make the shell display a new prompt on the next line after the dots are hidden. I've added a check for $terminfo rmam and smam values to be sure we have them before printing them out. If this commit breaks something post an issue with your terminal emulator and $TERM value and we'll figure out what went wrong. --- lib/completion.zsh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/completion.zsh b/lib/completion.zsh index 81250d9e..f5b29247 100644 --- a/lib/completion.zsh +++ b/lib/completion.zsh @@ -60,7 +60,11 @@ zstyle '*' single-ignored show if [[ $COMPLETION_WAITING_DOTS = true ]]; then expand-or-complete-with-dots() { + # toggle line-wrapping off and back on again + [[ -n "$terminfo[rmam]" && -n "$terminfo[smam]" ]] && echoti rmam print -Pn "%{%F{red}......%f%}" + [[ -n "$terminfo[rmam]" && -n "$terminfo[smam]" ]] && echoti smam + zle expand-or-complete zle redisplay } From 75844fe1a1c9bfc84270b593cc0357fd1c356d87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Mon, 10 Aug 2015 01:45:11 +0200 Subject: [PATCH 65/88] 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 diff --git a/plugins/taskwarrior/README.md b/plugins/taskwarrior/README.md new file mode 100644 index 00000000..053151e7 --- /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 5d1e6ffe..ab885943 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' From 38d25a335999753093011f93699725c865f73360 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Fri, 14 Aug 2015 20:43:11 +0200 Subject: [PATCH 66/88] 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 | 306 +++++++++++++++++++++----------------- 1 file changed, 170 insertions(+), 136 deletions(-) diff --git a/plugins/taskwarrior/_task b/plugins/taskwarrior/_task index 5cc25315..afa30d45 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 "$@" + _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 -} - -# 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 + 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)"} ) + # 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 + _task_subcommands + _describe -t tasks 'task IDs' _task_zshids + _describe -t aliases 'task aliases' _task_aliases + _call_function ret _task_filter - return ret + return ret } -_task +_task "$@" From cbdad588e65f4205fcdc4e34e97b04fa7fdb5457 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Fri, 7 Aug 2015 18:56:57 +0200 Subject: [PATCH 67/88] 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(-) diff --git a/plugins/xcode/xcode.plugin.zsh b/plugins/xcode/xcode.plugin.zsh index 1d1205b8..4aa6bfc9 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 } From 6a830f39b68300cf86504f1c60d9ab77c09b7971 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Fri, 4 Sep 2015 01:43:48 +0200 Subject: [PATCH 68/88] Return error if no xcode files where found --- plugins/xcode/xcode.plugin.zsh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/plugins/xcode/xcode.plugin.zsh b/plugins/xcode/xcode.plugin.zsh index 4aa6bfc9..274bd92e 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]}" From 24bdd8e29a344f0282b842f89a4a10f145344939 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Fri, 7 Aug 2015 19:04:26 +0200 Subject: [PATCH 69/88] Replace xcsel function with just an alias --- plugins/xcode/xcode.plugin.zsh | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/plugins/xcode/xcode.plugin.zsh b/plugins/xcode/xcode.plugin.zsh index 274bd92e..059c78fd 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/*' From ec3694c788d2b32eb1735687cf89b057d4ca4d4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Fri, 4 Sep 2015 22:08:57 +0200 Subject: [PATCH 70/88] 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(-) diff --git a/plugins/xcode/xcode.plugin.zsh b/plugins/xcode/xcode.plugin.zsh index 059c78fd..f80de36d 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 +} From d95589d4e43d3a6288b8a66492c17d12c4e4eca0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Sat, 5 Sep 2015 23:17:38 +0200 Subject: [PATCH 71/88] Add README for the xcode plugin --- plugins/xcode/README.md | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 plugins/xcode/README.md diff --git a/plugins/xcode/README.md b/plugins/xcode/README.md new file mode 100644 index 00000000..b8efef38 --- /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. From 5584aa05c7c94949665f024ad0d88b8162654cb9 Mon Sep 17 00:00:00 2001 From: Andrew Janke Date: Fri, 4 Sep 2015 17:17:16 -0400 Subject: [PATCH 72/88] xcode: add version-based xcselv() --- plugins/xcode/xcode.plugin.zsh | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/plugins/xcode/xcode.plugin.zsh b/plugins/xcode/xcode.plugin.zsh index f80de36d..b3058cef 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)" From 213f46a296bd76031eb6a2fa66c72efeb912481d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Mon, 7 Sep 2015 12:08:50 +0200 Subject: [PATCH 73/88] Add xcselv documentation in the README --- plugins/xcode/README.md | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/plugins/xcode/README.md b/plugins/xcode/README.md index b8efef38..362940b9 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` From 82ae41ca4cf4fac253294f17b33b0c718755ffc5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Mon, 7 Sep 2015 12:09:08 +0200 Subject: [PATCH 74/88] Reorder xcode plugin file --- plugins/xcode/xcode.plugin.zsh | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/plugins/xcode/xcode.plugin.zsh b/plugins/xcode/xcode.plugin.zsh index b3058cef..1f547470 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 From 9e9b790fe1e3150b36bb1e01b432f5b38e52b512 Mon Sep 17 00:00:00 2001 From: Ilia Choly Date: Tue, 8 Sep 2015 17:34:39 -0400 Subject: [PATCH 75/88] 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 diff --git a/plugins/golang/golang.plugin.zsh b/plugins/golang/golang.plugin.zsh index 900fc630..4e6ca0a9 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 00000000..2b75cce3 --- /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 00000000..e69de29b From 953e4d892631f93e31cfdfb72199fb8f413c6b49 Mon Sep 17 00:00:00 2001 From: Ben Klein Date: Thu, 10 Sep 2015 22:19:53 -0400 Subject: [PATCH 76/88] 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(-) diff --git a/plugins/atom/atom.plugin.zsh b/plugins/atom/atom.plugin.zsh index 9adb9031..ec1a114e 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 From dca429557aef7b700ae2f1088115a707af78a31b Mon Sep 17 00:00:00 2001 From: Ben Klein Date: Thu, 10 Sep 2015 22:22:00 -0400 Subject: [PATCH 77/88] 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(-) diff --git a/plugins/atom/README.md b/plugins/atom/README.md index 75d77a0a..6350c647 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` From 36fea45bfc564c667007421a643df38c02235c8b Mon Sep 17 00:00:00 2001 From: Andrew Janke Date: Fri, 11 Sep 2015 03:11:01 -0400 Subject: [PATCH 78/88] 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(-) diff --git a/plugins/svn/svn.plugin.zsh b/plugins/svn/svn.plugin.zsh index 9f7a4c6e..816055af 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 From 22287d0153047cf5d5872d294202d9ce35e8eac8 Mon Sep 17 00:00:00 2001 From: Ilia Choly Date: Fri, 11 Sep 2015 12:20:26 -0400 Subject: [PATCH 79/88] handle multiple paths in GOPATH --- plugins/golang/golang.plugin.zsh | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/plugins/golang/golang.plugin.zsh b/plugins/golang/golang.plugin.zsh index 4e6ca0a9..1ce3cea5 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) From 6642a99fac11dd4e10869566f1d38761f1e8746c Mon Sep 17 00:00:00 2001 From: Andrew Janke Date: Thu, 10 Sep 2015 01:48:24 -0400 Subject: [PATCH 80/88] 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 diff --git a/plugins/xcode/README.md b/plugins/xcode/README.md index 362940b9..15e65785 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 00000000..f9861d54 --- /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 1f547470..b63a857a 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 { From c9af79fcad9af8e4f2fd102336e7b0ffc1df0336 Mon Sep 17 00:00:00 2001 From: Andrew Janke Date: Fri, 11 Sep 2015 18:37:39 -0400 Subject: [PATCH 81/88] 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 diff --git a/plugins/jira/README.md b/plugins/jira/README.md new file mode 100644 index 00000000..efb8a743 --- /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 b0ea658e..03fe6a49 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 89559767..341e23ec 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 From 797e1f9a64c0d2775723bb28c76745b327f86d56 Mon Sep 17 00:00:00 2001 From: Tim O'Brien Date: Mon, 14 Sep 2015 15:32:50 -0700 Subject: [PATCH 82/88] [plugins/bgnotify] fix for iTerm2 notification clicks --- plugins/bgnotify/bgnotify.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/bgnotify/bgnotify.plugin.zsh b/plugins/bgnotify/bgnotify.plugin.zsh index f6dd3886..459f5214 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 || From a8a8bc3967fc7b6906bd03c8f893a206ebc055f5 Mon Sep 17 00:00:00 2001 From: Daniel Stankevich Date: Wed, 16 Sep 2015 17:18:27 +1000 Subject: [PATCH 83/88] Add simple Stack commands list --- plugins/stack/stack.plugin.zsh | 49 ++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 plugins/stack/stack.plugin.zsh diff --git a/plugins/stack/stack.plugin.zsh b/plugins/stack/stack.plugin.zsh new file mode 100644 index 00000000..7cc25639 --- /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 + From bb10ad0a13f0dfc1d716ea023d4fc806a4e167d0 Mon Sep 17 00:00:00 2001 From: Daniel Stankevich Date: Wed, 16 Sep 2015 17:25:39 +1000 Subject: [PATCH 84/88] Remove unnecessary sandbox fn --- plugins/stack/stack.plugin.zsh | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/plugins/stack/stack.plugin.zsh b/plugins/stack/stack.plugin.zsh index 7cc25639..a149208d 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 - From 8c5b9481622759d2081e0b28faef64a39200f122 Mon Sep 17 00:00:00 2001 From: Henrik Hodne Date: Wed, 16 Sep 2015 15:28:08 +0200 Subject: [PATCH 85/88] =?UTF-8?q?chruby:=20don=CA=BCt=20try=20to=20execute?= =?UTF-8?q?=20.sh=20files=20before=20loading?= 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(-) diff --git a/plugins/chruby/chruby.plugin.zsh b/plugins/chruby/chruby.plugin.zsh index b461b0c9..5be6528b 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 } From 5cf0a0128b2dbee9aecbd6124dff72d2568001ac Mon Sep 17 00:00:00 2001 From: Alexander Olsson Date: Thu, 17 Sep 2015 10:10:23 +0200 Subject: [PATCH 86/88] Use local gradlew Instead of requiring to add `cwd` to path, just use `gradlew` from the local folder. This is how most gradle wrapper projects are laid out --- plugins/gradle/gradle.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/gradle/gradle.plugin.zsh b/plugins/gradle/gradle.plugin.zsh index 6f634d1b..97941756 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 From dce052dac00f83dae364358cdc6c24ed3486e9ea Mon Sep 17 00:00:00 2001 From: Alexis Hildebrandt Date: Fri, 18 Sep 2015 14:24:46 +0200 Subject: [PATCH 87/88] 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 diff --git a/plugins/emotty/emotty.plugin.zsh b/plugins/emotty/emotty.plugin.zsh new file mode 100644 index 00000000..b32dd1a4 --- /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 00000000..00e31713 --- /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 00000000..f761feae --- /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 00000000..8f19e690 --- /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 00000000..8dab4c1b --- /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 00000000..8e7e6106 --- /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 00000000..bde6e3d2 --- /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 + " From 550573bfb8a9369f279a46c70a0278a03d866dd3 Mon Sep 17 00:00:00 2001 From: Alexis Hildebrandt Date: Fri, 18 Sep 2015 14:25:47 +0200 Subject: [PATCH 88/88] Add emotty theme --- themes/emotty.zsh-theme | 99 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100644 themes/emotty.zsh-theme diff --git a/themes/emotty.zsh-theme b/themes/emotty.zsh-theme new file mode 100644 index 00000000..f646b2fa --- /dev/null +++ b/themes/emotty.zsh-theme @@ -0,0 +1,99 @@ +#!/usr/bin/env zsh +# ------------------------------------------------------------------------------ +# FILE: emotty.zsh-theme +# DESCRIPTION: A varying emoji based theme +# AUTHOR: Alexis Hildebrandt (afh[at]surryhill.net) +# VERSION: 1.0.0 +# DEPENDS: emotty plugin +# RECOMMENDS: Hasklig font +# +# This theme shows a different emoji for each tty at the main prompt. +# +# There are pre-defined different emoji sets to choose from, e.g.: +# emoji, stellar, floral, zodiac, love (see emotty plugin). +# +# To choose a different emotty set than the default (emoji) +# % export emotty_set=nature +# +# For the superuser (root) this theme shows a designated indicator +# and switches the foreground color to red +# (see root_prompt variable, default: skull). +# But you are using sudo (8) instead of designated a root shell, right‽ +# +# When logged in via SSH the main prompt also shows the user- and hostname. +# +# The exit status of the last failed command is displayed in the window title +# along with an indicator (see warn_glyph variable, default: collision symbol). +# To clear it just run: $NULL, true or : +# +# The right prompt shows the current working directory (3 levels up) in cyan. +# +# When in a git repository the main prompt shows the current branch name +# with a branch indicator in yellow +# (see vcs_branch_glyph variable, default: Hasklig branch glyph). +# +# If there are modified files the prompt switches to red and shows an unstaged +# indicator (see vcs_unstaged_glyph variable, default: circled letter M). +# +# If there are staged files the prompt switches to green and shows an staged +# indicator (see vcs_staged_glyph variable, default: high voltage sign). +# +# In a git repository the right prompt shows the repository name in bold and +# prepends the current working directory subpath within the repository. +# +# When git currently performs an action such as merge or rebase, the action is +# displayed in red instead of the branch name and a special action indicator +# is shown (see vcs_action_glyph variable, default: chevron). +# ------------------------------------------------------------------------------ + +user_prompt="$(emotty)" +root_prompt="$emoji[skull]" +warn_prompt="$emoji[collision_symbol]" + +vcs_unstaged_glyph="%{$emoji[circled_latin_capital_letter_m]$emoji2[emoji_style] %2G%}" +vcs_staged_glyph="%{$emoji[high_voltage_sign] %1G%}" +vcs_branch_glyph=$(print -P $'\Ue0a0') #  +vcs_action_glyph=$(print -P $'\U276f') # ❯ + +red="$FG[001]" +yellow="$FG[003]" +green="$FG[002]" +cyan="$FG[014]" + +prompt_glyph="%{%(#.${root_prompt}.${user_prompt})%1G%}" + +# Uncomment the next line if you also like to see the warn_prompt in the prompt on the right. +#last_command_failed="%(?.. %F{red}%1{${warn_prompt} %1G%}%?%f)" + + +setopt promptsubst + +autoload -U add-zsh-hook +autoload -Uz vcs_info + +zstyle ':vcs_info:*' enable git #hg svn cvs +zstyle ':vcs_info:*' get-revision false +zstyle ':vcs_info:*' check-for-changes true +zstyle ':vcs_info:git:*' unstagedstr "${red}${vcs_unstaged_glyph}" +zstyle ':vcs_info:*' stagedstr "${green}${vcs_staged_glyph}" + +# %(K|F){color} set (back|fore)ground color +# %(k|f) reset (back|fore)ground color +zstyle ':vcs_info:*' max-exports 3 +zstyle ':vcs_info:*' nvcsformats "${prompt_glyph} " '%3~' '' +zstyle ':vcs_info:*' formats "${yellow}%u%c%b${vcs_branch_glyph}%f" '%S|' "$FX[bold]%r$FX[no-bold]" +zstyle ':vcs_info:*' actionformats "${red}%K{white}%a${vcs_action_glyph}%k%f" '%S|' "$FX[bold]%r$FX[no-bold]" + +red_if_root="%(!.%F{red}.)" +sshuser_on_host="${SSH_TTY:+%(!.$red.$yellow)%n@%m$reset_color}" + +PROMPT='${sshuser_on_host}${vcs_info_msg_0_}${red_if_root} ' +RPROMPT='${cyan}${vcs_info_msg_1_##.|}${vcs_info_msg_2_}%f${last_command_failed}' + +emotty_title() { + title "${${?/[^0]*/$warn_prompt $?}/0/${prompt_glyph}}" +} +add-zsh-hook precmd emotty_title +add-zsh-hook precmd vcs_info + +# vim:ft=zsh ts=2 sw=2 sts=2