summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/compfix.zsh60
-rw-r--r--lib/functions.zsh132
-rw-r--r--lib/termsupport.zsh37
-rw-r--r--lib/theme-and-appearance.zsh7
-rw-r--r--oh-my-zsh.sh14
-rw-r--r--plugins/capistrano/_capistrano53
-rw-r--r--plugins/capistrano/capistrano.plugin.zsh11
-rw-r--r--plugins/frontend-search/README.md114
-rw-r--r--plugins/frontend-search/frontend-search.plugin.zsh220
-rw-r--r--plugins/git-extras/git-extras.plugin.zsh194
-rw-r--r--plugins/gulp/gulp.plugin.zsh29
-rw-r--r--plugins/svn/svn.plugin.zsh10
-rw-r--r--plugins/terminalapp/terminalapp.plugin.zsh45
-rwxr-xr-xtools/install.sh18
14 files changed, 592 insertions, 352 deletions
diff --git a/lib/compfix.zsh b/lib/compfix.zsh
new file mode 100644
index 000000000..208aaadb1
--- /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
+}
diff --git a/lib/functions.zsh b/lib/functions.zsh
index 0d632a268..efb73a1bd 100644
--- a/lib/functions.zsh
+++ b/lib/functions.zsh
@@ -89,3 +89,135 @@ 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] <string>
+#
+# -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 <urlstring> - prints decoded string followed by a newline
+function omz_urldecode {
+ emulate -L zsh
+ local encoded_url=$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/}
+ 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 babbaa957..5f61fe8ef 100644
--- a/lib/termsupport.zsh
+++ b/lib/termsupport.zsh
@@ -33,6 +33,7 @@ fi
# Runs before showing the prompt
function omz_termsupport_precmd {
+ emulate -L zsh
if [[ $DISABLE_AUTO_TITLE == true ]]; then
return
fi
@@ -42,11 +43,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
@@ -60,14 +61,28 @@ 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
+# With extra fixes to handle multibyte chars and non-UTF-8 locales
-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() {
+ emulate -L zsh
+ # 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 -P $PWD)
+ [[ $? != 0 ]] && return 1
+ local PWD_URL="file://$HOST$URL_PATH"
+ # Undocumented Terminal.app-specific control sequence
+ 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/lib/theme-and-appearance.zsh b/lib/theme-and-appearance.zsh
index 926303ca4..ebb11fb31 100644
--- a/lib/theme-and-appearance.zsh
+++ b/lib/theme-and-appearance.zsh
@@ -11,8 +11,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'
diff --git a/oh-my-zsh.sh b/oh-my-zsh.sh
index 4e5f77990..8e31ddd0f 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
@@ -59,9 +62,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
diff --git a/plugins/capistrano/_capistrano b/plugins/capistrano/_capistrano
index 3cadf3d54..e6e71ffcc 100644
--- a/plugins/capistrano/_capistrano
+++ b/plugins/capistrano/_capistrano
@@ -1,10 +1,49 @@
-#compdef cap
+#compdef shipit
#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 `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
+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
+ 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
+ IFS=$'\n'
+ _values 'cap commands' $(< .cap_tasks~)
+ IFS=$OLD_IFS
+ # zmodload zsh/mapfile
+ # _values ${(f)mapfile[.cap_tasks~]}
fi
- compadd `cat .cap_tasks~`
-fi
+}
+
+_cap_stages() {
+ compadd $(find config/deploy -name \*.rb | cut -d/ -f3 | sed s:.rb::g)
+}
+
+case $state in
+ cmds)
+ # check if it uses multistage
+ if [[ -d config/deploy ]]; then
+ _cap_stages
+ else
+ _cap_tasks
+ fi
+ ret=0
+ ;;
+ args)
+ _cap_tasks
+ ret=0
+ ;;
+esac
+
+return ret
diff --git a/plugins/capistrano/capistrano.plugin.zsh b/plugins/capistrano/capistrano.plugin.zsh
new file mode 100644
index 000000000..c85eb474c
--- /dev/null
+++ b/plugins/capistrano/capistrano.plugin.zsh
@@ -0,0 +1,11 @@
+# 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 shipit() {
+ if [ -f Gemfile ]
+ then
+ bundle exec cap $*
+ else
+ cap $*
+ fi
+}
diff --git a/plugins/frontend-search/README.md b/plugins/frontend-search/README.md
index b8e96ea4a..d0bc5589f 100644
--- a/plugins/frontend-search/README.md
+++ b/plugins/frontend-search/README.md
@@ -1,76 +1,60 @@
-## Rationale ##
+## Introduction ##
-> Searches for your Frontend contents more easier
+> Searches for your frontend web development made easier
-## Instalation ##
+## Installation ##
+Open your `~/.zshrc` file and enable the `frontend-search` plugin:
-Open your `.zshrc` file and load `frontend-search` plugin
+```zsh
+
+plugins=( ... frontend-search)
-```bash
-...
-plugins=( <your-plugins-list>... frontend-search)
-...
```
-## Commands ##
-
-All command searches are accept only in format
-
-* `frontend <search-content> <search-term>`
-
-The search content are
-
-* `jquery <api.jquery.com>`
-* `mdn <developer.mozilla.org>`
-* `compass <compass-style.org>`
-* `html5please <html5please.com>`
-* `caniuse <caniuse.com>`
-* `aurajs <aurajs.com>`
-* `dartlang <api.dartlang.org/apidocs/channels/stable/dartdoc-viewer>`
-* `lodash <search>`
-* `qunit <api.qunitjs.com>`
-* `fontello <fontello.com>`
-* `bootsnipp <bootsnipp.com>`
-* `cssflow <cssflow.com>`
-* `codepen <codepen.io>`
-* `unheap <www.unheap.com>`
-* `bem <google.com/search?as_q=<search-term>&as_sitesearch=bem.info>`
-* `smacss <google.com/search?as_q=<search-term>&as_sitesearch=smacss.com>`
-* `angularjs <google.com/search?as_q=<search-term>&as_sitesearch=angularjs.org>`
-* `reactjs <google.com/search?as_q=<search-term>&as_sitesearch=facebook.github.io/react>`
-* `emberjs <emberjs.com>`
-* `stackoverflow <stackoverflow.com>`
-* `npmjs <npmjs.com>`
-
-
-## Aliases ##
-
-There are a few aliases presented as well:
-
-* `jquery` A shorthand for `frontend jquery`
-* `mdn` A shorthand for `frontend mdn`
-* `compass` A shorthand for `frontend compass`
-* `html5please` A shorthand for `frontend html5please`
-* `caniuse` A shorthand for `frontend caniuse`
-* `aurajs` A shorthand for `frontend aurajs`
-* `dartlang` A shorthand for `frontend dartlang`
-* `lodash` A shorthand for `frontend lodash`
-* `qunit` A shorthand for `frontend qunit`
-* `fontello` A shorthand for `frontend fontello`
-* `bootsnipp` A shorthand for `frontend bootsnipp`
-* `cssflow` A shorthand for `frontend cssflow`
-* `codepen` A shorthand for `frontend codepen`
-* `unheap` A shorthand for `frontend unheap`
-* `bem` A shorthand for `frontend bem`
-* `smacss` A shorthand for `frontend smacss`
-* `angularjs` A shorthand for `frontend angularjs`
-* `reactjs` A shorthand for `frontend reactjs`
-* `emberjs` A shorthand for `frontend emberjs`
-* `stackoverflow` A shorthand for `frontend stackoverflow`
-* `npmjs` A shorthand for `frontend npmjs`
+## Usage ##
+
+You can use the frontend-search plugin in these two forms:
+
+* `frontend <context> <term> [more terms if you want]`
+* `<context> <term> [more terms if you want]`
+
+For example, these two are equivalent:
+
+```zsh
+$ frontend angularjs dependency injection
+$ angularjs dependency injection
+```
+
+Available search contexts are:
+
+| context | URL |
+|---------------|--------------------------------------------------------------------------|
+| angularjs | `https://google.com/search?as_sitesearch=angularjs.org&as_q=` |
+| aurajs | `http://aurajs.com/api/#stq=` |
+| bem | `https://google.com/search?as_sitesearch=bem.info&as_q=` |
+| bootsnipp | `http://bootsnipp.com/search?q=` |
+| caniuse | `http://caniuse.com/#search=` |
+| codepen | `http://codepen.io/search?q=` |
+| compass | `http://compass-style.org/search?q=` |
+| cssflow | `http://www.cssflow.com/search?q=` |
+| dartlang | `https://api.dartlang.org/apidocs/channels/stable/dartdoc-viewer/dart:` |
+| emberjs | `http://emberjs.com/api/#stp=1&stq=` |
+| fontello | `http://fontello.com/#search=` |
+| html5please | `http://html5please.com/#` |
+| jquery | `https://api.jquery.com/?s=` |
+| lodash | `https://devdocs.io/lodash/index#` |
+| mdn | `https://developer.mozilla.org/search?q=` |
+| npmjs | `https://www.npmjs.com/search?q=` |
+| qunit | `https://api.qunitjs.com/?s=` |
+| reactjs | `https://google.com/search?as_sitesearch=facebook.github.io/react&as_q=` |
+| smacss | `https://google.com/search?as_sitesearch=smacss.com&as_q=` |
+| stackoverflow | `http://stackoverflow.com/search?q=` |
+| unheap | `http://www.unheap.com/?s=` |
+
+If you want to have another context, open an Issue and tell us!
## Author
@@ -79,5 +63,3 @@ There are a few aliases presented as well:
+ <https://plus.google.com/+WilsonMendes>
+ <https://twitter.com/willmendesneto>
+ <http://github.com/willmendesneto>
-
-New features comming soon.
diff --git a/plugins/frontend-search/frontend-search.plugin.zsh b/plugins/frontend-search/frontend-search.plugin.zsh
index e47735a60..2fd5416b3 100644
--- a/plugins/frontend-search/frontend-search.plugin.zsh
+++ b/plugins/frontend-search/frontend-search.plugin.zsh
@@ -1,155 +1,91 @@
-# frontend from terminal
+alias angularjs='frontend angularjs'
+alias aurajs='frontend aurajs'
+alias bem='frontend bem'
+alias bootsnipp='frontend bootsnipp'
+alias caniuse='frontend caniuse'
+alias codepen='frontend codepen'
+alias compass='frontend compass'
+alias cssflow='frontend cssflow'
+alias dartlang='frontend dartlang'
+alias emberjs='frontend emberjs'
+alias fontello='frontend fontello'
+alias html5please='frontend html5please'
+alias jquery='frontend jquery'
+alias lodash='frontend lodash'
+alias mdn='frontend mdn'
+alias npmjs='frontend npmjs'
+alias qunit='frontend qunit'
+alias reactjs='frontend reactjs'
+alias smacss='frontend smacss'
+alias stackoverflow='frontend stackoverflow'
+alias unheap='frontend unheap'
function frontend() {
-
- # no keyword provided, simply show how call methods
- if [[ $# -le 1 ]]; then
- echo "Please provide a search-content and a search-term for app.\nEx:\nfrontend <search-content> <search-term>\n"
- return 1
+ emulate -L zsh
+
+ # define search context URLS
+ typeset -A urls
+ urls=(
+ angularjs 'https://google.com/search?as_sitesearch=angularjs.org&as_q='
+ aurajs 'http://aurajs.com/api/#stq='
+ bem 'https://google.com/search?as_sitesearch=bem.info&as_q='
+ bootsnipp 'http://bootsnipp.com/search?q='
+ caniuse 'http://caniuse.com/#search='
+ codepen 'http://codepen.io/search?q='
+ compass 'http://compass-style.org/search?q='
+ cssflow 'http://www.cssflow.com/search?q='
+ dartlang 'https://api.dartlang.org/apidocs/channels/stable/dartdoc-viewer/dart:'
+ emberjs 'http://emberjs.com/api/#stp=1&stq='
+ fontello 'http://fontello.com/#search='
+ html5please 'http://html5please.com/#'
+ jquery 'https://api.jquery.com/?s='
+ lodash 'https://devdocs.io/lodash/index#'
+ mdn 'https://developer.mozilla.org/search?q='
+ npmjs 'https://www.npmjs.com/search?q='
+ qunit 'https://api.qunitjs.com/?s='
+ reactjs 'https://google.com/search?as_sitesearch=facebook.github.io/react&as_q='
+ smacss 'https://google.com/search?as_sitesearch=smacss.com&as_q='
+ stackoverflow 'http://stackoverflow.com/search?q='
+ unheap 'http://www.unheap.com/?s='
+ )
+
+ # show help for command list
+ if [[ $# -lt 2 ]]
+ then
+ print -P "Usage: frontend %Ucontext%u %Uterm%u [...%Umore%u] (or just: %Ucontext%u %Uterm%u [...%Umore%u])"
+ print -P ""
+ print -P "%Uterm%u and what follows is what will be searched for in the %Ucontext%u website,"
+ print -P "and %Ucontext%u is one of the following:"
+ print -P ""
+ print -P " angularjs, aurajs, bem, bootsnipp, caniuse, codepen, compass, cssflow,"
+ print -P " dartlang, emberjs, fontello, html5please, jquery, lodash, mdn, npmjs,"
+ print -P " qunit, reactjs, smacss, stackoverflow, unheap"
+ print -P ""
+ print -P "For example: frontend npmjs mocha (or just: npmjs mocha)."
+ print -P ""
+ return 1
fi
- # check whether the search engine is supported
- if [[ ! $1 =~ '(jquery|mdn|compass|html5please|caniuse|aurajs|dartlang|qunit|fontello|bootsnipp|cssflow|codepen|unheap|bem|smacss|angularjs|reactjs|emberjs|stackoverflow|npmjs)' ]];
+ # check whether the search context is supported
+ if [[ -z "$urls[$1]" ]]
then
- echo "Search valid search content $1 not supported."
- echo "Valid contents: (formats 'frontend <search-content>' or '<search-content>')"
- echo "* jquery"
- echo "* mdn"
- echo "* compass"
- echo "* html5please"
- echo "* caniuse"
- echo "* aurajs"
- echo "* dartlang"
- echo "* lodash"
- echo "* qunit"
- echo "* fontello"
- echo "* bootsnipp"
- echo "* cssflow"
- echo "* codepen"
- echo "* unheap"
- echo "* bem"
- echo "* smacss"
- echo "* angularjs"
- echo "* reactjs"
- echo "* emberjs"
- echo "* stackoverflow"
- echo "* npmjs"
+ echo "Search context \"$1\" currently not supported."
+ echo ""
+ echo "Valid contexts are:"
+ echo ""
+ echo " angularjs, aurajs, bem, bootsnipp, caniuse, codepen, compass, cssflow, "
+ echo " dartlang, emberjs, fontello, html5please, jquery, lodash, mdn, npmjs, "
+ echo " qunit, reactjs, smacss, stackoverflow, unheap"
echo ""
-
return 1
fi
- local url="http://"
- local query=""
+ # build search url:
+ # join arguments passed with '+', then append to search context URL
+ # TODO substitute for proper urlencode method
+ url="${urls[$1]}${(j:+:)@[2,-1]}"
- case "$1" in
- "jquery")
- url="${url}api.jquery.com"
- url="${url}/?s=$2" ;;
- "mdn")
- url="${url}developer.mozilla.org"
- url="${url}/search?q=$2" ;;
- "compass")
- url="${url}compass-style.org"
- url="${url}/search?q=$2" ;;
- "html5please")
- url="${url}html5please.com"
- url="${url}/#$2" ;;
- "caniuse")
- url="${url}caniuse.com"
- url="${url}/#search=$2" ;;
- "aurajs")
- url="${url}aurajs.com"
- url="${url}/api/#stq=$2" ;;
- "dartlang")
- url="${url}api.dartlang.org/apidocs/channels/stable/dartdoc-viewer"
- url="${url}/dart-$2" ;;
- "qunit")
- url="${url}api.qunitjs.com"
- url="${url}/?s=$2" ;;
- "fontello")
- url="${url}fontello.com"
- url="${url}/#search=$2" ;;
- "bootsnipp")
- url="${url}bootsnipp.com"
- url="${url}/search?q=$2" ;;
- "cssflow")
- url="${url}cssflow.com"
- url="${url}/search?q=$2" ;;
- "codepen")
- url="${url}codepen.io"
- url="${url}/search?q=$2" ;;
- "unheap")
- url="${url}www.unheap.com"
- url="${url}/?s=$2" ;;
- "bem")
- url="${url}google.com"
- url="${url}/search?as_q=$2&as_sitesearch=bem.info" ;;
- "smacss")
- url="${url}google.com"
- url="${url}/search?as_q=$2&as_sitesearch=smacss.com" ;;
- "angularjs")
- url="${url}google.com"
- url="${url}/search?as_q=$2&as_sitesearch=angularjs.org" ;;
- "reactjs")
- url="${url}google.com"
- url="${url}/search?as_q=$2&as_sitesearch=facebook.github.io/react" ;;
- "emberjs")
- url="${url}emberjs.com"
- url="${url}/api/#stq=$2&stp=1" ;;
- "stackoverflow")
- url="${url}stackoverflow.com"
- url="${url}/search?q=$2" ;;
- "npmjs")
- url="${url}www.npmjs.com"
- url="${url}/search?q=$2" ;;
- *) echo "INVALID PARAM!"
- return ;;
- esac
-
- echo "$url"
+ echo "Opening $url ..."
open_command "$url"
-
}
-
-# javascript
-alias jquery='frontend jquery'
-alias mdn='frontend mdn'
-
-# pre processors frameworks
-alias compassdoc='frontend compass'
-
-# important links
-alias html5please='frontend html5please'
-alias caniuse='frontend caniuse'
-
-# components and libraries
-alias aurajs='frontend aurajs'
-alias dartlang='frontend dartlang'
-alias lodash='frontend lodash'
-
-#tests
-alias qunit='frontend qunit'
-
-#fonts
-alias fontello='frontend fontello'
-
-# snippets
-alias bootsnipp='frontend bootsnipp'
-alias cssflow='frontend cssflow'
-alias codepen='frontend codepen'
-alias unheap='frontend unheap'
-
-# css architecture
-alias bem='frontend bem'
-alias smacss='frontend smacss'
-
-# frameworks
-alias angularjs='frontend angularjs'
-alias reactjs='frontend reactjs'
-alias emberjs='frontend emberjs'
-
-# search websites
-alias stackoverflow='frontend stackoverflow'
-alias npmjs='frontend npmjs'
diff --git a/plugins/git-extras/git-extras.plugin.zsh b/plugins/git-extras/git-extras.plugin.zsh
index 8419166ab..d91c1af81 100644
--- a/plugins/git-extras/git-extras.plugin.zsh
+++ b/plugins/git-extras/git-extras.plugin.zsh
@@ -3,19 +3,20 @@
# Description
# -----------
#
-# Completion script for git-extras (http://github.com/visionmedia/git-extras).
+# Completion script for git-extras (http://github.com/tj/git-extras).
#
# ------------------------------------------------------------------------------
# Authors
# -------
#
# * Alexis GRIMALDI (https://github.com/agrimaldi)
+# * spacewander (https://github.com/spacewander)
#
# ------------------------------------------------------------------------------
# Inspirations
# -----------
#
-# * git-extras (http://github.com/visionmedia/git-extras)
+# * git-extras (http://github.com/tj/git-extras)
# * git-flow-completion (http://github.com/bobthecow/git-flow-completion)
#
# ------------------------------------------------------------------------------
@@ -30,10 +31,21 @@ __git_command_successful () {
}
+__git_commits() {
+ declare -A commits
+ git log --oneline -15 | sed 's/\([[:alnum:]]\{7\}\) /\1:/' | while read commit
+ do
+ hash=$(echo $commit | cut -d':' -f1)
+ commits[$hash]="$commit"
+ done
+ local ret=1
+ _describe -t commits commit commits && ret=0
+}
+
__git_tag_names() {
local expl
declare -a tag_names
- tag_names=(${${(f)"$(_call_program branchrefs git for-each-ref --format='"%(refname)"' refs/tags 2>/dev/null)"}#refs/tags/})
+ tag_names=(${${(f)"$(_call_program tags git for-each-ref --format='"%(refname)"' refs/tags 2>/dev/null)"}#refs/tags/})
__git_command_successful || return
_wanted tag-names expl tag-name compadd $* - $tag_names
}
@@ -47,31 +59,27 @@ __git_branch_names() {
_wanted branch-names expl branch-name compadd $* - $branch_names
}
-
-__git_feature_branch_names() {
+__git_specific_branch_names() {
local expl
declare -a branch_names
- branch_names=(${${(f)"$(_call_program branchrefs git for-each-ref --format='"%(refname)"' refs/heads/feature 2>/dev/null)"}#refs/heads/feature/})
+ branch_names=(${${(f)"$(_call_program branchrefs git for-each-ref --format='"%(refname)"' refs/heads/"$1" 2>/dev/null)"}#refs/heads/$1/})
__git_command_successful || return
_wanted branch-names expl branch-name compadd $* - $branch_names
}
+__git_feature_branch_names() {
+ __git_specific_branch_names 'feature'
+}
+
+
__git_refactor_branch_names() {
- local expl
- declare -a branch_names
- branch_names=(${${(f)"$(_call_program branchrefs git for-each-ref --format='"%(refname)"' refs/heads/refactor 2>/dev/null)"}#refs/heads/refactor/})
- __git_command_successful || return
- _wanted branch-names expl branch-name compadd $* - $branch_names
+ __git_specific_branch_names 'refactor'
}
__git_bug_branch_names() {
- local expl
- declare -a branch_names
- branch_names=(${${(f)"$(_call_program branchrefs git for-each-ref --format='"%(refname)"' refs/heads/bug 2>/dev/null)"}#refs/heads/bug/})
- __git_command_successful || return
- _wanted branch-names expl branch-name compadd $* - $branch_names
+ __git_specific_branch_names 'bug'
}
@@ -92,19 +100,43 @@ __git_author_names() {
_wanted author-names expl author-name compadd $* - $author_names
}
+# subcommands
-_git-changelog() {
- _arguments \
- '(-l --list)'{-l,--list}'[list commits]' \
+_git-bug() {
+ local curcontext=$curcontext state line ret=1
+ declare -A opt_args
+
+ _arguments -C \
+ ': :->command' \
+ '*:: :->option-or-argument' && ret=0
+
+ case $state in
+ (command)
+ declare -a commands
+ commands=(
+ 'finish:merge bug into the current branch'
+ )
+ _describe -t commands command commands && ret=0
+ ;;
+ (option-or-argument)
+ curcontext=${curcontext%:*}-$line[1]:
+ case $line[1] in
+ (finish)
+ _arguments -C \
+ ':branch-name:__git_bug_branch_names'
+ ;;
+ esac
+ esac
}
-_git-effort() {
+_git-changelog() {
_arguments \
- '--above[ignore file with less than x commits]' \
+ '(-l --list)'{-l,--list}'[list commits]' \
}
+
_git-contrib() {
_arguments \
':author:__git_author_names'
@@ -135,6 +167,11 @@ _git-delete-tag() {
}
+_git-effort() {
+ _arguments \
+ '--above[ignore file with less than x commits]'
+}
+
_git-extras() {
local curcontext=$curcontext state line ret=1
declare -A opt_args
@@ -154,20 +191,7 @@ _git-extras() {
esac
_arguments \
- '(-v --version)'{-v,--version}'[show current version]' \
-}
-
-
-_git-graft() {
- _arguments \
- ':src-branch-name:__git_branch_names' \
- ':dest-branch-name:__git_branch_names'
-}
-
-
-_git-squash() {
- _arguments \
- ':branch-name:__git_branch_names'
+ '(-v --version)'{-v,--version}'[show current version]'
}
@@ -199,6 +223,25 @@ _git-feature() {
}
+_git-graft() {
+ _arguments \
+ ':src-branch-name:__git_branch_names' \
+ ':dest-branch-name:__git_branch_names'
+}
+
+
+_git-ignore() {
+ _arguments -C \
+ '(--local -l)'{--local,-l}'[show local gitignore]' \
+ '(--global -g)'{--global,-g}'[show global gitignore]'
+}
+
+_git-missing() {
+ _arguments \
+ ':first-branch-name:__git_branch_names' \
+ ':second-branch-name:__git_branch_names'
+}
+
_git-refactor() {
local curcontext=$curcontext state line ret=1
declare -A opt_args
@@ -227,59 +270,62 @@ _git-refactor() {
}
-_git-bug() {
- local curcontext=$curcontext state line ret=1
- declare -A opt_args
-
- _arguments -C \
- ': :->command' \
- '*:: :->option-or-argument' && ret=0
+_git-squash() {
+ _arguments \
+ ':branch-name:__git_branch_names'
+}
- case $state in
- (command)
- declare -a commands
- commands=(
- 'finish:merge bug into the current branch'
- )
- _describe -t commands command commands && ret=0
- ;;
- (option-or-argument)
- curcontext=${curcontext%:*}-$line[1]:
- case $line[1] in
- (finish)
- _arguments -C \
- ':branch-name:__git_bug_branch_names'
- ;;
- esac
- esac
+_git-summary() {
+ _arguments '--line[summarize with lines other than commits]'
+ __git_commits
}
+_git-undo(){
+ _arguments -C \
+ '(--soft -s)'{--soft,-s}'[only rolls back the commit but changes remain un-staged]' \
+ '(--hard -h)'{--hard,-h}'[wipes your commit(s)]'
+}
+
zstyle ':completion:*:*:git:*' user-commands \
+ alias:'define, search and show aliases' \
+ archive-file:'export the current HEAD of the git repository to a archive' \
+ back:'undo and stage latest commits' \
+ bug:'create a bug branch' \
changelog:'populate changelog file with commits since the previous tag' \
+ commits-since:'list commits since a given date' \
contrib:'display author contributions' \
count:'count commits' \
+ create-branch:'create local and remote branch' \
delete-branch:'delete local and remote branch' \
+ delete-merged-brancees:'delete merged branches'\
delete-submodule:'delete submodule' \
delete-tag:'delete local and remote tag' \
+ effort:'display effort statistics' \
extras:'git-extras' \
- graft:'merge commits from source branch to destination branch' \
- squash:'merge commits from source branch into the current one as a single commit' \
feature:'create a feature branch' \
- refactor:'create a refactor branch' \
- bug:'create a bug branch' \
- summary:'repository summary' \
- effort:'display effort statistics' \
- repl:'read-eval-print-loop' \
- commits-since:'list commits since a given date' \
- release:'release commit with the given tag' \
- alias:'define, search and show aliases' \
+ fork:'fork a repo on github' \
+ fresh-branch:'create empty local branch' \
+ gh-pages:'create the GitHub Pages branch' \
+ graft:'merge commits from source branch to destination branch' \
ignore:'add patterns to .gitignore' \
info:'show info about the repository' \
- create-branch:'create local and remote branch' \
- fresh-branch:'create empty local branch' \
- undo:'remove the latest commit' \
+ local-commits:'list unpushed commits on the local branch' \
+ lock:'lock a file excluded from version control' \
+ locked:'ls files that have been locked' \
+ missing:'show commits missing from another branch' \
+ pr:'checks out a pull request locally' \
+ rebase-patch:'rebases a patch' \
+ refactor:'create a refactor branch' \
+ release:'commit, tag and push changes to the repository' \
+ rename-tag:'rename a tag' \
+ repl:'read-eval-print-loop' \
+ reset-file:'reset one file' \
+ root:'show path of root' \
setup:'setup a git repository' \
+ show-tree:'show branch tree of commit history' \
+ squash:'merge commits from source branch into the current one as a single commit' \
+ summary:'repository summary' \
touch:'one step creation of new files' \
- obliterate:'Completely remove a file from the repository, including past commits and tags' \
- local-commits:'list unpushed commits on the local branch' \
+ undo:'remove the latest commit' \
+ unlock:'unlock a file excluded from version control'
diff --git a/plugins/gulp/gulp.plugin.zsh b/plugins/gulp/gulp.plugin.zsh
new file mode 100644
index 000000000..6017c7b60
--- /dev/null
+++ b/plugins/gulp/gulp.plugin.zsh
@@ -0,0 +1,29 @@
+#!/usr/bin/env zsh
+
+#
+# gulp-autocompletion-zsh
+#
+# Autocompletion for your gulp.js tasks
+#
+# Copyright(c) 2014 André König <andre.koenig@posteo.de>
+# MIT Licensed
+#
+
+#
+# André König
+# Github: https://github.com/akoenig
+# Twitter: https://twitter.com/caiifr
+#
+
+#
+# Grabs all available tasks from the `gulpfile.js`
+# in the current directory.
+#
+function $$gulp_completion() {
+ compls=$(grep -Eo "gulp.task\(('(([a-zA-Z0-9]|-)*)',)" gulpfile.js 2>/dev/null | grep -Eo "'(([a-zA-Z0-9]|-)*)'" | sed s/"'"//g | sort)
+
+ completions=(${=compls})
+ compadd -- $completions
+}
+
+compdef $$gulp_completion gulp \ No newline at end of file
diff --git a/plugins/svn/svn.plugin.zsh b/plugins/svn/svn.plugin.zsh
index 9f7a4c6eb..816055afe 100644
--- a/plugins/svn/svn.plugin.zsh
+++ b/plugins/svn/svn.plugin.zsh
@@ -1,16 +1,17 @@
# vim:ft=zsh ts=2 sw=2 sts=2
#
function svn_prompt_info() {
+ local _DISPLAY
if in_svn; then
if [ "x$SVN_SHOW_BRANCH" = "xtrue" ]; then
unset SVN_SHOW_BRANCH
_DISPLAY=$(svn_get_branch_name)
else
_DISPLAY=$(svn_get_repo_name)
+ _DISPLAY=$(omz_urldecode "${_DISPLAY}")
fi
echo "$ZSH_PROMPT_BASE_COLOR$ZSH_THEME_SVN_PROMPT_PREFIX\
$ZSH_THEME_REPO_NAME_COLOR$_DISPLAY$ZSH_PROMPT_BASE_COLOR$ZSH_THEME_SVN_PROMPT_SUFFIX$ZSH_PROMPT_BASE_COLOR$(svn_dirty)$(svn_dirty_pwd)$ZSH_PROMPT_BASE_COLOR"
- unset _DISPLAY
fi
}
@@ -30,7 +31,7 @@ function svn_get_repo_name() {
}
function svn_get_branch_name() {
- _DISPLAY=$(
+ local _DISPLAY=$(
svn info 2> /dev/null | \
awk -F/ \
'/^URL:/ { \
@@ -49,7 +50,6 @@ function svn_get_branch_name() {
else
echo $_DISPLAY
fi
- unset _DISPLAY
}
function svn_get_rev_nr() {
@@ -60,7 +60,7 @@ function svn_get_rev_nr() {
function svn_dirty_choose() {
if in_svn; then
- root=`svn info 2> /dev/null | sed -n 's/^Working Copy Root Path: //p'`
+ local root=`svn info 2> /dev/null | sed -n 's/^Working Copy Root Path: //p'`
if $(svn status $root 2> /dev/null | command grep -Eq '^\s*[ACDIM!?L]'); then
# Grep exits with 0 when "One or more lines were selected", return "dirty".
echo $1
@@ -77,7 +77,7 @@ function svn_dirty() {
function svn_dirty_choose_pwd () {
if in_svn; then
- root=$PWD
+ local root=$PWD
if $(svn status $root 2> /dev/null | command grep -Eq '^\s*[ACDIM!?L]'); then
# Grep exits with 0 when "One or more lines were selected", return "dirty".
echo $1
diff --git a/plugins/terminalapp/terminalapp.plugin.zsh b/plugins/terminalapp/terminalapp.plugin.zsh
index 6e47ee188..7c0c278b9 100644
--- a/plugins/terminalapp/terminalapp.plugin.zsh
+++ b/plugins/terminalapp/terminalapp.plugin.zsh
@@ -1,39 +1,6 @@
-# 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
+# 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.
diff --git a/tools/install.sh b/tools/install.sh
index 1586cdee5..aebd28371 100755
--- a/tools/install.sh
+++ b/tools/install.sh
@@ -16,6 +16,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"
@@ -41,12 +48,17 @@ export PATH=\"$PATH\"
" ~/.zshrc > ~/.zshrc-omztemp
mv -f ~/.zshrc-omztemp ~/.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"