diff options
-rw-r--r-- | CONTRIBUTING.md | 42 | ||||
-rw-r--r-- | cache/.easter-egg | 4 | ||||
-rw-r--r-- | lib/aliases.zsh | 1 | ||||
-rw-r--r-- | lib/functions.zsh | 4 | ||||
-rw-r--r-- | lib/termsupport.zsh | 5 | ||||
-rw-r--r-- | oh-my-zsh.sh | 2 | ||||
-rw-r--r-- | plugins/adb/_adb | 39 | ||||
-rw-r--r-- | plugins/aws/aws.plugin.zsh | 15 | ||||
-rw-r--r-- | plugins/brew/_brew | 1 | ||||
-rw-r--r-- | plugins/composer/composer.plugin.zsh | 4 | ||||
-rw-r--r-- | plugins/gem/_gem | 2 | ||||
-rw-r--r-- | plugins/git-prompt/gitstatus.py | 2 | ||||
-rw-r--r-- | plugins/git/git.plugin.zsh | 4 | ||||
-rw-r--r-- | plugins/pass/_pass | 33 | ||||
-rw-r--r-- | plugins/tmuxinator/_tmuxinator | 6 | ||||
-rw-r--r-- | plugins/wd/LICENSE | 21 | ||||
-rw-r--r-- | plugins/wd/README.md | 26 | ||||
-rw-r--r-- | plugins/wd/_wd.sh | 15 | ||||
-rw-r--r-- | plugins/wd/wd.plugin.zsh | 4 | ||||
-rwxr-xr-x | plugins/wd/wd.sh | 159 | ||||
-rw-r--r-- | plugins/zsh_reload/zsh_reload.plugin.zsh | 5 | ||||
-rw-r--r-- | tools/check_for_upgrade.sh | 2 | ||||
-rwxr-xr-x | tools/install.sh | 4 |
23 files changed, 284 insertions, 116 deletions
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 000000000..9964c380d --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,42 @@ +# CONTRIBUTING GUIDELINE + +1. [Luke, use the search](#luke-use-the-search) +2. [You have a problem](#you-have-a-problem) +3. [You have a solution](#you-have-a-solution) + +**BONUS:** [You have free time to volunteer](#you-have-free-time-to-volunteer) + +## LUKE, USE THE SEARCH + +May the experiences of other people be with you + + +## YOU HAVE A PROBLEM + +See point 1, then look at FAQ or Troubleshooting wiki pages (first we'll have to make them) + + +## YOU HAVE A SOLUTION + +See point 1, then go ahead (unless your solution is yet another theme) + + +## YOU HAVE FREE TIME TO VOLUNTEER + +Cool! Please have a look at the list below to understand how oh-my-zsh categorizes its issues. + +Classification of issues and + +- Bugs, which may be: + - Specific of zsh \* + - Regressions, in which we should summon the author of the offending commit once it is located + +- Feature requests + +- Helpdesk, which may be: + - Specific of zsh \* + - Everything else + +\* In the case of bugs, I see the benefit in going through the trouble of responding to that. After all, oh-my-zsh should be the missing link that makes zsh perfect, and hunting down an upstream bug can lead to a submitted PR. +In the case of helpdesk, minimal response should be done. That is, provide a link to the wiki with the relevant information, or +add it to the FAQ of the wiki and point to it afterwards. diff --git a/cache/.easter-egg b/cache/.easter-egg new file mode 100644 index 000000000..4b6164edb --- /dev/null +++ b/cache/.easter-egg @@ -0,0 +1,4 @@ +This file is only here so that Git will keep a cache directory as .gitignore is ignoring all the files within it. + +Feel free to add love notes for people here. + diff --git a/lib/aliases.zsh b/lib/aliases.zsh index 3044c9660..aae865046 100644 --- a/lib/aliases.zsh +++ b/lib/aliases.zsh @@ -30,7 +30,6 @@ alias lsa='ls -lah' alias l='ls -lah' alias ll='ls -lh' alias la='ls -lAh' -alias sl=ls # often screw this up alias afind='ack-grep -il' diff --git a/lib/functions.zsh b/lib/functions.zsh index fda84a953..17f5f9cbf 100644 --- a/lib/functions.zsh +++ b/lib/functions.zsh @@ -3,11 +3,11 @@ function zsh_stats() { } function uninstall_oh_my_zsh() { - /usr/bin/env ZSH=$ZSH /bin/sh $ZSH/tools/uninstall.sh + env ZSH=$ZSH /bin/sh $ZSH/tools/uninstall.sh } function upgrade_oh_my_zsh() { - /usr/bin/env ZSH=$ZSH /bin/sh $ZSH/tools/upgrade.sh + env ZSH=$ZSH /bin/sh $ZSH/tools/upgrade.sh } function take() { diff --git a/lib/termsupport.zsh b/lib/termsupport.zsh index 9c0a430fb..9d6681603 100644 --- a/lib/termsupport.zsh +++ b/lib/termsupport.zsh @@ -34,6 +34,5 @@ function omz_termsupport_preexec { title '$CMD' '%100>...>$LINE%<<' } -autoload -U add-zsh-hook -add-zsh-hook precmd omz_termsupport_precmd -add-zsh-hook preexec omz_termsupport_preexec +precmd_functions+=(omz_termsupport_precmd) +preexec_functions+=(omz_termsupport_preexec) diff --git a/oh-my-zsh.sh b/oh-my-zsh.sh index c217b91bb..a90b3e98a 100644 --- a/oh-my-zsh.sh +++ b/oh-my-zsh.sh @@ -1,6 +1,6 @@ # 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 + env ZSH=$ZSH DISABLE_UPDATE_PROMPT=$DISABLE_UPDATE_PROMPT zsh -f $ZSH/tools/check_for_upgrade.sh fi # Initializes Oh My Zsh diff --git a/plugins/adb/_adb b/plugins/adb/_adb new file mode 100644 index 000000000..4c998172d --- /dev/null +++ b/plugins/adb/_adb @@ -0,0 +1,39 @@ +#compdef adb +#autoload + +# in order to make this work, you will need to have the android adb tools + +# adb zsh completion, based on homebrew completion + +local -a _1st_arguments +_1st_arguments=( +'bugreport:return all information from the device that should be included in a bug report.' +'connect:connect to a device via TCP/IP Port 5555 is default.' +'devices:list all connected devices' +'disconnect:disconnect from a TCP/IP device. Port 5555 is default.' +'emu:run emulator console command' +'forward:forward socket connections' +'help:show the help message' +'install:push this package file to the device and install it' +'jdwp:list PIDs of processes hosting a JDWP transport' +'logcat:View device log' +'pull:copy file/dir from device' +'push:copy file/dir to device' +'shell:run remote shell interactively' +'sync:copy host->device only if changed (-l means list but dont copy)' +'uninstall:remove this app package from the device' +'version:show version num' +) + +local expl +local -a pkgs installed_pkgs + +_arguments \ + '*:: :->subcmds' && return 0 + +if (( CURRENT == 1 )); then + _describe -t commands "adb subcommand" _1st_arguments + return +fi + +_files diff --git a/plugins/aws/aws.plugin.zsh b/plugins/aws/aws.plugin.zsh index 3f7fb1995..8b57d7db1 100644 --- a/plugins/aws/aws.plugin.zsh +++ b/plugins/aws/aws.plugin.zsh @@ -1,3 +1,11 @@ +_homebrew-installed() { + type brew &> /dev/null +} + +_awscli-homebrew-installed() { + brew --prefix awscli &> /dev/null +} + export AWS_HOME=~/.aws function agp { @@ -14,4 +22,9 @@ function aws_profiles { } compctl -K aws_profiles asp -source `which aws_zsh_completer.sh` + +if _homebrew-installed && _awscli-homebrew-installed ; then + source $(brew --prefix)/opt/awscli/libexec/bin/aws_zsh_completer.sh +else + source `which aws_zsh_completer.sh` +fi diff --git a/plugins/brew/_brew b/plugins/brew/_brew index 9eb3bb557..40442a1d3 100644 --- a/plugins/brew/_brew +++ b/plugins/brew/_brew @@ -50,6 +50,7 @@ _1st_arguments=( 'server:start a local web app that lets you browse formulae (requires Sinatra)' 'services:small wrapper around `launchctl` for supported formulae' 'tap:tap a new formula repository from GitHub, or list existing taps' + 'uninstall:uninstall a formula' 'unlink:unlink a formula' 'unpin:unpin specified formulae' 'untap:remove a tapped repository' diff --git a/plugins/composer/composer.plugin.zsh b/plugins/composer/composer.plugin.zsh index 86f2ca4df..2243dd3c1 100644 --- a/plugins/composer/composer.plugin.zsh +++ b/plugins/composer/composer.plugin.zsh @@ -47,5 +47,5 @@ alias cdu='composer dump-autoload' # install composer in the current directory alias cget='curl -s https://getcomposer.org/installer | php' -# Add Composer's global binaries to PATH -export PATH=$PATH:~/.composer/vendor/bin +# Add Composer's global & local binaries to PATH +export PATH=$PATH:~/.composer/vendor/bin:./bin diff --git a/plugins/gem/_gem b/plugins/gem/_gem index 25967f1e7..92feebe95 100644 --- a/plugins/gem/_gem +++ b/plugins/gem/_gem @@ -59,6 +59,8 @@ case "$words[1]" in build) _files -g "*.gemspec" ;; + install) + _files ;; list) if [[ "$state" == forms ]]; then _gem_installed diff --git a/plugins/git-prompt/gitstatus.py b/plugins/git-prompt/gitstatus.py index c665a9ee1..256841432 100644 --- a/plugins/git-prompt/gitstatus.py +++ b/plugins/git-prompt/gitstatus.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python2 +#!/usr/bin/env python # -*- coding: UTF-8 -*- from subprocess import Popen, PIPE import re diff --git a/plugins/git/git.plugin.zsh b/plugins/git/git.plugin.zsh index 9f7819df3..1ec4d6310 100644 --- a/plugins/git/git.plugin.zsh +++ b/plugins/git/git.plugin.zsh @@ -7,6 +7,8 @@ alias gd='git diff' compdef _git gd=git-diff alias gdc='git diff --cached' compdef _git gdc=git-diff +alias gdt='git diff-tree --no-commit-id --name-only -r' +compdef _git gdc=git diff-tree --no-commit-id --name-only -r alias gl='git pull' compdef _git gl=git-pull alias gup='git pull --rebase' @@ -108,12 +110,14 @@ alias gsd='git svn dcommit' # Usage example: git pull origin $(current_branch) # function current_branch() { + if [ ! -d .git ]; then return; fi ref=$(git symbolic-ref HEAD 2> /dev/null) || \ ref=$(git rev-parse --short HEAD 2> /dev/null) || return echo ${ref#refs/heads/} } function current_repository() { + if [ ! -d .git ]; then return; fi ref=$(git symbolic-ref HEAD 2> /dev/null) || \ ref=$(git rev-parse --short HEAD 2> /dev/null) || return echo $(git remote -v | cut -d':' -f 2) diff --git a/plugins/pass/_pass b/plugins/pass/_pass index d8ec38828..7a9b1f955 100644 --- a/plugins/pass/_pass +++ b/plugins/pass/_pass @@ -1,13 +1,16 @@ #compdef pass #autoload -# Copyright (C) 2012: +# Copyright (C) 2012 - 2014: # Johan Venant <jvenant@invicem.pro> # Brian Mattern <rephorm@rephorm.com> # Jason A. Donenfeld <Jason@zx2c4.com>. -# Santiago Borrazás <sanbor@gmail.com> # All Rights Reserved. -# This file is licensed under the GPLv2+. Please see COPYING for more information. +# +# This file is licensed under the GPLv2+. +# Please visit http://git.zx2c4.com/password-store/tree/COPYING for more information. +# +# Oh my zsh plugin maintainer: Santiago Borrazás <sanbor@gmail.com> _pass () { @@ -23,8 +26,8 @@ _pass () { case "${cmd}" in init) _arguments : \ - "-r[re-encrypt existing passwords]" \ - "--reencrypt[re-encrypt existing passwords]" + "-p[gpg-id will only be applied to this subfolder]" \ + "--path[gpg-id will only be applied to this subfolder]" _pass_complete_keys ;; ls|list|edit) @@ -43,9 +46,19 @@ _pass () { "-n[don't include symbols in password]" \ "--no-symbols[don't include symbols in password]" \ "-c[copy password to the clipboard]" \ - "--clip[copy password to the clipboard]" + "--clip[copy password to the clipboard]" \ + "-f[force overwrite]" \ + "--force[force overwrite]" \ + "-i[replace first line]" \ + "--in-place[replace first line]" _pass_complete_entries_with_subdirs ;; + cp|copy|mv|rename) + _arguments : \ + "-f[force rename]" \ + "--force[force rename]" + _pass_complete_entries_with_subdirs + ;; rm) _arguments : \ "-f[force deletion]" \ @@ -75,10 +88,14 @@ _pass () { subcommands=( "init:Initialize new password storage" "ls:List passwords" + "find:Find password files or directories based on pattern" + "grep:Search inside decrypted password files for matching pattern" "show:Decrypt and print a password" "insert:Insert a new password" "generate:Generate a new password using pwgen" "edit:Edit a password with \$EDITOR" + "mv:Rename the password" + "cp:Copy the password" "rm:Remove the password" "git:Call git on the password store" "version:Output version information" @@ -101,7 +118,7 @@ _pass_cmd_show () { _pass_complete_entries_helper () { local IFS=$'\n' local prefix="${PASSWORD_STORE_DIR:-$HOME/.password-store}" - _values -C 'passwords' $(find -L "$prefix" \( -name .git -o -name .gpg-id \) -prune -o $@ -print | sed -e "s#${prefix}.##" -e 's#\.gpg##' | sort) + _values -C 'passwords' ${$(find -L "$prefix" \( -name .git -o -name .gpg-id \) -prune -o $@ -print 2>/dev/null | sed -e "s#${prefix}/\{0,1\}##" -e 's#\.gpg##' | sort):-""} } _pass_complete_entries_with_subdirs () { @@ -117,3 +134,5 @@ _pass_complete_keys () { # Extract names and email addresses from gpg --list-keys _values 'gpg keys' $(gpg2 --list-secret-keys --with-colons | cut -d : -f 10 | sort -u | sed '/^$/d') } + +_pass diff --git a/plugins/tmuxinator/_tmuxinator b/plugins/tmuxinator/_tmuxinator index cd227b7df..e4f8b6ce0 100644 --- a/plugins/tmuxinator/_tmuxinator +++ b/plugins/tmuxinator/_tmuxinator @@ -11,10 +11,12 @@ _arguments -C \ case $state in cmds) _values "tmuxinator command" \ + "new[create a new project file and open it in your editor]" \ "start[start a tmux session using project's tmuxinator config]" \ "open[create a new project file and open it in your editor]" \ "copy[copy source_project project file to a new project called new_project]" \ "delete[deletes the project called project_name]" \ + "debug[output the shell commands generated by a projet]" \ "implode[deletes all existing projects!]" \ "list[list all existing projects]" \ "doctor[look for problems in your configuration]" \ @@ -24,9 +26,9 @@ case $state in ;; args) case $line[1] in - start|open|copy|delete) + start|open|copy|delete|debug) _configs=(`find ~/.tmuxinator -name \*.yml | cut -d/ -f5 | sed s:.yml::g`) - _values 'configs' $_configs + [[ -n "$_configs" ]] && _values 'configs' $_configs ret=0 ;; esac diff --git a/plugins/wd/LICENSE b/plugins/wd/LICENSE new file mode 100644 index 000000000..8caa6c6ce --- /dev/null +++ b/plugins/wd/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2014 Markus Færevaag + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE.
\ No newline at end of file diff --git a/plugins/wd/README.md b/plugins/wd/README.md index f9f4e7ac1..bc0ebe334 100644 --- a/plugins/wd/README.md +++ b/plugins/wd/README.md @@ -2,37 +2,39 @@ **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) +`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 * Add warp point to current working directory: - wd add test + $ wd add foo If a warp point with the same name exists, use `add!` to overwrite it. - * From an other directory, warp to test with: + Note, a warp point cannot contain colons, or only consist of only spaces and dots. The first will conflict in how `wd` stores the warp points, and the second will conflict other features, as below. - wd test + * From an other directory (not necessarily), warp to `foo` with: - * You can warp back to previous directory, and so on, with the puncticulation syntax: + $ wd foo - wd .. - wd ... + * You can warp back to previous directory, and so on, with this dot syntax: + + $ wd .. + $ wd ... This is a wrapper for the zsh `dirs` function. * Remove warp point test point: - wd rm test + $ wd rm foo - * List warp points to current directory (stored in `~/.warprc`): + * List all warp points (stored in `~/.warprc`): - wd show + $ wd ls - * List all warp points (stored in `~/.warprc`): + * List warp points to current directory - wd ls + $ wd show * Print usage with no opts or the `help` argument. diff --git a/plugins/wd/_wd.sh b/plugins/wd/_wd.sh index 29df63520..0b03d8fff 100644 --- a/plugins/wd/_wd.sh +++ b/plugins/wd/_wd.sh @@ -5,23 +5,16 @@ zstyle ':completion::complete:wd:*:commands' group-name commands zstyle ':completion::complete:wd:*:warp_points' group-name warp_points zstyle ':completion::complete:wd::' list-grouped -# Call `_wd()` when when trying to complete the command `wd` - zmodload zsh/mapfile + function _wd() { - local ret=1 local CONFIG=$HOME/.warprc - - # Stolen from - # http://stackoverflow.com/questions/9000698/completion-when-program-has-sub-commands - - # local curcontext="$curcontext" state line - # typeset -A opt_args + local ret=1 local -a commands local -a warp_points - warp_points=( "${(f)mapfile[$CONFIG]}" ) - # LIST="${mapfile[$FNAME]}" # Not required unless stuff uses it + + warp_points=( "${(f)mapfile[$CONFIG]//$HOME/~}" ) commands=( 'add:Adds the current working directory to your warp points' diff --git a/plugins/wd/wd.plugin.zsh b/plugins/wd/wd.plugin.zsh index 9800335fc..c0559293d 100644 --- a/plugins/wd/wd.plugin.zsh +++ b/plugins/wd/wd.plugin.zsh @@ -1,7 +1,7 @@ #!/bin/zsh -# WARP -# ==== +# WARP DIRECTORY +# ============== # oh-my-zsh plugin # # @github.com/mfaerevaag/wd diff --git a/plugins/wd/wd.sh b/plugins/wd/wd.sh index 9ebad6808..dfb9ad89a 100755 --- a/plugins/wd/wd.sh +++ b/plugins/wd/wd.sh @@ -1,7 +1,7 @@ #!/bin/zsh -# WARP -# ==== +# WARP DIRECTORY +# ============== # Jump to custom directories in terminal # because `cd` takes too long... # @@ -9,26 +9,28 @@ ## variables -CONFIG=$HOME/.warprc +readonly CONFIG=$HOME/.warprc -## colors -BLUE="\033[96m" -GREEN="\033[92m" -YELLOW="\033[93m" -RED="\033[91m" -NOC="\033[m" +# colors +readonly BLUE="\033[96m" +readonly GREEN="\033[92m" +readonly YELLOW="\033[93m" +readonly RED="\033[91m" +readonly NOC="\033[m" +## init + # check if config file exists -if [[ ! -a $CONFIG ]] +if [ ! -e $CONFIG ] then - # if not: create config file - touch $CONFIG + # if not, create config file + touch $CONFIG fi -## load warp points +# load warp points typeset -A points -while read line +while read -r line do arr=(${(s,:,)line}) key=${arr[1]} @@ -39,72 +41,78 @@ done < $CONFIG ## functions -# prepended wd_ to not conflict with your environment (no sub shell) wd_warp() { - if [[ $1 =~ "^\.+$" ]] + local point=$1 + + if [[ $point =~ "^\.+$" ]] then - if [[ $#1 < 2 ]] + if [ $#1 < 2 ] then wd_print_msg $YELLOW "Warping to current directory?" else (( n = $#1 - 1 )) - #wd_print_msg $BLUE "Warping..." cd -$n > /dev/null fi - elif [[ ${points[$1]} != "" ]] + elif [[ ${points[$point]} != "" ]] then - #wd_print_msg $BLUE "Warping..." - cd ${points[$1]} + cd ${points[$point]} else - wd_print_msg $RED "Unknown warp point '$1'" + wd_print_msg $RED "Unknown warp point '${point}'" fi } wd_add() { - if [[ $2 =~ "^\.+$" || $2 =~ "^\s*$" ]] + 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 "Illegal warp point (see README)." - elif [[ ${points[$2]} == "" ]] || $1 + wd_print_msg $RED "Warp point should not contain whitespace" + elif [[ $point == *:* ]] then - wd_remove $2 > /dev/null - print "$2:$PWD" >> $CONFIG + 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 '$2' already exists. Use 'add!' to overwrite." + wd_print_msg $YELLOW "Warp point '${point}' already exists. Use 'add!' to overwrite." fi } wd_remove() { - if [[ ${points[$1]} != "" ]] + local point=$1 + + if [[ ${points[$point]} != "" ]] then - if wd_tmp=`sed "/^$1:/d" $CONFIG` + if sed -i.bak "s,^${point}:.*$,,g" $CONFIG then - # `>!` forces overwrite - # we need this if people use `setopt NO_CLOBBER` - echo $wd_tmp >! $CONFIG wd_print_msg $GREEN "Warp point removed" else - wd_print_msg $RED "Warp point unsuccessfully removed. Sorry!" + wd_print_msg $RED "Something bad happened! Sorry." fi else wd_print_msg $RED "Warp point was not found" fi } -wd_show() -{ - wd_print_msg $BLUE "Warp points to current directory:" - wd_list_all | grep $PWD$ -} - wd_list_all() { wd_print_msg $BLUE "All warp points:" - while read line + + while IFS= read -r line do if [[ $line != "" ]] then @@ -112,38 +120,52 @@ wd_list_all() key=${arr[1]} val=${arr[2]} - print "\t" $key "\t -> \t" $val + printf "%20s -> %s\n" $key $val fi - done < $CONFIG + 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() { - if [[ $1 == "" || $2 == "" ]] + local color=$1 + local msg=$2 + + if [[ $color == "" || $msg == "" ]] then - print " $RED*$NOC Could not print message. Sorry!" + print " ${RED}*${NOC} Could not print message. Sorry!" else - print " $1*$NOC $2" + print " ${color}*${NOC} ${msg}" fi } wd_print_usage() { - print "Usage: wd [add|-a|--add] [rm|-r|--remove] [ls|-l|--list] <point>" - print "\nCommands:" - print "\t add \t Adds the current working directory to your warp points" - print "\t add! \t Overwrites existing warp point" - print "\t rm \t Removes the given warp point" - print "\t show \t Outputs warp points to current directory" - print "\t ls \t Outputs all stored warp points" - print "\t help \t Show this extremely helpful text" + cat <<- EOF +Usage: wd [add|-a|--add] [rm|-r|--remove] <point> + +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 # get opts -args=`getopt -o a:r:lhs -l add:,rm:,ls,help,show -- $*` +args=$(getopt -o a:r:lhs -l add:,rm:,ls,help,show -- $*) # check if no arguments were given if [[ $? -ne 0 || $#* -eq 0 ]] @@ -151,19 +173,16 @@ then wd_print_usage # check if config file is writeable -elif [[ ! -w $CONFIG ]] +elif [ ! -w $CONFIG ] then - wd_print_msg $RED "\'$CONFIG\' is not writeable." - # do nothing => exit + # do nothing # can't run `exit`, as this would exit the executing shell - # i.e. your terminal + wd_print_msg $RED "\'$CONFIG\' is not writeable." else - #set -- $args # WTF - - for i + for o do - case "$i" + case "$o" in -a|--add|add) wd_add false $2 @@ -190,7 +209,7 @@ else break ;; *) - wd_warp $i + wd_warp $o break ;; --) @@ -200,10 +219,18 @@ else done fi - ## garbage collection # if not, next time warp will pick up variables from this run # remember, there's no sub shell -unset points + +unset wd_warp +unset wd_add +unset wd_remove +unset wd_show +unset wd_list_all +unset wd_print_msg +unset wd_print_usage + unset args +unset points unset val &> /dev/null # fixes issue #1 diff --git a/plugins/zsh_reload/zsh_reload.plugin.zsh b/plugins/zsh_reload/zsh_reload.plugin.zsh index 94945bd48..3f44b99c6 100644 --- a/plugins/zsh_reload/zsh_reload.plugin.zsh +++ b/plugins/zsh_reload/zsh_reload.plugin.zsh @@ -1,10 +1,11 @@ # reload zshrc function src() { + local cache="$ZSH/cache" autoload -U compinit zrecompile - compinit -d "$ZSH/cache/zcomp-$HOST" + compinit -d "$cache/zcomp-$HOST" - for f in ~/.zshrc "$ZSH/cache/zcomp-$HOST"; do + for f in ~/.zshrc "$cache/zcomp-$HOST"; do zrecompile -p $f && command rm -f $f.zwc.old done diff --git a/tools/check_for_upgrade.sh b/tools/check_for_upgrade.sh index 8b8ecae03..35e074297 100644 --- a/tools/check_for_upgrade.sh +++ b/tools/check_for_upgrade.sh @@ -9,7 +9,7 @@ function _update_zsh_update() { } function _upgrade_zsh() { - /usr/bin/env ZSH=$ZSH /bin/sh $ZSH/tools/upgrade.sh + env ZSH=$ZSH /bin/sh $ZSH/tools/upgrade.sh # update the zsh file _update_zsh_update } diff --git a/tools/install.sh b/tools/install.sh index fc7ad70cf..7efab10b9 100755 --- a/tools/install.sh +++ b/tools/install.sh @@ -10,7 +10,7 @@ if [ -d "$ZSH" ]; then fi echo "\033[0;34mCloning Oh My Zsh...\033[0m" -hash git >/dev/null 2>&1 && /usr/bin/env git clone https://github.com/robbyrussell/oh-my-zsh.git $ZSH || { +hash git >/dev/null 2>&1 && env git clone https://github.com/robbyrussell/oh-my-zsh.git $ZSH || { echo "git not installed" exit } @@ -43,5 +43,5 @@ echo "\033[0;32m"'\____/_/ /_/ /_/ /_/ /_/\__, / /___/____/_/ /_/ '"\033[0m echo "\033[0;32m"' /____/ ....is now installed!'"\033[0m" echo "\n\n \033[0;32mPlease look over the ~/.zshrc file to select plugins, themes, and options.\033[0m" echo "\n\n \033[0;32mp.s. Follow us at http://twitter.com/ohmyzsh.\033[0m" -/usr/bin/env zsh +env zsh . ~/.zshrc |