summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/functions.zsh2
-rw-r--r--lib/grep.zsh23
-rw-r--r--plugins/brew-cask/brew-cask.plugin.zsh84
-rw-r--r--plugins/bundler/bundler.plugin.zsh2
-rw-r--r--plugins/docker/_docker2
-rw-r--r--plugins/git-prompt/gitstatus.py2
-rw-r--r--plugins/history-substring-search/history-substring-search.zsh9
-rw-r--r--themes/agnoster.zsh-theme14
8 files changed, 124 insertions, 14 deletions
diff --git a/lib/functions.zsh b/lib/functions.zsh
index aaf8a03e3..fda84a953 100644
--- a/lib/functions.zsh
+++ b/lib/functions.zsh
@@ -1,5 +1,5 @@
function zsh_stats() {
- history | awk '{CMD[$2]++;count++;}END { for (a in CMD)print CMD[a] " " CMD[a]/count*100 "% " a;}' | grep -v "./" | column -c3 -s " " -t | sort -nr | nl | head -n20
+ fc -l 1 | awk '{CMD[$2]++;count++;}END { for (a in CMD)print CMD[a] " " CMD[a]/count*100 "% " a;}' | grep -v "./" | column -c3 -s " " -t | sort -nr | nl | head -n20
}
function uninstall_oh_my_zsh() {
diff --git a/lib/grep.zsh b/lib/grep.zsh
index 977435ee4..276fec382 100644
--- a/lib/grep.zsh
+++ b/lib/grep.zsh
@@ -3,11 +3,22 @@
# Examples: http://rubyurl.com/ZXv
#
-# avoid VCS folders
-GREP_OPTIONS=
-for PATTERN in .cvs .git .hg .svn; do
- GREP_OPTIONS+="--exclude-dir=$PATTERN "
-done
-GREP_OPTIONS+="--color=auto"
+GREP_OPTIONS="--color=auto"
+
+# avoid VCS folders (if the necessary grep flags are available)
+grep-flag-available() {
+ echo | grep $1 "" >/dev/null 2>&1
+}
+if grep-flag-available --exclude-dir=.cvs; then
+ for PATTERN in .cvs .git .hg .svn; do
+ GREP_OPTIONS+=" --exclude-dir=$PATTERN"
+ done
+elif grep-flag-available --exclude=.cvs; then
+ for PATTERN in .cvs .git .hg .svn; do
+ GREP_OPTIONS+=" --exclude=$PATTERN"
+ done
+fi
+unfunction grep-flag-available
+
export GREP_OPTIONS="$GREP_OPTIONS"
export GREP_COLOR='1;32'
diff --git a/plugins/brew-cask/brew-cask.plugin.zsh b/plugins/brew-cask/brew-cask.plugin.zsh
new file mode 100644
index 000000000..91ce0f498
--- /dev/null
+++ b/plugins/brew-cask/brew-cask.plugin.zsh
@@ -0,0 +1,84 @@
+# Autocompletion for homebrew-cask.
+#
+# This script intercepts calls to the brew plugin and adds autocompletion
+# for the cask subcommand.
+#
+# Author: https://github.com/pstadler
+
+compdef _brew-cask brew
+
+_brew-cask()
+{
+ local curcontext="$curcontext" state line
+ typeset -A opt_args
+
+ _arguments -C \
+ ':command:->command' \
+ ':subcmd:->subcmd' \
+ '*::options:->options'
+
+ case $state in
+ (command)
+ __call_original_brew
+ cask_commands=(
+ 'cask:manage casks'
+ )
+ _describe -t commands 'brew cask command' cask_commands ;;
+
+ (subcmd)
+ case "$line[1]" in
+ cask)
+ if (( CURRENT == 3 )); then
+ local -a subcommands
+ subcommands=(
+ "alfred:used to modify Alfred's scope to include the Caskroom"
+ 'audit:verifies installability of casks'
+ 'checklinks:checks for bad cask links'
+ 'cleanup:cleans up cached downloads'
+ 'create:creates a cask of the given name and opens it in an editor'
+ 'doctor:checks for configuration issues'
+ 'edit:edits the cask of the given name'
+ 'fetch:downloads Cask resources to local cache'
+ 'home:opens the homepage of the cask of the given name'
+ 'info:displays information about the cask of the given name'
+ 'install:installs the cask of the given name'
+ 'list:with no args, lists installed casks; given installed casks, lists installed files'
+ 'search:searches all known casks'
+ 'uninstall:uninstalls the cask of the given name'
+ "update:a synonym for 'brew update'"
+ )
+ _describe -t commands "brew cask subcommand" subcommands
+ fi ;;
+
+ *)
+ __call_original_brew ;;
+ esac ;;
+
+ (options)
+ local -a casks installed_casks
+ local expl
+ case "$line[2]" in
+ list|uninstall)
+ __brew_installed_casks
+ _wanted installed_casks expl 'installed casks' compadd -a installed_casks ;;
+ audit|edit|home|info|install)
+ __brew_all_casks
+ _wanted casks expl 'all casks' compadd -a casks ;;
+ esac ;;
+ esac
+}
+
+__brew_all_casks() {
+ casks=(`brew cask search`)
+}
+
+__brew_installed_casks() {
+ installed_casks=(`brew cask list`)
+}
+
+__call_original_brew()
+{
+ local ret=1
+ _call_function ret _brew
+ compdef _brew-cask brew
+}
diff --git a/plugins/bundler/bundler.plugin.zsh b/plugins/bundler/bundler.plugin.zsh
index e4b03e7b0..3338d78be 100644
--- a/plugins/bundler/bundler.plugin.zsh
+++ b/plugins/bundler/bundler.plugin.zsh
@@ -6,7 +6,7 @@ alias bu="bundle update"
# The following is based on https://github.com/gma/bundler-exec
-bundled_commands=(annotate berks cap capify cucumber foodcritic foreman guard irb jekyll kitchen knife mailcatcher middleman nanoc puma rackup rainbows rake rspec ruby shotgun spec spin spork strainer tailor taps thin thor unicorn unicorn_rails)
+bundled_commands=(annotate berks cap capify cucumber foodcritic foreman guard irb jekyll kitchen knife middleman nanoc puma rackup rainbows rake rspec ruby shotgun spec spin spork strainer tailor taps thin thor unicorn unicorn_rails)
# Remove $UNBUNDLED_COMMANDS from the bundled_commands list
for cmd in $UNBUNDLED_COMMANDS; do
diff --git a/plugins/docker/_docker b/plugins/docker/_docker
index 5acd19edf..c291037a3 100644
--- a/plugins/docker/_docker
+++ b/plugins/docker/_docker
@@ -166,7 +166,7 @@ __rm() {
__rmi() {
_arguments \
- '(-f,--force=)'{-f,--force=}'[Force]' \
+ '(-f,--force=)'{-f,--force=}'[Force]'
__docker_images
}
diff --git a/plugins/git-prompt/gitstatus.py b/plugins/git-prompt/gitstatus.py
index ef894bff2..256841432 100644
--- a/plugins/git-prompt/gitstatus.py
+++ b/plugins/git-prompt/gitstatus.py
@@ -16,7 +16,7 @@ symbols = {
}
output, error = Popen(
- ['git', 'status'], stdout=PIPE, stderr=PIPE).communicate()
+ ['git', 'status'], stdout=PIPE, stderr=PIPE, universal_newlines=True).communicate()
if error:
import sys
diff --git a/plugins/history-substring-search/history-substring-search.zsh b/plugins/history-substring-search/history-substring-search.zsh
index 53f707c79..22f03dd6d 100644
--- a/plugins/history-substring-search/history-substring-search.zsh
+++ b/plugins/history-substring-search/history-substring-search.zsh
@@ -163,8 +163,13 @@ function history-substring-search-down() {
zle -N history-substring-search-up
zle -N history-substring-search-down
-bindkey '\e[A' history-substring-search-up
-bindkey '\e[B' history-substring-search-down
+zmodload zsh/terminfo
+if [[ -n "$terminfo[kcuu1]" ]]; then
+ bindkey "$terminfo[kcuu1]" history-substring-search-up
+fi
+if [[ -n "$terminfo[kcud1]" ]]; then
+ bindkey "$terminfo[kcud1]" history-substring-search-down
+fi
#-----------------------------------------------------------------------------
# implementation details
diff --git a/themes/agnoster.zsh-theme b/themes/agnoster.zsh-theme
index 85b846cb5..2b33c48bc 100644
--- a/themes/agnoster.zsh-theme
+++ b/themes/agnoster.zsh-theme
@@ -69,7 +69,9 @@ prompt_context() {
# Git: branch/detached head, dirty status
prompt_git() {
- local ref dirty
+ local ref dirty mode repo_path
+ repo_path=$(git rev-parse --git-dir 2>/dev/null)
+
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)"
@@ -79,6 +81,14 @@ prompt_git() {
prompt_segment green black
fi
+ if [[ -e "${repo_path}/BISECT_LOG" ]]; then
+ mode=" <B>"
+ elif [[ -e "${repo_path}/MERGE_HEAD" ]]; then
+ mode=" >M<"
+ elif [[ -e "${repo_path}/rebase" || -e "${repo_path}/rebase-apply" || -e "${repo_path}/rebase-merge" || -e "${repo_path}/../.dotest" ]]; then
+ mode=" >R>"
+ fi
+
setopt promptsubst
autoload -Uz vcs_info
@@ -90,7 +100,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_%% }"
+ echo -n "${ref/refs\/heads\// }${vcs_info_msg_0_%% }${mode}"
fi
}