diff options
106 files changed, 1824 insertions, 549 deletions
diff --git a/README.textile b/README.textile index 4325c91eb..09cff2135 100644 --- a/README.textile +++ b/README.textile @@ -1,110 +1,111 @@ !https://s3.amazonaws.com/ohmyzsh/oh-my-zsh-logo.png! -oh-my-zsh is an open source, community-driven framework for managing your ZSH configuration. It comes bundled with a ton of helpful functions, helpers, plugins, themes, and few things that make you shout... +@oh-my-zsh@ is an open source, community-driven framework for managing your "Zsh":http://www.zsh.org/ configuration. + +It comes bundled with a ton of helpful functions, helpers, plugins, themes, and a few things that make you shout… bq. "OH MY ZSHELL!" h2. Setup -@oh-my-zsh@ should work with any recent release of "zsh":http://www.zsh.org/, the minimum recommended version is 4.3.9. +@oh-my-zsh@ should work with any recent release of "Zsh":http://www.zsh.org/. The minimum recommended version is *4.3.9*. + +If not already installed, you can install "Zsh":http://www.zsh.org/ using the command-line. -h3. The automatic installer... (do you trust me?) +h3. The automatic installer… do you trust me? -You can install this via the command line with either `curl` or `wget`. +You can install this via the command-line with either @curl@ or @wget@. -h4. via `curl` +h4. via @curl@: @curl -L http://install.ohmyz.sh | sh@ -h4. via `wget` +h4. via @wget@: @wget --no-check-certificate http://install.ohmyz.sh -O - | sh@ -h4. Optional: change the install directory +h4. *Optionally*, change the install directory: -The default location is `~/.oh-my-zsh` (hidden in your home directory). +The default location is @~/.oh-my-zsh@ (hidden in your home directory). -You can change the install directory with the ZSH environment variable, either -by running `export ZSH=/your/path` before installing, or setting it before the -end of the install pipeline like this: +You can change the install directory with the @ZSH@ environment variable, either by running @export ZSH=/your/path@ before installing, or by setting it before the end of the install pipeline like this: @curl -L https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh | ZSH=~/.dotfiles/zsh sh@ - h3. The manual way -1. Clone the repository +1. Clone the repository: - @git clone git://github.com/robbyrussell/oh-my-zsh.git ~/.oh-my-zsh@ +@git clone git://github.com/robbyrussell/oh-my-zsh.git ~/.oh-my-zsh@ -2. *OPTIONAL* Backup your existing ~/.zshrc file +2. *Optionally*, backup your existing @~/.zshrc@ file: - @cp ~/.zshrc ~/.zshrc.orig@ +@cp ~/.zshrc ~/.zshrc.orig@ -3. Create a new zsh config by copying the zsh template we've provided. +3. Create a new "Zsh":http://www.zsh.org/ config file by copying the "Zsh":http://www.zsh.org/ template we've provided: - @cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc@ +@cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc@ -4. Set zsh as your default shell: +4. Set "Zsh":http://www.zsh.org/ as your default shell: - @chsh -s /bin/zsh@ +@chsh -s /bin/zsh@ -5. Start / restart zsh (open a new terminal is easy enough...) +5. Start or restart "Zsh":http://www.zsh.org/ by opening a new command-line window. h3. Problems? -You _might_ need to modify your PATH in ~/.zshrc if you're not able to find some commands after switching to _Oh My Zsh_. +You _might_ need to modify your @PATH@ in @~/.zshrc@ if you're not able to find some commands after switching to @oh-my-zsh@. -If you installed manually or changed the install location, check ZSH in ~/.zshrc +If you installed manually or changed the install location, check the @ZSH@ environment variable in @~/.zshrc@. h2. Usage -* enable the plugins you want in your @~/.zshrc@ (take a look at the @plugins/@ directory and the "wiki":https://github.com/robbyrussell/oh-my-zsh/wiki/Plugins to see what's possible) +* enable the plugins you want in your @~/.zshrc@ (take a look at the @plugins/@ directory and the "wiki":https://github.com/robbyrussell/oh-my-zsh/wiki/Plugins to see what's available) ** example: @plugins=(git osx ruby)@ -* Theme support: Change the @ZSH_THEME@ environment variable in @~/.zshrc@. -** Take a look at the "current themes":https://wiki.github.com/robbyrussell/oh-my-zsh/themes that come bundled with _Oh My Zsh_. -* much much more... take a look at @lib/@ what _Oh My Zsh_ offers... +* theme support: change the @ZSH_THEME@ environment variable in @~/.zshrc@ +** take a look at the @themes/@ directory and the "wiki":https://wiki.github.com/robbyrussell/oh-my-zsh/themes to see what comes bundled with @oh-my-zsh@ +* & much, much more… take a look at the @lib/@ directory to see what @oh-my-zsh@ has to offer… h2. Useful -the "refcard":http://www.bash2zsh.com/zsh_refcard/refcard.pdf is pretty tasty for tips. +The "refcard":http://www.bash2zsh.com/zsh_refcard/refcard.pdf is pretty useful for tips. h3. Customization -If you want to override any of the default behavior, just add a new file (ending in @.zsh@) into the @custom/@ directory. -If you have many functions which go well together you can put them as a *.plugin.zsh file in the @custom/plugins/@ directory and then enable this plugin. -If you would like to override the functionality of a plugin distributed with oh-my-zsh, create a plugin of the same name in the @custom/plugins/@ directory and it will be loaded instead of the one in @plugins/@. +If you want to override any of the default behaviors, just add a new file (ending in @.zsh@) in the @custom/@ directory. + +If you have many functions that go well together, you can put them as a @*.plugin.zsh@ file in the @custom/plugins/@ directory and then enable this plugin (see '"Usage":https://github.com/robbyrussell/oh-my-zsh#usage' above). + +If you would like to override the functionality of a plugin distributed with @oh-my-zsh@, create a plugin of the same name in the @custom/plugins/@ directory and it will be loaded instead of the one in @plugins/@. h3. Updates -By default you will be prompted to check for updates. If you would like oh-my-zsh to automatically update itself without prompting you, set the following in your ~/.zshrc +By default you will be prompted to check for upgrades. If you would like @oh-my-zsh@ to automatically upgrade itself without prompting you, set the following in your @~/.zshrc@: @DISABLE_UPDATE_PROMPT=true@ -To disable updates entirely, put this in your ~/.zshrc +To disable upgrades entirely, set the following in your @~/.zshrc@: @DISABLE_AUTO_UPDATE=true@ -To upgrade directly from the command line, just run @upgrade_oh_my_zsh@ +To upgrade directly from the command-line, just run @upgrade_oh_my_zsh@. h3. Uninstalling -If you want to uninstall it, just run @uninstall_oh_my_zsh@ from the command line and it'll remove itself and revert you to bash (or your previous zsh config). +If you want to uninstall @oh-my-zsh@, just run @uninstall_oh_my_zsh@ from the command-line and it'll remove itself and revert you to @bash@ (or your previous "Zsh":http://www.zsh.org/ configuration). h2. Help out! -I'm far from being a zsh-expert and suspect there are many ways to improve. If you have ideas on how to make the configuration easier to maintain (and faster), don't hesitate to fork and send pull requests! +I'm far from being a "Zsh":http://www.zsh.org/ expert and suspect there are many ways to improve – if you have ideas on how to make the configuration easier to maintain (and faster), don't hesitate to fork and send pull requests! -h3. (Don't) Send us your theme! (for now) +h3. (Don't) send us your theme (for now)! --I'm hoping to collect a bunch of themes for our command prompts. You can see existing ones in the @themes/@ directory.- +-I'm hoping to collect a bunch of themes – you can see existing ones in the @themes/@ directory.- -We have enough themes for the time being. Please fork the project and add on in there, you can let people know how to grab it from there. +We have enough themes for the time being. Please fork the project and add on in there – you can let people know how to grab it from there. h2. Contributors -This project wouldn't exist without all of our awesome users and contributors. - -* "View our growing list of contributors":https://github.com/robbyrussell/oh-my-zsh/contributors +This project wouldn't exist without all of our awesome users and contributors: "view our growing list of contributors":https://github.com/robbyrussell/oh-my-zsh/contributors Thank you so much! 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/completion.zsh b/lib/completion.zsh index c54249c52..fa1d97f48 100644 --- a/lib/completion.zsh +++ b/lib/completion.zsh @@ -44,7 +44,7 @@ zstyle ':completion:*:*:*:users' ignored-patterns \ named netdump news nfsnobody nobody nscd ntp nut nx obsrun openvpn \ operator pcap polkitd postfix postgres privoxy pulse pvm quagga radvd \ rpc rpcuser rpm rtkit scard shutdown squid sshd statd svn sync tftp \ - usbmux uucp vcsa wwwrun xfs + usbmux uucp vcsa wwwrun xfs '_*' # ... unless we really want to. zstyle '*' single-ignored show diff --git a/lib/correction.zsh b/lib/correction.zsh index 47eb83b1d..3e1415a0b 100644 --- a/lib/correction.zsh +++ b/lib/correction.zsh @@ -1,13 +1,13 @@ -alias man='nocorrect man' -alias mv='nocorrect mv' -alias mysql='nocorrect mysql' -alias mkdir='nocorrect mkdir' -alias gist='nocorrect gist' -alias heroku='nocorrect heroku' -alias ebuild='nocorrect ebuild' -alias hpodder='nocorrect hpodder' -alias sudo='nocorrect sudo' - if [[ "$ENABLE_CORRECTION" == "true" ]]; then + alias ebuild='nocorrect ebuild' + alias gist='nocorrect gist' + alias heroku='nocorrect heroku' + alias hpodder='nocorrect hpodder' + alias man='nocorrect man' + alias mkdir='nocorrect mkdir' + alias mv='nocorrect mv' + alias mysql='nocorrect mysql' + alias sudo='nocorrect sudo' + setopt correct_all fi diff --git a/lib/directories.zsh b/lib/directories.zsh index 1896945f4..02743e0c7 100644 --- a/lib/directories.zsh +++ b/lib/directories.zsh @@ -1,5 +1,4 @@ # Changing/making/removing directory -setopt auto_name_dirs setopt auto_pushd setopt pushd_ignore_dups setopt pushdminus diff --git a/lib/functions.zsh b/lib/functions.zsh index aaf8a03e3..17f5f9cbf 100644 --- a/lib/functions.zsh +++ b/lib/functions.zsh @@ -1,13 +1,13 @@ function zsh_stats() { - history | awk '{CMD[$2]++;count++;}END { for (a in CMD)print CMD[a] " " CMD[a]/count*100 "% " a;}' | grep -v "./" | column -c3 -s " " -t | sort -nr | nl | head -n20 + fc -l 1 | awk '{CMD[$2]++;count++;}END { for (a in CMD)print CMD[a] " " CMD[a]/count*100 "% " a;}' | grep -v "./" | column -c3 -s " " -t | sort -nr | nl | head -n20 } function uninstall_oh_my_zsh() { - /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/git.zsh b/lib/git.zsh index 305a77aff..e1ca9b113 100644 --- a/lib/git.zsh +++ b/lib/git.zsh @@ -1,8 +1,8 @@ # get the name of the branch we are on function git_prompt_info() { - if [[ "$(git config --get oh-my-zsh.hide-status)" != "1" ]]; then + if [[ "$(command git config --get oh-my-zsh.hide-status 2>/dev/null)" != "1" ]]; then ref=$(command git symbolic-ref HEAD 2> /dev/null) || \ - ref=$(command git rev-parse --short HEAD 2> /dev/null) || return + ref=$(command git rev-parse --short HEAD 2> /dev/null) || return 0 echo "$ZSH_THEME_GIT_PROMPT_PREFIX${ref#refs/heads/}$(parse_git_dirty)$ZSH_THEME_GIT_PROMPT_SUFFIX" fi } @@ -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 @@ -54,11 +54,19 @@ git_remote_status() { # Checks if there are commits ahead from remote function git_prompt_ahead() { - if $(echo "$(command git log origin/$(current_branch)..HEAD 2> /dev/null)" | grep '^commit' &> /dev/null); then + if $(echo "$(command git log @{upstream}..HEAD 2> /dev/null)" | grep '^commit' &> /dev/null); then echo "$ZSH_THEME_GIT_PROMPT_AHEAD" fi } +# Gets the number of commits ahead from remote +function git_commits_ahead() { + if $(echo "$(command git log @{upstream}..HEAD 2> /dev/null)" | grep '^commit' &> /dev/null); then + COMMITS=$(command git log @{upstream}..HEAD | grep '^commit' | wc -l | tr -d ' ') + echo "$ZSH_THEME_GIT_COMMITS_AHEAD_PREFIX$COMMITS$ZSH_THEME_GIT_COMMITS_AHEAD_SUFFIX" + fi +} + # Formats prompt string for current git commit short SHA function git_prompt_short_sha() { SHA=$(command git rev-parse --short HEAD 2> /dev/null) && echo "$ZSH_THEME_GIT_PROMPT_SHA_BEFORE$SHA$ZSH_THEME_GIT_PROMPT_SHA_AFTER" diff --git a/lib/grep.zsh b/lib/grep.zsh index 977435ee4..276fec382 100644 --- a/lib/grep.zsh +++ b/lib/grep.zsh @@ -3,11 +3,22 @@ # Examples: http://rubyurl.com/ZXv # -# avoid VCS folders -GREP_OPTIONS= -for PATTERN in .cvs .git .hg .svn; do - GREP_OPTIONS+="--exclude-dir=$PATTERN " -done -GREP_OPTIONS+="--color=auto" +GREP_OPTIONS="--color=auto" + +# avoid VCS folders (if the necessary grep flags are available) +grep-flag-available() { + echo | grep $1 "" >/dev/null 2>&1 +} +if grep-flag-available --exclude-dir=.cvs; then + for PATTERN in .cvs .git .hg .svn; do + GREP_OPTIONS+=" --exclude-dir=$PATTERN" + done +elif grep-flag-available --exclude=.cvs; then + for PATTERN in .cvs .git .hg .svn; do + GREP_OPTIONS+=" --exclude=$PATTERN" + done +fi +unfunction grep-flag-available + export GREP_OPTIONS="$GREP_OPTIONS" export GREP_COLOR='1;32' diff --git a/lib/key-bindings.zsh b/lib/key-bindings.zsh index 5f3f237c7..9063c6a18 100644 --- a/lib/key-bindings.zsh +++ b/lib/key-bindings.zsh @@ -46,8 +46,8 @@ bindkey ' ' magic-space # [Space] - do history exp bindkey '^[[1;5C' forward-word # [Ctrl-RightArrow] - move forward one word bindkey '^[[1;5D' backward-word # [Ctrl-LeftArrow] - move backward one word -if [[ "${terminfo[kdch1]}" != "" ]]; then - bindkey "${terminfo[kdch1]}" reverse-menu-complete # [Shift-Tab] - move through the completion menu backwards +if [[ "${terminfo[kcbt]}" != "" ]]; then + bindkey "${terminfo[kcbt]}" reverse-menu-complete # [Shift-Tab] - move through the completion menu backwards fi bindkey '^?' backward-delete-char # [Backspace] - delete backward diff --git a/lib/termsupport.zsh b/lib/termsupport.zsh index 5f2fe63d4..9d6681603 100644 --- a/lib/termsupport.zsh +++ b/lib/termsupport.zsh @@ -26,11 +26,13 @@ function omz_termsupport_precmd { function omz_termsupport_preexec { emulate -L zsh setopt extended_glob - local CMD=${1[(wr)^(*=*|sudo|ssh|rake|-*)]} #cmd name only, or if this is sudo or ssh, the next cmd + + # cmd name only, or if this is sudo or ssh, the next cmd + local CMD=${1[(wr)^(*=*|sudo|ssh|rake|-*)]:gs/%/%%} local LINE="${2:gs/%/%%}" + 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 3c0f4f8f5..d0e89f31b 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 @@ -38,15 +38,17 @@ for plugin ($plugins); do done # Figure out the SHORT hostname -if [ -n "$commands[scutil]" ]; then - # OS X - SHORT_HOST=$(scutil --get ComputerName) +if [[ "$OSTYPE" = darwin* ]]; then + # OS X's $HOST changes with dhcp, etc. Use ComputerName if possible. + SHORT_HOST=$(scutil --get ComputerName 2>/dev/null) || SHORT_HOST=${HOST/.*/} else SHORT_HOST=${HOST/.*/} fi # Save the location of the current completion dump file. -ZSH_COMPDUMP="${ZDOTDIR:-${HOME}}/.zcompdump-${SHORT_HOST}-${ZSH_VERSION}" +if [ -z "$ZSH_COMPDUMP" ]; then + ZSH_COMPDUMP="${ZDOTDIR:-${HOME}}/.zcompdump-${SHORT_HOST}-${ZSH_VERSION}" +fi # Load and run compinit autoload -U compinit diff --git a/plugins/adb/README.md b/plugins/adb/README.md new file mode 100644 index 000000000..075beec0e --- /dev/null +++ b/plugins/adb/README.md @@ -0,0 +1,8 @@ +# adb autocomplete plugin + +* Adds autocomplete options for all adb commands. + + +## Requirements + +In order to make this work, you will need to have the Android adb tools set up in your path. 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/archlinux/archlinux.plugin.zsh b/plugins/archlinux/archlinux.plugin.zsh index bffe9657a..059884c27 100644 --- a/plugins/archlinux/archlinux.plugin.zsh +++ b/plugins/archlinux/archlinux.plugin.zsh @@ -21,10 +21,14 @@ if [[ -x `which yaourt` ]]; then alias yalst='yaourt -Qe' # List installed packages, even those installed from AUR (they're tagged as "local") alias yaorph='yaourt -Qtd' # Remove orphans using yaourt # Additional yaourt alias examples - if [[ -x `which abs` ]]; then + if [[ -x `which abs` && -x `which aur` ]]; then + alias yaupd='yaourt -Sy && sudo abs && sudo aur' # Update and refresh the local package, ABS and AUR databases against repositories + elif [[ -x `which abs` ]]; then alias yaupd='yaourt -Sy && sudo abs' # Update and refresh the local package and ABS databases against repositories + elif [[ -x `which aur` ]]; then + alias yaupd='yaourt -Sy && sudo aur' # Update and refresh the local package and AUR databases against repositories else - alias yaupd='yaourt -Sy' # Update and refresh the local package and ABS databases against repositories + alias yaupd='yaourt -Sy' # Update and refresh the local package database against repositories fi alias yainsd='yaourt -S --asdeps' # Install given package(s) as dependencies of another package alias yamir='yaourt -Syy' # Force refresh of all package lists after updating /etc/pacman.d/mirrorlist @@ -45,10 +49,14 @@ alias pacreps='pacman -Ss' # Search for package(s) in the repositori alias pacloc='pacman -Qi' # Display information about a given package in the local database alias paclocs='pacman -Qs' # Search for package(s) in the local database # Additional pacman alias examples -if [[ -x `which abs` ]]; then - alias pacupd='sudo pacman -Sy && sudo abs' # Update and refresh the local package and ABS databases against repositories +if [[ -x `which abs` && -x `which aur` ]]; then + alias pacupd='sudo pacman -Sy && sudo abs && sudo aur' # Update and refresh the local package, ABS and AUR databases against repositories +elif [[ -x `which abs` ]]; then + alias pacupd='sudo pacman -Sy && sudo abs' # Update and refresh the local package and ABS databases against repositories +elif [[ -x `which aur` ]]; then + alias pacupd='sudo pacman -Sy && sudo aur' # Update and refresh the local package and AUR databases against repositories else - alias pacupd='sudo pacman -Sy' # Update and refresh the local package and ABS databases against repositories + alias pacupd='sudo pacman -Sy' # Update and refresh the local package database against repositories fi alias pacinsd='sudo pacman -S --asdeps' # Install given package(s) as dependencies of another package alias pacmir='sudo pacman -Syy' # Force refresh of all package lists after updating /etc/pacman.d/mirrorlist diff --git a/plugins/autojump/autojump.plugin.zsh b/plugins/autojump/autojump.plugin.zsh index 0aa14959d..50a694764 100644 --- a/plugins/autojump/autojump.plugin.zsh +++ b/plugins/autojump/autojump.plugin.zsh @@ -1,5 +1,7 @@ if [ $commands[autojump] ]; then # check if autojump is installed - if [ -f /usr/share/autojump/autojump.zsh ]; then # debian and ubuntu package + if [ -f $HOME/.autojump/etc/profile.d/autojump.zsh ]; then # manual user-local installation + . $HOME/.autojump/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 . /etc/profile.d/autojump.zsh @@ -7,8 +9,6 @@ if [ $commands[autojump] ]; then # check if autojump is installed . /etc/profile.d/autojump.sh elif [ -f /usr/local/share/autojump/autojump.zsh ]; then # freebsd installation . /usr/local/share/autojump/autojump.zsh - elif [ -f $HOME/.autojump/etc/profile.d/autojump.zsh ]; then # manual user-local installation - . $HOME/.autojump/etc/profile.d/autojump.zsh elif [ -f /opt/local/etc/profile.d/autojump.zsh ]; then # mac os x with ports . /opt/local/etc/profile.d/autojump.zsh elif [ $commands[brew] -a -f `brew --prefix`/etc/autojump.zsh ]; then # mac os x with brew 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/battery/battery.plugin.zsh b/plugins/battery/battery.plugin.zsh index 32dd4b624..014bb15dd 100644 --- a/plugins/battery/battery.plugin.zsh +++ b/plugins/battery/battery.plugin.zsh @@ -8,7 +8,7 @@ # Modified to add support for Apple Mac # ########################################### -if [[ $(uname) == "Darwin" ]] ; then +if [[ "$OSTYPE" = darwin* ]] ; then function battery_pct() { local smart_battery_status="$(ioreg -rc "AppleSmartBattery")" diff --git a/plugins/bbedit/README.md b/plugins/bbedit/README.md new file mode 100644 index 000000000..ec2b743d6 --- /dev/null +++ b/plugins/bbedit/README.md @@ -0,0 +1,20 @@ +## bbedit + +Plugin for BBEdit, an HTML and text editor for Mac OS X + +### Requirements + + * [BBEdit](http://www.barebones.com/products/bbedit/) + * [BBEdit Command-Line Tools](http://www.barebones.com/support/bbedit/cmd-line-tools.html) + +### Usage + + * If the `bb` command is called without an argument, launch BBEdit + + * If `bb` is passed a directory, cd to it and open it in BBEdit + + * If `bb` is passed a file, open it in BBEdit + + * If `bbpb` create a new BBEdit document with the contents of the clipboard + + * If `bbd` alias for BBEdit diff tool diff --git a/plugins/bbedit/bbedit.plugin.zsh b/plugins/bbedit/bbedit.plugin.zsh new file mode 100644 index 000000000..fe9e72c65 --- /dev/null +++ b/plugins/bbedit/bbedit.plugin.zsh @@ -0,0 +1,21 @@ +alias bbpb='pbpaste | bbedit --clean --view-top' + +alias bbd=bbdiff + +# +# If the bb command is called without an argument, launch BBEdit +# If bb is passed a directory, cd to it and open it in BBEdit +# If bb is passed a file, open it in BBEdit +# +function bb() { + if [[ -z "$1" ]] + then + bbedit --launch + else + bbedit "$1" + if [[ -d "$1" ]] + then + cd "$1" + fi + fi +} diff --git a/plugins/bower/_bower b/plugins/bower/_bower index ae0ca4a4e..ae0ca4a4e 100755..100644 --- a/plugins/bower/_bower +++ b/plugins/bower/_bower diff --git a/plugins/brew-cask/brew-cask.plugin.zsh b/plugins/brew-cask/brew-cask.plugin.zsh new file mode 100644 index 000000000..91ce0f498 --- /dev/null +++ b/plugins/brew-cask/brew-cask.plugin.zsh @@ -0,0 +1,84 @@ +# Autocompletion for homebrew-cask. +# +# This script intercepts calls to the brew plugin and adds autocompletion +# for the cask subcommand. +# +# Author: https://github.com/pstadler + +compdef _brew-cask brew + +_brew-cask() +{ + local curcontext="$curcontext" state line + typeset -A opt_args + + _arguments -C \ + ':command:->command' \ + ':subcmd:->subcmd' \ + '*::options:->options' + + case $state in + (command) + __call_original_brew + cask_commands=( + 'cask:manage casks' + ) + _describe -t commands 'brew cask command' cask_commands ;; + + (subcmd) + case "$line[1]" in + cask) + if (( CURRENT == 3 )); then + local -a subcommands + subcommands=( + "alfred:used to modify Alfred's scope to include the Caskroom" + 'audit:verifies installability of casks' + 'checklinks:checks for bad cask links' + 'cleanup:cleans up cached downloads' + 'create:creates a cask of the given name and opens it in an editor' + 'doctor:checks for configuration issues' + 'edit:edits the cask of the given name' + 'fetch:downloads Cask resources to local cache' + 'home:opens the homepage of the cask of the given name' + 'info:displays information about the cask of the given name' + 'install:installs the cask of the given name' + 'list:with no args, lists installed casks; given installed casks, lists installed files' + 'search:searches all known casks' + 'uninstall:uninstalls the cask of the given name' + "update:a synonym for 'brew update'" + ) + _describe -t commands "brew cask subcommand" subcommands + fi ;; + + *) + __call_original_brew ;; + esac ;; + + (options) + local -a casks installed_casks + local expl + case "$line[2]" in + list|uninstall) + __brew_installed_casks + _wanted installed_casks expl 'installed casks' compadd -a installed_casks ;; + audit|edit|home|info|install) + __brew_all_casks + _wanted casks expl 'all casks' compadd -a casks ;; + esac ;; + esac +} + +__brew_all_casks() { + casks=(`brew cask search`) +} + +__brew_installed_casks() { + installed_casks=(`brew cask list`) +} + +__call_original_brew() +{ + local ret=1 + _call_function ret _brew + compdef _brew-cask brew +} diff --git a/plugins/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/brew/brew.plugin.zsh b/plugins/brew/brew.plugin.zsh index c2e95884e..42fb80c9a 100644 --- a/plugins/brew/brew.plugin.zsh +++ b/plugins/brew/brew.plugin.zsh @@ -1 +1,2 @@ alias brews='brew list -1' +alias bubu="brew update && brew upgrade && brew cleanup" diff --git a/plugins/bundler/README.md b/plugins/bundler/README.md new file mode 100644 index 000000000..56f0c7176 --- /dev/null +++ b/plugins/bundler/README.md @@ -0,0 +1,49 @@ +# Bundler + +- adds completion for basic bundler commands +- adds short aliases for common bundler commands + - `be` aliased to `bundle exec` + - `bl` aliased to `bundle list` + - `bp` aliased to `bundle package` + - `bo` aliased to `bundle open` + - `bu` aliased to `bundle update` + - `bi` aliased to `bundle install --jobs=<cpu core count>` (only for bundler `>= 1.4.0`) +- adds a wrapper for common gems: + - looks for a binstub under `./bin/` and executes it (if present) + - calls `bundle exec <gem executable>` otherwise + +For a full list of *common gems* being wrapped by default please look at the `bundler.plugin.zsh` file. + +## Configuration + +Please use the exact name of the executable and not the gem name. + +### Add additional gems to be wrapped + +Add this before the plugin-list in your `.zshrc`: +```sh +BUNDLED_COMMANDS=(rubocop) +plugins=(... bundler ...) +``` +This will add the wrapper for the `rubocop` gem (i.e. the executable). + + +### Exclude gems from being wrapped + +Add this before the plugin-list in your `.zshrc`: +```sh +UNBUNDLED_COMMANDS=(foreman spin) +plugins=(... bundler ...) +``` +This will exclude the `foreman` and `spin` gems (i.e. their executable) from being wrapped. + +## Excluded gems + +These gems should not be called with `bundle exec`. Please see the Issues on GitHub for clarification. + +`berks` +`foreman` +`mailcatcher` +`rails` +`ruby` +`spin` diff --git a/plugins/bundler/_bundler b/plugins/bundler/_bundler index 2ec3a5f9c..ba647ab80 100644 --- a/plugins/bundler/_bundler +++ b/plugins/bundler/_bundler @@ -18,11 +18,13 @@ case $state in "check[Determine whether the requirements for your application are installed]" \ "list[Show all of the gems in the current bundle]" \ "show[Show the source location of a particular gem in the bundle]" \ + "outdated[Show all of the outdated gems in the current bundle]" \ "console[Start an IRB session in the context of the current bundle]" \ "open[Open an installed gem in the editor]" \ "viz[Generate a visual representation of your dependencies]" \ "init[Generate a simple Gemfile, placed in the current directory]" \ "gem[Create a simple gem, suitable for development with bundler]" \ + "platform[Displays platform compatibility information]" \ "clean[Cleans up unused gems in your bundler directory]" \ "help[Describe available tasks or one specific task]" ret=0 @@ -39,11 +41,13 @@ case $state in 'check' \ 'list' \ 'show' \ + 'outdated' \ 'console' \ 'open' \ 'viz' \ 'init' \ 'gem' \ + 'platform' \ 'help' && ret=0 ;; install) @@ -71,6 +75,15 @@ case $state in '(--verbose)--verbose[Enable verbose output mode]' ret=0 ;; + outdated) + _arguments \ + '(--pre)--pre[Check for newer pre-release gems]' \ + '(--source)--source[Check against a specific source]' \ + '(--local)--local[Do not attempt to fetch gems remotely and use the gem cache instead]' \ + '(--no-color)--no-color[Disable colorization in output]' \ + '(--verbose)--verbose[Enable verbose output mode]' + ret=0 + ;; (open|show) _gems=( $(bundle show 2> /dev/null | sed -e '/^ \*/!d; s/^ \* \([^ ]*\) .*/\1/') ) if [[ $_gems != "" ]]; then diff --git a/plugins/bundler/bundler.plugin.zsh b/plugins/bundler/bundler.plugin.zsh index e4b03e7b0..ba3d3f623 100644 --- a/plugins/bundler/bundler.plugin.zsh +++ b/plugins/bundler/bundler.plugin.zsh @@ -3,23 +3,58 @@ alias bl="bundle list" alias bp="bundle package" alias bo="bundle open" alias bu="bundle update" +alias bi="bundle_install" -# The following is based on https://github.com/gma/bundler-exec - -bundled_commands=(annotate berks cap capify cucumber foodcritic foreman guard irb jekyll kitchen knife mailcatcher middleman nanoc puma rackup rainbows rake rspec ruby shotgun spec spin spork strainer tailor taps thin thor unicorn unicorn_rails) +bundled_commands=( + annotate + cap + capify + cucumber + foodcritic + guard + irb + jekyll + kitchen + knife + middleman + nanoc + pry + puma + rackup + rainbows + rake + rspec + shotgun + sidekiq + spec + spork + spring + strainer + tailor + taps + thin + thor + unicorn + unicorn_rails +) # Remove $UNBUNDLED_COMMANDS from the bundled_commands list for cmd in $UNBUNDLED_COMMANDS; do bundled_commands=(${bundled_commands#$cmd}); done +# Add $BUNDLED_COMMANDS to the bundled_commands list +for cmd in $BUNDLED_COMMANDS; do + bundled_commands+=($cmd); +done + ## Functions -bi() { +bundle_install() { if _bundler-installed && _within-bundled-project; then local bundler_version=`bundle version | cut -d' ' -f3` if [[ $bundler_version > '1.4.0' || $bundler_version = '1.4.0' ]]; then - if [[ "$(uname)" == 'Darwin' ]] + if [[ "$OSTYPE" = darwin* ]] then local cores_num="$(sysctl hw.ncpu | awk '{print $2}')" else @@ -39,17 +74,25 @@ _bundler-installed() { } _within-bundled-project() { - local check_dir=$PWD - while [ $check_dir != "/" ]; do + local check_dir="$PWD" + while [ "$check_dir" != "/" ]; do [ -f "$check_dir/Gemfile" ] && return check_dir="$(dirname $check_dir)" done false } +_binstubbed() { + [ -f "./bin/${1}" ] +} + _run-with-bundler() { if _bundler-installed && _within-bundled-project; then - bundle exec $@ + if _binstubbed $1; then + ./bin/$@ + else + bundle exec $@ + fi else $@ fi @@ -62,7 +105,6 @@ for cmd in $bundled_commands; do alias $cmd=bundled_$cmd if which _$cmd > /dev/null 2>&1; then - compdef _$cmd bundled_$cmd=$cmd + compdef _$cmd bundled_$cmd=$cmd fi done - diff --git a/plugins/colemak/colemak.plugin.zsh b/plugins/colemak/colemak.plugin.zsh index 34d42c280..cb7cc5068 100644 --- a/plugins/colemak/colemak.plugin.zsh +++ b/plugins/colemak/colemak.plugin.zsh @@ -19,4 +19,4 @@ bindkey -a 'N' vi-join bindkey -a 'j' vi-forward-word-end bindkey -a 'J' vi-forward-blank-word-end -lesskey $ZSH_CUSTOM/plugins/colemak/colemak-less +lesskey $ZSH/plugins/colemak/colemak-less diff --git a/plugins/colorize/colorize.plugin.zsh b/plugins/colorize/colorize.plugin.zsh index 0696607d9..11b58e69d 100644 --- a/plugins/colorize/colorize.plugin.zsh +++ b/plugins/colorize/colorize.plugin.zsh @@ -1,4 +1,4 @@ -# Plugin for highligthing file content +# Plugin for highlighting file content # Plugin highlights file content based on the filename extension. # If no highlighting method supported for given extension then it tries # guess it by looking for file content. @@ -6,9 +6,9 @@ alias colorize='colorize_via_pygmentize' colorize_via_pygmentize() { - if [ ! -x $(which pygmentize) ]; then - echo package \'pygmentize\' is not installed! - exit -1 + if [ ! -x "$(which pygmentize)" ]; then + echo "package \'pygmentize\' is not installed!" + return -1 fi if [ $# -eq 0 ]; then @@ -25,4 +25,4 @@ colorize_via_pygmentize() { pygmentize -g "$FNAME" fi done -}
\ No newline at end of file +} diff --git a/plugins/common-aliases/common-aliases.plugin.zsh b/plugins/common-aliases/common-aliases.plugin.zsh index b19650fee..228a39da0 100644 --- a/plugins/common-aliases/common-aliases.plugin.zsh +++ b/plugins/common-aliases/common-aliases.plugin.zsh @@ -3,7 +3,6 @@ # # ls, the common ones I use a lot shortened for rapid fire usage -alias ls='ls --color' #I like color alias l='ls -lFh' #size,show type,human readable alias la='ls -lAFh' #long list,show almost all,show type,human readable alias lr='ls -tRFh' #sorted by date,recursive,show type,human readable @@ -39,7 +38,7 @@ alias -g NE="2> /dev/null" alias -g NUL="> /dev/null 2>&1" alias -g P="2>&1| pygmentize -l pytb" -alias dud='du --max-depth=1 -h' +alias dud='du -d 1 -h' alias duf='du -sh *' alias fd='find . -type d -name' alias ff='find . -type f -name' diff --git a/plugins/composer/composer.plugin.zsh b/plugins/composer/composer.plugin.zsh index 9975aaca4..86f2ca4df 100644 --- a/plugins/composer/composer.plugin.zsh +++ b/plugins/composer/composer.plugin.zsh @@ -46,3 +46,6 @@ 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 diff --git a/plugins/debian/debian.plugin.zsh b/plugins/debian/debian.plugin.zsh index 28dfb82a5..6e45e0521 100644 --- a/plugins/debian/debian.plugin.zsh +++ b/plugins/debian/debian.plugin.zsh @@ -21,8 +21,8 @@ fi # Aliases ################################################################### # These are for more obscure uses of apt-get and aptitude that aren't covered # below. -alias ag='apt-get' -alias ap='aptitude' +alias age='apt-get' +alias api='aptitude' # Some self-explanatory aliases alias acs="apt-cache search" diff --git a/plugins/django/django.plugin.zsh b/plugins/django/django.plugin.zsh index 9d898edca..aaaa7d21d 100644 --- a/plugins/django/django.plugin.zsh +++ b/plugins/django/django.plugin.zsh @@ -141,6 +141,7 @@ _managepy-sqlinitialdata(){} _managepy-sqlreset(){} _managepy-sqlsequencereset(){} _managepy-startapp(){} +_managepy-startproject(){} _managepy-syncdb() { _arguments -s : \ @@ -198,6 +199,7 @@ _managepy-commands() { 'sqlreset:Prints the DROP TABLE SQL, then the CREATE TABLE SQL, for the given app name(s).' 'sqlsequencereset:Prints the SQL statements for resetting sequences for the given app name(s).' "startapp:Creates a Django app directory structure for the given app name in this project's directory." + "startproject:Creates a Django project directory structure for the given project name in this current directory." "syncdb:Create the database tables for all apps in INSTALLED_APPS whose tables haven't already been created." 'test:Runs the test suite for the specified applications, or the entire site if no apps are specified.' 'testserver:Runs a development server with data from the given fixture(s).' diff --git a/plugins/docker/_docker b/plugins/docker/_docker index 12eee7a15..28568a6e5 100644 --- a/plugins/docker/_docker +++ b/plugins/docker/_docker @@ -2,7 +2,8 @@ # Docker autocompletion for oh-my-zsh # Requires: Docker installed -# Author : Azaan (@aeonazaan) +# Author: Azaan (@aeonazaan) +# Updates: Bob Maerten (@bobmaerten) for Docker v0.9+ # ----- Helper functions @@ -24,21 +25,30 @@ __docker_images() { # Seperate function for each command, makes extension easier later # --------------------------- __attach() { + _arguments \ + '--no-stdin[Do not attach stdin]' \ + '--sig-proxy[Proxify all received signal to the process (even in non-tty mode)]' __docker_containers } __build() { _arguments \ - '-q=false[Suppress verbose build output]' \ - '-t="[fuck to be applied to the resulting image in case of success]' \ + '--no-cache[Do not use cache when building the image]' \ + '(-q,--quiet)'{-q,--quiet}'[Suppress the verbose output generated by the containers]' \ + '--rm[Remove intermediate containers after a successful build]' \ + '(-t,--tag=)'{-t,--tag=}'[Repository name (and optionally a tag) to be applied to the resulting image in case of success]' \ '*:files:_files' } __commit() { _arguments \ - '-author="[Author]' \ - '-m="[Commit message]' \ - '-run="[Config automatically applied when the image is run.\n]' + '(-a,--author=)'{-a,--author=}'[Author (eg. "John Hannibal Smith <hannibal@a-team.com>"]' \ + '(-m,--message=)'{-m,--message=}'[Commit message]' \ + '--run=[Config automatically applied when the image is run.]' + __docker_containers +} + +__cp() { __docker_containers } @@ -46,21 +56,29 @@ __diff() { __docker_containers } +__events() { + _arguments \ + '--since=[Show previously created events and then stream.]' +} + __export() { __docker_containers } - __history() { + _arguments \ + '--no-trunc=[Don''t truncate output]' \ + '(-q,--quiet)'{-q,--quiet}'[Only show numeric IDs]' __docker_images } __images() { _arguments \ - '-a[show all images]' \ - '-notrunc[dont truncate output]' \ - '-q[only show numeric IDs]' \ - '-viz[output graph in graphviz format]' + '(-a,--all)'{-a,--all}'[Show all images (by default filter out the intermediate images used to build)]' \ + '--no-trunc[Don''t truncate output]' \ + '(-q,--quiet=)'{-q,--quiet=}'[Only show numeric IDs]' \ + '(-t,--tree=)'{-t,--tree=}'[Output graph in tree format]' \ + '(-v,--viz=)'{-v,--viz=}'[Output graph in graphviz format]' __docker_images } @@ -86,14 +104,20 @@ __kill() { __docker_containers } +__load() { + _arguments '*:files:_files' +} + __login() { _arguments \ - '-e="[email]' \ - '-p="[password]' \ - '-u="[username]' \ + '(-e,--email=)'{-e,-email=}'[Email]' \ + '(-p,--password=)'{-p,-password=}'[Password]' \ + '(-u,--username=)'{-u,-username=}'[Username]' } __logs() { + _arguments \ + '(-f,--follow)'{-f,-follow}'[Follow log output]' __docker_containers } @@ -107,77 +131,107 @@ __top() { __ps() { _arguments \ - '-a[Show all containers. Only running containers are shown by default.]' \ - '-beforeId="[Show only container created before Id, include non-running ones.]' \ - '-l[Show only the latest created container, include non-running ones.]' \ - '-n=[Show n last created containers, include non-running ones.]' \ - '-notrunc[Dont truncate output]' \ - '-q[Only display numeric IDs]' \ - '-s[Display sizes]' \ - '-sinceId="[Show only containers created since Id, include non-running ones.]' + '(-a,--all)'{-a,--all}'[Show all containers. Only running containers are shown by default.]' \ + '--before-id=[Show only container created before Id, include non-running ones.]' \ + '(-l,--latest)'{-l,--latest}'[Show only the latest created container, include non-running ones.]' \ + '-n=[Show n last created containers, include non-running ones. default=-1.]' \ + '--no-trunc[Don''t truncate output]' \ + '(-q,--quiet)'{-q,--quiet}'[Only display numeric IDs]' \ + '(-s,--size)'{-s,--size}'[Display sizes]' \ + '--since-id=[Show only containers created since Id, include non-running ones.]' } __pull() { - _arguments '-t="[Download tagged image in repository]' + _arguments \ + '(-t,--tag=)'{-t,--tag=}'[Download tagged image in repository]' } __push() { - + # no arguments } __restart() { - _arguments '-t=[number of seconds to try to stop before killing]' + _arguments \ + '(-t,--time=)'{-t,--time=}'[Number of seconds to try to stop for before killing the container. Once killed it will then be restarted. Default=10]' __docker_containers } __rm() { - _arguments '-v[Remove the volumes associated to the container]' + _arguments \ + '(-f,--force=)'{-f,--force=}'[Force removal of running container]' \ + '(-l,--link=)'{-l,--link=}'[Remove the specified link and not the underlying container]' \ + '(-v,--volumes=)'{-v,--volumes=}'[Remove the volumes associated to the container]' __docker_containers } __rmi() { + _arguments \ + '(-f,--force=)'{-f,--force=}'[Force]' __docker_images } __run() { _arguments \ - '-a=[Attach to stdin, stdout or stderr.]' \ - '-c=[CPU shares (relative weight)]' \ - '-d[Detached mode: leave the container running in the background]' \ - '-dns=[Set custom dns servers]' \ - '-e=[Set environment variables]' \ - '-entrypoint="[Overwrite the default entrypoint of the image]' \ - '-h="[Container host name]' \ - '-i[Keep stdin open even if not attached]' \ - '-m=[Memory limit (in bytes)]' \ - '-p=[Expose a containers port to the host (use docker port to see the actual mapping)]' \ - '-t[Allocate a pseudo-tty]' \ - '-u="[Username or UID]' \ - '-v=[Bind mount a volume (e.g. from the host: -v /host:/container, from docker: -v /container)]' \ - '-volumes-from="[Mount volumes from the specified container]' + '(-P,--publish-all=)'{-P,--publish-all=}'[Publish all exposed ports to the host interfaces]' \ + '(-a,--attach=)'{-a,--attach=}'[Attach to stdin, stdout or stderr.]' \ + '(-c,--cpu-shares=)'{-c,--cpu-shares=}': CPU shares (relative weight)]' \ + '--cidfile=[Write the container ID to the file]' \ + '(-d,--detach=)'{-d,--detach=}'[Detached mode: Run container in the background, print new container id]' \ + '--dns=[Set custom dns servers]' \ + '(-e,--env=)'{-e,--env=}'[Set environment variables]' \ + '--entrypoint=[Overwrite the default entrypoint of the image]' \ + '--expose=[Expose a port from the container without publishing it to your host]' \ + '(-h,--hostname=)'{-h,--hostname=}'[Container host name]' \ + '(-i,--interactive=)'{-i,--interactive=}'[Keep stdin open even if not attached]' \ + '--link=[Add link to another container (name:alias)]' \ + '--lxc-conf=[Add custom lxc options -lxc-conf="lxc.cgroup.cpuset.cpus = 0,1"]' \ + '(-m,--memory=)'{-m,--memory=}'[Memory limit (format: <number><optional unit>, where unit = b, k, m or g)]' \ + '(-n,--networking=)'{-n,--networking=}'[Enable networking for this container]' \ + '--name=[Assign a name to the container]' \ + '(-p,--publish=)'{-p,--publish=}'[Publish a container''s port to the host (format: ip:hostPort:containerPort | ip::containerPort | hostPort:containerPort) (use "docker port" to see the actual mapping)]' \ + '--privileged=[Give extended privileges to this container]' \ + '--rm=[Automatically remove the container when it exits (incompatible with -d)]' \ + '--sig-proxy=[Proxify all received signal to the process (even in non-tty mode)]' \ + '(-t,--tty=)'{-t,--tty=}'[Allocate a pseudo-tty]' \ + '(-u,--user=)'{-u,--user=}'[Username or UID]' \ + '(-v,--volume=)'{-v,--volume=}'[Bind mount a volume (e.g. from the host: -v /host:/container, from docker: -v /container)]' \ + '--volumes-from=[Mount volumes from the specified container(s)]' \ + '(-w,--workdir=)'{-w,--workdir=}'[Working directory inside the container]' __docker_images } __search() { - _arguments '-notrunc[Dont truncate output]' + _arguments \ + '--no-trunc=[Don''t truncate output]' \ + '-s,--stars=)'{-s,--stars=}'[Only displays with at least xxx stars]' \ + '-t,--trusted=)'{-t,--trusted=}'[Only show trusted builds]' +} + +__save() { + __docker_images } __start() { + _arguments \ + '(-a,--attach=)'{-a,--attach=}'[Attach container''s stdout/stderr and forward all signals to the process]' \ + '(-i,--interactive=)'{-i,--interactive=}'[Attach container''s stdin]' __docker_containers } __stop() { - _arguments '-t=[number of seconds to try to stop before killing]' + _arguments \ + '(-t,--time=)'{-t,--time=}'[Number of seconds to wait for the container to stop before killing it.]' __docker_containers } __tag() { - _arguments '-f[Force]' + _arguments \ + '(-f,--force=)'{-f,--force=}'[Force]' __docker_images } __version() { - + # no arguments } __wait() { @@ -192,7 +246,9 @@ _1st_arguments=( "attach":"Attach to a running container" "build":"Build a container from a Dockerfile" "commit":"Create a new image from a container's changes" + "cp":"Copy files/folders from the containers filesystem to the host path" "diff":"Inspect changes on a container's filesystem" + "events":"Get real time events from the server" "export":"Stream the contents of a container as a tar archive" "history":"Show the history of an image" "images":"List images" @@ -201,10 +257,10 @@ _1st_arguments=( "insert":"Insert a file in an image" "inspect":"Return low-level information on a container" "kill":"Kill a running container" + "load":"Load an image from a tar archive" "login":"Register or Login to the docker registry server" "logs":"Fetch the logs of a container" "port":"Lookup the public-facing port which is NAT-ed to PRIVATE_PORT" - "top":"Lookup the running processes of a container" "ps":"List containers" "pull":"Pull an image or a repository from the docker registry server" "push":"Push an image or a repository to the docker registry server" @@ -212,10 +268,12 @@ _1st_arguments=( "rm":"Remove one or more containers" "rmi":"Remove one or more images" "run":"Run a command in a new container" + "save":"Save an image to a tar archive" "search":"Search for an image in the docker index" "start":"Start a stopped container" "stop":"Stop a running container" "tag":"Tag an image into a repository" + "top":"Lookup the running processes of a container" "version":"Show the docker version information" "wait":"Block until a container stops, then print its exit code" ) @@ -230,13 +288,17 @@ fi local -a _command_args case "$words[1]" in attach) - __docker_containers ;; + __attach ;; build) __build ;; commit) __commit ;; + cp) + __cp ;; diff) __diff ;; + events) + __events ;; export) __export ;; history) @@ -253,14 +315,14 @@ case "$words[1]" in __inspect ;; kill) __kill ;; + load) + __load ;; login) __login ;; logs) __logs ;; port) __port ;; - top) - __top ;; ps) __ps ;; pull) @@ -275,6 +337,8 @@ case "$words[1]" in __rmi ;; run) __run ;; + save) + __save ;; search) __search ;; start) @@ -283,6 +347,8 @@ case "$words[1]" in __stop ;; tag) __tag ;; + top) + __top ;; version) __version ;; wait) diff --git a/plugins/emacs/emacsclient.sh b/plugins/emacs/emacsclient.sh index 38d419813..625201a16 100755 --- a/plugins/emacs/emacsclient.sh +++ b/plugins/emacs/emacsclient.sh @@ -3,7 +3,7 @@ # get list of available X windows. x=`emacsclient --alternate-editor '' --eval '(x-display-list)' 2>/dev/null` -if [ -z "$x" ] ;then +if [ -z "$x" ] || [ "$x" = "nil" ] ;then # Create one if there is no X window yet. emacsclient --alternate-editor "" --create-frame "$@" else diff --git a/plugins/emoji-clock/emoji-clock.plugin.zsh b/plugins/emoji-clock/emoji-clock.plugin.zsh index 7351a02ec..a69446e3c 100644 --- a/plugins/emoji-clock/emoji-clock.plugin.zsh +++ b/plugins/emoji-clock/emoji-clock.plugin.zsh @@ -8,8 +8,8 @@ # ----------------------------------------------------------------------------- function emoji-clock() { - hour=$(date '+%I') - minutes=$(date '+%M') + hour=$(date -v '+15M' '+%I') + minutes=$(date -v '+15M' '+%M') case $hour in 01) clock="🕐"; [ $minutes -ge 30 ] && clock="🕜";; 02) clock="🕑"; [ $minutes -ge 30 ] && clock="🕝";; diff --git a/plugins/extract/extract.plugin.zsh b/plugins/extract/extract.plugin.zsh index 7352e5bad..a6e16ddf7 100644 --- a/plugins/extract/extract.plugin.zsh +++ b/plugins/extract/extract.plugin.zsh @@ -52,7 +52,7 @@ function extract() { (*.xz) unxz "$1" ;; (*.lzma) unlzma "$1" ;; (*.Z) uncompress "$1" ;; - (*.zip|*.war|*.jar) unzip "$1" -d $extract_dir ;; + (*.zip|*.war|*.jar|*.sublime-package) unzip "$1" -d $extract_dir ;; (*.rar) unrar x -ad "$1" ;; (*.7z) 7za x "$1" ;; (*.deb) diff --git a/plugins/frontend-search/README.md b/plugins/frontend-search/README.md new file mode 100644 index 000000000..32784d03b --- /dev/null +++ b/plugins/frontend-search/README.md @@ -0,0 +1,82 @@ +## Rationale ## + +The idea for this script is to help searches in important doc contents from frontend. + +## Instalation ## + +I will send a Pull Request with this plugin for .oh-my-zsh official repository. If accept them, it's only add in plugins list that exists in ```.zshrc``` file. + +For now, you can clone this repository and add in ```custom/plugins``` folder + +```bash +$ git clone git://github.com/willmendesneto/frontend-search.git ~/.oh-my-zsh/custom/plugins/frontend-search +``` + +After this, restart your terminal and frontend-search plugin is configurated in you CLI. + +```bash +... +plugins=( <your-plugins-list>... frontend-search) +... +``` + +## Commands ## + +All command searches are accept only in format + +* `frontend <search-content> <search-term>` + +The search content are + +* `jquery <api.jquery.com>` +* `mdn <developer.mozilla.org>` +* `compass <compass-style.org>` +* `html5please <html5please.com>` +* `caniuse <caniuse.com>` +* `aurajs <aurajs.com>` +* `dartlang <api.dartlang.org/apidocs/channels/stable/dartdoc-viewer>` +* `lodash <search>` +* `qunit <api.qunitjs.com>` +* `fontello <fontello.com>` +* `bootsnipp <bootsnipp.com>` +* `cssflow <cssflow.com>` +* `codepen <codepen.io>` +* `unheap <www.unheap.com>` +* `bem <google.com/search?as_q=<search-term>&as_sitesearch=bem.info>` +* `smacss <google.com/search?as_q=<search-term>&as_sitesearch=smacss.com>` +* `angularjs <google.com/search?as_q=<search-term>&as_sitesearch=angularjs.org>` +* `reactjs <google.com/search?as_q=<search-term>&as_sitesearch=facebook.github.io/react>` +* `emberjs <emberjs.com>` + + +## Aliases ## + +There are a few aliases presented as well: + +* `jquery` A shorthand for `frontend jquery` +* `mdn` A shorthand for `frontend mdn` +* `compass` A shorthand for `frontend compass` +* `html5please` A shorthand for `frontend html5please` +* `caniuse` A shorthand for `frontend caniuse` +* `aurajs` A shorthand for `frontend aurajs` +* `dartlang` A shorthand for `frontend dartlang` +* `lodash` A shorthand for `frontend lodash` +* `qunit` A shorthand for `frontend qunit` +* `fontello` A shorthand for `frontend fontello` +* `bootsnipp` A shorthand for `frontend bootsnipp` +* `cssflow` A shorthand for `frontend cssflow` +* `codepen` A shorthand for `frontend codepen` +* `unheap` A shorthand for `frontend unheap` +* `bem` A shorthand for `frontend bem` +* `smacss` A shorthand for `frontend smacss` +* `angularjs` A shorthand for `frontend angularjs` +* `reactjs` A shorthand for `frontend reactjs` +* `emberjs` A shorthand for `frontend emberjs` + +## Author + +**Wilson Mendes (willmendesneto)** ++ <https://twitter.com/willmendesneto> ++ <http://github.com/willmendesneto> + +New features comming soon. diff --git a/plugins/frontend-search/frontend-search.plugin.zsh b/plugins/frontend-search/frontend-search.plugin.zsh new file mode 100644 index 000000000..f1d45b0d1 --- /dev/null +++ b/plugins/frontend-search/frontend-search.plugin.zsh @@ -0,0 +1,151 @@ +# frontend from terminal + +function frontend() { + + # get the open command + local open_cmd + if [[ $(uname -s) == 'Darwin' ]]; then + open_cmd='open' + else + open_cmd='xdg-open' + fi + + # no keyword provided, simply show how call methods + if [[ $# -le 1 ]]; then + echo "Please provide a search-content and a search-term for app.\nEx:\nfrontend <search-content> <search-term>\n" + return 1 + fi + + # check whether the search engine is supported + if [[ ! $1 =~ '(jquery|mdn|compass|html5please|caniuse|aurajs|dartlang|qunit|fontello|bootsnipp|cssflow|codepen|unheap|bem|smacss|angularjs|reactjs|emberjs)' ]]; + then + echo "Search valid search content $1 not supported." + echo "Valid contents: (formats 'frontend <search-content>' or '<search-content>')" + echo "* jquery" + echo "* mdn" + echo "* compass" + echo "* html5please" + echo "* caniuse" + echo "* aurajs" + echo "* dartlang" + echo "* lodash" + echo "* qunit" + echo "* fontello" + echo "* bootsnipp" + echo "* cssflow" + echo "* codepen" + echo "* unheap" + echo "* bem" + echo "* smacss" + echo "* angularjs" + echo "* reactjs" + echo "* emberjs" + echo "" + + return 1 + fi + + local url="http://" + local query="" + + case "$1" in + "jquery") + url="${url}api.jquery.com" + url="${url}/?s=$2" ;; + "mdn") + url="${url}developer.mozilla.org" + url="${url}/search?q=$2" ;; + "compass") + url="${url}compass-style.org" + url="${url}/search?q=$2" ;; + "html5please") + url="${url}html5please.com" + url="${url}/#$2" ;; + "caniuse") + url="${url}caniuse.com" + url="${url}/#search=$2" ;; + "aurajs") + url="${url}aurajs.com" + url="${url}/api/#stq=$2" ;; + "dartlang") + url="${url}api.dartlang.org/apidocs/channels/stable/dartdoc-viewer" + url="${url}/dart-$2" ;; + "qunit") + url="${url}api.qunitjs.com" + url="${url}/?s=$2" ;; + "fontello") + url="${url}fontello.com" + url="${url}/#search=$2" ;; + "bootsnipp") + url="${url}bootsnipp.com" + url="${url}/search?q=$2" ;; + "cssflow") + url="${url}cssflow.com" + url="${url}/search?q=$2" ;; + "codepen") + url="${url}codepen.io" + url="${url}/search?q=$2" ;; + "unheap") + url="${url}www.unheap.com" + url="${url}/?s=$2" ;; + "bem") + url="${url}google.com" + url="${url}/search?as_q=$2&as_sitesearch=bem.info" ;; + "smacss") + url="${url}google.com" + url="${url}/search?as_q=$2&as_sitesearch=smacss.com" ;; + "angularjs") + url="${url}google.com" + url="${url}/search?as_q=$2&as_sitesearch=angularjs.org" ;; + "reactjs") + url="${url}google.com" + url="${url}/search?as_q=$2&as_sitesearch=facebook.github.io/react" ;; + "emberjs") + url="${url}emberjs.com" + url="${url}/api/#stq=$2&stp=1" ;; + *) echo "INVALID PARAM!" + return ;; + esac + + echo "$url" + + $open_cmd "$url" + +} + +# javascript +alias jquery='frontend jquery' +alias mdn='frontend mdn' + +# pre processors frameworks +alias compassdoc='frontend compass' + +# important links +alias html5please='frontend html5please' +alias caniuse='frontend caniuse' + +# components and libraries +alias aurajs='frontend aurajs' +alias dartlang='frontend dartlang' +alias lodash='frontend lodash' + +#tests +alias qunit='frontend qunit' + +#fonts +alias fontello='frontend fontello' + +# snippets +alias bootsnipp='frontend bootsnipp' +alias cssflow='frontend cssflow' +alias codepen='frontend codepen' +alias unheap='frontend unheap' + +# css architecture +alias bem='frontend bem' +alias smacss='frontend smacss' + +# frameworks +alias angularjs='frontend angularjs' +alias reactjs='frontend reactjs' +alias emberjs='frontend emberjs' 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 ef894bff2..256841432 100644 --- a/plugins/git-prompt/gitstatus.py +++ b/plugins/git-prompt/gitstatus.py @@ -16,7 +16,7 @@ symbols = { } output, error = Popen( - ['git', 'status'], stdout=PIPE, stderr=PIPE).communicate() + ['git', 'status'], stdout=PIPE, stderr=PIPE, universal_newlines=True).communicate() if error: import sys diff --git a/plugins/git/git.plugin.zsh b/plugins/git/git.plugin.zsh index 9f7819df3..bf7cd1ac9 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' @@ -16,6 +18,7 @@ compdef _git gp=git-push alias gd='git diff' gdv() { git diff -w "$@" | view - } compdef _git gdv=git-diff +alias gdt='git difftool' alias gc='git commit -v' compdef _git gc=git-commit alias gc!='git commit -v --amend' @@ -51,6 +54,7 @@ alias gb='git branch' compdef _git gb=git-branch alias gba='git branch -a' compdef _git gba=git-branch +alias gbr='git branch --remote' alias gcount='git shortlog -sn' compdef gcount=git alias gcl='git config --list' @@ -70,6 +74,7 @@ alias gss='git status -s' compdef _git gss=git-status alias ga='git add' compdef _git ga=git-add +alias gap='git add --patch' alias gm='git merge' compdef _git gm=git-merge alias grh='git reset HEAD' @@ -77,6 +82,18 @@ alias grhh='git reset HEAD --hard' alias gclean='git reset --hard && git clean -dfx' alias gwc='git whatchanged -p --abbrev-commit --pretty=medium' +# Sign and verify commits with GPG +alias gcs='git commit -S' +compdef _git gcs=git-commit +alias gsps='git show --pretty=short --show-signature' +compdef _git gsps=git-show + +# Sign and verify tags with GPG +alias gts='git tag -s' +compdef _git gts=git-tag +alias gvt='git verify-tag' +compdef _git gvt=git verify-tag + #remove the gf alias #alias gf='git ls-files | grep' diff --git a/plugins/github/github.plugin.zsh b/plugins/github/github.plugin.zsh index 25b1a1e1b..bd69b1bd5 100644 --- a/plugins/github/github.plugin.zsh +++ b/plugins/github/github.plugin.zsh @@ -40,7 +40,7 @@ fi # # Use this when creating a new repo from scratch. empty_gh() { # [NAME_OF_REPO] - repo = $1 + repo=$1 ghuser=$( git config github.user ) mkdir "$repo" diff --git a/plugins/gitignore/gitignore.plugin.zsh b/plugins/gitignore/gitignore.plugin.zsh index be037d87a..481d487ba 100644 --- a/plugins/gitignore/gitignore.plugin.zsh +++ b/plugins/gitignore/gitignore.plugin.zsh @@ -1,12 +1,12 @@ -function gi() { curl http://www.gitignore.io/api/$@ ;} +function gi() { curl -sL https://www.gitignore.io/api/$@ ;} -_gitignireio_get_command_list() { - curl -s http://www.gitignore.io/api/list | tr "," "\n" +_gitignoreio_get_command_list() { + curl -sL 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 diff --git a/plugins/golang/golang.plugin.zsh b/plugins/golang/golang.plugin.zsh index 18bcaaff2..f2be6ca9c 100644 --- a/plugins/golang/golang.plugin.zsh +++ b/plugins/golang/golang.plugin.zsh @@ -158,3 +158,6 @@ __go_tool_complete() { } compdef __go_tool_complete go + +# aliases +alias gfa='go fmt . ./...' diff --git a/plugins/gradle/gradle.plugin.zsh b/plugins/gradle/gradle.plugin.zsh index 9229512f7..97bf50b43 100644 --- a/plugins/gradle/gradle.plugin.zsh +++ b/plugins/gradle/gradle.plugin.zsh @@ -60,7 +60,7 @@ function in_gradle() { ############################################################################ _gradle_does_task_list_need_generating () { [ ! -f .gradletasknamecache ] && return 0; - [ .gradletasknamecache -nt build.gradle ] && return 0; + [ build.gradle -nt .gradletasknamecache ] && return 0; return 1; } diff --git a/plugins/grails/grails.plugin.zsh b/plugins/grails/grails.plugin.zsh index 11777738c..11777738c 100755..100644 --- a/plugins/grails/grails.plugin.zsh +++ b/plugins/grails/grails.plugin.zsh diff --git a/plugins/history-substring-search/history-substring-search.zsh b/plugins/history-substring-search/history-substring-search.zsh index 53f707c79..22f03dd6d 100644 --- a/plugins/history-substring-search/history-substring-search.zsh +++ b/plugins/history-substring-search/history-substring-search.zsh @@ -163,8 +163,13 @@ function history-substring-search-down() { zle -N history-substring-search-up zle -N history-substring-search-down -bindkey '\e[A' history-substring-search-up -bindkey '\e[B' history-substring-search-down +zmodload zsh/terminfo +if [[ -n "$terminfo[kcuu1]" ]]; then + bindkey "$terminfo[kcuu1]" history-substring-search-up +fi +if [[ -n "$terminfo[kcud1]" ]]; then + bindkey "$terminfo[kcud1]" history-substring-search-down +fi #----------------------------------------------------------------------------- # implementation details diff --git a/plugins/jira/jira.plugin.zsh b/plugins/jira/jira.plugin.zsh index 739ee7142..4a36b882d 100644 --- a/plugins/jira/jira.plugin.zsh +++ b/plugins/jira/jira.plugin.zsh @@ -12,7 +12,7 @@ # jira ABC-123 # Opens an existing issue open_jira_issue () { local open_cmd - if [[ $(uname -s) == 'Darwin' ]]; then + if [[ "$OSTYPE" = darwin* ]]; then open_cmd='open' else open_cmd='xdg-open' @@ -26,20 +26,65 @@ open_jira_issue () { jira_url=$JIRA_URL else echo "JIRA url is not specified anywhere." - return 0 + return 1 + fi + + if [ -f .jira-prefix ]; then + jira_prefix=$(cat .jira-prefix) + elif [ -f ~/.jira-prefix ]; then + jira_prefix=$(cat ~/.jira-prefix) + else + jira_prefix="" fi if [ -z "$1" ]; then echo "Opening new issue" - $open_cmd "$jira_url/secure/CreateIssue!default.jspa" + $open_cmd "${jira_url}/secure/CreateIssue!default.jspa" + elif [[ "$1" = "assigned" || "$1" = "reported" ]]; then + jira_query $@ else echo "Opening issue #$1" if [[ "x$JIRA_RAPID_BOARD" = "xtrue" ]]; then - $open_cmd "$jira_url/issues/$1" + $open_cmd "$jira_url/issues/$jira_prefix$1" else - $open_cmd "$jira_url/browse/$1" + $open_cmd "$jira_url/browse/$jira_prefix$1" fi fi } +jira_name () { + if [[ -z "$1" ]]; then + if [[ "x${JIRA_NAME}" != "x" ]]; then + jira_name=${JIRA_NAME} + else + echo "JIRA_NAME not specified" + return 1 + fi + else + jira_name=$@ + fi +} + +jira_query () { + verb="$1" + if [[ "${verb}" = "reported" ]]; then + lookup=reporter + preposition=by + elif [[ "${verb}" = "assigned" ]]; then + lookup=assignee + preposition=to + else + echo "not a valid lookup $verb" + return 1 + fi + shift 1 + jira_name $@ + if [[ $? = 1 ]]; then + return 1 + fi + echo "Browsing issues ${verb} ${preposition} ${jira_name}" + $open_cmd "${jira_url}/secure/IssueNavigator.jspa?reset=true&jqlQuery=${lookup}+%3D+%22${jira_name}%22+AND+resolution+%3D+unresolved+ORDER+BY+priority+DESC%2C+created+ASC" +} + alias jira='open_jira_issue' + diff --git a/plugins/jruby/jruby.plugin.zsh b/plugins/jruby/jruby.plugin.zsh index bb7975b10..bb7975b10 100755..100644 --- a/plugins/jruby/jruby.plugin.zsh +++ b/plugins/jruby/jruby.plugin.zsh diff --git a/plugins/jsontools/README.md b/plugins/jsontools/README.md new file mode 100644 index 000000000..4faf58b98 --- /dev/null +++ b/plugins/jsontools/README.md @@ -0,0 +1,42 @@ +# jsontools + +Handy command line tools for dealing with json data. + +## Tools + +- **pp_json** - pretty prints json +- **is_json** - returns true if valid json; false otherwise +- **urlencode_json** - returns a url encoded string for the given json +- **urldecode_json** - returns decoded json for the given url encoded string + +## Usage +Usage is simple...just take your json data and pipe it into the appropriate jsontool. +```sh +<json data> | <jsontools tool> +``` +## Examples + +##### pp_json + +```sh +# curl json data and pretty print the results +curl https://coderwall.com/bobwilliams.json | pp_json +``` + +##### is_json +```sh +# pretty print the contents of an existing json file +less data.json | is_json +``` + +##### urlencode_json +```sh +# json data directly from the command line +echo '{"b":2, "a":1}' | urlencode_json +``` + +##### urldecode_json +```sh +# url encoded string to decode +echo '%7B%22b%22:2,%20%22a%22:1%7D%0A' | urldecode_json +```
\ No newline at end of file diff --git a/plugins/jsontools/jsontools.plugin.zsh b/plugins/jsontools/jsontools.plugin.zsh index 7b6f8c585..20d5eb1c9 100644 --- a/plugins/jsontools/jsontools.plugin.zsh +++ b/plugins/jsontools/jsontools.plugin.zsh @@ -2,15 +2,38 @@ # Adds command line aliases useful for dealing with JSON if [[ $(whence $JSONTOOLS_METHOD) = "" ]]; then - JSONTOOLS_METHOD="" + JSONTOOLS_METHOD="" fi if [[ $(whence node) != "" && ( "x$JSONTOOLS_METHOD" = "x" || "x$JSONTOOLS_METHOD" = "xnode" ) ]]; then - alias pp_json='node -e "console.log(JSON.stringify(process.argv[1]), null, 4)"' + alias pp_json='xargs -0 node -e "console.log(JSON.stringify(JSON.parse(process.argv[1]), null, 4));"' + alias is_json='xargs -0 node -e "try {json = JSON.parse(process.argv[1]);} catch (e) { console.log(false); json = null; } if(json) { console.log(true); }"' + alias urlencode_json='xargs -0 node -e "console.log(encodeURIComponent(process.argv[1]))"' + alias urldecode_json='xargs -0 node -e "console.log(decodeURIComponent(process.argv[1]))"' elif [[ $(whence python) != "" && ( "x$JSONTOOLS_METHOD" = "x" || "x$JSONTOOLS_METHOD" = "xpython" ) ]]; then alias pp_json='python -mjson.tool' + alias is_json='python -c " +import json, sys; +try: + json.loads(sys.stdin.read()) +except ValueError, e: + print False +else: + print True +sys.exit(0)"' + alias urlencode_json='python -c " +import urllib, json, sys; +print urllib.quote_plus(sys.stdin.read()) +sys.exit(0)"' + alias urldecode_json='python -c " +import urllib, json, sys; +print urllib.unquote_plus(sys.stdin.read()) +sys.exit(0)"' elif [[ $(whence ruby) != "" && ( "x$JSONTOOLS_METHOD" = "x" || "x$JSONTOOLS_METHOD" = "xruby" ) ]]; then alias pp_json='ruby -e "require \"json\"; require \"yaml\"; puts JSON.parse(STDIN.read).to_yaml"' + alias is_json='ruby -e "require \"json\"; begin; JSON.parse(STDIN.read); puts true; rescue Exception => e; puts false; end"' + alias urlencode_json='ruby -e "require \"uri\"; puts URI.escape(STDIN.read)"' + alias urldecode_json='ruby -e "require \"uri\"; puts URI.unescape(STDIN.read)"' fi unset JSONTOOLS_METHOD
\ No newline at end of file diff --git a/plugins/jump/jump.plugin.zsh b/plugins/jump/jump.plugin.zsh index 5096879d8..1b23b5d42 100644 --- a/plugins/jump/jump.plugin.zsh +++ b/plugins/jump/jump.plugin.zsh @@ -39,7 +39,7 @@ marks() { _completemarks() { if [[ $(ls "${MARKPATH}" | wc -l) -gt 1 ]]; then - reply=($(ls $MARKPATH/**/*(-) | grep : | sed -E 's/(.*)\/([_\da-zA-Z\-]*):$/\2/g')) + reply=($(ls $MARKPATH/**/*(-) | grep : | sed -E 's/(.*)\/([_a-zA-Z0-9\.\-]*):$/\2/g')) else if readlink -e "${MARKPATH}"/* &>/dev/null; then reply=($(ls "${MARKPATH}")) diff --git a/plugins/marked2/README.md b/plugins/marked2/README.md new file mode 100644 index 000000000..101343abb --- /dev/null +++ b/plugins/marked2/README.md @@ -0,0 +1,13 @@ +## marked2 + +Plugin for Marked 2, a previewer for Markdown files on Mac OS X + +### Requirements + + * [Marked 2](http://marked2app.com) + +### Usage + + * If `marked` is called without an argument, open Marked + + * If `marked` is passed a file, open it in Marked diff --git a/plugins/marked2/marked2.plugin.zsh b/plugins/marked2/marked2.plugin.zsh new file mode 100644 index 000000000..56863ade5 --- /dev/null +++ b/plugins/marked2/marked2.plugin.zsh @@ -0,0 +1,12 @@ +# +# If marked is called without an argument, open Marked +# If marked is passed a file, open it in Marked +# +function marked() { + if [ "$1" ] + then + open -a "marked 2.app" "$1" + else + open -a "marked 2.app" + fi +} diff --git a/plugins/mercurial/mercurial.plugin.zsh b/plugins/mercurial/mercurial.plugin.zsh index 2e99a12fb..ff95d5e40 100644 --- a/plugins/mercurial/mercurial.plugin.zsh +++ b/plugins/mercurial/mercurial.plugin.zsh @@ -16,6 +16,8 @@ alias hgs='hg status' alias hgsl='hg log --limit 20 --template "{node|short} | {date|isodatesec} | {author|user}: {desc|strip|firstline}\n" ' # this is the 'git commit --amend' equivalent alias hgca='hg qimport -r tip ; hg qrefresh -e ; hg qfinish tip' +# list unresolved files (since hg does not list unmerged files in the status command) +alias hgun='hg resolve --list' function in_hg() { if [[ -d .hg ]] || $(hg summary > /dev/null 2>&1); then diff --git a/plugins/mvn/mvn.plugin.zsh b/plugins/mvn/mvn.plugin.zsh index ed7968534..0c4f77162 100644 --- a/plugins/mvn/mvn.plugin.zsh +++ b/plugins/mvn/mvn.plugin.zsh @@ -44,24 +44,27 @@ mvn-color() # aliases alias mvncie='mvn clean install eclipse:eclipse' alias mvnci='mvn clean install' +alias mvncist='mvn clean install -DskipTests' alias mvne='mvn eclipse:eclipse' alias mvnce='mvn clean eclipse:clean eclipse:eclipse' alias mvnd='mvn deploy' alias mvnp='mvn package' alias mvnc='mvn clean' alias mvncom='mvn compile' +alias mvnct='mvn clean test' alias mvnt='mvn test' alias mvnag='mvn archetype:generate' alias mvn-updates='mvn versions:display-dependency-updates' alias mvntc7='mvn tomcat7:run' alias mvntc='mvn tomcat:run' alias mvnjetty='mvn jetty:run' - +alias mvndt='mvn dependency:tree' +alias mvns='mvn site' function listMavenCompletions { reply=( # common lifecycle - clean process-resources compile process-test-resources test-compile test package verify install deploy site + clean process-resources compile process-test-resources test-compile test integration-test package verify install deploy site # common plugins deploy failsafe install site surefire checkstyle javadoc jxr pmd ant antrun archetype assembly dependency enforcer gpg help release repository source eclipse idea jetty cargo jboss tomcat tomcat6 tomcat7 exec versions war ear ejb android scm buildnumber nexus repository sonar license hibernate3 liquibase flyway gwt @@ -126,6 +129,10 @@ function listMavenCompletions { tomcat6:run tomcat6:run-war tomcat6:run-war-only tomcat6:stop tomcat6:deploy tomcat6:undeploy # tomcat7 tomcat7:run tomcat7:run-war tomcat7:run-war-only tomcat7:deploy + # tomee + tomee:run tomee:run-war tomee:run-war-only tomee:stop tomee:deploy tomee:undeploy + # spring-boot + spring-boot:run spring-boot:repackage # exec exec:exec exec:java # versions diff --git a/plugins/node/node.plugin.zsh b/plugins/node/node.plugin.zsh index 2d78f2b4c..39d8b10d9 100644 --- a/plugins/node/node.plugin.zsh +++ b/plugins/node/node.plugin.zsh @@ -3,7 +3,7 @@ function node-docs { # get the open command local open_cmd - if [[ $(uname -s) == 'Darwin' ]]; then + if [[ "$OSTYPE" = darwin* ]]; then open_cmd='open' else open_cmd='xdg-open' diff --git a/plugins/osx/osx.plugin.zsh b/plugins/osx/osx.plugin.zsh index 608ec3789..a63f0ee05 100644 --- a/plugins/osx/osx.plugin.zsh +++ b/plugins/osx/osx.plugin.zsh @@ -174,20 +174,23 @@ function itunes() { next|previous) opt="$opt track" ;; + vol) + opt="set sound volume to $1" #$1 Due to the shift + ;; ""|-h|--help) echo "Usage: itunes <option>" echo "option:" echo "\tlaunch|play|pause|stop|rewind|resume|quit" echo "\tmute|unmute\tcontrol volume set" echo "\tnext|previous\tplay next or previous track" + echo "\tvol\tSet the volume, takes an argument from 0 to 100" echo "\thelp\tshow this message and exit" return 0 ;; *) - print "Unkonwn option: $opt" + print "Unknown option: $opt" return 1 ;; esac osascript -e "tell application \"iTunes\" to $opt" } - 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/per-directory-history/README.md b/plugins/per-directory-history/README.md new file mode 100644 index 000000000..d8ff93dc0 --- /dev/null +++ b/plugins/per-directory-history/README.md @@ -0,0 +1,56 @@ +[Per-Directory-History][6] +========================= + +Per directory history for zsh, as well as global history, and the +ability to toggle between them with ^G. + +This is a implementation of per directory history for zsh, some +implementations of which exist in bash[1][],[2][]. It also implements +a per-directory-history-toggle-history function to change from using the +directory history to using the global history. In both cases the history is +always saved to both the global history and the directory history, so the +toggle state will not effect the saved histories. Being able to switch +between global and directory histories on the fly is a novel feature as far +as I am aware. + +This is a standalone repository for the script, however it is also included in +[oh-my-zsh][4] as a plugin. + +---------------------------------------------------------------------------- +Usage +---------------------------------------------------------------------------- + +1. Load this script into your interactive ZSH session: + + % source zsh-per-directory-history.zsh + +2. The default mode if per directory history, interact with your history as normal. + +3. Press ^G (the Control and G keys simultaneously) to toggle between local + and global histories. + + + +------------------------------------------------------------------------------- +Configuration +------------------------------------------------------------------------------- + +* HISTORY_BASE a global variable that defines the base directory in which the + directory histories are stored +* per-directory-history-toggle-history is the function to toggle the history + +------------------------------------------------------------------------------- +History +------------------------------------------------------------------------------- + +The idea/inspiration for a per directory history is from [Stewart MacArthur][1] +and [Dieter][2], the implementation idea is from [Bart Schaefer][3]. The +implementation is by [Jim Hester][5] in September 2012. + +[1]: http://www.compbiome.com/2010/07/bash-per-directory-bash-history.html +[2]: http://dieter.plaetinck.be/per_directory_bash +[3]: http://www.zsh.org/mla/users/1997/msg00226.html +[4]: https://github.com/robbyrussell/oh-my-zsh +[5]: http://jimhester.com +[6]: http://github.com/jimhester/per-directory-history + diff --git a/plugins/per-directory-history/per-directory-history.plugin.zsh b/plugins/per-directory-history/per-directory-history.plugin.zsh index 61e8b5a62..142d9541d 100644..120000 --- a/plugins/per-directory-history/per-directory-history.plugin.zsh +++ b/plugins/per-directory-history/per-directory-history.plugin.zsh @@ -1,149 +1 @@ -#!/usr/bin/env zsh -# -# This is a implementation of per directory history for zsh, some -# implementations of which exist in bash[1,2]. It also implements -# a per-directory-history-toggle-history function to change from using the -# directory history to using the global history. In both cases the history is -# always saved to both the global history and the directory history, so the -# toggle state will not effect the saved histories. Being able to switch -# between global and directory histories on the fly is a novel feature as far -# as I am aware. -# -#------------------------------------------------------------------------------- -# Configuration -#------------------------------------------------------------------------------- -# -# HISTORY_BASE a global variable that defines the base directory in which the -# directory histories are stored -# -#------------------------------------------------------------------------------- -# History -#------------------------------------------------------------------------------- -# -# The idea/inspiration for a per directory history is from Stewart MacArthur[1] -# and Dieter[2], the implementation idea is from Bart Schaefer on the the zsh -# mailing list[3]. The implementation is by Jim Hester in September 2012. -# -# [1]: http://www.compbiome.com/2010/07/bash-per-directory-bash-history.html -# [2]: http://dieter.plaetinck.be/per_directory_bash -# [3]: http://www.zsh.org/mla/users/1997/msg00226.html -# -################################################################################ -# -# Copyright (c) 2012 Jim Hester -# -# This software is provided 'as-is', without any express or implied warranty. -# In no event will the authors be held liable for any damages arising from the -# use of this software. -# -# Permission is granted to anyone to use this software for any purpose, -# including commercial applications, and to alter it and redistribute it -# freely, subject to the following restrictions: -# -# 1. The origin of this software must not be misrepresented; you must not claim -# that you wrote the original software. If you use this software in a product, -# an acknowledgment in the product documentation would be appreciated but is -# not required. -# -# 2. Altered source versions must be plainly marked as such, and must not be -# misrepresented as being the original software. -# -# 3. This notice may not be removed or altered from any source distribution.. -# -################################################################################ - -#------------------------------------------------------------------------------- -# configuration, the base under which the directory histories are stored -#------------------------------------------------------------------------------- - -[[ -z $HISTORY_BASE ]] && HISTORY_BASE="$HOME/.directory_history" - -#------------------------------------------------------------------------------- -# toggle global/directory history used for searching - ctrl-G by default -#------------------------------------------------------------------------------- - -function per-directory-history-toggle-history() { - if [[ $_per_directory_history_is_global == true ]]; then - _per-directory-history-set-directory-history - print "\nusing local history\n" - else - _per-directory-history-set-global-history - print "\nusing global history\n" - fi - zle .push-line - zle .accept-line -} - -autoload per-directory-history-toggle-history -zle -N per-directory-history-toggle-history -bindkey '^G' per-directory-history-toggle-history - -#------------------------------------------------------------------------------- -# implementation details -#------------------------------------------------------------------------------- - -_per_directory_history_directory="$HISTORY_BASE${PWD:A}/history" - -function _per-directory-history-change-directory() { - _per_directory_history_directory="$HISTORY_BASE${PWD:A}/history" - mkdir -p ${_per_directory_history_directory:h} - if [[ $_per_directory_history_is_global == false ]]; then - #save to the global history - fc -AI $HISTFILE - #save history to previous file - local prev="$HISTORY_BASE${OLDPWD:A}/history" - mkdir -p ${prev:h} - fc -AI $prev - - #discard previous directory's history - local original_histsize=$HISTSIZE - HISTSIZE=0 - HISTSIZE=$original_histsize - - #read history in new file - if [[ -e $_per_directory_history_directory ]]; then - fc -R $_per_directory_history_directory - fi - fi -} - -function _per-directory-history-addhistory() { - print -sr -- ${1%%$'\n'} - fc -p $_per_directory_history_directory -} - - -function _per-directory-history-set-directory-history() { - if [[ $_per_directory_history_is_global == true ]]; then - fc -AI $HISTFILE - local original_histsize=$HISTSIZE - HISTSIZE=0 - HISTSIZE=$original_histsize - if [[ -e "$_per_directory_history_directory" ]]; then - fc -R "$_per_directory_history_directory" - fi - fi - _per_directory_history_is_global=false -} -function _per-directory-history-set-global-history() { - if [[ $_per_directory_history_is_global == false ]]; then - fc -AI $_per_directory_history_directory - local original_histsize=$HISTSIZE - HISTSIZE=0 - HISTSIZE=$original_histsize - if [[ -e "$HISTFILE" ]]; then - fc -R "$HISTFILE" - fi - fi - _per_directory_history_is_global=true -} - - -#add functions to the exec list for chpwd and zshaddhistory -chpwd_functions=(${chpwd_functions[@]} "_per-directory-history-change-directory") -zshaddhistory_functions=(${zshaddhistory_functions[@]} "_per-directory-history-addhistory") - -#start in directory mode -mkdir -p ${_per_directory_history_directory:h} -_per_directory_history_is_global=true -_per-directory-history-set-directory-history +per-directory-history.zsh
\ No newline at end of file diff --git a/plugins/per-directory-history/per-directory-history.zsh b/plugins/per-directory-history/per-directory-history.zsh new file mode 100644 index 000000000..bdee341bd --- /dev/null +++ b/plugins/per-directory-history/per-directory-history.zsh @@ -0,0 +1,149 @@ +#!/usr/bin/env zsh +# +# This is a implementation of per directory history for zsh, some +# implementations of which exist in bash[1,2]. It also implements +# a per-directory-history-toggle-history function to change from using the +# directory history to using the global history. In both cases the history is +# always saved to both the global history and the directory history, so the +# toggle state will not effect the saved histories. Being able to switch +# between global and directory histories on the fly is a novel feature as far +# as I am aware. +# +#------------------------------------------------------------------------------- +# Configuration +#------------------------------------------------------------------------------- +# +# HISTORY_BASE a global variable that defines the base directory in which the +# directory histories are stored +# +#------------------------------------------------------------------------------- +# History +#------------------------------------------------------------------------------- +# +# The idea/inspiration for a per directory history is from Stewart MacArthur[1] +# and Dieter[2], the implementation idea is from Bart Schaefer on the the zsh +# mailing list[3]. The implementation is by Jim Hester in September 2012. +# +# [1]: http://www.compbiome.com/2010/07/bash-per-directory-bash-history.html +# [2]: http://dieter.plaetinck.be/per_directory_bash +# [3]: http://www.zsh.org/mla/users/1997/msg00226.html +# +################################################################################ +# +# Copyright (c) 2012 Jim Hester +# +# This software is provided 'as-is', without any express or implied warranty. +# In no event will the authors be held liable for any damages arising from the +# use of this software. +# +# Permission is granted to anyone to use this software for any purpose, +# including commercial applications, and to alter it and redistribute it +# freely, subject to the following restrictions: +# +# 1. The origin of this software must not be misrepresented; you must not claim +# that you wrote the original software. If you use this software in a product, +# an acknowledgment in the product documentation would be appreciated but is +# not required. +# +# 2. Altered source versions must be plainly marked as such, and must not be +# misrepresented as being the original software. +# +# 3. This notice may not be removed or altered from any source distribution.. +# +################################################################################ + +#------------------------------------------------------------------------------- +# configuration, the base under which the directory histories are stored +#------------------------------------------------------------------------------- + +[[ -z $HISTORY_BASE ]] && HISTORY_BASE="$HOME/.directory_history" + +#------------------------------------------------------------------------------- +# toggle global/directory history used for searching - ctrl-G by default +#------------------------------------------------------------------------------- + +function per-directory-history-toggle-history() { + if [[ $_per_directory_history_is_global == true ]]; then + _per-directory-history-set-directory-history + print -n "\nusing local history" + else + _per-directory-history-set-global-history + print -n "\nusing global history" + fi + zle .push-line + zle .accept-line +} + +autoload per-directory-history-toggle-history +zle -N per-directory-history-toggle-history +bindkey '^G' per-directory-history-toggle-history + +#------------------------------------------------------------------------------- +# implementation details +#------------------------------------------------------------------------------- + +_per_directory_history_directory="$HISTORY_BASE${PWD:A}/history" + +function _per-directory-history-change-directory() { + _per_directory_history_directory="$HISTORY_BASE${PWD:A}/history" + mkdir -p ${_per_directory_history_directory:h} + if [[ $_per_directory_history_is_global == false ]]; then + #save to the global history + fc -AI $HISTFILE + #save history to previous file + local prev="$HISTORY_BASE${OLDPWD:A}/history" + mkdir -p ${prev:h} + fc -AI $prev + + #discard previous directory's history + local original_histsize=$HISTSIZE + HISTSIZE=0 + HISTSIZE=$original_histsize + + #read history in new file + if [[ -e $_per_directory_history_directory ]]; then + fc -R $_per_directory_history_directory + fi + fi +} + +function _per-directory-history-addhistory() { + print -Sr -- ${1%%$'\n'} + fc -p $_per_directory_history_directory +} + + +function _per-directory-history-set-directory-history() { + if [[ $_per_directory_history_is_global == true ]]; then + fc -AI $HISTFILE + local original_histsize=$HISTSIZE + HISTSIZE=0 + HISTSIZE=$original_histsize + if [[ -e "$_per_directory_history_directory" ]]; then + fc -R "$_per_directory_history_directory" + fi + fi + _per_directory_history_is_global=false +} +function _per-directory-history-set-global-history() { + if [[ $_per_directory_history_is_global == false ]]; then + fc -AI $_per_directory_history_directory + local original_histsize=$HISTSIZE + HISTSIZE=0 + HISTSIZE=$original_histsize + if [[ -e "$HISTFILE" ]]; then + fc -R "$HISTFILE" + fi + fi + _per_directory_history_is_global=true +} + + +#add functions to the exec list for chpwd and zshaddhistory +chpwd_functions=(${chpwd_functions[@]} "_per-directory-history-change-directory") +zshaddhistory_functions=(${zshaddhistory_functions[@]} "_per-directory-history-addhistory") + +#start in directory mode +mkdir -p ${_per_directory_history_directory:h} +_per_directory_history_is_global=true +_per-directory-history-set-directory-history diff --git a/plugins/pip/_pip b/plugins/pip/_pip index 9892dd19c..cb155e5f4 100644 --- a/plugins/pip/_pip +++ b/plugins/pip/_pip @@ -1,4 +1,4 @@ -#compdef pip +#compdef pip pip2 pip-2.7 pip3 pip-3.2 pip-3.3 pip-3.4 #autoload # pip zsh completion, based on homebrew completion diff --git a/plugins/pj/pj.plugin.zsh b/plugins/pj/pj.plugin.zsh index ba3765b83..f9cbddf1a 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,11 @@ 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 + projects=($PROJECT_PATHS/*) + projects=$projects:t + _arguments '*:file:($projects)' } compdef _pj pj diff --git a/plugins/postgres/postgres.plugin.zsh b/plugins/postgres/postgres.plugin.zsh index cdd142e92..c2dbef244 100644 --- a/plugins/postgres/postgres.plugin.zsh +++ b/plugins/postgres/postgres.plugin.zsh @@ -1,6 +1,8 @@ -# Aliases to stop, start and restart Postgres -# Paths noted below are for Postgress installed via Homebrew on OSX +# Aliases to control Postgres +# Paths noted below are for Postgres installed via Homebrew on OSX alias startpost='pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start' alias stoppost='pg_ctl -D /usr/local/var/postgres stop -s -m fast' -alias restartpost='stoppost && sleep 1 && startpost'
\ No newline at end of file +alias restartpost='stoppost && sleep 1 && startpost' +alias reloadpost='pg_ctl reload -D /usr/local/var/postgres -s' +alias statuspost='pg_ctl status -D /usr/local/var/postgres -s'
\ No newline at end of file diff --git a/plugins/pow/pow.plugin.zsh b/plugins/pow/pow.plugin.zsh index 7f86c0c76..d85c88777 100644 --- a/plugins/pow/pow.plugin.zsh +++ b/plugins/pow/pow.plugin.zsh @@ -21,8 +21,8 @@ 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 @@ -30,7 +30,7 @@ rack_root(){ basedir="$(pwd)" done - builtin cd $orgdir 2>/dev/null + builtin cd "$orgdir" 2>/dev/null [[ ${basedir} == "/" ]] && return 1 echo $basedir } @@ -56,19 +56,19 @@ 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 ] then echo "pow: Symlinking your app with pow. ${vhost}" - [ ! -d ~/.pow/${vhost} ] && ln -s $basedir ~/.pow/$vhost + [ ! -d ~/.pow/${vhost} ] && ln -s "$basedir" ~/.pow/$vhost return 1 fi } powed(){ - local basedir=$(rack_root) + local basedir="$(rack_root)" find ~/.pow/ -type l -lname "*$basedir*" -exec basename {}'.dev' \; } @@ -82,4 +82,4 @@ repow(){ } # View the standard out (puts) from any pow app -alias kaput="tail -f ~/Library/Logs/Pow/apps/*"
\ No newline at end of file +alias kaput="tail -f ~/Library/Logs/Pow/apps/*" diff --git a/plugins/rake-fast/README.md b/plugins/rake-fast/README.md new file mode 100644 index 000000000..f56142f69 --- /dev/null +++ b/plugins/rake-fast/README.md @@ -0,0 +1,23 @@ +# rake-fast + +Fast rake autocompletion plugin. + +This script caches the output for later usage and significantly speeds it up. It generates a .rake_tasks cache file in parallel to the Rakefile. It also checks the file modification dates to see if it needs to regenerate the cache file. + +This is entirely based on [this pull request by Ullrich Schäfer](https://github.com/robb/.dotfiles/pull/10/), which is inspired by [this Ruby on Rails trick from 2006](http://weblog.rubyonrails.org/2006/3/9/fast-rake-task-completion-for-zsh/). + +Think about that. 2006. + +## Installation + +Just add the plugin to your `.zshrc`: + +```bash +plugins=(foo bar rake-fast) +``` + +You might consider adding `.rake_tasks` to your [global .gitignore](https://help.github.com/articles/ignoring-files#global-gitignore) + +## Usage + +`rake`, then press tab diff --git a/plugins/rake-fast/rake-fast.plugin.zsh b/plugins/rake-fast/rake-fast.plugin.zsh index 320855233..cfc9a079f 100644 --- a/plugins/rake-fast/rake-fast.plugin.zsh +++ b/plugins/rake-fast/rake-fast.plugin.zsh @@ -1,20 +1,3 @@ -# rake-fast -# Fast rake autocompletion plugin for oh-my-zsh - -# This script caches the output for later usage and significantly speeds it up. -# It generates a .rake_tasks file in parallel to the Rakefile. - -# You'll want to add `.rake_tasks` to your global .git_ignore file: -# https://help.github.com/articles/ignoring-files#global-gitignore - -# You can force .rake_tasks to refresh with: -# $ rake_refresh - -# This is entirely based on Ullrich Schäfer's work -# (https://github.com/robb/.dotfiles/pull/10/), -# which is inspired by this Ruby on Rails trick from 2006: -# http://weblog.rubyonrails.org/2006/3/9/fast-rake-task-completion-for-zsh/ - _rake_refresh () { if [ -f .rake_tasks ]; then rm .rake_tasks @@ -27,8 +10,13 @@ _rake_refresh () { _rake_does_task_list_need_generating () { if [ ! -f .rake_tasks ]; then return 0; else - accurate=$(stat -f%m .rake_tasks) - changed=$(stat -f%m Rakefile) + if [[ "$OSTYPE" = darwin* ]]; then + accurate=$(stat -f%m .rake_tasks) + changed=$(stat -f%m Rakefile) + else + accurate=$(stat -c%Y .rake_tasks) + changed=$(stat -c%Y Rakefile) + fi return $(expr $accurate '>=' $changed) fi } diff --git a/plugins/rbenv/rbenv.plugin.zsh b/plugins/rbenv/rbenv.plugin.zsh index b6795b91c..213e1beb0 100644 --- a/plugins/rbenv/rbenv.plugin.zsh +++ b/plugins/rbenv/rbenv.plugin.zsh @@ -7,7 +7,7 @@ _rbenv-from-homebrew-installed() { } FOUND_RBENV=0 -rbenvdirs=("$HOME/.rbenv" "/usr/local/rbenv" "/opt/rbenv") +rbenvdirs=("$HOME/.rbenv" "/usr/local/rbenv" "/opt/rbenv" "/usr/local/opt/rbenv") if _homebrew-installed && _rbenv-from-homebrew-installed ; then rbenvdirs=($(brew --prefix rbenv) "${rbenvdirs[@]}") fi diff --git a/plugins/repo/repo.plugin.zsh b/plugins/repo/repo.plugin.zsh index d690a9d22..33f4195c7 100644 --- a/plugins/repo/repo.plugin.zsh +++ b/plugins/repo/repo.plugin.zsh @@ -10,3 +10,9 @@ compdef _repo rs='repo sync' alias rsrra='repo sync ; repo rebase --auto-stash' compdef _repo rsrra='repo sync ; repo rebase --auto-stash' + +alias ru='repo upload' +compdef _repo ru='repo upload' + +alias rst='repo status' +compdef _repo rst='repo status' diff --git a/plugins/rsync/rsync.plugin.zsh b/plugins/rsync/rsync.plugin.zsh index 33a31a5c1..1a3bb4cc3 100644 --- a/plugins/rsync/rsync.plugin.zsh +++ b/plugins/rsync/rsync.plugin.zsh @@ -1,4 +1,4 @@ -alias rsync-copy="rsync -av --progress -h" -alias rsync-move="rsync -av --progress -h --remove-source-files" -alias rsync-update="rsync -avu --progress -h" -alias rsync-synchronize="rsync -avu --delete --progress -h" +alias rsync-copy="rsync -avz --progress -h" +alias rsync-move="rsync -avz --progress -h --remove-source-files" +alias rsync-update="rsync -avzu --progress -h" +alias rsync-synchronize="rsync -avzu --delete --progress -h" diff --git a/plugins/rvm/rvm.plugin.zsh b/plugins/rvm/rvm.plugin.zsh index 3bde154df..234ac1642 100644 --- a/plugins/rvm/rvm.plugin.zsh +++ b/plugins/rvm/rvm.plugin.zsh @@ -6,6 +6,7 @@ alias gemsets='rvm gemset list' local ruby18='ruby-1.8.7' local ruby19='ruby-1.9.3' local ruby20='ruby-2.0.0' +local ruby21='ruby-2.1.2' function rb18 { if [ -z "$1" ]; then @@ -40,6 +41,17 @@ function rb20 { _rb20() {compadd `ls -1 $rvm_path/gems | grep "^$ruby20@" | sed -e "s/^$ruby20@//" | awk '{print $1}'`} compdef _rb20 rb20 +function rb21 { + if [ -z "$1" ]; then + rvm use "$ruby21" + else + rvm use "$ruby21@$1" + fi +} + +_rb21() {compadd `ls -1 $rvm_path/gems | grep "^$ruby21@" | sed -e "s/^$ruby21@//" | awk '{print $1}'`} +compdef _rb21 rb21 + function rvm-update { rvm get head } diff --git a/plugins/ssh-agent/ssh-agent.plugin.zsh b/plugins/ssh-agent/ssh-agent.plugin.zsh index 2fb8d5462..610ad34dc 100644 --- a/plugins/ssh-agent/ssh-agent.plugin.zsh +++ b/plugins/ssh-agent/ssh-agent.plugin.zsh @@ -1,7 +1,7 @@ # # INSTRUCTIONS # -# To enabled agent forwarding support add the following to +# To enable agent forwarding support add the following to # your .zshrc file: # # zstyle :omz:plugins:ssh-agent agent-forwarding on diff --git a/plugins/sublime/sublime.plugin.zsh b/plugins/sublime/sublime.plugin.zsh index a2042343a..5acc75cc7 100755..100644 --- a/plugins/sublime/sublime.plugin.zsh +++ b/plugins/sublime/sublime.plugin.zsh @@ -7,6 +7,7 @@ if [[ $('uname') == 'Linux' ]]; then "/opt/sublime_text/sublime_text" "/usr/bin/sublime_text" "/usr/local/bin/sublime_text" + "/usr/bin/subl" ) for _sublime_path in $_sublime_linux_paths; do if [[ -a $_sublime_path ]]; then @@ -16,7 +17,7 @@ if [[ $('uname') == 'Linux' ]]; then fi done -elif [[ $('uname') == 'Darwin' ]]; then +elif [[ "$OSTYPE" = darwin* ]]; then local _sublime_darwin_paths > /dev/null 2>&1 _sublime_darwin_paths=( "/usr/local/bin/subl" diff --git a/plugins/symfony2/symfony2.plugin.zsh b/plugins/symfony2/symfony2.plugin.zsh index 0d2bb68c3..8df22e9ad 100644 --- a/plugins/symfony2/symfony2.plugin.zsh +++ b/plugins/symfony2/symfony2.plugin.zsh @@ -1,21 +1,26 @@ # Symfony2 basic command completion +_symfony_console () { + echo "php $(find . -maxdepth 2 -mindepth 1 -name 'console' -type f | head -n 1)" +} + _symfony2_get_command_list () { - php app/console --no-ansi | sed "1,/Available commands/d" | awk '/^ [a-z]+/ { print $1 }' + `_symfony_console` --no-ansi | sed "1,/Available commands/d" | awk '/^ [a-z]+/ { print $1 }' } _symfony2 () { - if [ -f app/console ]; then - compadd `_symfony2_get_command_list` - fi + compadd `_symfony2_get_command_list` } -compdef _symfony2 app/console +compdef _symfony2 '`_symfony_console`' +compdef _symfony2 'app/console' +compdef _symfony2 'bin/console' compdef _symfony2 sf #Alias -alias sf='php app/console' -alias sfcl='php app/console cache:clear' -alias sfroute='php app/console router:debug' -alias sfgb='php app/console generate:bundle' - +alias sf='`_symfony_console`' +alias sfcl='sf cache:clear' +alias sfcw='sf cache:warmup' +alias sfroute='sf router:debug' +alias sfcontainer='sf container:debug' +alias sfgb='sf generate:bundle'
\ No newline at end of file diff --git a/plugins/systemadmin/systemadmin.zsh b/plugins/systemadmin/systemadmin.plugin.zsh index f5e44c66f..f5e44c66f 100644 --- a/plugins/systemadmin/systemadmin.zsh +++ b/plugins/systemadmin/systemadmin.plugin.zsh diff --git a/plugins/textastic/README.md b/plugins/textastic/README.md new file mode 100644 index 000000000..369c2c137 --- /dev/null +++ b/plugins/textastic/README.md @@ -0,0 +1,15 @@ +## textastic + +Plugin for Textastic, a text and code editor for Mac OS X + +### Requirements + + * [Textastic](http://www.textasticapp.com/mac.html) + +### Usage + + * If `tt` command is called without an argument, launch Textastic + + * If `tt` is passed a directory, cd to it and open it in Textastic + + * If `tt` is passed a file, open it in Textastic diff --git a/plugins/textastic/textastic.plugin.zsh b/plugins/textastic/textastic.plugin.zsh new file mode 100644 index 000000000..f5901eae2 --- /dev/null +++ b/plugins/textastic/textastic.plugin.zsh @@ -0,0 +1,17 @@ +# +# If the tt command is called without an argument, launch Textastic +# If tt is passed a directory, cd to it and open it in Textastic +# If tt is passed a file, open it in Textastic +# +function tt() { + if [[ -z "$1" ]] + then + open -a "textastic.app" + else + open -a "textastic.app" "$1" + if [[ -d "$1" ]] + then + cd "$1" + fi + fi +} 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/vagrant/_vagrant b/plugins/vagrant/_vagrant index d55ae6709..0c82acd42 100644 --- a/plugins/vagrant/_vagrant +++ b/plugins/vagrant/_vagrant @@ -6,19 +6,26 @@ local -a _1st_arguments _1st_arguments=( 'box:Box commands' + 'connect:Connects to a shared, remote Vagrant environment' 'destroy:Destroys the vagrant environment' + 'docker-logs:Shows Docker logs' + 'docker-run:Run one-off commands against a Docker container' + 'global-status:Reports the status of all active Vagrant environments on the system' 'halt:Halts the currently running vagrant environment' 'init:[box_name] [box_url] Initializes current folder for Vagrant usage' + 'login:Authenticates against a Vagrant Cloud server to access protected boxes' 'package:Packages a vagrant environment for distribution' 'plugin:Plugin commands' 'provision:Run the provisioner' 'reload:Reload the vagrant environment' 'resume:Resumes a suspend vagrant environment' + 'share:Shares the Vagrant environment and allows remote access' 'ssh:SSH into the currently running environment' - 'ssh-config:outputs .ssh/config valid syntax for connecting to this environment via ssh.' - 'status:Shows the status of the current Vagrant environment.' + 'ssh-config:outputs .ssh/config valid syntax for connecting to this environment via ssh' + 'status:Shows the status of the current Vagrant environment' 'suspend:Suspends the currently running vagrant environment' 'up:Creates the vagrant environment' + 'version:Prints the currently installed Vagrant version and checks for new updates' '--help:[TASK] Describe available tasks or one specific task' '--version:Prints the Vagrant version information' ) @@ -49,7 +56,8 @@ __box_list () __vm_list () { - _wanted application expl 'command' compadd $(command grep Vagrantfile -oe '^[^#]*\.vm\.define *:\([a-zA-Z0-9]\+\)' 2>/dev/null | cut -d: -f2) + _wanted application expl 'command' compadd $(command grep Vagrantfile -oe '^[^#]*\.vm\.define *[:"]\([a-zA-Z0-9_-]\+\)' 2>/dev/null | awk '{print substr($2, 2)}') + _wanted application expl 'command' compadd $(command ls .vagrant/machines/ 2>/dev/null) } __vagrant-box () diff --git a/plugins/virtualenv/virtualenv.plugin.zsh b/plugins/virtualenv/virtualenv.plugin.zsh index 8e06450b1..e250eb63e 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 diff --git a/plugins/vundle/vundle.plugin.zsh b/plugins/vundle/vundle.plugin.zsh index 936c8d7d2..830774fe3 100644 --- a/plugins/vundle/vundle.plugin.zsh +++ b/plugins/vundle/vundle.plugin.zsh @@ -4,7 +4,7 @@ function vundle-init () { mkdir -p ~/.vim/bundle/vundle/ fi - if [ ! -d ~/.vim/bundle/vundle/.git/ ] + if [ ! -d ~/.vim/bundle/vundle/.git ] && [ ! -f ~/.vim/bundle/vundle/.git ] then git clone http://github.com/gmarik/vundle.git ~/.vim/bundle/vundle echo "\n\tRead about vim configuration for vundle at https://github.com/gmarik/vundle\n" 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 100755..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 96a3426fc..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 "Unkown 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/web-search/web-search.plugin.zsh b/plugins/web-search/web-search.plugin.zsh index 8eedb90ee..371e3a303 100644 --- a/plugins/web-search/web-search.plugin.zsh +++ b/plugins/web-search/web-search.plugin.zsh @@ -1,10 +1,9 @@ # web_search from terminal function web_search() { - # get the open command local open_cmd - if [[ $(uname -s) == 'Darwin' ]]; then + if [[ "$OSTYPE" = darwin* ]]; then open_cmd='open' else open_cmd='xdg-open' @@ -38,8 +37,8 @@ function web_search() { done url="${url%?}" # remove the last '+' - - $open_cmd "$url" + nohup $open_cmd "$url" + rm nohup.out } diff --git a/plugins/wp-cli/README.md b/plugins/wp-cli/README.md new file mode 100644 index 000000000..6dda07d17 --- /dev/null +++ b/plugins/wp-cli/README.md @@ -0,0 +1,105 @@ +# WP-CLI + +**Maintainer:** [joshmedeski](https://github.com/joshmedeski) + +WordPress Command Line Interface (http://wp-cli.org/) + +WP-CLI is a set of command-line tools for managing WordPress installations. You can update plugins, set up multisite installs and much more, without using a web browser. + +## List of Aliases + +### Core +- wpcc='wp core config' +- wpcd='wp core download' +- wpci='wp core install' +- wpcii='wp core is-installed' +- wpcmc='wp core multisite-convert' +- wpcmi='wp core multisite-install' +- wpcu='wp core update' +- wpcudb='wp core update-db' +- wpcvc='wp core verify-checksums' + +### Cron +- wpcre='wp cron event' +- wpcrs='wp cron schedule' +- wpcrt='wp cron test' + +### Menu +- wpmc='wp menu create' +- wpmd='wp menu delete' +- wpmi='wp menu item' +- wpml='wp menu list' +- wpmlo='wp menu location' + +### Plugin +- wppa='activate' +- wppda='deactivate' +- wppd='delete' +- wppg='get' +- wppi='install' +- wppis='is-installed' +- wppl='list' +- wppp='path' +- wpps='search' +- wppst='status' +- wppt='toggle' +- wppu='uninstall' +- wppu='update' + +### Post +- wppoc='wp post create' +- wppod='wp post delete' +- wppoe='wp post edit' +- wppogen='wp post generate' +- wppog='wp post get' +- wppol='wp post list' +- wppom='wp post meta' +- wppou='wp post update' +- wppou='wp post url' + +### Sidebar +- wpsbl='wp sidebar list' + +### Theme +- wpta='wp theme activate' +- wptd='wp theme delete' +- wptdis='wp theme disable' +- wpte='wp theme enable' +- wptg='wp theme get' +- wpti='wp theme install' +- wptis='wp theme is-installed' +- wptl='wp theme list' +- wptm='wp theme mod' +- wptp='wp theme path' +- wpts='wp theme search' +- wptst='wp theme status' +- wptu='wp theme updatet' + +### User +- wpuac='wp user add-cap' +- wpuar='wp user add-role' +- wpuc='wp user create' +- wpud='wp user delete' +- wpugen='wp user generate' +- wpug='wp user get' +- wpui='wp user import-csv' +- wpul='wp user list' +- wpulc='wp user list-caps' +- wpum='wp user meta' +- wpurc='wp user remove-cap' +- wpurr='wp user remove-role' +- wpusr='wp user set-role' +- wpuu='wp user update' + +### Widget +- wpwa='wp widget add' +- wpwda='wp widget deactivate' +- wpwd='wp widget delete' +- wpwl='wp widget list' +- wpwm='wp widget move' +- wpwu='wp widget update' + +The entire list of wp-cli commands can be found here: http://wp-cli.org/commands/ + +I only included the commands that are most used. Please feel free to contribute to this project if you want more commands. + diff --git a/plugins/wp-cli/wp-cli.plugin.zsh b/plugins/wp-cli/wp-cli.plugin.zsh new file mode 100644 index 000000000..5d9551e24 --- /dev/null +++ b/plugins/wp-cli/wp-cli.plugin.zsh @@ -0,0 +1,138 @@ +# WP-CLI +# A command line interface for WordPress +# http://wp-cli.org/ + +# Cache + +# Cap + +# CLI + +# Comment + +# Core +alias wpcc='wp core config' +alias wpcd='wp core download' +alias wpci='wp core install' +alias wpcii='wp core is-installed' +alias wpcmc='wp core multisite-convert' +alias wpcmi='wp core multisite-install' +alias wpcu='wp core update' +alias wpcudb='wp core update-db' +alias wpcvc='wp core verify-checksums' + +# Cron +alias wpcre='wp cron event' +alias wpcrs='wp cron schedule' +alias wpcrt='wp cron test' + +# Db + +# Eval + +# Eval-File + +# Export + +# Help + +# Import + +# Media + +# Menu +alias wpmc='wp menu create' +alias wpmd='wp menu delete' +alias wpmi='wp menu item' +alias wpml='wp menu list' +alias wpmlo='wp menu location' + +# Network + +# Option + +# Plugin +alias wppa='activate' +alias wppda='deactivate' +alias wppd='delete' +alias wppg='get' +alias wppi='install' +alias wppis='is-installed' +alias wppl='list' +alias wppp='path' +alias wpps='search' +alias wppst='status' +alias wppt='toggle' +alias wppu='uninstall' +alias wppu='update' + +# Post +alias wppoc='wp post create' +alias wppod='wp post delete' +alias wppoe='wp post edit' +alias wppogen='wp post generate' +alias wppog='wp post get' +alias wppol='wp post list' +alias wppom='wp post meta' +alias wppou='wp post update' +alias wppou='wp post url' + +# Rewrite + +# Role + +# Scaffold + +# Search-Replace + +# Shell + +# Sidebar +alias wpsbl='wp sidebar list' + +# Site + +# Super-Admin + +# Term + +# Theme +alias wpta='wp theme activate' +alias wptd='wp theme delete' +alias wptdis='wp theme disable' +alias wpte='wp theme enable' +alias wptg='wp theme get' +alias wpti='wp theme install' +alias wptis='wp theme is-installed' +alias wptl='wp theme list' +alias wptm='wp theme mod' +alias wptp='wp theme path' +alias wpts='wp theme search' +alias wptst='wp theme status' +alias wptu='wp theme updatet' + +# Transient + +# User +alias wpuac='wp user add-cap' +alias wpuar='wp user add-role' +alias wpuc='wp user create' +alias wpud='wp user delete' +alias wpugen='wp user generate' +alias wpug='wp user get' +alias wpui='wp user import-csv' +alias wpul='wp user list' +alias wpulc='wp user list-caps' +alias wpum='wp user meta' +alias wpurc='wp user remove-cap' +alias wpurr='wp user remove-role' +alias wpusr='wp user set-role' +alias wpuu='wp user update' + +# Widget +alias wpwa='wp widget add' +alias wpwda='wp widget deactivate' +alias wpwd='wp widget delete' +alias wpwl='wp widget list' +alias wpwm='wp widget move' +alias wpwu='wp widget update' diff --git a/plugins/xcode/xcode.plugin.zsh b/plugins/xcode/xcode.plugin.zsh index 4816ab0ed..b7b75cf93 100644 --- a/plugins/xcode/xcode.plugin.zsh +++ b/plugins/xcode/xcode.plugin.zsh @@ -1,6 +1,6 @@ #xc function courtesy of http://gist.github.com/subdigital/5420709 function xc { - xcode_proj=`find . -name "*.xc*" -d 1 | sort -r | head -1` + xcode_proj=`ls | grep "\.xc" | sort -r | head -1` if [[ `echo -n $xcode_proj | wc -m` == 0 ]] then echo "No xcworkspace/xcodeproj file found in the current directory." @@ -16,4 +16,9 @@ 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' + +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 diff --git a/plugins/zsh_reload/zsh_reload.plugin.zsh b/plugins/zsh_reload/zsh_reload.plugin.zsh index a435dbc8d..3f44b99c6 100644 --- a/plugins/zsh_reload/zsh_reload.plugin.zsh +++ b/plugins/zsh_reload/zsh_reload.plugin.zsh @@ -1,13 +1,13 @@ -zsh_cache=$HOME/.zsh_cache -mkdir -p $zsh_cache - # reload zshrc function src() { + local cache="$ZSH/cache" autoload -U compinit zrecompile - compinit -d $zsh_cache/zcomp-$HOST - for f in $HOME/.zshrc $zsh_cache/zcomp-$HOST; do - zrecompile -p $f && rm -f $f.zwc.old + compinit -d "$cache/zcomp-$HOST" + + for f in ~/.zshrc "$cache/zcomp-$HOST"; do + zrecompile -p $f && command rm -f $f.zwc.old done + source ~/.zshrc -}
\ No newline at end of file +} diff --git a/templates/zshrc.zsh-template b/templates/zshrc.zsh-template index 7b7f1df85..a12eca2a0 100644 --- a/templates/zshrc.zsh-template +++ b/templates/zshrc.zsh-template @@ -7,38 +7,34 @@ export ZSH=$HOME/.oh-my-zsh # time that oh-my-zsh is loaded. ZSH_THEME="robbyrussell" -# Example aliases -# alias zshconfig="mate ~/.zshrc" -# alias ohmyzsh="mate ~/.oh-my-zsh" - -# Set this to use case-sensitive completion +# Uncomment the following line to use case-sensitive completion. # CASE_SENSITIVE="true" -# Uncomment this to disable bi-weekly auto-update checks +# Uncomment the following line to disable bi-weekly auto-update checks. # DISABLE_AUTO_UPDATE="true" -# Uncomment to change how often to auto-update? (in days) +# Uncomment the following line to change how often to auto-update (in days). # export UPDATE_ZSH_DAYS=13 -# Uncomment following line if you want to disable colors in ls +# Uncomment the following line to disable colors in ls. # DISABLE_LS_COLORS="true" -# Uncomment following line if you want to disable autosetting terminal title. +# Uncomment the following line to disable auto-setting terminal title. # DISABLE_AUTO_TITLE="true" -# Uncomment following line if you want to disable command autocorrection -# DISABLE_CORRECTION="true" +# Uncomment the following line to enable command auto-correction. +# ENABLE_CORRECTION="true" -# Uncomment following line if you want red dots to be displayed while waiting for completion +# Uncomment the following line to display red dots whilst waiting for completion. # COMPLETION_WAITING_DOTS="true" -# Uncomment following line if you want to disable marking untracked files under -# VCS as dirty. This makes repository status check for large repositories much, -# much faster. +# Uncomment the following line if you want to disable marking untracked files +# under VCS as dirty. This makes repository status check for large repositories +# much, much faster. # DISABLE_UNTRACKED_FILES_DIRTY="true" -# Uncomment following line if you want to the command execution time stamp shown -# in the history command output. +# Uncomment the following line if you want to change the command execution time +# stamp shown in the history command output. # The optional three formats: "mm/dd/yyyy"|"dd.mm.yyyy"|"yyyy-mm-dd" # HIST_STAMPS="mm/dd/yyyy" @@ -48,6 +44,7 @@ ZSH_THEME="robbyrussell" # Which plugins would you like to load? (plugins can be found in ~/.oh-my-zsh/plugins/*) # Custom plugins may be added to ~/.oh-my-zsh/custom/plugins/ # Example format: plugins=(rails git textmate ruby lighthouse) +# Add wisely, as too many plugins slow down shell startup. plugins=(git) source $ZSH/oh-my-zsh.sh @@ -60,7 +57,7 @@ export PATH=$HOME/bin:/usr/local/bin:$PATH # You may need to manually set your language environment # export LANG=en_US.UTF-8 -# # Preferred editor for local and remote sessions +# Preferred editor for local and remote sessions # if [[ -n $SSH_CONNECTION ]]; then # export EDITOR='vim' # else @@ -72,3 +69,12 @@ export PATH=$HOME/bin:/usr/local/bin:$PATH # ssh # export SSH_KEY_PATH="~/.ssh/dsa_id" + +# Set personal aliases, overriding those provided by oh-my-zsh libs, +# plugins, and themes. Aliases can be placed here, though oh-my-zsh +# users are encouraged to define aliases within the ZSH_CUSTOM folder. +# For a full list of active aliases, run `alias`. +# +# Example aliases +# alias zshconfig="mate ~/.zshrc" +# alias ohmyzsh="mate ~/.oh-my-zsh" diff --git a/themes/Soliah.zsh-theme b/themes/Soliah.zsh-theme index 237e70fda..070c54981 100644 --- a/themes/Soliah.zsh-theme +++ b/themes/Soliah.zsh-theme @@ -32,11 +32,12 @@ function check_git_prompt_info() { # Determine if we are using a gemset. function rvm_gemset() { - GEMSET=`rvm gemset list | grep '=>' | cut -b4-` - if [[ -n $GEMSET ]]; then - echo "%{$fg[yellow]%}$GEMSET%{$reset_color%}|" - fi - + if hash rvm 2>/dev/null; then + GEMSET=`rvm gemset list | grep '=>' | cut -b4-` + if [[ -n $GEMSET ]]; then + echo "%{$fg[yellow]%}$GEMSET%{$reset_color%}|" + fi + fi } # Determine the time since last commit. If branch is clean, diff --git a/themes/agnoster.zsh-theme b/themes/agnoster.zsh-theme index 85b846cb5..2b33c48bc 100644 --- a/themes/agnoster.zsh-theme +++ b/themes/agnoster.zsh-theme @@ -69,7 +69,9 @@ prompt_context() { # Git: branch/detached head, dirty status prompt_git() { - local ref dirty + local ref dirty mode repo_path + repo_path=$(git rev-parse --git-dir 2>/dev/null) + if $(git rev-parse --is-inside-work-tree >/dev/null 2>&1); then dirty=$(parse_git_dirty) ref=$(git symbolic-ref HEAD 2> /dev/null) || ref="➦ $(git show-ref --head -s --abbrev |head -n1 2> /dev/null)" @@ -79,6 +81,14 @@ prompt_git() { prompt_segment green black fi + if [[ -e "${repo_path}/BISECT_LOG" ]]; then + mode=" <B>" + elif [[ -e "${repo_path}/MERGE_HEAD" ]]; then + mode=" >M<" + elif [[ -e "${repo_path}/rebase" || -e "${repo_path}/rebase-apply" || -e "${repo_path}/rebase-merge" || -e "${repo_path}/../.dotest" ]]; then + mode=" >R>" + fi + setopt promptsubst autoload -Uz vcs_info @@ -90,7 +100,7 @@ prompt_git() { zstyle ':vcs_info:*' formats ' %u%c' zstyle ':vcs_info:*' actionformats ' %u%c' vcs_info - echo -n "${ref/refs\/heads\// }${vcs_info_msg_0_%% }" + echo -n "${ref/refs\/heads\// }${vcs_info_msg_0_%% }${mode}" fi } diff --git a/themes/bureau.zsh-theme b/themes/bureau.zsh-theme index 4d9cae0cc..443d1d5ee 100644 --- a/themes/bureau.zsh-theme +++ b/themes/bureau.zsh-theme @@ -70,7 +70,7 @@ bureau_git_prompt () { _PATH="%{$fg_bold[white]%}%~%{$reset_color%}" -if [[ "%#" == "#" ]]; then +if [[ $EUID -eq 0 ]]; then _USERNAME="%{$fg_bold[red]%}%n" _LIBERTY="%{$fg[red]%}#" else diff --git a/themes/fino.zsh-theme b/themes/fino.zsh-theme index 35e6e02c1..411dec9b9 100644 --- a/themes/fino.zsh-theme +++ b/themes/fino.zsh-theme @@ -35,7 +35,7 @@ local prompt_char='$(prompt_char)' PROMPT="╭─%{$FG[040]%}%n%{$reset_color%} %{$FG[239]%}at%{$reset_color%} %{$FG[033]%}$(box_name)%{$reset_color%} %{$FG[239]%}in%{$reset_color%} %{$terminfo[bold]$FG[226]%}${current_dir}%{$reset_color%}${git_info} %{$FG[239]%}using%{$FG[243]%}${ruby_env} -╰─${prompt_char} " +╰─${prompt_char}%{$reset_color%} " ZSH_THEME_GIT_PROMPT_PREFIX=" %{$FG[239]%}on%{$reset_color%} %{$fg[255]%}" ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}" diff --git a/themes/gnzh.zsh-theme b/themes/gnzh.zsh-theme index 33f187bc6..0519fbefb 100644 --- a/themes/gnzh.zsh-theme +++ b/themes/gnzh.zsh-theme @@ -14,11 +14,11 @@ eval PR_NO_COLOR="%{$terminfo[sgr0]%}" eval PR_BOLD="%{$terminfo[bold]%}" # Check the UID -if [[ $UID -ge 1000 ]]; then # normal user +if [[ $UID -ne 0 ]]; then # normal user eval PR_USER='${PR_GREEN}%n${PR_NO_COLOR}' eval PR_USER_OP='${PR_GREEN}%#${PR_NO_COLOR}' local PR_PROMPT='$PR_NO_COLOR➤ $PR_NO_COLOR' -elif [[ $UID -eq 0 ]]; then # root +else # root eval PR_USER='${PR_RED}%n${PR_NO_COLOR}' eval PR_USER_OP='${PR_RED}%#${PR_NO_COLOR}' local PR_PROMPT='$PR_RED➤ $PR_NO_COLOR' diff --git a/themes/half-life.zsh-theme b/themes/half-life.zsh-theme index c8d09ce47..942affa94 100644 --- a/themes/half-life.zsh-theme +++ b/themes/half-life.zsh-theme @@ -51,8 +51,8 @@ zstyle ':vcs_info:*:prompt:*' check-for-changes true PR_RST="%{${reset_color}%}" FMT_BRANCH=" on %{$turquoise%}%b%u%c${PR_RST}" FMT_ACTION=" performing a %{$limegreen%}%a${PR_RST}" -FMT_UNSTAGED="%{$orange%}●" -FMT_STAGED="%{$limegreen%}●" +FMT_UNSTAGED="%{$orange%} ●" +FMT_STAGED="%{$limegreen%} ●" zstyle ':vcs_info:*:prompt:*' unstagedstr "${FMT_UNSTAGED}" zstyle ':vcs_info:*:prompt:*' stagedstr "${FMT_STAGED}" @@ -83,7 +83,7 @@ function steeef_precmd { # check for untracked files or updated submodules, since vcs_info doesn't if [[ ! -z $(git ls-files --other --exclude-standard 2> /dev/null) ]]; then PR_GIT_UPDATE=1 - FMT_BRANCH="${PM_RST} on %{$turquoise%}%b%u%c%{$hotpink%}●${PR_RST}" + FMT_BRANCH="${PM_RST} on %{$turquoise%}%b%u%c%{$hotpink%} ●${PR_RST}" else FMT_BRANCH="${PM_RST} on %{$turquoise%}%b%u%c${PR_RST}" fi @@ -95,5 +95,4 @@ function steeef_precmd { } add-zsh-hook precmd steeef_precmd -PROMPT=$' -%{$purple%}%n%{$reset_color%} in %{$limegreen%}%~%{$reset_color%}$(rvm-prompt " with%{$fg[red]%} " v g "%{$reset_color%}")$vcs_info_msg_0_%{$orange%} λ%{$reset_color%} ' +PROMPT=$'%{$purple%}%n%{$reset_color%} in %{$limegreen%}%~%{$reset_color%}$(ruby_prompt_info " with%{$fg[red]%} " v g "%{$reset_color%}")$vcs_info_msg_0_%{$orange%} λ%{$reset_color%} ' diff --git a/themes/pygmalion.zsh-theme b/themes/pygmalion.zsh-theme index 654e0fc37..5f5fe7f9a 100644 --- a/themes/pygmalion.zsh-theme +++ b/themes/pygmalion.zsh-theme @@ -12,7 +12,7 @@ prompt_setup_pygmalion(){ base_prompt_nocolor=$(echo "$base_prompt" | perl -pe "s/%\{[^}]+\}//g") post_prompt_nocolor=$(echo "$post_prompt" | perl -pe "s/%\{[^}]+\}//g") - add-zsh-hook precmd prompt_pygmalion_precmd + precmd_functions+=(prompt_pygmalion_precmd) } prompt_pygmalion_precmd(){ diff --git a/themes/steeef.zsh-theme b/themes/steeef.zsh-theme index e0080b8a5..9d27410b8 100644 --- a/themes/steeef.zsh-theme +++ b/themes/steeef.zsh-theme @@ -81,7 +81,7 @@ add-zsh-hook chpwd steeef_chpwd function steeef_precmd { if [[ -n "$PR_GIT_UPDATE" ]] ; then # check for untracked files or updated submodules, since vcs_info doesn't - if git ls-files --other --exclude-standard --directory 2> /dev/null | grep -q "."; then + if git ls-files --other --exclude-standard 2> /dev/null | grep -q "."; then PR_GIT_UPDATE=1 FMT_BRANCH="(%{$turquoise%}%b%u%c%{$hotpink%}●${PR_RST})" else diff --git a/themes/terminalparty.zsh-theme b/themes/terminalparty.zsh-theme index 216ce37eb..cd7370bba 100644 --- a/themes/terminalparty.zsh-theme +++ b/themes/terminalparty.zsh-theme @@ -1,4 +1,4 @@ -PROMPT='%{$fg[green]%} %% ' +PROMPT='%(?,%{$fg[green]%},%{$fg[red]%}) %% ' # RPS1='%{$fg[blue]%}%~%{$reset_color%} ' RPS1='%{$fg[white]%}%2~$(git_prompt_info) %{$fg_bold[blue]%}%m%{$reset_color%}' @@ -6,4 +6,3 @@ ZSH_THEME_GIT_PROMPT_PREFIX=" %{$fg[yellow]%}(" ZSH_THEME_GIT_PROMPT_SUFFIX=")%{$reset_color%}" ZSH_THEME_GIT_PROMPT_CLEAN="" ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[red]%} ⚡%{$fg[yellow]%}" - diff --git a/tools/check_for_upgrade.sh b/tools/check_for_upgrade.sh index 0f8c9c391..35e074297 100644 --- a/tools/check_for_upgrade.sh +++ b/tools/check_for_upgrade.sh @@ -5,11 +5,11 @@ function _current_epoch() { } function _update_zsh_update() { - echo "LAST_EPOCH=$(_current_epoch)" > ~/.zsh-update + echo "LAST_EPOCH=$(_current_epoch)" >! ~/.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 } @@ -22,6 +22,10 @@ fi [ -f ~/.profile ] && source ~/.profile +# Cancel upgrade if the current user doesn't have write permissions for the +# oh-my-zsh directory. +[[ -w "$ZSH" ]] || return 0 + if [ -f ~/.zsh-update ] then . ~/.zsh-update diff --git a/tools/install.sh b/tools/install.sh index 71e19a389..a53ac48ab 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 && /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 } @@ -32,8 +32,10 @@ sed -i -e "/export PATH=/ c\\ export PATH=\"$PATH\" " ~/.zshrc -echo "\033[0;34mTime to change your default shell to zsh!\033[0m" -chsh -s `which zsh` +if [ "$SHELL" != "$(which zsh)" ]; then + echo "\033[0;34mTime to change your default shell to zsh!\033[0m" + chsh -s `which zsh` +fi echo "\033[0;32m"' __ __ '"\033[0m" echo "\033[0;32m"' ____ / /_ ____ ___ __ __ ____ _____/ /_ '"\033[0m" @@ -43,5 +45,6 @@ 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 +echo "\n\n \033[0;32mp.p.s. Get stickers and t-shirts at http://shop.planetargon.com.\033[0m" +env zsh . ~/.zshrc diff --git a/tools/upgrade.sh b/tools/upgrade.sh index 9a8497d96..5f0a81f1d 100644 --- a/tools/upgrade.sh +++ b/tools/upgrade.sh @@ -9,8 +9,8 @@ then printf '\033[0;32m%s\033[0m\n' '\____/_/ /_/ /_/ /_/ /_/\__, / /___/____/_/ /_/ ' printf '\033[0;32m%s\033[0m\n' ' /____/ ' printf '\033[0;34m%s\033[0m\n' 'Hooray! Oh My Zsh has been updated and/or is at the current version.' - printf '\033[0;34m%s\033[1m%s\033[0m\n' 'To keep up on the latest, be sure to follow Oh My Zsh on twitter: ' 'http://twitter.com/ohmyzsh' + printf '\033[0;34m%s\033[1m%s\033[0m\n' 'To keep up on the latest news and updates, follow us on twitter: ' 'http://twitter.com/ohmyzsh' + printf '\033[0;34m%s\033[1m%s\033[0m\n' 'Get your Oh My Zsh swag at: ' 'http://shop.planetargon.com/' else printf '\033[0;31m%s\033[0m\n' 'There was an error updating. Try again later?' fi - |