From 7fb17127c7ef2ff11240af5c42430ae3ae1c0369 Mon Sep 17 00:00:00 2001 From: Dmitri Akatov Date: Wed, 24 Jul 2013 14:30:12 -0700 Subject: [PATCH 001/158] carton completion plugin --- plugins/carton/carton.plugin.zsh | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 plugins/carton/carton.plugin.zsh diff --git a/plugins/carton/carton.plugin.zsh b/plugins/carton/carton.plugin.zsh new file mode 100644 index 00000000..23868b09 --- /dev/null +++ b/plugins/carton/carton.plugin.zsh @@ -0,0 +1,6 @@ +if which carton &> /dev/null +then + source $(dirname $(which carton))/../etc/carton_completion.zsh +else + print "zsh carton plugin: carton not found" +fi From 55c90b1d6cbda581f9ccd41ea1c8da15da98d5ee Mon Sep 17 00:00:00 2001 From: Dmitri Akatov Date: Fri, 26 Jul 2013 20:00:45 -0700 Subject: [PATCH 002/158] grunt completion courtesy of @yonchu: https://github.com/yonchu/grunt-zsh-completion --- plugins/grunt/grunt.plugin.zsh | 253 +++++++++++++++++++++++++++++++++ 1 file changed, 253 insertions(+) create mode 100644 plugins/grunt/grunt.plugin.zsh diff --git a/plugins/grunt/grunt.plugin.zsh b/plugins/grunt/grunt.plugin.zsh new file mode 100644 index 00000000..48f6cb5a --- /dev/null +++ b/plugins/grunt/grunt.plugin.zsh @@ -0,0 +1,253 @@ +#compdef grunt +# ----------------------------------------------------------------------------- +# _grunt +# +# Completion script for grunt. +# - https://github.com/gruntjs/grunt +# - https://github.com/gruntjs/grunt-cli +# +# ----------------------------------------------------------------------------- +# +# Version : 0.1.0 +# Author : Yonchu +# License : MIT License +# Repository : https://github.com/yonchu/grunt-zsh-completion +# Last Change : 22 Jul 2013. +# +# Copyright (c) 2013 Yonchu. +# +# ----------------------------------------------------------------------------- +# USAGE +# ----- +# +# Enable caching: +# +# If you want to use the cache, set the followings in your .zshrc: +# +# zstyle ':completion:*' use-cache yes +# +# +# Settings: +# +# - Show grunt file path: +# zstyle ':completion::complete:grunt::options:' show_grunt_path yes +# +# - Cache expiration days (default: 7): +# zstyle ':completion::complete:grunt::options:' expire 1 +# +# - Not update options cache if target gruntfile is changed. +# zstyle ':completion::complete:grunt::options:' no_update_options yes +# +# Note that if you change the zstyle settings, +# you should delete the cache file and restart zsh. +# +# $ rm ~/.zcompcache/grunt +# $ exec zsh +# +# ----------------------------------------------------------------------------- + +function _grunt() { + local curcontext="$curcontext" update_policy state + local show_grunt_path update_msg gruntfile opts tasks + + # Setup cache-policy. + zstyle -s ":completion:${curcontext}:" cache-policy update_policy + if [[ -z $update_policy ]]; then + zstyle ":completion:${curcontext}:" cache-policy __grunt_caching_policy + fi + + # Check show_path option. + zstyle -b ":completion:${curcontext}:options:" show_grunt_path show_grunt_path + + # Get current gruntfile. + gruntfile=$(__grunt_get_gruntfile) + + # Initialize opts and tasks. + opts=() + tasks=() + + # Add help options. + opts+=('(- 1 *)'{-h,--help}'[Display this help text.]') + + ## Complete without gruntfile. + if [[ ! -f $gruntfile ]]; then + _arguments "${opts[@]}" + return + fi + + ## Complete with gruntfile. + # Retrieve cache. + if ! __grunt_update_cache "$gruntfile"; then + update_msg=' (cache updated)' + fi + + # Make optioins completion. + if [[ ${#__grunt_opts} -gt 0 ]]; then + opts+=("${__grunt_opts[@]}") + fi + + # Complete arguments. + _arguments \ + "${opts[@]}" \ + '*: :->tasks' \ + && return + + case $state in + tasks) + if [[ $show_grunt_path == 'yes' ]]; then + update_msg="$update_msg: ${${gruntfile/#$HOME/~}%/}" + fi + # Make tasks completion. + if [[ ${#__grunt_tasks} -gt 0 ]]; then + tasks+=("${__grunt_tasks[@]}") + _describe -t grunt-task "$verbose grunt task$update_msg" tasks || return 1 + fi + ;; + esac + + return 0 +} + +# Cache policy: +# The cache file name: grunt +# The cache variable name: __grunt_version __grunt_gruntfile __grunt_opts __grunt_tasks +function __grunt_update_cache() { + # TODO + local version='0.1.0' + local is_updating=0 + local gruntfile="$1" + local grunt_info no_update_options cache_path + + # Check no_update_options option. + zstyle -b ":completion:${curcontext}:options:" no_update_options no_update_options + + + if ! ( (( $+__grunt_gruntfile )) \ + && (( $+__grunt_opts )) \ + && (( $+__grunt_tasks )) ) \ + && ! _retrieve_cache 'grunt'; then + is_updating=1 + fi + + if [[ $gruntfile != $__grunt_gruntfile ]]; then + # Except for --help options. + __grunt_gruntfile=$gruntfile + if [[ $no_update_options == 'yes' ]]; then + if [[ $PREFIX == ${PREFIX#-} ]]; then + # Not options completions. + is_updating=1 + elif [[ ${#__grunt_opts} -lt 2 ]]; then + is_updating=1 + else + unset __grunt_gruntfile + fi + else + is_updating=1 + fi + else + if [[ $PREFIX != ${PREFIX#-} && ${#__grunt_opts} -gt 1 ]]; then + unset __grunt_gruntfile + fi + fi + + if _cache_invalid 'grunt'; then + is_updating=1 + fi + + # Check _grunt version. + if [[ $__grunt_version != $version ]]; then + is_updating=1 + fi + + if [[ $is_updating -ne 0 ]]; then + # Update caceh. + __grunt_version=$version + __grunt_gruntfile=$gruntfile + is_updating=1 + grunt_info=$(grunt --help --no-color --gruntfile "$__grunt_gruntfile" 2>/dev/null) + __grunt_opts=(${(f)"$(__grunt_get_opts "$grunt_info")"}) + __grunt_tasks=(${(f)"$(__grunt_get_tasks "$grunt_info")"}) + _store_cache 'grunt' __grunt_version __grunt_gruntfile __grunt_opts __grunt_tasks + fi + return $is_updating +} + +function __grunt_get_tasks() { + echo -E "$1" \ + | grep 'Available tasks' -A 100 \ + | grep '^ ' \ + | sed -e 's/^[[:blank:]]*//' -e 's/[[:blank:]]*$//' \ + | sed -e 's/ /:/' +} + +function __grunt_get_opts() { + local opt_hunk opt_sep opt_num line opt + opt_hunk=$(echo -E "$1" \ + | grep 'Options$' -A 100 \ + | sed '1 d' \ + | sed -e 's/[[:blank:]]*$//' \ + ) + + opt_sep=() + opt_hunk=(${(f)opt_hunk}) + opt_num=0 + for line in "$opt_hunk[@]"; do + opt=$(echo -E "$line" | sed -e 's/^[[:blank:]]*//') + if [[ $line == $opt ]]; then + break + fi + if [[ $opt != ${opt#-} ]]; then + # Start with - + (( opt_num++ )) + opt=$(echo -E "$opt" | sed 's/^\(\(--[^ ]*\)\(, \(-[^ ]*\)\)*\) */\2\\t\4\\\t/') + fi + opt_sep[$opt_num]=("${opt_sep[$opt_num]}${opt}") + done + + for line in "$opt_sep[@]"; do + opt=(${(s:\t:)line}) + if [[ ${opt[1]} == '--help' ]]; then + continue + fi + if [[ ${#opt} -eq 2 ]]; then + echo -E "(${opt[1]})${opt[1]}[${opt[2]}]" + else + echo -E "(${opt[1]},${opt[2]})${opt[1]}[${opt[3]}]" + echo -E "(${opt[1]},${opt[2]})${opt[2]}[${opt[3]}]" + fi + done +} + +function __grunt_get_gruntfile() { + local gruntfile + local curpath="$PWD" + while [ "$curpath" ]; do + for gruntfile in "$curpath/"{G,g}runtfile.{js,coffee}; do + if [[ -e "$gruntfile" ]]; then + echo "$gruntfile" + return + fi + done + curpath=${curpath%/*} + done + return 1 +} + +function __grunt_caching_policy() { + # Returns status zero if the completions cache needs rebuilding. + + # Rebuild if .agignore more recent than cache. + if [[ -f $__grunt_gruntfile && $__grunt_gruntfile -nt $1 ]]; then + # Invalid cache because gruntfile is old. + return 0 + fi + + local -a oldp + local expire + zstyle -s ":completion:${curcontext}:options:" expire expire || expire=7 + # Rebuild if cache is more than $expire days. + oldp=( "$1"(Nm+$expire) ) + (( $#oldp )) +} + +compdef _grunt grunt From 1af012d4991a36bfb0e2def3e67f5a0e56fc49e4 Mon Sep 17 00:00:00 2001 From: Dmitri Akatov Date: Tue, 6 Aug 2013 13:28:52 -0700 Subject: [PATCH 003/158] carton was renamed to cask --- plugins/carton/carton.plugin.zsh | 6 ------ plugins/cask/cask.plugin.zsh | 5 +++++ 2 files changed, 5 insertions(+), 6 deletions(-) delete mode 100644 plugins/carton/carton.plugin.zsh create mode 100644 plugins/cask/cask.plugin.zsh diff --git a/plugins/carton/carton.plugin.zsh b/plugins/carton/carton.plugin.zsh deleted file mode 100644 index 23868b09..00000000 --- a/plugins/carton/carton.plugin.zsh +++ /dev/null @@ -1,6 +0,0 @@ -if which carton &> /dev/null -then - source $(dirname $(which carton))/../etc/carton_completion.zsh -else - print "zsh carton plugin: carton not found" -fi diff --git a/plugins/cask/cask.plugin.zsh b/plugins/cask/cask.plugin.zsh new file mode 100644 index 00000000..c5586292 --- /dev/null +++ b/plugins/cask/cask.plugin.zsh @@ -0,0 +1,5 @@ +if which cask &> /dev/null; then + source $(dirname $(which cask))/../etc/cask_completion.zsh +else + print "zsh cask plugin: cask not found" +fi From a7c88c988a4be02b8883c06e57c6eb290c8fcb21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A4ntz=20Miccoli?= Date: Sun, 15 Sep 2013 23:16:11 +0200 Subject: [PATCH 004/158] Removed comments and other elements that might appear in the phing -l output. The current version doesn't work at all on my environment (OSX 10.7) --- plugins/phing/phing.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/phing/phing.plugin.zsh b/plugins/phing/phing.plugin.zsh index 795f1db8..9af03af2 100644 --- a/plugins/phing/phing.plugin.zsh +++ b/plugins/phing/phing.plugin.zsh @@ -7,7 +7,7 @@ _phing_does_target_list_need_generating () { _phing () { if [ -f build.xml ]; then if _phing_does_target_list_need_generating; then - phing -l |grep -v ":$" |grep -v "^-*$" > .phing_targets + phing -l|grep -v "\[property\]"|grep -v "Buildfile"|sed 1d|grep -v ":$" |grep -v "^\-*$"|awk '{print $1}' > .phing_targets fi compadd `cat .phing_targets` fi From 33ef34baa5f703ee7fcc502eabed4f1ab968127e Mon Sep 17 00:00:00 2001 From: Mitchel Humpherys Date: Tue, 7 Jan 2014 12:47:58 -0800 Subject: [PATCH 005/158] Fix gmt compdef Fix typo: gm -> gmt --- plugins/git/git.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/git/git.plugin.zsh b/plugins/git/git.plugin.zsh index 9f7819df..c579d1e8 100644 --- a/plugins/git/git.plugin.zsh +++ b/plugins/git/git.plugin.zsh @@ -82,7 +82,7 @@ alias gwc='git whatchanged -p --abbrev-commit --pretty=medium' alias gpoat='git push origin --all && git push origin --tags' alias gmt='git mergetool --no-prompt' -compdef _git gm=git-mergetool +compdef _git gmt=git-mergetool alias gg='git gui citool' alias gga='git gui citool --amend' From d3acea3965ebe13d6ed9885984ba8f5cc8ab4936 Mon Sep 17 00:00:00 2001 From: Zbigniew Siciarz Date: Sat, 14 Dec 2013 18:57:46 +0100 Subject: [PATCH 006/158] Updated cabal plugin with Cabal 1.18 commands. --- plugins/cabal/cabal.plugin.zsh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/plugins/cabal/cabal.plugin.zsh b/plugins/cabal/cabal.plugin.zsh index 9f76add7..acd7f828 100644 --- a/plugins/cabal/cabal.plugin.zsh +++ b/plugins/cabal/cabal.plugin.zsh @@ -23,6 +23,7 @@ function _cabal_commands() { "copy:Copy teh files into the install locations" "configure:Prepare to build the package" "fetch:Downloads packages for later installation" + "get:Gets a package's source code" "haddock:Generate HAddock HTML documentation" "help:Help about commands" "hscolour:Generate HsColour colourised code, in HTML format" @@ -31,7 +32,10 @@ function _cabal_commands() { "install:Installs a list of packages" "list:List packages matching a search string" "register:Register this package with the compiler" + "repl:Open an interpreter session for the given target" "report:Upload build reports to a remote server" + "run:Runs the compiled executable" + "sandbox:Create/modify/delete a sandbox" "sdist:Generate a source distribution file (.tar.gz)" "test:Run the test suite, if any (configure with UserHooks)" "unpack:Unpacks packages for user inspection" From 859a37d4f14838b20d09b8d7814f270d9b54b8e5 Mon Sep 17 00:00:00 2001 From: Zbigniew Siciarz Date: Sun, 8 Jun 2014 12:04:52 +0200 Subject: [PATCH 007/158] Fixed typo in cabal plugin. --- plugins/cabal/cabal.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/cabal/cabal.plugin.zsh b/plugins/cabal/cabal.plugin.zsh index acd7f828..3e611ddc 100644 --- a/plugins/cabal/cabal.plugin.zsh +++ b/plugins/cabal/cabal.plugin.zsh @@ -20,7 +20,7 @@ function _cabal_commands() { "build:Make this package ready for installation" "check:Check the package for common mistakes" "clean:Clean up after a build" - "copy:Copy teh files into the install locations" + "copy:Copy the files into the install locations" "configure:Prepare to build the package" "fetch:Downloads packages for later installation" "get:Gets a package's source code" From 1ab0f771bc85bbdd86d14e616281cc138c3afe91 Mon Sep 17 00:00:00 2001 From: Zbigniew Siciarz Date: Sun, 8 Jun 2014 12:08:02 +0200 Subject: [PATCH 008/158] Updated cabal commands for Cabal 1.20 --- plugins/cabal/cabal.plugin.zsh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/plugins/cabal/cabal.plugin.zsh b/plugins/cabal/cabal.plugin.zsh index 3e611ddc..b59438f9 100644 --- a/plugins/cabal/cabal.plugin.zsh +++ b/plugins/cabal/cabal.plugin.zsh @@ -17,14 +17,15 @@ function _cabal_commands() { subcommand) subcommands=( "bench:Run the benchmark, if any (configure with UserHooks)" - "build:Make this package ready for installation" + "build:Compile all targets or specific target." "check:Check the package for common mistakes" "clean:Clean up after a build" "copy:Copy the files into the install locations" "configure:Prepare to build the package" + "exec:Run a command with the cabal environment" "fetch:Downloads packages for later installation" "get:Gets a package's source code" - "haddock:Generate HAddock HTML documentation" + "haddock:Generate Haddock HTML documentation" "help:Help about commands" "hscolour:Generate HsColour colourised code, in HTML format" "info:Display detailed information about a particular package" From 1274a5e3ab23720e64cf2044cdbe6aa86d402864 Mon Sep 17 00:00:00 2001 From: Zbigniew Siciarz Date: Mon, 9 Jun 2014 21:03:09 +0200 Subject: [PATCH 009/158] Added cabal freeze subcommand. --- plugins/cabal/cabal.plugin.zsh | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/cabal/cabal.plugin.zsh b/plugins/cabal/cabal.plugin.zsh index b59438f9..148af5cc 100644 --- a/plugins/cabal/cabal.plugin.zsh +++ b/plugins/cabal/cabal.plugin.zsh @@ -24,6 +24,7 @@ function _cabal_commands() { "configure:Prepare to build the package" "exec:Run a command with the cabal environment" "fetch:Downloads packages for later installation" + "freeze:Freeze dependencies." "get:Gets a package's source code" "haddock:Generate Haddock HTML documentation" "help:Help about commands" From 9c11202fde61bf3db6755f4083c320d710fe3bd5 Mon Sep 17 00:00:00 2001 From: frantzmiccoli Date: Fri, 13 Jun 2014 20:28:37 +0200 Subject: [PATCH 010/158] fix `-nt` usage --- plugins/phing/phing.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/phing/phing.plugin.zsh b/plugins/phing/phing.plugin.zsh index 9af03af2..1f022047 100644 --- a/plugins/phing/phing.plugin.zsh +++ b/plugins/phing/phing.plugin.zsh @@ -1,6 +1,6 @@ _phing_does_target_list_need_generating () { [ ! -f .phing_targets ] && return 0; - [ .phing_targets -nt build.xml ] && return 0; + [ build.xml -nt .phing_targets ] && return 0; return 1; } From 49e10ae449d2e5570542e4f9011ea4e2fb14a348 Mon Sep 17 00:00:00 2001 From: Daniel Oaks Date: Thu, 14 Aug 2014 00:01:35 +1000 Subject: [PATCH 011/158] Make 'ys' theme use hg repo info too --- themes/ys.zsh-theme | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/themes/ys.zsh-theme b/themes/ys.zsh-theme index a44f295f..9332b677 100644 --- a/themes/ys.zsh-theme +++ b/themes/ys.zsh-theme @@ -14,12 +14,35 @@ function box_name { # Directory info. local current_dir='${PWD/#$HOME/~}' +# VCS +YS_VCS_PROMPT_PREFIX1=" %{$fg[white]%}on%{$reset_color%} " +YS_VCS_PROMPT_PREFIX2=":%{$fg[cyan]%}" +YS_VCS_PROMPT_SUFFIX="%{$reset_color%}" +YS_VCS_PROMPT_DIRTY=" %{$fg[red]%}x" +YS_VCS_PROMPT_CLEAN=" %{$fg[green]%}o" + # Git info. local git_info='$(git_prompt_info)' -ZSH_THEME_GIT_PROMPT_PREFIX=" %{$fg[white]%}on%{$reset_color%} git:%{$fg[cyan]%}" -ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}" -ZSH_THEME_GIT_PROMPT_DIRTY=" %{$fg[red]%}x" -ZSH_THEME_GIT_PROMPT_CLEAN=" %{$fg[green]%}o" +ZSH_THEME_GIT_PROMPT_PREFIX="${YS_VCS_PROMPT_PREFIX1}git${YS_VCS_PROMPT_PREFIX2}" +ZSH_THEME_GIT_PROMPT_SUFFIX="$YS_VCS_PROMPT_SUFFIX" +ZSH_THEME_GIT_PROMPT_DIRTY="$YS_VCS_PROMPT_DIRTY" +ZSH_THEME_GIT_PROMPT_CLEAN="$YS_VCS_PROMPT_CLEAN" + +# HG info +local hg_info='$(ys_hg_prompt_info)' +ys_hg_prompt_info() { + # make sure this is a hg dir + if [ -d '.hg' ]; then + echo -n "${YS_VCS_PROMPT_PREFIX1}hg${YS_VCS_PROMPT_PREFIX2}" + echo -n $(hg branch 2>/dev/null) + if [ -n "$(hg status 2>/dev/null)" ]; then + echo -n "$YS_VCS_PROMPT_DIRTY" + else + echo -n "$YS_VCS_PROMPT_CLEAN" + fi + echo -n "$YS_VCS_PROMPT_SUFFIX" + fi +} # Prompt format: \n # USER at MACHINE in DIRECTORY on git:BRANCH STATE [TIME] \n $ PROMPT=" @@ -29,6 +52,7 @@ PROMPT=" %{$fg[green]%}$(box_name) \ %{$fg[white]%}in \ %{$terminfo[bold]$fg[yellow]%}${current_dir}%{$reset_color%}\ +${hg_info}\ ${git_info} \ %{$fg[white]%}[%*] %{$terminfo[bold]$fg[red]%}$ %{$reset_color%}" @@ -41,6 +65,7 @@ PROMPT=" %{$fg[green]%}$(box_name) \ %{$fg[white]%}in \ %{$terminfo[bold]$fg[yellow]%}${current_dir}%{$reset_color%}\ +${hg_info}\ ${git_info} \ %{$fg[white]%}[%*] %{$terminfo[bold]$fg[red]%}$ %{$reset_color%}" From 1e7c6743a7b221cb2069a84c70890014597672d8 Mon Sep 17 00:00:00 2001 From: Giel van Schijndel Date: Mon, 15 Sep 2014 15:36:34 +0200 Subject: [PATCH 012/158] sudo: maintain cursor position I.e. when prefixing the current command-line with 'sudo ' maintain the current cursor position instead of jumping to the end of the line. --- plugins/sudo/sudo.plugin.zsh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/plugins/sudo/sudo.plugin.zsh b/plugins/sudo/sudo.plugin.zsh index d12e0685..e3ba3991 100644 --- a/plugins/sudo/sudo.plugin.zsh +++ b/plugins/sudo/sudo.plugin.zsh @@ -13,9 +13,8 @@ # ------------------------------------------------------------------------------ sudo-command-line() { -[[ -z $BUFFER ]] && zle up-history -[[ $BUFFER != sudo\ * ]] && BUFFER="sudo $BUFFER" -zle end-of-line + [[ -z $BUFFER ]] && zle up-history + [[ $BUFFER != sudo\ * ]] && LBUFFER="sudo $LBUFFER" } zle -N sudo-command-line # Defined shortcut keys: [Esc] [Esc] From eb0549750fccde126584d6be59df8d2d62882750 Mon Sep 17 00:00:00 2001 From: Peter Butkovic Date: Tue, 16 Sep 2014 10:35:43 +0200 Subject: [PATCH 013/158] additional tmux aliases --- plugins/tmux/tmux.plugin.zsh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/plugins/tmux/tmux.plugin.zsh b/plugins/tmux/tmux.plugin.zsh index 626c41f3..bc32c890 100644 --- a/plugins/tmux/tmux.plugin.zsh +++ b/plugins/tmux/tmux.plugin.zsh @@ -5,6 +5,8 @@ alias ta='tmux attach -t' alias ts='tmux new-session -s' alias tl='tmux list-sessions' +alias tksv='tmux kill-server' +alias tkss='tmux kill-session -t' # Only run if tmux is actually installed if which tmux &> /dev/null From b0013ceb29e4214a76c92bfbdc0d87354c374277 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rodrigo=20Ram=C3=ADrez=20Norambuena?= Date: Mon, 15 Sep 2014 12:13:43 -0300 Subject: [PATCH 014/158] remove path not found for linuxonly theme --- themes/linuxonly.zsh-theme | 1 - 1 file changed, 1 deletion(-) diff --git a/themes/linuxonly.zsh-theme b/themes/linuxonly.zsh-theme index a11b80d7..f9e0aa07 100644 --- a/themes/linuxonly.zsh-theme +++ b/themes/linuxonly.zsh-theme @@ -13,7 +13,6 @@ local c7=$(printf "\033[38;5;149m") local c8=$(printf "\033[38;5;126m") local c9=$(printf "\033[38;5;162m") -local foopath=$(perl /home/scp1/bin/foopath) if [ "$TERM" = "linux" ]; then c1=$(printf "\033[34;1m") From e16d3e45d30fbf981f503b4d078d84c71a070a1d Mon Sep 17 00:00:00 2001 From: Tim O'Brien Date: Thu, 6 Nov 2014 10:34:26 -0800 Subject: [PATCH 015/158] Add bgnotify plugin, a cross-platform background notifier! --- plugins/bgnotify/README.md | 39 +++++++++++++++++ plugins/bgnotify/bgnotify.plugin.zsh | 65 ++++++++++++++++++++++++++++ 2 files changed, 104 insertions(+) create mode 100644 plugins/bgnotify/README.md create mode 100755 plugins/bgnotify/bgnotify.plugin.zsh diff --git a/plugins/bgnotify/README.md b/plugins/bgnotify/README.md new file mode 100644 index 00000000..bf4b1fd0 --- /dev/null +++ b/plugins/bgnotify/README.md @@ -0,0 +1,39 @@ +# bgnotify zsh plugin + +cross-platform background notifications for long running commands! Supports OSX and Ubuntu linux. + +Standalone homepage: [t413/zsh-background-notify](https://github.com/t413/zsh-background-notify) + +---------------------------------- + +## How to use! + +Just add bgnotify to your plugins list in your `.zshrc` + +- On OS X you'll need [terminal-notifer](https://github.com/alloy/terminal-notifier) + * `brew install terminal-notifier` (or `gem install terminal-notifier`) +- On ubuntu you're already all set! + + +## Configuration + +One can configure a few things: + +- `bgnotify_threshold` sets the notification threshold time (default 6 seconds) +- `function bgnotify_formatted` lets you change the notification + +Use these by adding a function definition before the your call to source. Example: + +~~~ sh +bgnotify_threshold=4 ## set your own notification threshold + +function bgnotify_formatted { + ## $1=exit_status, $2=command, $3=elapsed_time + [ $1 -eq 0 ] && title="Holy Smokes Batman!" || title="Holy Graf Zeppelin!" + bgnotify "$title -- after $3 s" "$2"; +} + +plugins=(git bgnotify) ## add to plugins list +source $ZSH/oh-my-zsh.sh ## existing source call +~~~ + diff --git a/plugins/bgnotify/bgnotify.plugin.zsh b/plugins/bgnotify/bgnotify.plugin.zsh new file mode 100755 index 00000000..f204d9dc --- /dev/null +++ b/plugins/bgnotify/bgnotify.plugin.zsh @@ -0,0 +1,65 @@ +#!/usr/bin/env zsh + + +## setup ## + +[[ -o interactive ]] || return #interactive only! +zmodload zsh/datetime || { print "can't load zsh/datetime"; return } # faster than date() +autoload -Uz add-zsh-hook || { print "can't add zsh hook!"; return } + +(( ${+bgnotify_threshold} )) || bgnotify_threshold=5 #default 10 seconds + + +## definitions ## + +if ! (type notify_formatted | grep -q 'function'); then + echo "using default notify_formatted" + function bgnotify_formatted { + ## exit_status, command, elapsed_time + [ $1 -eq 0 ] && title="#win (took $3 s)" || title="#fail (took $3 s)" + bgnotify "$title" "$2" + } +fi + +currentWindowId () { + if hash notify-send 2>/dev/null; then #ubuntu! + xprop -root | awk '/NET_ACTIVE_WINDOW/ { print $5; exit }' + elif 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 + fi +} + +bgnotify () { + if hash notify-send 2>/dev/null; then #ubuntu! + notify-send $1 $2 + elif hash terminal-notifier 2>/dev/null; then #osx + terminal-notifier -message $2 -title $1 + elif hash growlnotify 2>/dev/null; then #osx growl + growlnotify -m $1 $2 + fi +} + + +## Zsh hooks ## + +bgnotify_begin() { + bgnotify_timestamp=$EPOCHSECONDS + bgnotify_lastcmd=$1 + bgnotify_windowid=$(currentWindowId) +} + +bgnotify_end() { + didexit=$? + elapsed=$(( $EPOCHSECONDS - $bgnotify_timestamp )) + past_threshold=$(( $elapsed >= $bgnotify_threshold )) + if (( bgnotify_timestamp > 0 )) && (( past_threshold )); then + if [ $(currentWindowId) != "$bgnotify_windowid" ]; then + print -n "\a" + bgnotify_formatted "$didexit" "$bgnotify_lastcmd" "$elapsed" + fi + fi + bgnotify_timestamp=0 #reset it to 0! +} + +add-zsh-hook preexec bgnotify_begin +add-zsh-hook precmd bgnotify_end From 0b0cc2cdea1e3b3e4af78d8d4a9992be468031eb Mon Sep 17 00:00:00 2001 From: Tim O'Brien Date: Thu, 6 Nov 2014 10:31:27 -0800 Subject: [PATCH 016/158] Fixed math on linux, removed debug echo. --- plugins/bgnotify/bgnotify.plugin.zsh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/plugins/bgnotify/bgnotify.plugin.zsh b/plugins/bgnotify/bgnotify.plugin.zsh index f204d9dc..b5fb76f7 100755 --- a/plugins/bgnotify/bgnotify.plugin.zsh +++ b/plugins/bgnotify/bgnotify.plugin.zsh @@ -13,7 +13,6 @@ autoload -Uz add-zsh-hook || { print "can't add zsh hook!"; return } ## definitions ## if ! (type notify_formatted | grep -q 'function'); then - echo "using default notify_formatted" function bgnotify_formatted { ## exit_status, command, elapsed_time [ $1 -eq 0 ] && title="#win (took $3 s)" || title="#fail (took $3 s)" @@ -50,8 +49,8 @@ bgnotify_begin() { bgnotify_end() { didexit=$? - elapsed=$(( $EPOCHSECONDS - $bgnotify_timestamp )) - past_threshold=$(( $elapsed >= $bgnotify_threshold )) + elapsed=$(( EPOCHSECONDS - bgnotify_timestamp )) + past_threshold=$(( elapsed >= bgnotify_threshold )) if (( bgnotify_timestamp > 0 )) && (( past_threshold )); then if [ $(currentWindowId) != "$bgnotify_windowid" ]; then print -n "\a" From adafe271f02ab767c29f80f5657f448d593cdaf6 Mon Sep 17 00:00:00 2001 From: Tim O'Brien Date: Thu, 6 Nov 2014 10:32:29 -0800 Subject: [PATCH 017/158] add cygwin windows support with notifu, add to readme --- plugins/bgnotify/README.md | 2 +- plugins/bgnotify/bgnotify.plugin.zsh | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/plugins/bgnotify/README.md b/plugins/bgnotify/README.md index bf4b1fd0..68fa7529 100644 --- a/plugins/bgnotify/README.md +++ b/plugins/bgnotify/README.md @@ -13,6 +13,7 @@ Just add bgnotify to your plugins list in your `.zshrc` - On OS X you'll need [terminal-notifer](https://github.com/alloy/terminal-notifier) * `brew install terminal-notifier` (or `gem install terminal-notifier`) - On ubuntu you're already all set! +- On windows you can use [notifu](http://www.paralint.com/projects/notifu/) or the Cygwin Ports libnotify package ## Configuration @@ -36,4 +37,3 @@ function bgnotify_formatted { plugins=(git bgnotify) ## add to plugins list source $ZSH/oh-my-zsh.sh ## existing source call ~~~ - diff --git a/plugins/bgnotify/bgnotify.plugin.zsh b/plugins/bgnotify/bgnotify.plugin.zsh index b5fb76f7..42129bd0 100755 --- a/plugins/bgnotify/bgnotify.plugin.zsh +++ b/plugins/bgnotify/bgnotify.plugin.zsh @@ -35,6 +35,8 @@ bgnotify () { terminal-notifier -message $2 -title $1 elif hash growlnotify 2>/dev/null; then #osx growl growlnotify -m $1 $2 + elif hash notifu 2>/dev/null; then #cygwyn support! + notifu /m "$2" /p "$1" fi } From 3d376bbd5b0a230e9e1a2d5497623d92ec94615e Mon Sep 17 00:00:00 2001 From: Tim O'Brien Date: Fri, 7 Nov 2014 08:35:31 -0800 Subject: [PATCH 018/158] Fix renamed method issue. --- 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 42129bd0..72221373 100755 --- a/plugins/bgnotify/bgnotify.plugin.zsh +++ b/plugins/bgnotify/bgnotify.plugin.zsh @@ -12,7 +12,7 @@ autoload -Uz add-zsh-hook || { print "can't add zsh hook!"; return } ## definitions ## -if ! (type notify_formatted | grep -q 'function'); then +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)" From cbec1d77b2b238eadcdad5d926339d4a034240e9 Mon Sep 17 00:00:00 2001 From: Tim O'Brien Date: Fri, 7 Nov 2014 10:57:02 -0800 Subject: [PATCH 019/158] Add window ID fallback for windows. - maybe someday use GetForegroundWindow() from User32.lib ... --- plugins/bgnotify/bgnotify.plugin.zsh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/plugins/bgnotify/bgnotify.plugin.zsh b/plugins/bgnotify/bgnotify.plugin.zsh index 72221373..f3cf0e3b 100755 --- a/plugins/bgnotify/bgnotify.plugin.zsh +++ b/plugins/bgnotify/bgnotify.plugin.zsh @@ -25,6 +25,8 @@ currentWindowId () { xprop -root | awk '/NET_ACTIVE_WINDOW/ { print $5; exit }' elif 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 + else + echo $EPOCHSECONDS #fallback for windows fi } From 8bd8597e12d25ada4a288bffef946ac62b9f9de4 Mon Sep 17 00:00:00 2001 From: Ian Lancaster Date: Sat, 8 Nov 2014 04:58:52 -0500 Subject: [PATCH 020/158] Remove deprecated brew commands, update core commands `brew services` and `brew server` were moved to homebrew-boneyard. --- plugins/brew/_brew | 38 +++++++++----------------------------- 1 file changed, 9 insertions(+), 29 deletions(-) diff --git a/plugins/brew/_brew b/plugins/brew/_brew index 40442a1d..d11aa245 100644 --- a/plugins/brew/_brew +++ b/plugins/brew/_brew @@ -19,21 +19,18 @@ _brew_outdated_formulae() { outdated_formulae=(`brew outdated`) } -_brew_running_services() { - running_services=(`brew services list | awk '{print $1}'`) -} - local -a _1st_arguments _1st_arguments=( 'audit:check formulae for Homebrew coding style' - 'bundle:look for a Brewfile and run each line as a brew command' 'cat:display formula file for a formula' 'cleanup:uninstall unused and old versions of packages' 'commands:show a list of commands' 'create:create a new formula' - 'deps:list dependencies and dependants of a formula' + 'deps:list dependencies of a formula' 'doctor:audits your installation for common issues' 'edit:edit a formula' + 'fetch:download formula resources to the cache' + 'gist-logs:generate a gist of the full build logs' 'home:visit the homepage of a formula or the brew project' 'info:information about a formula' 'install:install a formula' @@ -44,32 +41,24 @@ _1st_arguments=( 'missing:check all installed formuale for missing dependencies.' 'outdated:list formulae for which a newer version is available' 'pin:pin specified formulae' + 'postinstall:perform post_install for a given formula' 'prune:remove dead links' 'remove:remove a formula' 'search:search for a formula (/regex/ or string)' - 'server:start a local web app that lets you browse formulae (requires Sinatra)' - 'services:small wrapper around `launchctl` for supported formulae' + 'switch:switch linkage between installed versions of a formula' 'tap:tap a new formula repository from GitHub, or list existing taps' + 'test-bot:test a formula and build a bottle' 'uninstall:uninstall a formula' 'unlink:unlink a formula' 'unpin:unpin specified formulae' 'untap:remove a tapped repository' - 'update:freshen up links' + 'update:pull latest repository' 'upgrade:upgrade outdated formulae' 'uses:show formulae which depend on a formula' ) -local -a _service_arguments -_service_arguments=( - 'cleanup:get rid of stale services and unused plists' - 'list:list all services managed by `brew services`' - 'restart:gracefully restart selected service' - 'start:start selected service' - 'stop:stop selected service' -) - local expl -local -a formulae installed_formulae installed_taps outdated_formulae running_services +local -a formulae installed_formulae installed_taps outdated_formulae _arguments \ '(-v)-v[verbose]' \ @@ -80,6 +69,7 @@ _arguments \ '(--version)--version[version information]' \ '(--prefix)--prefix[where brew lives on this system]' \ '(--cache)--cache[brew cache]' \ + '(--force)--force[brew force]' \ '*:: :->subcmds' && return 0 if (( CURRENT == 1 )); then @@ -109,16 +99,6 @@ case "$words[1]" in _arguments \ '(--macports)--macports[search the macports repository]' \ '(--fink)--fink[search the fink repository]' ;; - services) - if [[ -n "$words[2]" ]]; then - case "$words[2]" in - restart|start|stop) - _brew_running_services - _wanted running_services expl 'running services' compadd -a running_services ;; - esac - else - _describe -t commands "brew services subcommand" _service_arguments - fi ;; untap) _brew_installed_taps _wanted installed_taps expl 'installed taps' compadd -a installed_taps ;; From 98fc8dd91adb5e8754b857127c4d121871d5fadb Mon Sep 17 00:00:00 2001 From: Tim O'Brien Date: Sat, 8 Nov 2014 14:16:56 -0800 Subject: [PATCH 021/158] Fix for OS X when no window id is returned (like on the desktop) --- 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 f3cf0e3b..259d2742 100755 --- a/plugins/bgnotify/bgnotify.plugin.zsh +++ b/plugins/bgnotify/bgnotify.plugin.zsh @@ -24,7 +24,7 @@ currentWindowId () { if hash notify-send 2>/dev/null; then #ubuntu! xprop -root | awk '/NET_ACTIVE_WINDOW/ { print $5; exit }' elif 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 + osascript -e 'tell application (path to frontmost application as text) to id of front window' 2&> /dev/null || echo "0" else echo $EPOCHSECONDS #fallback for windows fi From fd69c34e0ccb8b7754b05e6f0c797abddb00f920 Mon Sep 17 00:00:00 2001 From: Tim O'Brien Date: Sat, 8 Nov 2014 14:20:37 -0800 Subject: [PATCH 022/158] Add screenshots to readme --- plugins/bgnotify/README.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/plugins/bgnotify/README.md b/plugins/bgnotify/README.md index 68fa7529..b154916d 100644 --- a/plugins/bgnotify/README.md +++ b/plugins/bgnotify/README.md @@ -16,6 +16,21 @@ Just add bgnotify to your plugins list in your `.zshrc` - On windows you can use [notifu](http://www.paralint.com/projects/notifu/) or the Cygwin Ports libnotify package +## Screenshots + +**Linux** + +![screenshot from 2014-11-07 15 58 36](https://cloud.githubusercontent.com/assets/326829/4962187/256b465c-66da-11e4-927d-cc2fc105e31f.png) + +**OS X** + +![screenshot 2014-11-08 14 15 12](https://cloud.githubusercontent.com/assets/326829/4965780/19fa3eac-6795-11e4-8ed6-0355711123a9.png) + +**Windows** + +![screenshot from 2014-11-07 15 55 00](https://cloud.githubusercontent.com/assets/326829/4962159/a2625ca0-66d9-11e4-9e91-c5834913190e.png) + + ## Configuration One can configure a few things: From 00ec11d3c0a2b2b7413ad84940ddec299aafbb04 Mon Sep 17 00:00:00 2001 From: DanielFGray Date: Sun, 16 Nov 2014 02:47:35 -0600 Subject: [PATCH 023/158] ignore any grep aliases that might be defined --- lib/git.zsh | 2 +- plugins/mercurial/mercurial.plugin.zsh | 2 +- plugins/svn-fast-info/svn-fast-info.plugin.zsh | 12 ++++++------ plugins/svn/svn.plugin.zsh | 4 ++-- themes/agnoster.zsh-theme | 4 ++-- themes/bureau.zsh-theme | 2 +- themes/mortalscumbag.zsh-theme | 6 +++--- 7 files changed, 16 insertions(+), 16 deletions(-) diff --git a/lib/git.zsh b/lib/git.zsh index aba09542..913a642b 100644 --- a/lib/git.zsh +++ b/lib/git.zsh @@ -78,7 +78,7 @@ function git_prompt_long_sha() { git_prompt_status() { INDEX=$(command git status --porcelain -b 2> /dev/null) STATUS="" - if $(echo "$INDEX" | grep -E '^\?\? ' &> /dev/null); then + if $(echo "$INDEX" | command grep -E '^\?\? ' &> /dev/null); then STATUS="$ZSH_THEME_GIT_PROMPT_UNTRACKED$STATUS" fi if $(echo "$INDEX" | grep '^A ' &> /dev/null); then diff --git a/plugins/mercurial/mercurial.plugin.zsh b/plugins/mercurial/mercurial.plugin.zsh index ff95d5e4..ed4d2371 100644 --- a/plugins/mercurial/mercurial.plugin.zsh +++ b/plugins/mercurial/mercurial.plugin.zsh @@ -42,7 +42,7 @@ $ZSH_THEME_REPO_NAME_COLOR$_DISPLAY$ZSH_PROMPT_BASE_COLOR$ZSH_THEME_HG_PROMPT_SU function hg_dirty_choose { if [ $(in_hg) ]; then - hg status 2> /dev/null | grep -Eq '^\s*[ACDIM!?L]' + hg status 2> /dev/null | command grep -Eq '^\s*[ACDIM!?L]' if [ $pipestatus[-1] -eq 0 ]; then # Grep exits with 0 when "One or more lines were selected", return "dirty". echo $1 diff --git a/plugins/svn-fast-info/svn-fast-info.plugin.zsh b/plugins/svn-fast-info/svn-fast-info.plugin.zsh index ea19bcea..9ea7f641 100644 --- a/plugins/svn-fast-info/svn-fast-info.plugin.zsh +++ b/plugins/svn-fast-info/svn-fast-info.plugin.zsh @@ -63,11 +63,11 @@ function svn_current_revision() { function svn_status_info() { local svn_status_string="$ZSH_THEME_SVN_PROMPT_CLEAN" local svn_status="$(svn status 2> /dev/null)"; - if grep -E '^\s*A' &> /dev/null <<< $svn_status; then svn_status_string="$svn_status_string ${ZSH_THEME_SVN_PROMPT_ADDITIONS:-+}"; fi - if grep -E '^\s*D' &> /dev/null <<< $svn_status; then svn_status_string="$svn_status_string ${ZSH_THEME_SVN_PROMPT_DELETIONS:-✖}"; fi - if grep -E '^\s*M' &> /dev/null <<< $svn_status; then svn_status_string="$svn_status_string ${ZSH_THEME_SVN_PROMPT_MODIFICATIONS:-✎}"; fi - if grep -E '^\s*[R~]' &> /dev/null <<< $svn_status; then svn_status_string="$svn_status_string ${ZSH_THEME_SVN_PROMPT_REPLACEMENTS:-∿}"; fi - if grep -E '^\s*\?' &> /dev/null <<< $svn_status; then svn_status_string="$svn_status_string ${ZSH_THEME_SVN_PROMPT_UNTRACKED:-?}"; fi - if grep -E '^\s*[CI!L]' &> /dev/null <<< $svn_status; then svn_status_string="$svn_status_string ${ZSH_THEME_SVN_PROMPT_DIRTY:-'!'}"; fi + if command grep -E '^\s*A' &> /dev/null <<< $svn_status; then svn_status_string="$svn_status_string ${ZSH_THEME_SVN_PROMPT_ADDITIONS:-+}"; fi + if command grep -E '^\s*D' &> /dev/null <<< $svn_status; then svn_status_string="$svn_status_string ${ZSH_THEME_SVN_PROMPT_DELETIONS:-✖}"; fi + if command grep -E '^\s*M' &> /dev/null <<< $svn_status; then svn_status_string="$svn_status_string ${ZSH_THEME_SVN_PROMPT_MODIFICATIONS:-✎}"; fi + if command grep -E '^\s*[R~]' &> /dev/null <<< $svn_status; then svn_status_string="$svn_status_string ${ZSH_THEME_SVN_PROMPT_REPLACEMENTS:-∿}"; fi + if command grep -E '^\s*\?' &> /dev/null <<< $svn_status; then svn_status_string="$svn_status_string ${ZSH_THEME_SVN_PROMPT_UNTRACKED:-?}"; fi + if command grep -E '^\s*[CI!L]' &> /dev/null <<< $svn_status; then svn_status_string="$svn_status_string ${ZSH_THEME_SVN_PROMPT_DIRTY:-'!'}"; fi echo $svn_status_string } diff --git a/plugins/svn/svn.plugin.zsh b/plugins/svn/svn.plugin.zsh index ba281d79..9f7a4c6e 100644 --- a/plugins/svn/svn.plugin.zsh +++ b/plugins/svn/svn.plugin.zsh @@ -61,7 +61,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'` - if $(svn status $root 2> /dev/null | grep -Eq '^\s*[ACDIM!?L]'); then + 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 else @@ -78,7 +78,7 @@ function svn_dirty() { function svn_dirty_choose_pwd () { if in_svn; then root=$PWD - if $(svn status $root 2> /dev/null | grep -Eq '^\s*[ACDIM!?L]'); then + 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 else diff --git a/themes/agnoster.zsh-theme b/themes/agnoster.zsh-theme index 7a62bd86..8c7be6e0 100644 --- a/themes/agnoster.zsh-theme +++ b/themes/agnoster.zsh-theme @@ -123,10 +123,10 @@ prompt_hg() { st="" rev=$(hg id -n 2>/dev/null | sed 's/[^-0-9]//g') branch=$(hg id -b 2>/dev/null) - if `hg st | grep -Eq "^\?"`; then + if `hg st | grep -q "^\?"`; then prompt_segment red black st='±' - elif `hg st | grep -Eq "^(M|A)"`; then + elif `hg st | grep -q "^(M|A)"`; then prompt_segment yellow black st='±' else diff --git a/themes/bureau.zsh-theme b/themes/bureau.zsh-theme index 443d1d5e..148abec1 100644 --- a/themes/bureau.zsh-theme +++ b/themes/bureau.zsh-theme @@ -31,7 +31,7 @@ bureau_git_status () { if $(echo "$_INDEX" | grep '^.[MTD] ' &> /dev/null); then _STATUS="$_STATUS$ZSH_THEME_GIT_PROMPT_UNSTAGED" fi - if $(echo "$_INDEX" | grep -E '^\?\? ' &> /dev/null); then + if $(echo "$_INDEX" | command grep -E '^\?\? ' &> /dev/null); then _STATUS="$_STATUS$ZSH_THEME_GIT_PROMPT_UNTRACKED" fi if $(echo "$_INDEX" | grep '^UU ' &> /dev/null); then diff --git a/themes/mortalscumbag.zsh-theme b/themes/mortalscumbag.zsh-theme index 5dbf2e4f..ccce4197 100644 --- a/themes/mortalscumbag.zsh-theme +++ b/themes/mortalscumbag.zsh-theme @@ -10,12 +10,12 @@ function my_git_prompt() { fi # is anything staged? - if $(echo "$INDEX" | grep -E -e '^(D[ M]|[MARC][ MD]) ' &> /dev/null); then + if $(echo "$INDEX" | command grep -E -e '^(D[ M]|[MARC][ MD]) ' &> /dev/null); then STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_STAGED" fi # is anything unstaged? - if $(echo "$INDEX" | grep -E -e '^[ MARC][MD] ' &> /dev/null); then + if $(echo "$INDEX" | command grep -E -e '^[ MARC][MD] ' &> /dev/null); then STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_UNSTAGED" fi @@ -25,7 +25,7 @@ function my_git_prompt() { fi # is anything unmerged? - if $(echo "$INDEX" | grep -E -e '^(A[AU]|D[DU]|U[ADU]) ' &> /dev/null); then + if $(echo "$INDEX" | command grep -E -e '^(A[AU]|D[DU]|U[ADU]) ' &> /dev/null); then STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_UNMERGED" fi From 1dfadc734cb10c5512be4ec1dbe329a3e362ab20 Mon Sep 17 00:00:00 2001 From: Eric Ripa Date: Mon, 24 Nov 2014 09:54:50 +0100 Subject: [PATCH 024/158] Fix chruby plugin to not complain if chruby is *not* installed --- plugins/chruby/chruby.plugin.zsh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/chruby/chruby.plugin.zsh b/plugins/chruby/chruby.plugin.zsh index 2a2c80cf..b461b0c9 100644 --- a/plugins/chruby/chruby.plugin.zsh +++ b/plugins/chruby/chruby.plugin.zsh @@ -24,7 +24,7 @@ _homebrew-installed() { } _chruby-from-homebrew-installed() { - brew --prefix chruby &> /dev/null + [ -r $(brew --prefix chruby)] &> /dev/null } _ruby-build_installed() { @@ -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 ${_chruby_path} && [[ -r ${_chruby_path} ]]; then source ${_chruby_path} fi - if _chruby_auto && [[ -r _chruby_auto ]]; then + if ${_chruby_auto} && [[ -r ${_chruby_auto} ]]; then source ${_chruby_auto} fi } From 4b05e548d0b56238521b07dac1969e8cd2dcf608 Mon Sep 17 00:00:00 2001 From: benjaoming Date: Fri, 22 Nov 2013 11:48:13 +0100 Subject: [PATCH 025/158] Throw an error message when $WORKON_HOME is not set Took me a while to figure this one out, and I have a default installation of virtualenvwrapper -- this is a soft fix, just put an error message. But perhaps the fix should be to use the default value `~/.virtualenvs`. --- .../virtualenvwrapper.plugin.zsh | 100 ++++++++++-------- 1 file changed, 53 insertions(+), 47 deletions(-) diff --git a/plugins/virtualenvwrapper/virtualenvwrapper.plugin.zsh b/plugins/virtualenvwrapper/virtualenvwrapper.plugin.zsh index f58bda1a..52e02d3e 100644 --- a/plugins/virtualenvwrapper/virtualenvwrapper.plugin.zsh +++ b/plugins/virtualenvwrapper/virtualenvwrapper.plugin.zsh @@ -1,57 +1,63 @@ virtualenvwrapper='virtualenvwrapper.sh' if (( $+commands[$virtualenvwrapper] )); then + source ${${virtualenvwrapper}:c} - if [[ ! $DISABLE_VENV_CD -eq 1 ]]; then - # Automatically activate Git projects's virtual environments based on the - # directory name of the project. Virtual environment name can be overridden - # by placing a .venv file in the project root with a virtualenv name in it - function workon_cwd { - if [ ! $WORKON_CWD ]; then - WORKON_CWD=1 - # Check if this is a Git repo - PROJECT_ROOT=`git rev-parse --show-toplevel 2> /dev/null` - if (( $? != 0 )); then - PROJECT_ROOT="." - fi - # Check for virtualenv name override - if [[ -f "$PROJECT_ROOT/.venv" ]]; then - ENV_NAME=`cat "$PROJECT_ROOT/.venv"` - elif [[ -f "$PROJECT_ROOT/.venv/bin/activate" ]];then - ENV_NAME="$PROJECT_ROOT/.venv" - elif [[ "$PROJECT_ROOT" != "." ]]; then - ENV_NAME=`basename "$PROJECT_ROOT"` - else - ENV_NAME="" - fi - if [[ "$ENV_NAME" != "" ]]; then - # Activate the environment only if it is not already active - if [[ "$VIRTUAL_ENV" != "$WORKON_HOME/$ENV_NAME" ]]; then - if [[ -e "$WORKON_HOME/$ENV_NAME/bin/activate" ]]; then - workon "$ENV_NAME" && export CD_VIRTUAL_ENV="$ENV_NAME" - elif [[ -e "$ENV_NAME/bin/activate" ]]; then - source $ENV_NAME/bin/activate && export CD_VIRTUAL_ENV="$ENV_NAME" - fi - fi - elif [ $CD_VIRTUAL_ENV ]; then - # We've just left the repo, deactivate the environment - # Note: this only happens if the virtualenv was activated automatically - deactivate && unset CD_VIRTUAL_ENV - fi - unset PROJECT_ROOT - unset WORKON_CWD - fi - } + if [[ "$WORKON_HOME" == "" ]]; then + echo "\$WORKON_HOME is not defined so ZSH plugin virtualenvwrapper will not work" + else - # Append workon_cwd to the chpwd_functions array, so it will be called on cd - # http://zsh.sourceforge.net/Doc/Release/Functions.html - # TODO: replace with 'add-zsh-hook chpwd workon_cwd' when oh-my-zsh min version is raised above 4.3.4 - if (( ${+chpwd_functions} )); then - if (( $chpwd_functions[(I)workon_cwd] == 0 )); then - set -A chpwd_functions $chpwd_functions workon_cwd + if [[ ! $DISABLE_VENV_CD -eq 1 ]]; then + # Automatically activate Git projects's virtual environments based on the + # directory name of the project. Virtual environment name can be overridden + # by placing a .venv file in the project root with a virtualenv name in it + function workon_cwd { + if [ ! $WORKON_CWD ]; then + WORKON_CWD=1 + # Check if this is a Git repo + PROJECT_ROOT=`git rev-parse --show-toplevel 2> /dev/null` + if (( $? != 0 )); then + PROJECT_ROOT="." + fi + # Check for virtualenv name override + if [[ -f "$PROJECT_ROOT/.venv" ]]; then + ENV_NAME=`cat "$PROJECT_ROOT/.venv"` + elif [[ -f "$PROJECT_ROOT/.venv/bin/activate" ]];then + ENV_NAME="$PROJECT_ROOT/.venv" + elif [[ "$PROJECT_ROOT" != "." ]]; then + ENV_NAME=`basename "$PROJECT_ROOT"` + else + ENV_NAME="" + fi + if [[ "$ENV_NAME" != "" ]]; then + # Activate the environment only if it is not already active + if [[ "$VIRTUAL_ENV" != "$WORKON_HOME/$ENV_NAME" ]]; then + if [[ -e "$WORKON_HOME/$ENV_NAME/bin/activate" ]]; then + workon "$ENV_NAME" && export CD_VIRTUAL_ENV="$ENV_NAME" + elif [[ -e "$ENV_NAME/bin/activate" ]]; then + source $ENV_NAME/bin/activate && export CD_VIRTUAL_ENV="$ENV_NAME" + fi + fi + elif [ $CD_VIRTUAL_ENV ]; then + # We've just left the repo, deactivate the environment + # Note: this only happens if the virtualenv was activated automatically + deactivate && unset CD_VIRTUAL_ENV + fi + unset PROJECT_ROOT + unset WORKON_CWD fi - else + } + + # Append workon_cwd to the chpwd_functions array, so it will be called on cd + # http://zsh.sourceforge.net/Doc/Release/Functions.html + # TODO: replace with 'add-zsh-hook chpwd workon_cwd' when oh-my-zsh min version is raised above 4.3.4 + if (( ${+chpwd_functions} )); then + if (( $chpwd_functions[(I)workon_cwd] == 0 )); then + set -A chpwd_functions $chpwd_functions workon_cwd + fi + else set -A chpwd_functions workon_cwd + fi fi fi else From c6a8b2ea6d80e33716ce5590f4c4aff96776f06e Mon Sep 17 00:00:00 2001 From: mizabrik Date: Fri, 28 Nov 2014 19:40:56 +0300 Subject: [PATCH 026/158] Save ZSH path in newly created .zshrc --- tools/install.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/install.sh b/tools/install.sh index a53ac48a..35548005 100755 --- a/tools/install.sh +++ b/tools/install.sh @@ -23,8 +23,8 @@ fi echo "\033[0;34mUsing the Oh My Zsh template file and adding it to ~/.zshrc\033[0m" cp $ZSH/templates/zshrc.zsh-template ~/.zshrc -sed -i -e "/^ZSH=/ c\\ -ZSH=$ZSH +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" From 1ebc98b9ede5ad5084b3e504e4fc8c01cb93be71 Mon Sep 17 00:00:00 2001 From: Joe Block Date: Sun, 30 Nov 2014 17:37:47 -0800 Subject: [PATCH 027/158] Don't clobber HISTSIZE or SAVEHIST if they're already set --- lib/history.zsh | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/history.zsh b/lib/history.zsh index 1d83e56e..12dbcf4e 100644 --- a/lib/history.zsh +++ b/lib/history.zsh @@ -1,9 +1,13 @@ ## Command history configuration -if [ -z $HISTFILE ]; then +if [ -z "$HISTFILE" ]; then HISTFILE=$HOME/.zsh_history fi -HISTSIZE=10000 -SAVEHIST=10000 +if [ -z "$HISTSIZE" ]; then + HISTSIZE=10000 +fi +if [ -z "$SAVEHIST" ]; then + SAVEHIST=10000 +fi setopt extended_history setopt hist_expire_dups_first From 5bf715787a4483cafd70461417cb9a1bf8d1509f Mon Sep 17 00:00:00 2001 From: Joe Block Date: Sun, 30 Nov 2014 17:39:21 -0800 Subject: [PATCH 028/158] Existing code indents with spaces, not tabs, conform. --- lib/history.zsh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/history.zsh b/lib/history.zsh index 12dbcf4e..179c2284 100644 --- a/lib/history.zsh +++ b/lib/history.zsh @@ -3,10 +3,10 @@ if [ -z "$HISTFILE" ]; then HISTFILE=$HOME/.zsh_history fi if [ -z "$HISTSIZE" ]; then - HISTSIZE=10000 + HISTSIZE=10000 fi if [ -z "$SAVEHIST" ]; then - SAVEHIST=10000 + SAVEHIST=10000 fi setopt extended_history From 575bb91b5f2e1220e566385e2982ca4f72521819 Mon Sep 17 00:00:00 2001 From: Emil Marashliev Date: Mon, 1 Dec 2014 13:34:18 +0200 Subject: [PATCH 029/158] Added Xcode alias for deleting Derived Data. --- plugins/xcode/xcode.plugin.zsh | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/xcode/xcode.plugin.zsh b/plugins/xcode/xcode.plugin.zsh index b7b75cf9..1d1205b8 100644 --- a/plugins/xcode/xcode.plugin.zsh +++ b/plugins/xcode/xcode.plugin.zsh @@ -16,6 +16,7 @@ function xcsel { 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' From 011f25d492ab23b0f1dd50ea0f406892810e781e Mon Sep 17 00:00:00 2001 From: Ion Marusic Date: Tue, 2 Dec 2014 20:10:47 +0200 Subject: [PATCH 030/158] Fixed command autocomplete for Symfony 2.6.x --- plugins/symfony2/symfony2.plugin.zsh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/symfony2/symfony2.plugin.zsh b/plugins/symfony2/symfony2.plugin.zsh index 8df22e9a..7a19cbdd 100644 --- a/plugins/symfony2/symfony2.plugin.zsh +++ b/plugins/symfony2/symfony2.plugin.zsh @@ -5,7 +5,7 @@ _symfony_console () { } _symfony2_get_command_list () { - `_symfony_console` --no-ansi | sed "1,/Available commands/d" | awk '/^ [a-z]+/ { print $1 }' + `_symfony_console` --no-ansi | sed "1,/Available commands/d" | awk '/^ ?[a-z]+/ { print $1 }' } _symfony2 () { @@ -23,4 +23,4 @@ alias sfcl='sf cache:clear' alias sfcw='sf cache:warmup' alias sfroute='sf router:debug' alias sfcontainer='sf container:debug' -alias sfgb='sf generate:bundle' \ No newline at end of file +alias sfgb='sf generate:bundle' From a19d1d1f05281fc286991ff85010d6d431ae1d58 Mon Sep 17 00:00:00 2001 From: ZHANG Biao Date: Thu, 4 Dec 2014 11:38:37 +0800 Subject: [PATCH 031/158] autojump installed from github has mv the autojump.zsh to $HOME/.autojump/share/autojump/autojump.zsh --- plugins/autojump/autojump.plugin.zsh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/plugins/autojump/autojump.plugin.zsh b/plugins/autojump/autojump.plugin.zsh index 652d2269..4cf03640 100644 --- a/plugins/autojump/autojump.plugin.zsh +++ b/plugins/autojump/autojump.plugin.zsh @@ -1,6 +1,8 @@ if [ $commands[autojump] ]; then # check if autojump is installed if [ -f $HOME/.autojump/etc/profile.d/autojump.zsh ]; then # manual user-local installation . $HOME/.autojump/etc/profile.d/autojump.zsh + elif [ -f $HOME/.autojump/share/autojump/autojump.zsh ]; then # another manual user-local installation + . $HOME/.autojump/share/autojump/autojump.zsh elif [ -f $HOME/.nix-profile/etc/profile.d/autojump.zsh ]; then # nix installation . $HOME/.nix-profile/etc/profile.d/autojump.zsh elif [ -f /usr/share/autojump/autojump.zsh ]; then # debian and ubuntu package From 9bab8ccb89466be8bc8c579264f51b194aa89612 Mon Sep 17 00:00:00 2001 From: Anatoly Bubenkov Date: Wed, 10 Dec 2014 13:40:34 +0100 Subject: [PATCH 032/158] add current bookmark to rkj-repos theme --- themes/rkj-repos.zsh-theme | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/themes/rkj-repos.zsh-theme b/themes/rkj-repos.zsh-theme index 6289427c..eed084f1 100644 --- a/themes/rkj-repos.zsh-theme +++ b/themes/rkj-repos.zsh-theme @@ -4,7 +4,7 @@ function hg_prompt_info { hg prompt --angle-brackets "\ -%{$reset_color%}>\ +%{$reset_color%}><:%{$fg[magenta]%}%{$reset_color%}>\ %{$reset_color%}>\ %{$fg[red]%}%{$reset_color%}< patches: >" 2>/dev/null From 6f70d288cc4625142413227109bf1eeac7e2a180 Mon Sep 17 00:00:00 2001 From: zghember Date: Thu, 11 Dec 2014 19:47:29 +0800 Subject: [PATCH 033/158] Update theme "jispwoso" to support ret status and git --- themes/jispwoso.zsh-theme | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/themes/jispwoso.zsh-theme b/themes/jispwoso.zsh-theme index cdfef387..74843057 100644 --- a/themes/jispwoso.zsh-theme +++ b/themes/jispwoso.zsh-theme @@ -1,4 +1,10 @@ -PROMPT=$'%{$fg[green]%}%n@%m: %{$reset_color%}%{$fg[blue]%}%/%{$reset_color%} -%{$fg_bold[red]%}➜ %{$reset_color%} ' +local ret_status="%(?:%{$fg_bold[green]%}➜ :%{$fg_bold[red]%}➜ %s)" +PROMPT=$'%{$fg[green]%}%n@%m: %{$reset_color%}%{$fg[blue]%}%/ %{$reset_color%}%{$fg_bold[blue]%}$(git_prompt_info)%{$fg_bold[blue]%} % %{$reset_color%} +${ret_status} %{$reset_color%} ' PROMPT2="%{$fg_blod[black]%}%_> %{$reset_color%}" + +ZSH_THEME_GIT_PROMPT_PREFIX="git:(%{$fg[red]%}" +ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}" +ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[blue]%}) %{$fg[yellow]%}✗%{$reset_color%}" +ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg[blue]%})" From 9677cfb34e896a59896c4cc747108ca8e3d20e86 Mon Sep 17 00:00:00 2001 From: Rotem Yaari Date: Thu, 11 Dec 2014 23:41:47 +0200 Subject: [PATCH 034/158] Fix dircycle plugin dircycle right did not behave as expected and was fixed --- plugins/dircycle/dircycle.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/dircycle/dircycle.plugin.zsh b/plugins/dircycle/dircycle.plugin.zsh index 46a0ab26..c6b6ba78 100644 --- a/plugins/dircycle/dircycle.plugin.zsh +++ b/plugins/dircycle/dircycle.plugin.zsh @@ -5,6 +5,6 @@ eval "insert-cycledleft () { zle push-line; LBUFFER='pushd -q +1'; zle accept-line }" zle -N insert-cycledleft bindkey "\e[1;6D" insert-cycledleft -eval "insert-cycledright () { zle push-line; LBUFFER='pushd -q -0'; zle accept-line }" +eval "insert-cycledright () { zle push-line; LBUFFER='pushd -q +0'; zle accept-line }" zle -N insert-cycledright bindkey "\e[1;6C" insert-cycledright From 1d2c1e8ab80922fb673a08440a8e2b33b9231de1 Mon Sep 17 00:00:00 2001 From: "Pete \"Peteches\" McCabe" Date: Fri, 12 Dec 2014 17:37:35 +0000 Subject: [PATCH 035/158] Fixed output issues webith websearch plugin. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - if user has rm set as an alias to 'rm -i' user is prompted to whether to remove the nohup.out file. $ ddg fools nohup: ignoring input and appending output to ‘nohup.out’ rm: remove regular empty file ‘nohup.out’? - if output redirected to a file nohup will not create nohup.out and rm is unecessary. --- plugins/web-search/web-search.plugin.zsh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/plugins/web-search/web-search.plugin.zsh b/plugins/web-search/web-search.plugin.zsh index 371e3a30..28559deb 100644 --- a/plugins/web-search/web-search.plugin.zsh +++ b/plugins/web-search/web-search.plugin.zsh @@ -37,8 +37,7 @@ function web_search() { done url="${url%?}" # remove the last '+' - nohup $open_cmd "$url" - rm nohup.out + nohup $open_cmd "$url" >/dev/null 2&>1 } From 43a2e24c25531c27e502313d23c44bd5d7e0c405 Mon Sep 17 00:00:00 2001 From: Ryan Robeson Date: Fri, 12 Dec 2014 15:56:59 -0500 Subject: [PATCH 036/158] Add itunes shuffle command to OSX plugin. Added shuffle functionality to the itunes command in the OSX plugin. iTunes 12 doesn't support setting the "shuffle" property on the playlist from what I've read, so this simulates the user interacting with the iTunes interface. The toggle option "clicks" the shuffle button in the Now Playing area. This has the effect of toggling the shuffle setting on whatever is currently playing. The on and off options use the Shuffle menu bar items. Usage: itunes shuffle [on|off|toggle] --- plugins/osx/osx.plugin.zsh | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/plugins/osx/osx.plugin.zsh b/plugins/osx/osx.plugin.zsh index 2eea0d8e..d366f1fc 100644 --- a/plugins/osx/osx.plugin.zsh +++ b/plugins/osx/osx.plugin.zsh @@ -177,12 +177,43 @@ function itunes() { vol) opt="set sound volume to $1" #$1 Due to the shift ;; + shuf|shuff|shuffle) + # The shuffle property of current playlist can't be changed in iTunes 12, + # so this workaround uses AppleScript to simulate user input instead. + # Defaults to toggling when no options are given. + # The toggle option depends on the shuffle button being visible in the Now playing area. + # On and off use the menu bar items. + local state=$1 + + if [[ -n "$state" && ! "$state" =~ "^(on|off|toggle)$" ]] + then + print "Usage: itunes shuffle [on|off|toggle]. Invalid option." + return 1 + fi + + case "$state" in + on|off) + # Inspired by: http://stackoverflow.com/a/14675583 + osascript 1>/dev/null 2>&1 <<-EOF + tell application "System Events" to perform action "AXPress" of (menu item "${state}" of menu "Shuffle" of menu item "Shuffle" of menu "Controls" of menu bar item "Controls" of menu bar 1 of application process "iTunes" ) +EOF + return 0 + ;; + toggle|*) + osascript 1>/dev/null 2>&1 <<-EOF + tell application "System Events" to perform action "AXPress" of (button 2 of process "iTunes"'s window "iTunes"'s scroll area 1) +EOF + return 0 + ;; + esac + ;; ""|-h|--help) echo "Usage: itunes