From 9674a96b5bc296a767c2560757626bf2bc3a9ad3 Mon Sep 17 00:00:00 2001 From: Frank Louwers Date: Wed, 13 Feb 2013 12:02:36 +0100 Subject: [PATCH 01/42] [pj-plugin] delete ugly ls -l | awk print $9 thing to use something not depending on date format + add support for projects with spaces in them --- plugins/pj/pj.plugin.zsh | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/plugins/pj/pj.plugin.zsh b/plugins/pj/pj.plugin.zsh index ba3765b8..b98bfec3 100644 --- a/plugins/pj/pj.plugin.zsh +++ b/plugins/pj/pj.plugin.zsh @@ -18,8 +18,11 @@ function pj() { file=$1 if [[ "open" == "$file" ]] then - file=$2 + shift + file=$* cmd=(${(s: :)EDITOR}) + else + file=$* fi for project in $PROJECT_PATHS; do @@ -36,7 +39,14 @@ function pj() { alias pjo="pj open" function _pj () { - compadd `/bin/ls -l $PROJECT_PATHS 2>/dev/null | awk '{ print $9 }'` + # might be possible to improve this using glob, without the basename trick + typeset -a projects + foreach i ($PROJECT_PATHS/*) + do + projects+=`basename $i` + done + + _arguments '*:file:($projects)' } compdef _pj pj From df67f2ee30dbad61117e1886b0a4de326cb6daf7 Mon Sep 17 00:00:00 2001 From: Frank Louwers Date: Wed, 13 Feb 2013 13:39:47 +0100 Subject: [PATCH 02/42] [pj-plugin] avoid using basename. migth be (a lot?) faster --- plugins/pj/pj.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/pj/pj.plugin.zsh b/plugins/pj/pj.plugin.zsh index b98bfec3..dac56118 100644 --- a/plugins/pj/pj.plugin.zsh +++ b/plugins/pj/pj.plugin.zsh @@ -43,7 +43,7 @@ function _pj () { typeset -a projects foreach i ($PROJECT_PATHS/*) do - projects+=`basename $i` + projects+=(${i##*/}) done _arguments '*:file:($projects)' From d608fbfc7fcabf9994f8064e67670e69130d2ee1 Mon Sep 17 00:00:00 2001 From: Riyad Preukschas Date: Tue, 15 Oct 2013 14:34:03 +0200 Subject: [PATCH 03/42] Make the virtualenv plugin themable --- plugins/virtualenv/virtualenv.plugin.zsh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/plugins/virtualenv/virtualenv.plugin.zsh b/plugins/virtualenv/virtualenv.plugin.zsh index 8e06450b..e250eb63 100644 --- a/plugins/virtualenv/virtualenv.plugin.zsh +++ b/plugins/virtualenv/virtualenv.plugin.zsh @@ -1,7 +1,6 @@ function virtualenv_prompt_info(){ - if [[ -n $VIRTUAL_ENV ]]; then - printf "%s[%s] " "%{${fg[yellow]}%}" ${${VIRTUAL_ENV}:t} - fi + [[ -n ${VIRTUAL_ENV} ]] || return + echo "${ZSH_THEME_VIRTUALENV_PREFIX:=[}${VIRTUAL_ENV:t}${ZSH_THEME_VIRTUALENV_SUFFIX:=]}" } # disables prompt mangling in virtual_env/bin/activate From 9b811fb625c03c30a766191cdf65a1c7c1fd96b2 Mon Sep 17 00:00:00 2001 From: Michael Orr Date: Fri, 6 Dec 2013 17:31:35 -0500 Subject: [PATCH 04/42] accidentally blew away a git config setting used for another purpose, renaming in order to distinguish --- lib/git.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/git.zsh b/lib/git.zsh index 305a77af..a1396653 100644 --- a/lib/git.zsh +++ b/lib/git.zsh @@ -13,7 +13,7 @@ parse_git_dirty() { local SUBMODULE_SYNTAX='' local GIT_STATUS='' local CLEAN_MESSAGE='nothing to commit (working directory clean)' - if [[ "$(command git config --get oh-my-zsh.hide-status)" != "1" ]]; then + if [[ "$(command git config --get oh-my-zsh.hide-dirty)" != "1" ]]; then if [[ $POST_1_7_2_GIT -gt 0 ]]; then SUBMODULE_SYNTAX="--ignore-submodules=dirty" fi From 3976b93f3931a7ebc913576015ff395dcd495d95 Mon Sep 17 00:00:00 2001 From: Daniel Farrell Date: Sun, 23 Mar 2014 15:59:35 -0400 Subject: [PATCH 05/42] Fixed which output at each new shell creation --- themes/gallois.zsh-theme | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/themes/gallois.zsh-theme b/themes/gallois.zsh-theme index f1057a9a..f31d2195 100644 --- a/themes/gallois.zsh-theme +++ b/themes/gallois.zsh-theme @@ -18,7 +18,7 @@ else if which rbenv &> /dev/null; then RPS1='$(git_custom_status)%{$fg[red]%}[`rbenv version | sed -e "s/ (set.*$//"`]%{$reset_color%} $EPS1' else - if [[ -n `which chruby_prompt_info` && -n `chruby_prompt_info` ]]; then + if [[ -n `which chruby_prompt_info &> /dev/null` && -n `chruby_prompt_info` ]]; then RPS1='$(git_custom_status)%{$fg[red]%}[`chruby_prompt_info`]%{$reset_color%} $EPS1' else RPS1='$(git_custom_status) $EPS1' From b2ce306c4f49ebb1ef2bde5b86d553ce6ea674aa Mon Sep 17 00:00:00 2001 From: Daniel Farrell Date: Tue, 25 Mar 2014 23:37:28 -0400 Subject: [PATCH 06/42] Simplified gallois RPS1 setup using some helpful scripts --- themes/gallois.zsh-theme | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/themes/gallois.zsh-theme b/themes/gallois.zsh-theme index f31d2195..d383ed58 100644 --- a/themes/gallois.zsh-theme +++ b/themes/gallois.zsh-theme @@ -11,19 +11,11 @@ git_custom_status() { fi } -#RVM and git settings -if [[ -s ~/.rvm/scripts/rvm ]] ; then - RPS1='$(git_custom_status)%{$fg[red]%}[`~/.rvm/bin/rvm-prompt`]%{$reset_color%} $EPS1' -else - if which rbenv &> /dev/null; then - RPS1='$(git_custom_status)%{$fg[red]%}[`rbenv version | sed -e "s/ (set.*$//"`]%{$reset_color%} $EPS1' - else - if [[ -n `which chruby_prompt_info &> /dev/null` && -n `chruby_prompt_info` ]]; then - RPS1='$(git_custom_status)%{$fg[red]%}[`chruby_prompt_info`]%{$reset_color%} $EPS1' - else - RPS1='$(git_custom_status) $EPS1' - fi - fi -fi +# RVM component of prompt +ZSH_THEME_RVM_PROMPT_PREFIX="%{$fg[red]%}[" +ZSH_THEME_RVM_PROMPT_SUFFIX="]%{$reset_color%}" + +# Combine it all into a final right-side prompt +RPS1='$(git_custom_status)$(ruby_prompt_info) $EPS1' PROMPT='%{$fg[cyan]%}[%~% ]%(?.%{$fg[green]%}.%{$fg[red]%})%B$%b ' From bce74975d055529cbd186782e2fd99e6da840460 Mon Sep 17 00:00:00 2001 From: Frank Louwers Date: Wed, 28 May 2014 13:57:25 +0200 Subject: [PATCH 07/42] =?UTF-8?q?drop=20the=20foreach,=20make=20it=20even?= =?UTF-8?q?=20shorter.=20thanks=20Marc=20Cornell=C3=A0!?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/pj/pj.plugin.zsh | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/plugins/pj/pj.plugin.zsh b/plugins/pj/pj.plugin.zsh index dac56118..f9cbddf1 100644 --- a/plugins/pj/pj.plugin.zsh +++ b/plugins/pj/pj.plugin.zsh @@ -41,11 +41,8 @@ alias pjo="pj open" function _pj () { # might be possible to improve this using glob, without the basename trick typeset -a projects - foreach i ($PROJECT_PATHS/*) - do - projects+=(${i##*/}) - done - + projects=($PROJECT_PATHS/*) + projects=$projects:t _arguments '*:file:($projects)' } From 676fb4e4203eae0f3755a729a6582eb32fe9834f Mon Sep 17 00:00:00 2001 From: Simon Buchan Date: Thu, 3 Jul 2014 13:14:02 +1200 Subject: [PATCH 08/42] Fix parse_git_dirty() when status.branch is set. --- lib/git.zsh | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/lib/git.zsh b/lib/git.zsh index b0e73bf3..8742a857 100644 --- a/lib/git.zsh +++ b/lib/git.zsh @@ -10,23 +10,20 @@ function git_prompt_info() { # Checks if working tree is dirty parse_git_dirty() { - local SUBMODULE_SYNTAX='' - local GIT_STATUS='' - local CLEAN_MESSAGE='nothing to commit (working directory clean)' + local STATUS='' + local FLAGS + FLAGS=('--porcelain') if [[ "$(command git config --get oh-my-zsh.hide-status)" != "1" ]]; then if [[ $POST_1_7_2_GIT -gt 0 ]]; then - SUBMODULE_SYNTAX="--ignore-submodules=dirty" + FLAGS+='--ignore-submodules=dirty' fi if [[ "$DISABLE_UNTRACKED_FILES_DIRTY" == "true" ]]; then - GIT_STATUS=$(command git status -s ${SUBMODULE_SYNTAX} -uno 2> /dev/null | tail -n1) - else - GIT_STATUS=$(command git status -s ${SUBMODULE_SYNTAX} 2> /dev/null | tail -n1) - fi - if [[ -n $GIT_STATUS ]]; then - echo "$ZSH_THEME_GIT_PROMPT_DIRTY" - else - echo "$ZSH_THEME_GIT_PROMPT_CLEAN" + FLAGS+='--untracked-files=no' fi + STATUS=$(command git status ${FLAGS} 2> /dev/null | tail -n1) + fi + if [[ -n $STATUS ]]; then + echo "$ZSH_THEME_GIT_PROMPT_DIRTY" else echo "$ZSH_THEME_GIT_PROMPT_CLEAN" fi From 2927ce37141d52a8b4e2ca1e60d0cf0688125781 Mon Sep 17 00:00:00 2001 From: Simon Buchan Date: Thu, 3 Jul 2014 14:45:49 +1200 Subject: [PATCH 09/42] Fix POST_1_7_2_GIT check for parse_git_dirty submodules. --- lib/git.zsh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/git.zsh b/lib/git.zsh index 8742a857..55ed94a3 100644 --- a/lib/git.zsh +++ b/lib/git.zsh @@ -124,12 +124,16 @@ function git_compare_version() { INSTALLED_GIT_VERSION=(${(s/./)INSTALLED_GIT_VERSION[3]}); for i in {1..3}; do + if [[ $INSTALLED_GIT_VERSION[$i] -gt $INPUT_GIT_VERSION[$i] ]]; then + echo 1 + return 0 + fi if [[ $INSTALLED_GIT_VERSION[$i] -lt $INPUT_GIT_VERSION[$i] ]]; then echo -1 return 0 fi done - echo 1 + echo 0 } #this is unlikely to change so make it all statically assigned From 5e328e3a9c0784521ae4170f7958183c352bae83 Mon Sep 17 00:00:00 2001 From: Moinak Ghosh Date: Fri, 11 Jul 2014 18:41:49 +0530 Subject: [PATCH 10/42] Solaris portability tweaks. --- lib/completion.zsh | 7 ++++++- oh-my-zsh.sh | 1 + plugins/colored-man/colored-man.plugin.zsh | 21 +++++++++++++++++++++ tools/check_for_upgrade.sh | 8 +++++++- 4 files changed, 35 insertions(+), 2 deletions(-) diff --git a/lib/completion.zsh b/lib/completion.zsh index fa1d97f4..faea3611 100644 --- a/lib/completion.zsh +++ b/lib/completion.zsh @@ -25,7 +25,12 @@ bindkey -M menuselect '^o' accept-and-infer-next-history zstyle ':completion:*:*:*:*:*' menu select zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#) ([0-9a-z-]#)*=01;34=0=01' -zstyle ':completion:*:*:*:*:processes' command "ps -u `whoami` -o pid,user,comm -w -w" +if [ "$PLAT" = "SunOS" ] +then + zstyle ':completion:*:*:*:*:processes' command "ps -u `whoami` -o pid,user,comm" +else + zstyle ':completion:*:*:*:*:processes' command "ps -u `whoami` -o pid,user,comm -w -w" +fi # disable named-directories autocompletion zstyle ':completion:*:cd:*' tag-order local-directories directory-stack path-directories diff --git a/oh-my-zsh.sh b/oh-my-zsh.sh index c217b91b..4683c2bc 100644 --- a/oh-my-zsh.sh +++ b/oh-my-zsh.sh @@ -1,3 +1,4 @@ +PLAT=`uname -s` # Check for updates on initial load... if [ "$DISABLE_AUTO_UPDATE" != "true" ]; then /usr/bin/env ZSH=$ZSH DISABLE_UPDATE_PROMPT=$DISABLE_UPDATE_PROMPT zsh -f $ZSH/tools/check_for_upgrade.sh diff --git a/plugins/colored-man/colored-man.plugin.zsh b/plugins/colored-man/colored-man.plugin.zsh index 56056284..4956f434 100644 --- a/plugins/colored-man/colored-man.plugin.zsh +++ b/plugins/colored-man/colored-man.plugin.zsh @@ -1,3 +1,21 @@ +if [ "${PLAT}" = "SunOS" ] +then + if [ ! -x ${HOME}/bin/nroff ] + then + mkdir -p ${HOME}/bin + cat > ${HOME}/bin/nroff < Date: Tue, 15 Jul 2014 12:37:53 -0700 Subject: [PATCH 11/42] Fix for recusion limit hit for _rake_command alias --- plugins/rails/rails.plugin.zsh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/rails/rails.plugin.zsh b/plugins/rails/rails.plugin.zsh index fb46cdcf..824658e4 100644 --- a/plugins/rails/rails.plugin.zsh +++ b/plugins/rails/rails.plugin.zsh @@ -6,7 +6,7 @@ function _rails_command () { elif [ -e "script/server" ]; then ruby script/$@ else - rails $@ + command rails $@ fi } @@ -14,7 +14,7 @@ function _rake_command () { if [ -e "bin/rake" ]; then bin/rake $@ else - rake $@ + command rake $@ fi } From 73212ded4ee70c010a92eb7a126daa20c7453cba Mon Sep 17 00:00:00 2001 From: Elliott Williams Date: Mon, 21 Jul 2014 11:15:09 -0400 Subject: [PATCH 12/42] Fix osx function: "not valid in this context" I have been continually having problems with the "trash" function provided by the osx plugin, getting this error: trash:local:2: not valid in this context: It seems like adding quotes around the assignment in [osx.plugin.zsh#L142](https://github.com/robbyrussell/oh-my-zsh/blob/master/plugins/osx/osx.plugin.zsh#L142) fixed my problem. Does this look good to you? Thanks! --- plugins/osx/osx.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/osx/osx.plugin.zsh b/plugins/osx/osx.plugin.zsh index a63f0ee0..2eea0d8e 100644 --- a/plugins/osx/osx.plugin.zsh +++ b/plugins/osx/osx.plugin.zsh @@ -139,7 +139,7 @@ function man-preview() { function trash() { local trash_dir="${HOME}/.Trash" - local temp_ifs=$IFS + local temp_ifs="$IFS" IFS=$'\n' for item in "$@"; do if [[ -e "$item" ]]; then From 0e00f0b0342cc088c1c3d4163787efb8433b8ea1 Mon Sep 17 00:00:00 2001 From: Shammel Lee Date: Tue, 22 Jul 2014 13:25:04 -0400 Subject: [PATCH 13/42] typo line 1: of => or --- plugins/forklift/forklift.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/forklift/forklift.plugin.zsh b/plugins/forklift/forklift.plugin.zsh index b0e60a43..692ca579 100644 --- a/plugins/forklift/forklift.plugin.zsh +++ b/plugins/forklift/forklift.plugin.zsh @@ -1,4 +1,4 @@ -# Open folder in ForkLift.app of ForkLift2.app from console +# Open folder in ForkLift.app or ForkLift2.app from console # Author: Adam Strzelecki nanoant.com, modified by Bodo Tasche bitboxer.de # Updated to support ForkLift2 by Johan Kaving # From 87fb118dd252d7e9b658c66c51b5e3cb905f10fb Mon Sep 17 00:00:00 2001 From: Matt Walker Date: Wed, 3 Sep 2014 12:01:29 -0700 Subject: [PATCH 14/42] Changed brew cmd to properly report if awscli is installed via homebrew --- plugins/aws/aws.plugin.zsh | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/plugins/aws/aws.plugin.zsh b/plugins/aws/aws.plugin.zsh index 8b57d7db..de786725 100644 --- a/plugins/aws/aws.plugin.zsh +++ b/plugins/aws/aws.plugin.zsh @@ -3,19 +3,17 @@ _homebrew-installed() { } _awscli-homebrew-installed() { - brew --prefix awscli &> /dev/null + brew list awscli &> /dev/null } export AWS_HOME=~/.aws function agp { echo $AWS_DEFAULT_PROFILE - } function asp { export AWS_DEFAULT_PROFILE=$1 - export RPROMPT="" - + export RPROMPT="" } function aws_profiles { reply=($(grep profile $AWS_HOME/config|sed -e 's/.*profile \([a-zA-Z0-9_-]*\).*/\1/')) From 6855dd4727a395bfe8bd471c939819d907cb6c27 Mon Sep 17 00:00:00 2001 From: Markus Faerevaag Date: Sun, 7 Sep 2014 21:56:34 +0200 Subject: [PATCH 15/42] [wd] New minor version (v0.4) --- plugins/wd/README.md | 110 ++++++++++- plugins/wd/_wd.sh | 6 +- plugins/wd/wd.sh | 460 +++++++++++++++++++++++++++++-------------- 3 files changed, 426 insertions(+), 150 deletions(-) diff --git a/plugins/wd/README.md b/plugins/wd/README.md index bc0ebe33..bcfeab68 100644 --- a/plugins/wd/README.md +++ b/plugins/wd/README.md @@ -1,8 +1,60 @@ -## wd +wd +== + +[![Build Status](https://travis-ci.org/mfaerevaag/wd.png?branch=master)](https://travis-ci.org/mfaerevaag/wd) + +`wd` (*warp directory*) lets you jump to custom directories in zsh, without using `cd`. Why? Because `cd` seems ineffecient when the folder is frequently visited or has a long path. + + +### Setup + +### oh-my-zsh + +`wd` comes bundles with [oh-my-zshell](https://github.com/robbyrussell/oh-my-zsh)! + +Just add the plugin in your `~/.zshrc` file: + + plugins=(... wd) + + +#### Automatic + +Run either in terminal: + + * `curl -L https://github.com/mfaerevaag/wd/raw/master/install.sh | sh` + + * `wget --no-check-certificate https://github.com/mfaerevaag/wd/raw/master/install.sh -O - | sh` + + +#### Manual + + * Clone this repo to your liking + + * Add `wd` function to `.zshrc` (or `.profile` etc.): + + wd() { + . ~/paht/to/wd/wd.sh + } + + * Install manpage. From `wd`'s base directory (requires root permissions): + + # cp wd.1 /usr/share/man/man1/wd.1 + # chmod 644 /usr/share/man/man1/wd.1 + + Note, when pulling and updating `wd`, you'll need to do this again in case of changes to the manpage. + + +#### Completion + +If you're NOT using [oh-my-zsh](https://github.com/robbyrussell/oh-my-zsh) and you want to utelize the zsh-completion feature, you will also need to add the path to your `wd` installation (`~/bin/wd` if you used the automatic installer) to your `fpath`. E.g. in your `~/.zshrc`: + + fpath=(~/path/to/wd $fpath) + +Also, you may have to force a rebuild of `zcompdump` by running: + + $ rm -f ~/.zcompdump; compinit -**Maintainer:** [mfaerevaag](https://github.com/mfaerevaag) -`wd` (*warp directory*) lets you jump to custom directories in zsh, without using `cd`. Why? Because `cd` seems ineffecient when the folder is frequently visited or has a long path. [Source](https://github.com/mfaerevaag/wd) ### Usage @@ -24,6 +76,7 @@ $ wd ... This is a wrapper for the zsh `dirs` function. + (You might need `setopt AUTO_PUSHD` in your `.zshrc` if you hare not using [oh-my-zshell](https://github.com/robbyrussell/oh-my-zsh)). * Remove warp point test point: @@ -33,8 +86,55 @@ $ wd ls - * List warp points to current directory + * List warp points to current directory, or optionally, path to given warp point: $ wd show - * Print usage with no opts or the `help` argument. + * Remove warp points to non-existent directories. + + $ wd clean + + Use `clean!` to not be prompted with confirmation (force). + + * Print usage with no opts or the `help` argument: + + $ wd help + + * Print the running version of `wd`: + + $ wd --version + + * Specifically set the config file (default `~/.warprc`), which is useful when testing: + + $ wd --config ./file + + * Force `exit` with return code after running. This is not default, as it will *exit your terminal*, though required when testing/debugging. + + $ wd --debug + + * Silence all output: + + $ wd --quiet + + +### Testing + +`wd` comes with a small test suite, run with [shunit2](https://code.google.com/p/shunit2/). This can be used to confirm that things are working as it should on your setup, or to demonstrate an issue. + +To run, simply `cd` into the `test` directory and run the `tests.sh`. + + $ ./tests.sh + + +### License + +The project is licensed under the [MIT-license](https://github.com/mfaerevaag/wd/blob/master/LICENSE). + + +### Finally + +If you have issues, feedback or improvements, don't hesitate to report it or submit a pull-request. In the case of an issue, we would much appreciate if you would include a failing test in `test/tests.sh`. Explanation on how to run the tests, read the section "Testing" in this README. + +Credit to [altschuler](https://github.com/altschuler) for awesome idea. + +Hope you enjoy! diff --git a/plugins/wd/_wd.sh b/plugins/wd/_wd.sh index 0b03d8ff..2bb58dd3 100644 --- a/plugins/wd/_wd.sh +++ b/plugins/wd/_wd.sh @@ -21,7 +21,8 @@ function _wd() { 'add!:Overwrites existing warp point' 'rm:Removes the given warp point' 'ls:Outputs all stored warp points' - 'show:Outputs all warp points that point to the current directory' + 'show:Outputs all warp points that point to the current directory or shows a specific target directory for a point' + 'show:Outputs all warp points that point to the current directory or shows a specific target directory for a point' 'help:Show this extremely helpful text' '..:Go back to last directory' ) @@ -43,6 +44,9 @@ function _wd() { add) _message 'Write the name of your warp point' && ret=0 ;; + show) + _describe -t points "Warp points" warp_points && ret=0 + ;; esac ;; esac diff --git a/plugins/wd/wd.sh b/plugins/wd/wd.sh index dfb9ad89..4e45b48e 100755 --- a/plugins/wd/wd.sh +++ b/plugins/wd/wd.sh @@ -7,25 +7,301 @@ # # @github.com/mfaerevaag/wd - -## variables -readonly CONFIG=$HOME/.warprc +# version +readonly WD_VERSION=0.4 # colors -readonly BLUE="\033[96m" -readonly GREEN="\033[92m" -readonly YELLOW="\033[93m" -readonly RED="\033[91m" -readonly NOC="\033[m" +readonly WD_BLUE="\033[96m" +readonly WD_GREEN="\033[92m" +readonly WD_YELLOW="\033[93m" +readonly WD_RED="\033[91m" +readonly WD_NOC="\033[m" +## functions -## init +# helpers +wd_yesorno() +{ + # variables + local question="${1}" + local prompt="${question} " + local yes_RETVAL="0" + local no_RETVAL="3" + local RETVAL="" + local answer="" + + # read-eval loop + while true ; do + printf $prompt + read -r answer + + case ${answer:=${default}} in + Y|y|YES|yes|Yes ) + RETVAL=${yes_RETVAL} && \ + break + ;; + N|n|NO|no|No ) + RETVAL=${no_RETVAL} && \ + break + ;; + * ) + echo "Please provide a valid answer (y or n)" + ;; + esac + done + + return ${RETVAL} +} + +wd_print_msg() +{ + if [[ -z $wd_quiet_mode ]] + then + local color=$1 + local msg=$2 + + if [[ $color == "" || $msg == "" ]] + then + print " ${WD_RED}*${WD_NOC} Could not print message. Sorry!" + else + print " ${color}*${WD_NOC} ${msg}" + fi + fi +} + +wd_print_usage() +{ + cat <<- EOF +Usage: wd [command] + +Commands: + add Adds the current working directory to your warp points + add! Overwrites existing warp point + rm Removes the given warp point + show Print warp points to current directory + show Print path to given warp point + ls Print all stored warp points + clean! Remove points warping to nonexistent directories + + -v | --version Print version + -d | --debug Exit after execution with exit codes (for testing) + -c | --config Specify config file (default ~/.warprc) + -q | --quiet Suppress all output + + help Show this extremely helpful text +EOF +} + +wd_exit_fail() +{ + local msg=$1 + + wd_print_msg $WD_RED $1 + WD_EXIT_CODE=1 +} + +wd_exit_warn() +{ + local msg=$1 + + wd_print_msg $WD_YELLOW $msg + WD_EXIT_CODE=1 +} + +# core + +wd_warp() +{ + local point=$1 + + if [[ $point =~ "^\.+$" ]] + then + if [ $#1 < 2 ] + then + wd_exit_warn "Warping to current directory?" + else + (( n = $#1 - 1 )) + cd -$n > /dev/null + fi + elif [[ ${points[$point]} != "" ]] + then + cd ${points[$point]} + else + wd_exit_fail "Unknown warp point '${point}'" + fi +} + +wd_add() +{ + local force=$1 + local point=$2 + + if [[ $point =~ "^[\.]+$" ]] + then + wd_exit_fail "Warp point cannot be just dots" + elif [[ $point =~ "(\s|\ )+" ]] + then + wd_exit_fail "Warp point should not contain whitespace" + elif [[ $point == *:* ]] + then + wd_exit_fail "Warp point cannot contain colons" + elif [[ $point == "" ]] + then + wd_exit_fail "Warp point cannot be empty" + elif [[ ${points[$2]} == "" ]] || $force + then + wd_remove $point > /dev/null + printf "%q:%q\n" "${point}" "${PWD}" >> $WD_CONFIG + + wd_print_msg $WD_GREEN "Warp point added" + + # override exit code in case wd_remove did not remove any points + # TODO: we should handle this kind of logic better + WD_EXIT_CODE=0 + else + wd_exit_warn "Warp point '${point}' already exists. Use 'add!' to overwrite." + fi +} + +wd_remove() +{ + local point=$1 + + if [[ ${points[$point]} != "" ]] + then + local config_tmp=$WD_CONFIG.tmp + if sed -n "/^${point}:.*$/!p" $WD_CONFIG > $config_tmp && mv $config_tmp $WD_CONFIG + then + wd_print_msg $WD_GREEN "Warp point removed" + else + wd_exit_fail "Something bad happened! Sorry." + fi + else + wd_exit_fail "Warp point was not found" + fi +} + +wd_list_all() +{ + wd_print_msg $WD_BLUE "All warp points:" + + while IFS= read -r line + do + if [[ $line != "" ]] + then + arr=(${(s,:,)line}) + key=${arr[1]} + val=${arr[2]} + + if [[ -z $wd_quiet_mode ]] + then + printf "%20s -> %s\n" $key $val + fi + fi + done <<< $(sed "s:${HOME}:~:g" $WD_CONFIG) +} + +wd_show() +{ + local name_arg=$1 + # if there's an argument we look up the value + if [[ ! -z $name_arg ]] + then + if [[ -z $points[$name_arg] ]] + then + wd_print_msg $WD_BLUE "No warp point named $name_arg" + else + wd_print_msg $WD_GREEN "Warp point: ${WD_GREEN}$name_arg${WD_NOC} -> $points[$name_arg]" + fi + else + # hax to create a local empty array + local wd_matches + wd_matches=() + # do a reverse lookup to check whether PWD is in $points + if [[ ${points[(r)$PWD]} == $PWD ]] + then + for name in ${(k)points} + do + if [[ $points[$name] == $PWD ]] + then + wd_matches[$(($#wd_matches+1))]=$name + fi + done + + wd_print_msg $WD_BLUE "$#wd_matches warp point(s) to current directory: ${WD_GREEN}$wd_matches${WD_NOC}" + else + wd_print_msg $WD_BLUE "No warp points to $cwd" + fi + fi +} + +wd_clean() { + local force=$1 + local count=0 + local wd_tmp="" + + while read line + do + if [[ $line != "" ]] + then + arr=(${(s,:,)line}) + key=${arr[1]} + val=${arr[2]} + + if [ -d "$val" ] + then + wd_tmp=$wd_tmp"\n"`echo $line` + else + wd_print_msg $WD_YELLOW "Nonexistent directory: ${key} -> ${val}" + count=$((count+1)) + fi + fi + done < $WD_CONFIG + + if [[ $count -eq 0 ]] + then + wd_print_msg $WD_BLUE "No warp points to clean, carry on!" + else + if $force || wd_yesorno "Removing ${count} warp points. Continue? (Y/n)" + then + echo $wd_tmp >! $WD_CONFIG + wd_print_msg $WD_GREEN "Cleanup complete. ${count} warp point(s) removed" + else + wd_print_msg $WD_BLUE "Cleanup aborted" + fi + fi +} + +local WD_CONFIG=$HOME/.warprc +local WD_QUIET=0 +local WD_EXIT_CODE=0 +local WD_DEBUG=0 + +# Parse 'meta' options first to avoid the need to have them before +# other commands. The `-D` flag consumes recognized options so that +# the actual command parsing won't be affected. + +zparseopts -D -E \ + c:=wd_alt_config -config:=wd_alt_config \ + q=wd_quiet_mode -quiet=wd_quiet_mode \ + v=wd_print_version -version=wd_print_version \ + d=wd_debug_mode -debug=wd_debug_mode + +if [[ ! -z $wd_print_version ]] +then + echo "wd version $WD_VERSION" +fi + +if [[ ! -z $wd_alt_config ]] +then + WD_CONFIG=$wd_alt_config[2] +fi # check if config file exists -if [ ! -e $CONFIG ] +if [ ! -e $WD_CONFIG ] then # if not, create config file - touch $CONFIG + touch $WD_CONFIG fi # load warp points @@ -37,149 +313,26 @@ do val=${arr[2]} points[$key]=$val -done < $CONFIG - - -## functions - -wd_warp() -{ - local point=$1 - - if [[ $point =~ "^\.+$" ]] - then - if [ $#1 < 2 ] - then - wd_print_msg $YELLOW "Warping to current directory?" - else - (( n = $#1 - 1 )) - cd -$n > /dev/null - fi - elif [[ ${points[$point]} != "" ]] - then - cd ${points[$point]} - else - wd_print_msg $RED "Unknown warp point '${point}'" - fi -} - -wd_add() -{ - local force=$1 - local point=$2 - - if [[ $point =~ "^[\.]+$" ]] - then - wd_print_msg $RED "Warp point cannot be just dots" - elif [[ $point =~ "(\s|\ )+" ]] - then - wd_print_msg $RED "Warp point should not contain whitespace" - elif [[ $point == *:* ]] - then - wd_print_msg $RED "Warp point cannot contain colons" - elif [[ $point == "" ]] - then - wd_print_msg $RED "Warp point cannot be empty" - elif [[ ${points[$2]} == "" ]] || $force - then - wd_remove $point > /dev/null - printf "%q:%q\n" "${point}" "${PWD}" >> $CONFIG - - wd_print_msg $GREEN "Warp point added" - else - wd_print_msg $YELLOW "Warp point '${point}' already exists. Use 'add!' to overwrite." - fi -} - -wd_remove() -{ - local point=$1 - - if [[ ${points[$point]} != "" ]] - then - if sed -i.bak "s,^${point}:.*$,,g" $CONFIG - then - wd_print_msg $GREEN "Warp point removed" - else - wd_print_msg $RED "Something bad happened! Sorry." - fi - else - wd_print_msg $RED "Warp point was not found" - fi -} - -wd_list_all() -{ - wd_print_msg $BLUE "All warp points:" - - while IFS= read -r line - do - if [[ $line != "" ]] - then - arr=(${(s,:,)line}) - key=${arr[1]} - val=${arr[2]} - - printf "%20s -> %s\n" $key $val - fi - done <<< $(sed "s:${HOME}:~:g" $CONFIG) -} - -wd_show() -{ - local cwd=$(print $PWD | sed "s:^${HOME}:~:") - - wd_print_msg $BLUE "Warp points to current directory:" - wd_list_all | grep -e "${cwd}$" -} - -wd_print_msg() -{ - local color=$1 - local msg=$2 - - if [[ $color == "" || $msg == "" ]] - then - print " ${RED}*${NOC} Could not print message. Sorry!" - else - print " ${color}*${NOC} ${msg}" - fi -} - -wd_print_usage() -{ - cat <<- EOF -Usage: wd [add|-a|--add] [rm|-r|--remove] - -Commands: - add Adds the current working directory to your warp points - add! Overwrites existing warp point - rm Removes the given warp point - show Outputs warp points to current directory - ls Outputs all stored warp points - help Show this extremely helpful text -EOF -} - - -## run +done < $WD_CONFIG # get opts -args=$(getopt -o a:r:lhs -l add:,rm:,ls,help,show -- $*) +args=$(getopt -o a:r:c:lhs -l add:,rm:,clean\!,ls,help,show -- $*) -# check if no arguments were given -if [[ $? -ne 0 || $#* -eq 0 ]] +# check if no arguments were given, and that version is not set +if [[ ($? -ne 0 || $#* -eq 0) && -z $wd_print_version ]] then wd_print_usage -# check if config file is writeable -elif [ ! -w $CONFIG ] + # check if config file is writeable +elif [ ! -w $WD_CONFIG ] then # do nothing # can't run `exit`, as this would exit the executing shell - wd_print_msg $RED "\'$CONFIG\' is not writeable." + wd_exit_fail "\'$WD_CONFIG\' is not writeable." else + + # parse rest of options for o do case "$o" @@ -205,7 +358,15 @@ else break ;; -s|--show|show) - wd_show + wd_show $2 + break + ;; + -c|--clean|clean) + wd_clean false + break + ;; + -c!|--clean!|clean!) + wd_clean true break ;; *) @@ -229,8 +390,19 @@ unset wd_remove unset wd_show unset wd_list_all unset wd_print_msg +unset wd_yesorno unset wd_print_usage +unset wd_alt_config +unset wd_quiet_mode +unset wd_print_version unset args unset points unset val &> /dev/null # fixes issue #1 + +if [[ ! -z $wd_debug_mode ]] +then + exit $WD_EXIT_CODE +else + unset wd_debug_mode +fi From b5093859af472c04dfca33adfeba49bfbe417c9d Mon Sep 17 00:00:00 2001 From: Markus Faerevaag Date: Mon, 8 Sep 2014 09:09:44 +0200 Subject: [PATCH 16/42] [wd] Minor bug fix in show command --- plugins/wd/wd.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/wd/wd.sh b/plugins/wd/wd.sh index 4e45b48e..d63e9247 100755 --- a/plugins/wd/wd.sh +++ b/plugins/wd/wd.sh @@ -230,7 +230,7 @@ wd_show() wd_print_msg $WD_BLUE "$#wd_matches warp point(s) to current directory: ${WD_GREEN}$wd_matches${WD_NOC}" else - wd_print_msg $WD_BLUE "No warp points to $cwd" + wd_print_msg $WD_YELLOW "No warp point to $(echo $PWD | sed "s:$HOME:~:")" fi fi } From 7a5d68c96332b5f50969f75384f67694639dbce2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C3=96zg=C3=BCr?= Date: Sat, 13 Sep 2014 10:30:16 +0300 Subject: [PATCH 17/42] Remove j alias for autojump j alias conflicts with autojump's j() function. Fixes #2989 --- plugins/common-aliases/common-aliases.plugin.zsh | 1 - 1 file changed, 1 deletion(-) diff --git a/plugins/common-aliases/common-aliases.plugin.zsh b/plugins/common-aliases/common-aliases.plugin.zsh index 228a39da..90d59910 100644 --- a/plugins/common-aliases/common-aliases.plugin.zsh +++ b/plugins/common-aliases/common-aliases.plugin.zsh @@ -46,7 +46,6 @@ alias ff='find . -type f -name' alias h='history' alias hgrep="fc -El 0 | grep" alias help='man' -alias j='jobs' alias p='ps -f' alias sortnr='sort -n -r' alias unexport='unset' From 5f38a537cef0d79c9d53c01e8f88d150e985c70a Mon Sep 17 00:00:00 2001 From: Moinak Ghosh Date: Tue, 16 Sep 2014 22:29:52 +0530 Subject: [PATCH 18/42] Update Solaris changes to use OSTYPE and zsh datetime module. --- lib/completion.zsh | 2 +- oh-my-zsh.sh | 1 - plugins/colored-man/colored-man.plugin.zsh | 2 +- tools/check_for_upgrade.sh | 12 ++++-------- 4 files changed, 6 insertions(+), 11 deletions(-) diff --git a/lib/completion.zsh b/lib/completion.zsh index faea3611..83b6efb6 100644 --- a/lib/completion.zsh +++ b/lib/completion.zsh @@ -25,7 +25,7 @@ bindkey -M menuselect '^o' accept-and-infer-next-history zstyle ':completion:*:*:*:*:*' menu select zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#) ([0-9a-z-]#)*=01;34=0=01' -if [ "$PLAT" = "SunOS" ] +if [ "$OSTYPE[0,7]" = "solaris" ] then zstyle ':completion:*:*:*:*:processes' command "ps -u `whoami` -o pid,user,comm" else diff --git a/oh-my-zsh.sh b/oh-my-zsh.sh index 4683c2bc..c217b91b 100644 --- a/oh-my-zsh.sh +++ b/oh-my-zsh.sh @@ -1,4 +1,3 @@ -PLAT=`uname -s` # Check for updates on initial load... if [ "$DISABLE_AUTO_UPDATE" != "true" ]; then /usr/bin/env ZSH=$ZSH DISABLE_UPDATE_PROMPT=$DISABLE_UPDATE_PROMPT zsh -f $ZSH/tools/check_for_upgrade.sh diff --git a/plugins/colored-man/colored-man.plugin.zsh b/plugins/colored-man/colored-man.plugin.zsh index 4956f434..5c613f49 100644 --- a/plugins/colored-man/colored-man.plugin.zsh +++ b/plugins/colored-man/colored-man.plugin.zsh @@ -1,4 +1,4 @@ -if [ "${PLAT}" = "SunOS" ] +if [ "$OSTYPE[0,7]" = "solaris" ] then if [ ! -x ${HOME}/bin/nroff ] then diff --git a/tools/check_for_upgrade.sh b/tools/check_for_upgrade.sh index 1aba9a27..0e8845ab 100644 --- a/tools/check_for_upgrade.sh +++ b/tools/check_for_upgrade.sh @@ -1,13 +1,9 @@ -#!/bin/sh +#!/usr/bin/env zsh + +zmodload zsh/datetime -PLAT=`uname -s` function _current_epoch() { - if [ "$PLAT" = "SunOS" ] - then - echo $(($(perl -e 'print time') / 60 / 60 / 24)) - else - echo $(($(date +%s) / 60 / 60 / 24)) - fi + echo $EPOCHSECONDS } function _update_zsh_update() { From 90762eee49efcdfd6b92ad5d5d9e5f43d113ae0b Mon Sep 17 00:00:00 2001 From: Moinak Ghosh Date: Wed, 17 Sep 2014 11:11:48 +0530 Subject: [PATCH 19/42] Convert epoch_target from days to seconds. --- tools/check_for_upgrade.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tools/check_for_upgrade.sh b/tools/check_for_upgrade.sh index 0e8845ab..f49bb151 100644 --- a/tools/check_for_upgrade.sh +++ b/tools/check_for_upgrade.sh @@ -22,6 +22,8 @@ if [[ -z "$epoch_target" ]]; then epoch_target=13 fi +epoch_target_seconds=$((epoch_target * 86400)) + [ -f ~/.profile ] && source ~/.profile # Cancel upgrade if the current user doesn't have write permissions for the @@ -37,7 +39,7 @@ then fi epoch_diff=$(($(_current_epoch) - $LAST_EPOCH)) - if [ $epoch_diff -gt $epoch_target ] + if [ $epoch_diff -gt $epoch_target_seconds ] then if [ "$DISABLE_UPDATE_PROMPT" = "true" ] then From 3a3973284534c318e2cb987a0db1121302d04e10 Mon Sep 17 00:00:00 2001 From: Moinak Ghosh Date: Tue, 14 Oct 2014 12:05:01 +0530 Subject: [PATCH 20/42] Change to epoch target in days instead of seconds. --- tools/check_for_upgrade.sh | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/tools/check_for_upgrade.sh b/tools/check_for_upgrade.sh index f49bb151..a8ba4820 100644 --- a/tools/check_for_upgrade.sh +++ b/tools/check_for_upgrade.sh @@ -3,7 +3,7 @@ zmodload zsh/datetime function _current_epoch() { - echo $EPOCHSECONDS + echo $(( $EPOCHSECONDS / 60 / 60 / 24 )) } function _update_zsh_update() { @@ -22,8 +22,6 @@ if [[ -z "$epoch_target" ]]; then epoch_target=13 fi -epoch_target_seconds=$((epoch_target * 86400)) - [ -f ~/.profile ] && source ~/.profile # Cancel upgrade if the current user doesn't have write permissions for the @@ -39,7 +37,7 @@ then fi epoch_diff=$(($(_current_epoch) - $LAST_EPOCH)) - if [ $epoch_diff -gt $epoch_target_seconds ] + if [ $epoch_diff -gt $epoch_target ] then if [ "$DISABLE_UPDATE_PROMPT" = "true" ] then From 71ee0d7b2bc717e815cddc9ee8e062f84587d2c4 Mon Sep 17 00:00:00 2001 From: Nikhil Gupta Date: Sun, 12 Oct 2014 08:30:08 +0530 Subject: [PATCH 21/42] added support for GNU version of `date` --- plugins/emoji-clock/emoji-clock.plugin.zsh | 28 ++++++++++++---------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/plugins/emoji-clock/emoji-clock.plugin.zsh b/plugins/emoji-clock/emoji-clock.plugin.zsh index a69446e3..0a55528f 100644 --- a/plugins/emoji-clock/emoji-clock.plugin.zsh +++ b/plugins/emoji-clock/emoji-clock.plugin.zsh @@ -8,21 +8,25 @@ # ----------------------------------------------------------------------------- function emoji-clock() { - hour=$(date -v '+15M' '+%I') - minutes=$(date -v '+15M' '+%M') + # Add 15 minutes to the current time and save the value as $minutes. + (( minutes = $(date '+%M') + 15 )) + (( hour = $(date '+%I') + minutes / 60 )) + # make sure minutes and hours don't exceed 60 nor 12 respectively + (( minutes %= 60 )); (( hour %= 12 )) + case $hour in - 01) clock="🕐"; [ $minutes -ge 30 ] && clock="🕜";; - 02) clock="🕑"; [ $minutes -ge 30 ] && clock="🕝";; - 03) clock="🕒"; [ $minutes -ge 30 ] && clock="🕞";; - 04) clock="🕓"; [ $minutes -ge 30 ] && clock="🕟";; - 05) clock="🕔"; [ $minutes -ge 30 ] && clock="🕠";; - 06) clock="🕕"; [ $minutes -ge 30 ] && clock="🕡";; - 07) clock="🕖"; [ $minutes -ge 30 ] && clock="🕢";; - 08) clock="🕗"; [ $minutes -ge 30 ] && clock="🕣";; - 09) clock="🕘"; [ $minutes -ge 30 ] && clock="🕤";; + 0) clock="🕛"; [ $minutes -ge 30 ] && clock="🕧";; + 1) clock="🕐"; [ $minutes -ge 30 ] && clock="🕜";; + 2) clock="🕑"; [ $minutes -ge 30 ] && clock="🕝";; + 3) clock="🕒"; [ $minutes -ge 30 ] && clock="🕞";; + 4) clock="🕓"; [ $minutes -ge 30 ] && clock="🕟";; + 5) clock="🕔"; [ $minutes -ge 30 ] && clock="🕠";; + 6) clock="🕕"; [ $minutes -ge 30 ] && clock="🕡";; + 7) clock="🕖"; [ $minutes -ge 30 ] && clock="🕢";; + 8) clock="🕗"; [ $minutes -ge 30 ] && clock="🕣";; + 9) clock="🕘"; [ $minutes -ge 30 ] && clock="🕤";; 10) clock="🕙"; [ $minutes -ge 30 ] && clock="🕥";; 11) clock="🕚"; [ $minutes -ge 30 ] && clock="🕦";; - 12) clock="🕛"; [ $minutes -ge 30 ] && clock="🕧";; *) clock="⌛";; esac echo $clock From d794a502f6e551c2ccb1479fc68dbae352c839f5 Mon Sep 17 00:00:00 2001 From: Neal Date: Tue, 14 Oct 2014 13:57:02 -0500 Subject: [PATCH 22/42] Update path for the iOS simulator. --- plugins/xcode/xcode.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/xcode/xcode.plugin.zsh b/plugins/xcode/xcode.plugin.zsh index e59bee8c..3d7781bf 100644 --- a/plugins/xcode/xcode.plugin.zsh +++ b/plugins/xcode/xcode.plugin.zsh @@ -16,4 +16,4 @@ function xcsel { alias xcb='xcodebuild' alias xcp='xcode-select --print-path' -alias simulator='open $(xcode-select -p)/Platforms/iPhoneSimulator.platform/Developer/Applications/iPhone\ Simulator.app' +alias simulator='open $(xcode-select -p)/Applications/iOS\ Simulator.app' From 6f1eb081e343208f881b19d1c9499e6e93b29e4b Mon Sep 17 00:00:00 2001 From: willmendesneto Date: Thu, 16 Oct 2014 23:32:42 -0300 Subject: [PATCH 23/42] Fix error using compass search alias --- plugins/frontend-search/frontend-search.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/frontend-search/frontend-search.plugin.zsh b/plugins/frontend-search/frontend-search.plugin.zsh index 38b1a80e..f1d45b0d 100644 --- a/plugins/frontend-search/frontend-search.plugin.zsh +++ b/plugins/frontend-search/frontend-search.plugin.zsh @@ -118,7 +118,7 @@ alias jquery='frontend jquery' alias mdn='frontend mdn' # pre processors frameworks -alias compass='frontend compass' +alias compassdoc='frontend compass' # important links alias html5please='frontend html5please' From 9f801ff48d46847e3c91e58b2ba2f5b61f6dcef8 Mon Sep 17 00:00:00 2001 From: Markus Faerevaag Date: Tue, 21 Oct 2014 09:51:13 +0200 Subject: [PATCH 24/42] [wd] fix space in path --- plugins/wd/wd.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/wd/wd.sh b/plugins/wd/wd.sh index d63e9247..5ecbdc50 100755 --- a/plugins/wd/wd.sh +++ b/plugins/wd/wd.sh @@ -139,7 +139,7 @@ wd_add() if [[ $point =~ "^[\.]+$" ]] then wd_exit_fail "Warp point cannot be just dots" - elif [[ $point =~ "(\s|\ )+" ]] + elif [[ $point =~ "[[:space:]]+" ]] then wd_exit_fail "Warp point should not contain whitespace" elif [[ $point == *:* ]] @@ -151,7 +151,7 @@ wd_add() elif [[ ${points[$2]} == "" ]] || $force then wd_remove $point > /dev/null - printf "%q:%q\n" "${point}" "${PWD}" >> $WD_CONFIG + printf "%q:%s\n" "${point}" "${PWD}" >> $WD_CONFIG wd_print_msg $WD_GREEN "Warp point added" From b9a11b16fec80c5d68f8a215565da3624748197f Mon Sep 17 00:00:00 2001 From: Andrii Kostenko Date: Sat, 6 Sep 2014 22:44:18 +0300 Subject: [PATCH 25/42] fixed URL on github.io github.io moved to https and http returns 301 redirect --- plugins/gitignore/gitignore.plugin.zsh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/gitignore/gitignore.plugin.zsh b/plugins/gitignore/gitignore.plugin.zsh index be037d87..5bf30245 100644 --- a/plugins/gitignore/gitignore.plugin.zsh +++ b/plugins/gitignore/gitignore.plugin.zsh @@ -1,7 +1,7 @@ -function gi() { curl http://www.gitignore.io/api/$@ ;} +function gi() { curl https://www.gitignore.io/api/$@ ;} _gitignireio_get_command_list() { - curl -s http://www.gitignore.io/api/list | tr "," "\n" + curl -s https://www.gitignore.io/api/list | tr "," "\n" } _gitignireio () { From 69a0b280c7939406c930082469756e217d1bd789 Mon Sep 17 00:00:00 2001 From: Alex Shaindlin Date: Wed, 15 Oct 2014 09:33:49 -0400 Subject: [PATCH 26/42] Fix misspellings in gitignore plugin --- plugins/gitignore/gitignore.plugin.zsh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/gitignore/gitignore.plugin.zsh b/plugins/gitignore/gitignore.plugin.zsh index 5bf30245..3f2a6dec 100644 --- a/plugins/gitignore/gitignore.plugin.zsh +++ b/plugins/gitignore/gitignore.plugin.zsh @@ -1,12 +1,12 @@ function gi() { curl https://www.gitignore.io/api/$@ ;} -_gitignireio_get_command_list() { +_gitignoreio_get_command_list() { curl -s https://www.gitignore.io/api/list | tr "," "\n" } -_gitignireio () { +_gitignoreio () { compset -P '*,' - compadd -S '' `_gitignireio_get_command_list` + compadd -S '' `_gitignoreio_get_command_list` } -compdef _gitignireio gi +compdef _gitignoreio gi From 04d1428fcbda05a96d54396679c6c74c7006b032 Mon Sep 17 00:00:00 2001 From: WooParadog Date: Thu, 9 Oct 2014 13:17:35 +0800 Subject: [PATCH 27/42] Fix gitignore curl, should follow redirects --- plugins/gitignore/gitignore.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/gitignore/gitignore.plugin.zsh b/plugins/gitignore/gitignore.plugin.zsh index 3f2a6dec..484c6a69 100644 --- a/plugins/gitignore/gitignore.plugin.zsh +++ b/plugins/gitignore/gitignore.plugin.zsh @@ -1,4 +1,4 @@ -function gi() { curl https://www.gitignore.io/api/$@ ;} +function gi() { curl -L https://www.gitignore.io/api/$@ ;} _gitignoreio_get_command_list() { curl -s https://www.gitignore.io/api/list | tr "," "\n" From b452cafb163cde6619ac741027251bed2709f78e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Wed, 15 Oct 2014 17:17:04 +0200 Subject: [PATCH 28/42] Follow-redirect and silent mode curl throughout gitignore This commit completes previous efforts and standardizes both curl commands into using silent mode and following redirects in case the URL changes again in the future. --- plugins/gitignore/gitignore.plugin.zsh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/gitignore/gitignore.plugin.zsh b/plugins/gitignore/gitignore.plugin.zsh index 484c6a69..481d487b 100644 --- a/plugins/gitignore/gitignore.plugin.zsh +++ b/plugins/gitignore/gitignore.plugin.zsh @@ -1,7 +1,7 @@ -function gi() { curl -L https://www.gitignore.io/api/$@ ;} +function gi() { curl -sL https://www.gitignore.io/api/$@ ;} _gitignoreio_get_command_list() { - curl -s https://www.gitignore.io/api/list | tr "," "\n" + curl -sL https://www.gitignore.io/api/list | tr "," "\n" } _gitignoreio () { From 071de5fb39ff951bffe75a4d6f590d85f25871f3 Mon Sep 17 00:00:00 2001 From: Neal Date: Mon, 27 Oct 2014 22:17:11 -0500 Subject: [PATCH 29/42] Make the simulator alias work with older Xcode versions as well. --- plugins/xcode/xcode.plugin.zsh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/plugins/xcode/xcode.plugin.zsh b/plugins/xcode/xcode.plugin.zsh index 3d7781bf..b7b75cf9 100644 --- a/plugins/xcode/xcode.plugin.zsh +++ b/plugins/xcode/xcode.plugin.zsh @@ -16,4 +16,9 @@ function xcsel { alias xcb='xcodebuild' alias xcp='xcode-select --print-path' -alias simulator='open $(xcode-select -p)/Applications/iOS\ Simulator.app' + +if [[ -d $(xcode-select -p)/Platforms/iPhoneSimulator.platform/Developer/Applications/iPhone\ Simulator.app ]]; then + alias simulator='open $(xcode-select -p)/Platforms/iPhoneSimulator.platform/Developer/Applications/iPhone\ Simulator.app' +else + alias simulator='open $(xcode-select -p)/Applications/iOS\ Simulator.app' +fi From b6012bc2c32a124183d7c5713edee4e2341e1d3f Mon Sep 17 00:00:00 2001 From: Pavol Juhas Date: Wed, 2 Apr 2014 19:25:47 -0400 Subject: [PATCH 30/42] Update to the upstream smart-change-directory. Synced with the master branch pavoljuhas/smart-change-directory@20b5a80cf05f72c07e88a9b166593f52517029e4. --- plugins/scd/README.md | 15 +++--- plugins/scd/scd | 119 +++++++++++++++++++++++++++--------------- 2 files changed, 86 insertions(+), 48 deletions(-) diff --git a/plugins/scd/README.md b/plugins/scd/README.md index 197cea50..86ab6720 100644 --- a/plugins/scd/README.md +++ b/plugins/scd/README.md @@ -11,12 +11,9 @@ the index. A selection menu is displayed in case of several matches, with a preference given to recently visited paths. `scd` can create permanent directory aliases, which appear as named directories in zsh session. -## INSTALLATION +## INSTALLATION NOTES -For oh-my-zsh, add `scd` to the `plugins` array in the ~/.zshrc file as in the -[template file](../../templates/zshrc.zsh-template#L45). - -Besides zsh, `scd` can be used with *bash*, *dash* or *tcsh* +Besides oh-my-zsh, `scd` can be used with *bash*, *dash* or *tcsh* shells and is also available as [Vim](http://www.vim.org/) plugin and [IPython](http://ipython.org/) extension. For installation details, see https://github.com/pavoljuhas/smart-change-directory. @@ -34,7 +31,7 @@ scd [options] [pattern1 pattern2 ...] add specified directories to the directory index.
--unindex
- remove specified directories from the index.
+ remove current or specified directories from the index.
-r, --recursive
apply options --add or --unindex recursively.
@@ -47,6 +44,10 @@ scd [options] [pattern1 pattern2 ...] remove ALIAS definition for the current or specified directory from ~/.scdalias.zsh.
+-A, --all
+ include all matching directories. Disregard matching by directory + alias and filtering of less likely paths.
+ --list
show matching directories and exit.
@@ -70,7 +71,7 @@ scd doc scd a b c # Change to a directory path that ends with "ts" -scd "ts(#e)" +scd "ts$" # Show selection menu and ranking of 20 most likely directories scd -v diff --git a/plugins/scd/scd b/plugins/scd/scd index 1567d273..39b28237 100755 --- a/plugins/scd/scd +++ b/plugins/scd/scd @@ -11,20 +11,22 @@ fi local DOC='scd -- smart change to a recently used directory usage: scd [options] [pattern1 pattern2 ...] Go to a directory path that contains all fixed string patterns. Prefer -recently visited directories and directories with patterns in their tail -component. Display a selection menu in case of multiple matches. +recent or frequently visited directories as found in the directory index. +Display a selection menu in case of multiple matches. Options: - -a, --add add specified directories to the directory index - --unindex remove specified directories from the index - -r, --recursive apply options --add or --unindex recursively + -a, --add add specified directories to the directory index. + --unindex remove current or specified directories from the index. + -r, --recursive apply options --add or --unindex recursively. --alias=ALIAS create alias for the current or specified directory and - store it in ~/.scdalias.zsh + store it in ~/.scdalias.zsh. --unalias remove ALIAS definition for the current or specified - directory from ~/.scdalias.zsh - --list show matching directories and exit - -v, --verbose display directory rank in the selection menu - -h, --help display this message and exit + directory from ~/.scdalias.zsh. + -A, --all include all matching directories. Disregard matching by + directory alias and filtering of less likely paths. + --list show matching directories and exit. + -v, --verbose display directory rank in the selection menu. + -h, --help display this message and exit. ' local SCD_HISTFILE=${SCD_HISTFILE:-${HOME}/.scdhistory} @@ -35,9 +37,9 @@ local SCD_THRESHOLD=${SCD_THRESHOLD:-0.005} local SCD_SCRIPT=${RUNNING_AS_COMMAND:+$SCD_SCRIPT} local SCD_ALIAS=~/.scdalias.zsh -local ICASE a d m p i tdir maxrank threshold +local ICASE a d m p i maxrank threshold local opt_help opt_add opt_unindex opt_recursive opt_verbose -local opt_alias opt_unalias opt_list +local opt_alias opt_unalias opt_all opt_list local -A drank dalias local dmatching local last_directory @@ -56,7 +58,8 @@ zmodload -i zsh/zutil zmodload -i zsh/datetime zparseopts -D -- a=opt_add -add=opt_add -unindex=opt_unindex \ r=opt_recursive -recursive=opt_recursive \ - -alias:=opt_alias -unalias=opt_unalias -list=opt_list \ + -alias:=opt_alias -unalias=opt_unalias \ + A=opt_all -all=opt_all -list=opt_list \ v=opt_verbose -verbose=opt_verbose h=opt_help -help=opt_help \ || $EXIT $? @@ -68,6 +71,11 @@ fi # load directory aliases if they exist [[ -r $SCD_ALIAS ]] && source $SCD_ALIAS +# Private internal functions are prefixed with _scd_Y19oug_. +# Clean them up when the scd function returns. +setopt localtraps +trap 'unfunction -m "_scd_Y19oug_*"' EXIT + # works faster than the (:a) modifier and is compatible with zsh 4.2.6 _scd_Y19oug_abspath() { set -A $1 ${(ps:\0:)"$( @@ -123,11 +131,52 @@ if [[ -n $opt_unalias ]]; then $EXIT $? fi +# The "compress" function collapses repeated directories to +# one entry with a time stamp that gives equivalent-probability. +_scd_Y19oug_compress() { + awk -v epochseconds=$EPOCHSECONDS -v meanlife=$SCD_MEANLIFE ' + BEGIN { FS = "[:;]"; } + length($0) < 4096 && $2 > 0 { + tau = 1.0 * ($2 - epochseconds) / meanlife; + if (tau < -6.9078) tau = -6.9078; + prob = exp(tau); + sub(/^[^;]*;/, ""); + if (NF) { + dlist[last[$0]] = ""; + dlist[NR] = $0; + last[$0] = NR; + ptot[$0] += prob; + } + } + END { + for (i = 1; i <= NR; ++i) { + d = dlist[i]; + if (d) { + ts = log(ptot[d]) * meanlife + epochseconds; + printf(": %.0f:0;%s\n", ts, d); + } + } + } + ' $* +} + # Rewrite directory index if it is at least 20% oversized if [[ -s $SCD_HISTFILE ]] && \ (( $(wc -l <$SCD_HISTFILE) > 1.2 * $SCD_HISTSIZE )); then - m=( ${(f)"$(<$SCD_HISTFILE)"} ) - print -lr -- ${m[-$SCD_HISTSIZE,-1]} >| ${SCD_HISTFILE} + # compress repeated entries + m=( ${(f)"$(_scd_Y19oug_compress $SCD_HISTFILE)"} ) + # purge non-existent directories + m=( ${(f)"$( + for a in $m; do + if [[ -d ${a#*;} ]]; then print -r -- $a; fi + done + )"} + ) + # cut old entries if still oversized + if [[ $#m -gt $SCD_HISTSIZE ]]; then + m=( ${m[-$SCD_HISTSIZE,-1]} ) + fi + print -lr -- $m >| ${SCD_HISTFILE} fi # Determine the last recorded directory @@ -135,7 +184,6 @@ if [[ -s ${SCD_HISTFILE} ]]; then last_directory=${"$(tail -1 ${SCD_HISTFILE})"#*;} fi -# Internal functions are prefixed with "_scd_Y19oug_". # The "record" function adds its arguments to the directory index. _scd_Y19oug_record() { while [[ -n $last_directory && $1 == $last_directory ]]; do @@ -217,7 +265,7 @@ _scd_Y19oug_action() { # set global arrays dmatching and drank _scd_Y19oug_match() { ## single argument that is an existing directory or directory alias - if [[ $# == 1 ]] && \ + if [[ -z $opt_all && $# == 1 ]] && \ [[ -d ${d::=$1} || -d ${d::=${nameddirs[$1]}} ]] && [[ -x $d ]]; then _scd_Y19oug_abspath dmatching $d @@ -227,6 +275,8 @@ _scd_Y19oug_match() { # ignore case unless there is an argument with an uppercase letter [[ "$*" == *[[:upper:]]* ]] || ICASE='(#i)' + # support "$" as an anchor for the directory name ending + argv=( ${argv/(#m)?[$](#e)/${MATCH[1]}(#e)} ) # calculate rank of all directories in the SCD_HISTFILE and keep it as drank # include a dummy entry for splitting of an empty string is buggy @@ -237,10 +287,10 @@ _scd_Y19oug_match() { BEGIN { FS = "[:;]"; } length($0) < 4096 && $2 > 0 { tau = 1.0 * ($2 - epochseconds) / meanlife; - if (tau < -4.61) tau = -4.61; - prec = exp(tau); + if (tau < -6.9078) tau = -6.9078; + prob = exp(tau); sub(/^[^;]*;/, ""); - if (NF) ptot[$0] += prec; + if (NF) ptot[$0] += prob; } END { for (di in ptot) { print di; print ptot[di]; } }' )"} @@ -249,9 +299,12 @@ _scd_Y19oug_match() { # filter drank to the entries that match all arguments for a; do - p=${ICASE}"*${a}*" + p=${ICASE}"*(${a})*" drank=( ${(kv)drank[(I)${~p}]} ) done + # require at least one argument matches the directory name + p=${ICASE}"*(${(j:|:)argv})[^/]#" + drank=( ${(kv)drank[(I)${~p}]} ) # build a list of matching directories reverse-sorted by their probabilities dmatching=( ${(f)"$( @@ -261,26 +314,6 @@ _scd_Y19oug_match() { )"} ) - # if some directory paths match all patterns in order, discard all others - p=${ICASE}"*${(j:*:)argv}*" - m=( ${(M)dmatching:#${~p}} ) - [[ -d ${m[1]} ]] && dmatching=( $m ) - # if some directory names match last pattern, discard all others - p=${ICASE}"*${(j:*:)argv}[^/]#" - m=( ${(M)dmatching:#${~p}} ) - [[ -d ${m[1]} ]] && dmatching=( $m ) - # if some directory names match all patterns, discard all others - m=( $dmatching ) - for a; do - p=${ICASE}"*/[^/]#${a}[^/]#" - m=( ${(M)m:#${~p}} ) - done - [[ -d ${m[1]} ]] && dmatching=( $m ) - # if some directory names match all patterns in order, discard all others - p=${ICASE}"/*${(j:[^/]#:)argv}[^/]#" - m=( ${(M)dmatching:#${~p}} ) - [[ -d ${m[1]} ]] && dmatching=( $m ) - # do not match $HOME or $PWD when run without arguments if [[ $# == 0 ]]; then dmatching=( ${dmatching:#(${HOME}|${PWD})} ) @@ -302,6 +335,9 @@ _scd_Y19oug_match() { # discard all directories below the rank threshold threshold=$(( maxrank * SCD_THRESHOLD )) + if [[ -n ${opt_all} ]]; then + threshold=0 + fi dmatching=( ${^dmatching}(Ne:'(( ${drank[$REPLY]} >= threshold ))':) ) } @@ -339,6 +375,7 @@ fi ## here we have multiple matches - display selection menu a=( {a-z} {A-Z} ) +a=( ${a[1,${#dmatching}]} ) p=( ) for i in {1..${#dmatching}}; do [[ -n ${a[i]} ]] || break From eae70054d15948cc6ddb3d8d4f252ff2c7cf6ad5 Mon Sep 17 00:00:00 2001 From: Jaap Broekhuizen Date: Mon, 3 Nov 2014 12:29:19 +0100 Subject: [PATCH 31/42] Added VIRTUAL_ENV_DISABLE_PROMPT to steeef.zsh-theme This stops the virtual env name from being printed before it is actually being used in the zsh prompt. --- themes/steeef.zsh-theme | 2 ++ 1 file changed, 2 insertions(+) diff --git a/themes/steeef.zsh-theme b/themes/steeef.zsh-theme index 9d27410b..e38188d3 100644 --- a/themes/steeef.zsh-theme +++ b/themes/steeef.zsh-theme @@ -7,6 +7,8 @@ # git untracked files modification from Brian Carper: # http://briancarper.net/blog/570/git-info-in-your-zsh-prompt +export VIRTUAL_ENV_DISABLE_PROMPT=1 + function virtualenv_info { [ $VIRTUAL_ENV ] && echo '('$fg[blue]`basename $VIRTUAL_ENV`%{$reset_color%}') ' } From 74177c5320b2a1b2f8c4c695c05984b57fd7c6ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Thu, 9 Oct 2014 13:44:54 +0200 Subject: [PATCH 32/42] Change all whoami calls for $USER variable This avoid spawning additional processes, as the $USER variable will **always** contain the current logged-in user. --- lib/completion.zsh | 4 ++-- plugins/systemadmin/systemadmin.plugin.zsh | 2 +- themes/adben.zsh-theme | 5 ++--- themes/agnoster.zsh-theme | 6 ++---- themes/flazz.zsh-theme | 2 +- themes/obraun.zsh-theme | 2 +- themes/re5et.zsh-theme | 2 +- themes/sunrise.zsh-theme | 2 +- themes/ys.zsh-theme | 2 +- 9 files changed, 12 insertions(+), 15 deletions(-) diff --git a/lib/completion.zsh b/lib/completion.zsh index 83b6efb6..3a19a4eb 100644 --- a/lib/completion.zsh +++ b/lib/completion.zsh @@ -27,9 +27,9 @@ zstyle ':completion:*:*:*:*:*' menu select zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#) ([0-9a-z-]#)*=01;34=0=01' if [ "$OSTYPE[0,7]" = "solaris" ] then - zstyle ':completion:*:*:*:*:processes' command "ps -u `whoami` -o pid,user,comm" + zstyle ':completion:*:*:*:*:processes' command "ps -u $USER -o pid,user,comm" else - zstyle ':completion:*:*:*:*:processes' command "ps -u `whoami` -o pid,user,comm -w -w" + zstyle ':completion:*:*:*:*:processes' command "ps -u $USER -o pid,user,comm -w -w" fi # disable named-directories autocompletion diff --git a/plugins/systemadmin/systemadmin.plugin.zsh b/plugins/systemadmin/systemadmin.plugin.zsh index f5e44c66..e0b1773a 100644 --- a/plugins/systemadmin/systemadmin.plugin.zsh +++ b/plugins/systemadmin/systemadmin.plugin.zsh @@ -30,7 +30,7 @@ function retlog() { } alias ping='ping -c 5' -alias clr='clear;echo "Currently logged in on $(tty), as $(whoami) in directory $(pwd)."' +alias clr='clear;echo "Currently logged in on $(tty), as $USER in directory $(pwd)."' alias path='echo -e ${PATH//:/\\n}' alias mkdir='mkdir -pv' # get top process eating memory diff --git a/themes/adben.zsh-theme b/themes/adben.zsh-theme index aa3093f6..6869c8a2 100644 --- a/themes/adben.zsh-theme +++ b/themes/adben.zsh-theme @@ -89,9 +89,8 @@ function precmd { # Context: user@directory or just directory prompt_context () { - local user=`whoami` - if [[ "$user" != "$DEFAULT_USER" || -n "$SSH_CLIENT" ]]; then - echo -n "${PR_RESET}${PR_RED}$user@%m${PR_RESET}${PR_BRIGHT_YELLOW}%~%<<${PR_RESET}" + if [[ "$USER" != "$DEFAULT_USER" || -n "$SSH_CLIENT" ]]; then + echo -n "${PR_RESET}${PR_RED}$USER@%m${PR_RESET}${PR_BRIGHT_YELLOW}%~%<<${PR_RESET}" else echo -n "${PR_RESET}${PR_BRIGHT_YELLOW}%~%<<${PR_RESET}" fi diff --git a/themes/agnoster.zsh-theme b/themes/agnoster.zsh-theme index 2b33c48b..7a62bd86 100644 --- a/themes/agnoster.zsh-theme +++ b/themes/agnoster.zsh-theme @@ -60,10 +60,8 @@ prompt_end() { # Context: user@hostname (who am I and where am I) prompt_context() { - local user=`whoami` - - if [[ "$user" != "$DEFAULT_USER" || -n "$SSH_CLIENT" ]]; then - prompt_segment black default "%(!.%{%F{yellow}%}.)$user@%m" + if [[ "$USER" != "$DEFAULT_USER" || -n "$SSH_CLIENT" ]]; then + prompt_segment black default "%(!.%{%F{yellow}%}.)$USER@%m" fi } diff --git a/themes/flazz.zsh-theme b/themes/flazz.zsh-theme index 280794f2..c0a7fb5d 100644 --- a/themes/flazz.zsh-theme +++ b/themes/flazz.zsh-theme @@ -1,4 +1,4 @@ -if [ "$(whoami)" = "root" ] +if [ "$USER" = "root" ] then CARETCOLOR="red" else CARETCOLOR="blue" fi diff --git a/themes/obraun.zsh-theme b/themes/obraun.zsh-theme index 08d13766..7af44056 100644 --- a/themes/obraun.zsh-theme +++ b/themes/obraun.zsh-theme @@ -1,4 +1,4 @@ -if [ "$(whoami)" = "root" ]; then CARETCOLOR="red"; else CARETCOLOR="blue"; fi +if [ "$USER" = "root" ]; then CARETCOLOR="red"; else CARETCOLOR="blue"; fi local return_code="%(?..%{$fg[red]%}%? ↵%{$reset_color%})" diff --git a/themes/re5et.zsh-theme b/themes/re5et.zsh-theme index 5bded76a..95af1e2e 100644 --- a/themes/re5et.zsh-theme +++ b/themes/re5et.zsh-theme @@ -1,4 +1,4 @@ -if [ "$(whoami)" = "root" ]; then CARETCOLOR="red"; else CARETCOLOR="magenta"; fi +if [ "$USER" = "root" ]; then CARETCOLOR="red"; else CARETCOLOR="magenta"; fi local return_code="%(?..%{$fg_bold[red]%}:( %?%{$reset_color%})" diff --git a/themes/sunrise.zsh-theme b/themes/sunrise.zsh-theme index 4bea20a1..28befd01 100644 --- a/themes/sunrise.zsh-theme +++ b/themes/sunrise.zsh-theme @@ -10,7 +10,7 @@ Y=$fg_no_bold[yellow] B=$fg_no_bold[blue] RESET=$reset_color -if [ "$(whoami)" = "root" ]; then +if [ "$USER" = "root" ]; then PROMPTCOLOR="%{$R%}" PREFIX="-!-"; else PROMPTCOLOR="" PREFIX="---"; diff --git a/themes/ys.zsh-theme b/themes/ys.zsh-theme index a44f295f..65448964 100644 --- a/themes/ys.zsh-theme +++ b/themes/ys.zsh-theme @@ -33,7 +33,7 @@ ${git_info} \ %{$fg[white]%}[%*] %{$terminfo[bold]$fg[red]%}$ %{$reset_color%}" -if [[ "$(whoami)" == "root" ]]; then +if [[ "$USER" == "root" ]]; then PROMPT=" %{$terminfo[bold]$fg[blue]%}#%{$reset_color%} \ %{$bg[yellow]%}%{$fg[cyan]%}%n%{$reset_color%} \ From 4310a15de5d0587ef135f9e12857620c4788dec2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Thu, 9 Oct 2014 13:55:50 +0200 Subject: [PATCH 33/42] Change all pwd calls for $PWD variable This avoids spawning additional processes as $PWD **always** contains the current working directory. --- plugins/dirhistory/dirhistory.plugin.zsh | 6 +++--- plugins/jump/jump.plugin.zsh | 6 +++--- plugins/pow/pow.plugin.zsh | 8 ++++---- plugins/svn/svn.plugin.zsh | 2 +- plugins/systemadmin/systemadmin.plugin.zsh | 2 +- plugins/vim-interaction/vim-interaction.plugin.zsh | 2 +- 6 files changed, 13 insertions(+), 13 deletions(-) diff --git a/plugins/dirhistory/dirhistory.plugin.zsh b/plugins/dirhistory/dirhistory.plugin.zsh index 504d7ec1..d101cfca 100644 --- a/plugins/dirhistory/dirhistory.plugin.zsh +++ b/plugins/dirhistory/dirhistory.plugin.zsh @@ -3,7 +3,7 @@ # that the user has changed to in the past, and ALT-RIGHT undoes ALT-LEFT. # -dirhistory_past=(`pwd`) +dirhistory_past=($PWD) dirhistory_future=() export dirhistory_past export dirhistory_future @@ -50,7 +50,7 @@ function push_future() { # Called by zsh when directory changes function chpwd() { - push_past `pwd` + push_past $PWD # If DIRHISTORY_CD is not set... if [[ -z "${DIRHISTORY_CD+x}" ]]; then # ... clear future. @@ -73,7 +73,7 @@ function dirhistory_back() { pop_past cw if [[ "" == "$cw" ]]; then # Someone overwrote our variable. Recover it. - dirhistory_past=(`pwd`) + dirhistory_past=($PWD) return fi diff --git a/plugins/jump/jump.plugin.zsh b/plugins/jump/jump.plugin.zsh index 1b23b5d4..b16814fe 100644 --- a/plugins/jump/jump.plugin.zsh +++ b/plugins/jump/jump.plugin.zsh @@ -14,12 +14,12 @@ jump() { mark() { if (( $# == 0 )); then - MARK=$(basename "$(pwd)") + MARK=$(basename "$PWD") else MARK="$1" fi - if read -q \?"Mark $(pwd) as ${MARK}? (y/n) "; then - mkdir -p "$MARKPATH"; ln -s "$(pwd)" "$MARKPATH/$MARK" + if read -q \?"Mark $PWD as ${MARK}? (y/n) "; then + mkdir -p "$MARKPATH"; ln -s "$PWD" "$MARKPATH/$MARK" fi } diff --git a/plugins/pow/pow.plugin.zsh b/plugins/pow/pow.plugin.zsh index d85c8877..ded3336a 100644 --- a/plugins/pow/pow.plugin.zsh +++ b/plugins/pow/pow.plugin.zsh @@ -21,13 +21,13 @@ rack_root(){ setopt chaselinks - local orgdir="$(pwd)" - local basedir="$(pwd)" + local orgdir="$PWD" + local basedir="$PWD" while [[ $basedir != '/' ]]; do test -e "$basedir/config.ru" && break builtin cd ".." 2>/dev/null - basedir="$(pwd)" + basedir="$PWD" done builtin cd "$orgdir" 2>/dev/null @@ -56,7 +56,7 @@ kapow(){ compctl -W ~/.pow -/ kapow powit(){ - local basedir="$(pwd)" + local basedir="$PWD" local vhost=$1 [ ! -n "$vhost" ] && vhost=$(rack_root_detect) if [ ! -h ~/.pow/$vhost ] diff --git a/plugins/svn/svn.plugin.zsh b/plugins/svn/svn.plugin.zsh index ef6da5bd..ba281d79 100644 --- a/plugins/svn/svn.plugin.zsh +++ b/plugins/svn/svn.plugin.zsh @@ -77,7 +77,7 @@ function svn_dirty() { function svn_dirty_choose_pwd () { if in_svn; then - root=`pwd` + root=$PWD if $(svn status $root 2> /dev/null | 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/systemadmin/systemadmin.plugin.zsh b/plugins/systemadmin/systemadmin.plugin.zsh index e0b1773a..4ae70dfa 100644 --- a/plugins/systemadmin/systemadmin.plugin.zsh +++ b/plugins/systemadmin/systemadmin.plugin.zsh @@ -30,7 +30,7 @@ function retlog() { } alias ping='ping -c 5' -alias clr='clear;echo "Currently logged in on $(tty), as $USER in directory $(pwd)."' +alias clr='clear;echo "Currently logged in on $(tty), as $USER in directory $PWD."' alias path='echo -e ${PATH//:/\\n}' alias mkdir='mkdir -pv' # get top process eating memory diff --git a/plugins/vim-interaction/vim-interaction.plugin.zsh b/plugins/vim-interaction/vim-interaction.plugin.zsh index 5142f1f9..b0b9414c 100644 --- a/plugins/vim-interaction/vim-interaction.plugin.zsh +++ b/plugins/vim-interaction/vim-interaction.plugin.zsh @@ -9,7 +9,7 @@ function resolveFile if [ -f "$1" ]; then echo $(readlink -f "$1") elif [[ "${1#/}" == "$1" ]]; then - echo "$(pwd)/$1" + echo "$PWD/$1" else echo $1 fi From 95d795e8cad7d1a754dfad520309d7a41b69275f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Thu, 9 Oct 2014 17:05:48 +0200 Subject: [PATCH 34/42] Change all hostname calls for $HOST or $SHORT_HOST --- plugins/profiles/profiles.plugin.zsh | 2 +- themes/candy-kingdom.zsh-theme | 2 +- themes/dieter.zsh-theme | 2 +- themes/fino-time.zsh-theme | 2 +- themes/fino.zsh-theme | 2 +- themes/kardan.zsh-theme | 2 +- themes/michelebologna.zsh-theme | 2 +- themes/ys.zsh-theme | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/plugins/profiles/profiles.plugin.zsh b/plugins/profiles/profiles.plugin.zsh index 8faae6b5..4b3d6a85 100644 --- a/plugins/profiles/profiles.plugin.zsh +++ b/plugins/profiles/profiles.plugin.zsh @@ -2,7 +2,7 @@ # This will look for a custom profile for the local machine and each domain or # subdomain it belongs to. (e.g. com, example.com and foo.example.com) -parts=(${(s:.:)$(hostname)}) +parts=(${(s:.:)$HOST}) for i in {${#parts}..1}; do profile=${(j:.:)${parts[$i,${#parts}]}} file=$ZSH_CUSTOM/profiles/$profile diff --git a/themes/candy-kingdom.zsh-theme b/themes/candy-kingdom.zsh-theme index 718977d9..88912875 100644 --- a/themes/candy-kingdom.zsh-theme +++ b/themes/candy-kingdom.zsh-theme @@ -13,7 +13,7 @@ patches: Date: Fri, 7 Nov 2014 10:47:27 +0100 Subject: [PATCH 35/42] Fixes the profiles-plugin An error was introduced with 7f75bb9, which uses special vars. This is the fix. --- plugins/profiles/profiles.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/profiles/profiles.plugin.zsh b/plugins/profiles/profiles.plugin.zsh index 4b3d6a85..5bc56cea 100644 --- a/plugins/profiles/profiles.plugin.zsh +++ b/plugins/profiles/profiles.plugin.zsh @@ -2,7 +2,7 @@ # This will look for a custom profile for the local machine and each domain or # subdomain it belongs to. (e.g. com, example.com and foo.example.com) -parts=(${(s:.:)$HOST}) +parts=(${(s:.:)HOST}) for i in {${#parts}..1}; do profile=${(j:.:)${parts[$i,${#parts}]}} file=$ZSH_CUSTOM/profiles/$profile From d0f3fb3a4fdce51e1f59bdf4817c7adec80b0784 Mon Sep 17 00:00:00 2001 From: Jarin Udom Date: Tue, 10 Jun 2014 07:24:38 -0700 Subject: [PATCH 36/42] Merge simplified superjarin theme --- themes/superjarin.zsh-theme | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/themes/superjarin.zsh-theme b/themes/superjarin.zsh-theme index 2920d17a..86fa9c70 100644 --- a/themes/superjarin.zsh-theme +++ b/themes/superjarin.zsh-theme @@ -1,11 +1,5 @@ -# Grab the current version of ruby in use (via RVM): [ruby-1.8.7] -if [ -e ~/.rvm/bin/rvm-prompt ]; then - JARIN_CURRENT_RUBY_="%{$fg[white]%}[%{$fg[red]%}\$(~/.rvm/bin/rvm-prompt i v)%{$fg[white]%}]%{$reset_color%}" -else - if which rbenv &> /dev/null; then - JARIN_CURRENT_RUBY_="%{$fg[white]%}[%{$fg[red]%}\$(rbenv version | sed -e 's/ (set.*$//')%{$fg[white]%}]%{$reset_color%}" - fi -fi +# Grab the current version of ruby in use: [ruby-1.8.7] +JARIN_CURRENT_RUBY_="%{$fg[white]%}[%{$fg[red]%}\$(ruby_prompt_info)%{$fg[white]%}]%{$reset_color%}" # Grab the current filepath, use shortcuts: ~/Desktop # Append the current git branch, if in a git repository From 923d2c85b40e14ea90d4342be1e1905bb238ea0b Mon Sep 17 00:00:00 2001 From: Geoffrey Washburn Date: Sun, 19 Jan 2014 14:10:16 -0500 Subject: [PATCH 37/42] Fix autojump script to support Nix installations --- 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 50a69476..652d2269 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/.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 . /usr/share/autojump/autojump.zsh elif [ -f /etc/profile.d/autojump.zsh ]; then # manual installation From 0c04470f6370c329ce8252371fe617673b515d45 Mon Sep 17 00:00:00 2001 From: "Kravchuk S.V" Date: Fri, 14 Nov 2014 13:05:11 +0300 Subject: [PATCH 38/42] [~] fix plugin pj https://github.com/robbyrussell/oh-my-zsh/commit/bce74975d055529cbd186782e2fd99e6da840460 --- plugins/pj/pj.plugin.zsh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/pj/pj.plugin.zsh b/plugins/pj/pj.plugin.zsh index f9cbddf1..1572e936 100644 --- a/plugins/pj/pj.plugin.zsh +++ b/plugins/pj/pj.plugin.zsh @@ -42,8 +42,8 @@ function _pj () { # might be possible to improve this using glob, without the basename trick typeset -a projects projects=($PROJECT_PATHS/*) - projects=$projects:t - _arguments '*:file:($projects)' + projects=$projects:t + _arguments "*:file:($projects)" } compdef _pj pj From a301f567e3a7ac2eb0b1f77d6ff97f50d63ba864 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Wed, 19 Nov 2014 18:33:00 +0100 Subject: [PATCH 39/42] Switch back to oh-my-zsh.hide-dirty setting again Commit 81004dfaba509ff62a13ba303ab941938d619326 reverted the change in 9b811fb625c03c30a766191cdf65a1c7c1fd96b2 when editing the merge conflict from #2928. This commit fixes that so that we don't make the same mistake again. First seen in http://git.io/Cdaj5Q --- lib/git.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/git.zsh b/lib/git.zsh index aba09542..748520a6 100644 --- a/lib/git.zsh +++ b/lib/git.zsh @@ -13,7 +13,7 @@ parse_git_dirty() { local STATUS='' local FLAGS FLAGS=('--porcelain') - if [[ "$(command git config --get oh-my-zsh.hide-status)" != "1" ]]; then + if [[ "$(command git config --get oh-my-zsh.hide-dirty)" != "1" ]]; then if [[ $POST_1_7_2_GIT -gt 0 ]]; then FLAGS+='--ignore-submodules=dirty' fi From b6b1dd3cd713751c5295b8346af071b420a99f87 Mon Sep 17 00:00:00 2001 From: Doan Truong Thi Date: Fri, 21 Nov 2014 10:07:23 +0900 Subject: [PATCH 40/42] Fix Yosemite broken zsh where $PATH var does not get appended correctly. Sourcing oh-my-zsh immediately after export PATH. --- templates/zshrc.zsh-template | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/templates/zshrc.zsh-template b/templates/zshrc.zsh-template index a12eca2a..763288df 100644 --- a/templates/zshrc.zsh-template +++ b/templates/zshrc.zsh-template @@ -47,13 +47,13 @@ ZSH_THEME="robbyrussell" # Add wisely, as too many plugins slow down shell startup. plugins=(git) -source $ZSH/oh-my-zsh.sh - # User configuration export PATH=$HOME/bin:/usr/local/bin:$PATH # export MANPATH="/usr/local/man:$MANPATH" +source $ZSH/oh-my-zsh.sh + # You may need to manually set your language environment # export LANG=en_US.UTF-8 From db8eacf6fd0570c8e49e59a44c214bd927479861 Mon Sep 17 00:00:00 2001 From: Will Boyce Date: Mon, 9 Jun 2014 18:04:16 +0100 Subject: [PATCH 41/42] use pigz if available in extract plugin --- plugins/extract/extract.plugin.zsh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/extract/extract.plugin.zsh b/plugins/extract/extract.plugin.zsh index a6e16ddf..898d3d36 100644 --- a/plugins/extract/extract.plugin.zsh +++ b/plugins/extract/extract.plugin.zsh @@ -38,7 +38,7 @@ function extract() { file_name="$( basename "$1" )" extract_dir="$( echo "$file_name" | sed "s/\.${1##*.}//g" )" case "$1" in - (*.tar.gz|*.tgz) tar xvzf "$1" ;; + (*.tar.gz|*.tgz) [ -z $commands[pigz] ] && tar zxvf "$1" || pigz -dc "$1" | tar xv ;; (*.tar.bz2|*.tbz|*.tbz2) tar xvjf "$1" ;; (*.tar.xz|*.txz) tar --xz --help &> /dev/null \ && tar --xz -xvf "$1" \ @@ -47,7 +47,7 @@ function extract() { && tar --lzma -xvf "$1" \ || lzcat "$1" | tar xvf - ;; (*.tar) tar xvf "$1" ;; - (*.gz) gunzip "$1" ;; + (*.gz) [ -z $commands[pigz] ] && gunzip "$1" || pigz -d "$1" ;; (*.bz2) bunzip2 "$1" ;; (*.xz) unxz "$1" ;; (*.lzma) unlzma "$1" ;; From ed029f18010ea10c7bc4a2a90f75111503e613d9 Mon Sep 17 00:00:00 2001 From: Will Boyce Date: Tue, 29 Apr 2014 14:38:48 +0100 Subject: [PATCH 42/42] allow overriding lib/*.zsh in custom/lib --- oh-my-zsh.sh | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/oh-my-zsh.sh b/oh-my-zsh.sh index d0e89f31..d75b521c 100644 --- a/oh-my-zsh.sh +++ b/oh-my-zsh.sh @@ -8,18 +8,20 @@ fi # add a function path fpath=($ZSH/functions $ZSH/completions $fpath) -# Load all of the config files in ~/oh-my-zsh that end in .zsh -# TIP: Add files you don't want in git to .gitignore -for config_file ($ZSH/lib/*.zsh); do - source $config_file -done - # 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 ZSH_CUSTOM="$ZSH/custom" fi +# Load all of the config files in ~/oh-my-zsh that end in .zsh +# TIP: Add files you don't want in git to .gitignore +for config_file ($ZSH/lib/*.zsh); do + custom_config_file="${ZSH_CUSTOM}/lib/${config_file:t}" + [ -f "${custom_config_file}" ] && config_file=${custom_config_file} + source $config_file +done + is_plugin() { local base_dir=$1