diff options
Diffstat (limited to 'plugins')
44 files changed, 665 insertions, 258 deletions
diff --git a/plugins/adb/_adb b/plugins/adb/_adb index 8cbf6593c..e3c20d751 100644 --- a/plugins/adb/_adb +++ b/plugins/adb/_adb @@ -48,8 +48,8 @@ _arguments \ case "$state" in specify_device) - _values 'devices' $(adb devices -l|awk 'NR>1&& $1 ~ /^[a-zA-Z0-9].*$/ \ - {printf "%s[%s] ",$1,$6 }') + _values -C 'devices' ${$(adb devices -l|awk 'NR>1&& $1 \ + {sub(/ +/," ",$0);gsub(":","\\:",$1); printf "%s[%s] ",$1, $NF}'):-""} return ;; esac diff --git a/plugins/archlinux/README.md b/plugins/archlinux/README.md index c3521c523..0d1fdea3a 100644 --- a/plugins/archlinux/README.md +++ b/plugins/archlinux/README.md @@ -23,7 +23,7 @@ | trupd | trizen -Sy && sudo abs | Update and refresh the local package and ABS databases | | trupd | trizen -Sy && sudo aur | Update and refresh the local package and AUR databases | | trupd | trizen -Sy | Update and refresh the local package database | -| trupd | trizen -Syua | Sync with repositories before upgrading all packages (from AUR too) | +| trupg | trizen -Syua | Sync with repositories before upgrading all packages (from AUR too) | | trsu | trizen -Syua --no-confirm | Same as `trupg`, but without confirmation | | upgrade | trizen -Syu | Sync with repositories before upgrading packages | diff --git a/plugins/autojump/autojump.plugin.zsh b/plugins/autojump/autojump.plugin.zsh index 7339fad9e..c0af67631 100644 --- a/plugins/autojump/autojump.plugin.zsh +++ b/plugins/autojump/autojump.plugin.zsh @@ -15,8 +15,8 @@ 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 /opt/local/etc/profile.d/autojump.zsh ]; then # mac os x with ports - . /opt/local/etc/profile.d/autojump.zsh + elif [ -f /opt/local/etc/profile.d/autojump.sh ]; then # mac os x with ports + . /opt/local/etc/profile.d/autojump.sh elif [ $commands[brew] -a -f `brew --prefix`/etc/autojump.sh ]; then # mac os x with brew . `brew --prefix`/etc/autojump.sh fi diff --git a/plugins/bundler/bundler.plugin.zsh b/plugins/bundler/bundler.plugin.zsh index 6b10b78d1..ea199d09a 100644 --- a/plugins/bundler/bundler.plugin.zsh +++ b/plugins/bundler/bundler.plugin.zsh @@ -57,7 +57,7 @@ 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 [[ "$OSTYPE" = darwin* ]] + if [[ "$OSTYPE" = (darwin|freebsd)* ]] then local cores_num="$(sysctl -n hw.ncpu)" else diff --git a/plugins/common-aliases/common-aliases.plugin.zsh b/plugins/common-aliases/common-aliases.plugin.zsh index 742798f27..785a09c63 100644 --- a/plugins/common-aliases/common-aliases.plugin.zsh +++ b/plugins/common-aliases/common-aliases.plugin.zsh @@ -13,7 +13,7 @@ alias lS='ls -1FSsh' alias lart='ls -1Fcart' alias lrt='ls -1Fcrt' -alias zshrc='$EDITOR ~/.zshrc' # Quick access to the ~/.zshrc file +alias zshrc='${=EDITOR} ~/.zshrc' # Quick access to the ~/.zshrc file alias grep='grep --color' alias sgrep='grep -R -n -H -C 5 --exclude-dir={.git,.svn,CVS} ' @@ -44,8 +44,6 @@ alias p='ps -f' alias sortnr='sort -n -r' alias unexport='unset' -alias whereami=display_info - alias rm='rm -i' alias cp='cp -i' alias mv='mv -i' diff --git a/plugins/debian/debian.plugin.zsh b/plugins/debian/debian.plugin.zsh index 19966b6ac..42690e53e 100644 --- a/plugins/debian/debian.plugin.zsh +++ b/plugins/debian/debian.plugin.zsh @@ -5,9 +5,12 @@ # # Debian-related zsh aliases and functions for zsh -# Use aptitude if installed, or apt-get if not. +# Use apt or aptitude if installed, fallback is apt-get # You can just set apt_pref='apt-get' to override it. -if [[ -e $( which -p aptitude 2>&1 ) ]]; then +if [[ -e $( which -p apt 2>&1 ) ]]; then + apt_pref='apt' + apt_upgr='upgrade' +elif [[ -e $( which -p aptitude 2>&1 ) ]]; then apt_pref='aptitude' apt_upgr='safe-upgrade' else diff --git a/plugins/dotenv/README.md b/plugins/dotenv/README.md index ade09fbb2..e0e75571f 100644 --- a/plugins/dotenv/README.md +++ b/plugins/dotenv/README.md @@ -2,19 +2,19 @@ Automatically load your project ENV variables from `.env` file when you `cd` into project root directory. -Storing configuration in the environment is one of the tenets of a [twelve-factor app](http://www.12factor.net). Anything that is likely to change between deployment environments–such as resource handles for databases or credentials for external services–should be extracted from the code into environment variables. +Storing configuration in the environment is one of the tenets of a [twelve-factor app](http://www.12factor.net). Anything that is likely to change between deployment environments, such as resource handles for databases or credentials for external services, should be extracted from the code into environment variables. ## Installation Just add the plugin to your `.zshrc`: ```sh -plugins=(git man dotenv) +plugins=(... dotenv) ``` ## Usage -Create `.env` file inside your project directory and put your local ENV variables there. +Create `.env` file inside your project root directory and put your ENV variables there. For example: ```sh @@ -30,5 +30,16 @@ SECRET_KEY=7c6c72d959416d5aa368a409362ec6e2ac90d7f MONGO_URI=mongodb://127.0.0.1:27017 PORT=3001 ``` +You can even mix both formats, although it's probably a bad idea. -**It's strongly recommended to add `.env` file to `.gitignore`**, because usually it contains sensitive information such as your credentials, secret keys, passwords etc. You don't want to commit this file, it supposed to be local only. +## Version Control + +**It's strongly recommended to add `.env` file to `.gitignore`**, because usually it contains sensitive information such as your credentials, secret keys, passwords etc. You don't want to commit this file, it's supposed to be local only. + +## Disclaimer + +This plugin only sources the `.env` file. Nothing less, nothing more. It doesn't do any checks. It's designed to be the fastest and simplest option. You're responsible for the `.env` file content. You can put some code (or weird symbols) there, but do it on your own risk. `dotenv` is the basic tool, yet it does the job. + +If you need more advanced and feature-rich ENV management, check out these awesome projects: +* [direnv](https://github.com/direnv/direnv) +* [zsh-autoenv](https://github.com/Tarrasch/zsh-autoenv) diff --git a/plugins/dotenv/dotenv.plugin.zsh b/plugins/dotenv/dotenv.plugin.zsh index 9dd784229..fa47c4c68 100644 --- a/plugins/dotenv/dotenv.plugin.zsh +++ b/plugins/dotenv/dotenv.plugin.zsh @@ -2,7 +2,13 @@ source_env() { if [[ -f .env ]]; then - source .env + if [[ -o a ]]; then + source .env + else + set -a + source .env + set +a + fi fi } diff --git a/plugins/git/git.plugin.zsh b/plugins/git/git.plugin.zsh index 34598fb35..04ff22164 100644 --- a/plugins/git/git.plugin.zsh +++ b/plugins/git/git.plugin.zsh @@ -208,11 +208,12 @@ alias gra='git remote add' alias grb='git rebase' alias grba='git rebase --abort' alias grbc='git rebase --continue' +alias grbd='git rebase develop' alias grbi='git rebase -i' alias grbm='git rebase master' alias grbs='git rebase --skip' -alias grh='git reset HEAD' -alias grhh='git reset HEAD --hard' +alias grh='git reset' +alias grhh='git reset --hard' alias grmv='git remote rename' alias grrm='git remote remove' alias grset='git remote set-url' diff --git a/plugins/gitignore/gitignore.plugin.zsh b/plugins/gitignore/gitignore.plugin.zsh index f242169e4..15e38d3b7 100644 --- a/plugins/gitignore/gitignore.plugin.zsh +++ b/plugins/gitignore/gitignore.plugin.zsh @@ -1,7 +1,7 @@ function gi() { curl -fL https://www.gitignore.io/api/${(j:,:)@} } _gitignoreio_get_command_list() { - curl -fL https://www.gitignore.io/api/list | tr "," "\n" + curl -sfL https://www.gitignore.io/api/list | tr "," "\n" } _gitignoreio () { diff --git a/plugins/golang/golang.plugin.zsh b/plugins/golang/golang.plugin.zsh index d9d450690..d5c78ce6c 100644 --- a/plugins/golang/golang.plugin.zsh +++ b/plugins/golang/golang.plugin.zsh @@ -135,7 +135,7 @@ __go_tool_complete() { run) _arguments -s -w : \ ${build_flags[@]} \ - '*:file:_path_files -g "*.go"' + '*:file:_files -g "*.go"' ;; tool) if (( CURRENT == 3 )); then diff --git a/plugins/homestead/homestead.plugin.zsh b/plugins/homestead/homestead.plugin.zsh new file mode 100644 index 000000000..cdbc564e4 --- /dev/null +++ b/plugins/homestead/homestead.plugin.zsh @@ -0,0 +1,10 @@ +# Homestead basic command completion +_homestead_get_command_list () { + homestead --no-ansi | sed "1,/Available commands/d" | awk '/^ +[a-z]+/ { print $1 }' +} + +_homestead () { + compadd `_homestead_get_command_list` +} + +compdef _homestead homestead diff --git a/plugins/kube-ps1/kube-ps1.zsh b/plugins/kube-ps1/kube-ps1.plugin.zsh index e1cb4339d..e1cb4339d 100644 --- a/plugins/kube-ps1/kube-ps1.zsh +++ b/plugins/kube-ps1/kube-ps1.plugin.zsh diff --git a/plugins/kubectl/kubectl.plugin.zsh b/plugins/kubectl/kubectl.plugin.zsh index c4e30dacd..f91475b6c 100644 --- a/plugins/kubectl/kubectl.plugin.zsh +++ b/plugins/kubectl/kubectl.plugin.zsh @@ -10,7 +10,7 @@ if (( $+commands[kubectl] )); then unset __KUBECTL_COMPLETION_FILE fi -# This command is used ALOT both below and in daily life +# This command is used a LOT both below and in daily life alias k=kubectl # Apply a YML file diff --git a/plugins/lein/_lein b/plugins/lein/_lein new file mode 100644 index 000000000..9d022e968 --- /dev/null +++ b/plugins/lein/_lein @@ -0,0 +1,69 @@ +#compdef lein + +# Lein ZSH completion function +# Drop this somewhere in your $fpath (like /usr/share/zsh/site-functions) +# and rename it _lein + +_lein() { + if (( CURRENT > 2 )); then + # shift words so _arguments doesn't have to be concerned with second command + (( CURRENT-- )) + shift words + # use _call_function here in case it doesn't exist + _call_function 1 _lein_${words[1]} + else + _values "lein command" \ + "change[Rewrite project.clj by applying a function.]" \ + "check[Check syntax and warn on reflection.]" \ + "classpath[Print the classpath of the current project.]" \ + "clean[Remove all files from project's target-path.]" \ + "compile[Compile Clojure source into .class files.]" \ + "deploy[Build and deploy jar to remote repository.]" \ + "deps[Download all dependencies.]" \ + "do[Higher-order task to perform other tasks in succession.]" \ + "help[Display a list of tasks or help for a given task.]" \ + "install[Install the current project to the local repository.]" \ + "jar[Package up all the project's files into a jar file.]" \ + "javac[Compile Java source files.]" \ + "new[Generate project scaffolding based on a template.]" \ + "plugin[DEPRECATED. Please use the :user profile instead.]" \ + "pom[Write a pom.xml file to disk for Maven interoperability.]" \ + "release[Perform :release-tasks.]" \ + "repl[Start a repl session either with the current project or standalone.]" \ + "retest[Run only the test namespaces which failed last time around.]" \ + "run[Run a -main function with optional command-line arguments.]" \ + "search[Search remote maven repositories for matching jars.]" \ + "show-profiles[List all available profiles or display one if given an argument.]" \ + "test[Run the project's tests.]" \ + "trampoline[Run a task without nesting the project's JVM inside Leiningen's.]" \ + "uberjar[Package up the project files and dependencies into a jar file.]" \ + "update-in[Perform arbitrary transformations on your project map.]" \ + "upgrade[Upgrade Leiningen to specified version or latest stable.]" \ + "vcs[Interact with the version control system.]" \ + "version[Print version for Leiningen and the current JVM.]" \ + "with-profile[Apply the given task with the profile(s) specified.]" + fi +} + +_lein_plugin() { + _values "lein plugin commands" \ + "install[Download, package, and install plugin jarfile into ~/.lein/plugins]" \ + "uninstall[Delete the plugin jarfile: \[GROUP/\]ARTIFACT-ID VERSION]" +} + + +_lein_namespaces() { + if [ -f "./project.clj" -a -d "$1" ]; then + _values "lein valid namespaces" \ + $(find "$1" -type f -name "*.clj" -exec awk '/^\(ns */ {gsub("\\)", "", $2); print $2}' '{}' '+') + fi +} + + +_lein_run() { + _lein_namespaces "src/" +} + +_lein_test() { + _lein_namespaces "test/" +} diff --git a/plugins/lein/lein.plugin.zsh b/plugins/lein/lein.plugin.zsh deleted file mode 100644 index f4e50b447..000000000 --- a/plugins/lein/lein.plugin.zsh +++ /dev/null @@ -1,43 +0,0 @@ -function _lein_commands() { - local ret=1 state - _arguments ':subcommand:->subcommand' && ret=0 - - case $state in - subcommand) - subcommands=( - "classpath:print the classpath of the current project" - "clean:remove compiled files and dependencies from project" - "compile:ahead-of-time compile the project" - "deploy:build jar and deploy to remote repository" - "deps:download and install all dependencies" - "help:display a list of tasks or help for a given task" - "install:install the project and its dependencies in your local repository" - "int:enter an interactive task shell" - "interactive:enter an interactive task shell" - "jack-in:jack in to a clojure slime session from emacs." - "jar:create a jar file containing the compiled .class files" - "javac:compile java source files" - "new:create a new project skeleton" - "plugin:manage user-level plugins" - "pom:write a pom.xml file to disk for maven interop" - "repl:start a repl session either with the current project or standalone" - "retest:run only the test namespaces which failed last time around" - "run:run the project's -main function" - "search:search remote maven repositories for matching jars" - "swank:launch swank server for Emacs to connect" - "test:run the project's tests" - "test!:run a project's tests after cleaning and fetching dependencies" - "trampoline:run a task without nesting the project's JVM inside Leiningen's." - "uberjar:Create a jar including the contents of each of deps" - "upgrade:upgrade leiningen to the latest stable release" - "version:print leiningen's version" - ) - _describe -t subcommands 'leiningen subcommands' subcommands && ret=0 - ;; - *) _files - esac - - return ret -} - -compdef _lein_commands lein diff --git a/plugins/magic-enter/Readme.md b/plugins/magic-enter/Readme.md new file mode 100644 index 000000000..b401ab415 --- /dev/null +++ b/plugins/magic-enter/Readme.md @@ -0,0 +1,14 @@ +## Magic Enter + +**Maintainer:** [@dufferzafar](https://github.com/dufferzafar) + +Makes your enter key magical, by binding commonly used commands to it. + +You can set the commands to be run in your .zshrc, before the line containing plugins! + +```bash +MAGIC_ENTER_GIT_COMMAND='git status -u .' +MAGIC_ENTER_OTHER_COMMAND='ls -lh .' + +plugins=(magic-enter) +``` diff --git a/plugins/magic-enter/magic-enter.plugin.zsh b/plugins/magic-enter/magic-enter.plugin.zsh new file mode 100644 index 000000000..8e1859678 --- /dev/null +++ b/plugins/magic-enter/magic-enter.plugin.zsh @@ -0,0 +1,24 @@ +# Bind quick stuff to enter! +# +# Pressing enter in a git directory runs `git status` +# in other directories `ls` +magic-enter () { + + # If commands are not already set, use the defaults + [ -z "$MAGIC_ENTER_GIT_COMMAND" ] && MAGIC_ENTER_GIT_COMMAND="git status -u ." + [ -z "$MAGIC_ENTER_OTHER_COMMAND" ] && MAGIC_ENTER_OTHER_COMMAND="ls -lh ." + + if [[ -z $BUFFER ]]; then + echo "" + if git rev-parse --is-inside-work-tree &>/dev/null; then + eval "$MAGIC_ENTER_GIT_COMMAND" + else + eval "$MAGIC_ENTER_OTHER_COMMAND" + fi + zle redisplay + else + zle accept-line + fi +} +zle -N magic-enter +bindkey "^M" magic-enter diff --git a/plugins/meteor/_meteor b/plugins/meteor/_meteor index cd7fc304f..6a15c4bc2 100644 --- a/plugins/meteor/_meteor +++ b/plugins/meteor/_meteor @@ -13,19 +13,38 @@ _meteor_installed_packages() { local -a _1st_arguments _1st_arguments=( - 'run:[Default] Run this project in local development mode' - 'create:Create a new project' - 'update:Upgrade this project to the latest version of Meteor' - 'add:Add a package to this project' - 'remove:Remove a package from this project' - 'list:List available packages' - 'help:Display Meteor help' - 'bundle:Pack this project up into a tarball' - 'mongo:Connect to the Mongo database for the specified site' - 'deploy:Deploy this project to Meteor' - 'logs:Show logs for specified site' - 'reset:Reset the project state. Erases the local database.' - 'test-packages:Test one or more packages' + "add-platform:Add a platform to this project." + "add:Add a package to this project." + "admin:Administrative commands." + "authorized:View or change authorized users and organizations for a site." + "build:Build this project for all platforms." + "claim:Claim a site deployed with an old Meteor version." + "configure-android:Run the Android configuration tool from Meteor's ADK environment." + "create:Create a new project." + "debug:Run the project, but suspend the server process for debugging." + "deploy:Deploy this project to Meteor." + "install-sdk:Installs SDKs for a platform." + "lint:Build this project and run the linters printing all errors and warnings." + "list-platforms:List the platforms added to your project." + "list-sites:List sites for which you are authorized." + "list:List the packages explicitly used by your project." + "login:Log in to your Meteor developer account." + "logout:Log out of your Meteor developer account." + "logs:Show logs for specified site." + "mongo:Connect to the Mongo database for the specified site." + "publish-for-arch:Builds an already-published package for a new platform." + "publish-release:Publish a new meteor release to the package server." + "publish:Publish a new version of a package to the package server." + "remove-platform:Remove a platform from this project." + "remove:Remove a package from this project." + "reset:Reset the project state. Erases the local database." + "run:[default] Run this project in local development mode." + "search:Search through the package server database." + "shell:Launch a Node REPL for interactively evaluating server-side code." + "show:Show detailed information about a release or package." + "test-packages:Test one or more packages." + "update:Upgrade this project's dependencies to their latest versions." + "whoami:Prints the username of your Meteor developer account." ) local expl @@ -45,4 +64,4 @@ case "$words[2]" in add) _meteor_all_packages _wanted packages expl 'all packages' compadd -a packages ;; -esac
\ No newline at end of file +esac diff --git a/plugins/mvn/mvn.plugin.zsh b/plugins/mvn/mvn.plugin.zsh index ee6fe2770..d422ba5c7 100644 --- a/plugins/mvn/mvn.plugin.zsh +++ b/plugins/mvn/mvn.plugin.zsh @@ -59,11 +59,13 @@ alias mvn-updates='mvn versions:display-dependency-updates' alias mvntc7='mvn tomcat7:run' alias mvntc='mvn tomcat:run' alias mvnjetty='mvn jetty:run' +alias mvnboot='mvn spring-boot:run' alias mvndt='mvn dependency:tree' alias mvns='mvn site' alias mvnsrc='mvn dependency:sources' alias mvndocs='mvn dependency:resolve -Dclassifier=javadoc' + function listMavenCompletions { reply=( # common lifecycle diff --git a/plugins/nmap/nmap.plugin.zsh b/plugins/nmap/nmap.plugin.zsh index d09f2c615..82c275f23 100644 --- a/plugins/nmap/nmap.plugin.zsh +++ b/plugins/nmap/nmap.plugin.zsh @@ -17,16 +17,16 @@ alias nmap_open_ports="nmap --open" alias nmap_list_interfaces="nmap --iflist" -alias nmap_slow="nmap -sS -v -T1" -alias nmap_fin="nmap -sF -v" -alias nmap_full="nmap -sS -T4 -PE -PP -PS80,443 -PY -g 53 -A -p1-65535 -v" -alias nmap_check_for_firewall="nmap -sA -p1-65535 -v -T4" +alias nmap_slow="sudo nmap -sS -v -T1" +alias nmap_fin="sudo nmap -sF -v" +alias nmap_full="sudo nmap -sS -T4 -PE -PP -PS80,443 -PY -g 53 -A -p1-65535 -v" +alias nmap_check_for_firewall="sudo nmap -sA -p1-65535 -v -T4" alias nmap_ping_through_firewall="nmap -PS -PA" alias nmap_fast="nmap -F -T5 --version-light --top-ports 300" -alias nmap_detect_versions="nmap -sV -p1-65535 -O --osscan-guess -T4 -Pn" +alias nmap_detect_versions="sudo nmap -sV -p1-65535 -O --osscan-guess -T4 -Pn" alias nmap_check_for_vulns="nmap --script=vulscan" -alias nmap_full_udp="nmap -sS -sU -T4 -A -v -PE -PS22,25,80 -PA21,23,80,443,3389 " -alias nmap_traceroute="nmap -sP -PE -PS22,25,80 -PA21,23,80,3389 -PU -PO --traceroute " +alias nmap_full_udp="sudo nmap -sS -sU -T4 -A -v -PE -PS22,25,80 -PA21,23,80,443,3389 " +alias nmap_traceroute="sudo nmap -sP -PE -PS22,25,80 -PA21,23,80,3389 -PU -PO --traceroute " alias nmap_full_with_scripts="sudo nmap -sS -sU -T4 -A -v -PE -PP -PS21,22,23,25,80,113,31339 -PA80,113,443,10042 -PO --script all " alias nmap_web_safe_osscan="sudo nmap -p 80,443 -O -v --osscan-guess --fuzzy " diff --git a/plugins/npm/npm.plugin.zsh b/plugins/npm/npm.plugin.zsh index 43af35ddb..f62174a4f 100644 --- a/plugins/npm/npm.plugin.zsh +++ b/plugins/npm/npm.plugin.zsh @@ -1,5 +1,5 @@ (( $+commands[npm] )) && { - __NPM_COMPLETION_FILE="${ZSH_CACHE_DIR}/npm_completion" + __NPM_COMPLETION_FILE="${ZSH_CACHE_DIR:-$ZSH/cache}/npm_completion" if [[ ! -f $__NPM_COMPLETION_FILE ]]; then npm completion >! $__NPM_COMPLETION_FILE 2>/dev/null diff --git a/plugins/nvm/_nvm b/plugins/nvm/_nvm index 1414dcbb1..1eec48b0a 100644 --- a/plugins/nvm/_nvm +++ b/plugins/nvm/_nvm @@ -6,16 +6,23 @@ local -a _1st_arguments _1st_arguments=( 'help:show help' - 'install:download and install a version' + '--version:print out the latest released version of nvm' + 'install:download and install a version in <node|iojs|node version number>' 'uninstall:uninstall a version' - 'use:modify PATH to use version' - 'run:run version with given arguments' + 'use:modify PATH to use <version>. Uses .nvmrc if available' + 'exec:run <command> on <version>. Uses .nvmrc if available' + 'run:run `node` on <version> with <args> as arguments. Uses .nvmrc if available' + 'current:list installed versions' 'ls:list installed versions or versions matching a given description' + 'version:resolve the given description to a single local version' + 'version-remote:resolve the given description to a single remote version' 'ls-remote:list remote versions available for install' - 'deactivate:undo effects of NVM on current shell' + 'deactivate:undo effects of `nvm` on current shell' 'alias:show or set aliases' 'unalias:deletes an alias' - 'copy-packages:install global NPM packages to current version' + 'reinstall-packages:reinstall global `npm` packages contained in <version> to current version' + 'unload:unload `nvm` from shell' + 'which:display path to installed node version. Uses .nvmrc if available' ) _arguments -C '*:: :->subcmds' && return 0 @@ -23,4 +30,4 @@ _arguments -C '*:: :->subcmds' && return 0 if (( CURRENT == 1 )); then _describe -t commands "nvm subcommand" _1st_arguments return -fi
\ No newline at end of file +fi diff --git a/plugins/percol/README.md b/plugins/percol/README.md new file mode 100644 index 000000000..97cca6876 --- /dev/null +++ b/plugins/percol/README.md @@ -0,0 +1,23 @@ +## percol + +Provides some useful function to make [percol](https://github.com/mooz/percol) work with zsh history and [jump plugin](https://github.com/robbyrussell/oh-my-zsh/blob/master/plugins/jump/jump.plugin.zsh) + +### Preview +![Preview](http://t1.qpic.cn/mblogpic/eb1c8f9d2b9f62d19fa8/2000.jpg) + +### Requirements + +```shell +pip install percol +``` + +And [jump](https://github.com/robbyrussell/oh-my-zsh/blob/master/plugins/jump/jump.plugin.zsh) for `oh-my-zsh` is a optional requirement. + +### Usage + +For default + +- `^-r` bind to `percol_select_history`.You can use it to grep your history with percol. + +- `^-b` bind to `percol_select_marks`.You can use it to grep your bookmarks with percol. + diff --git a/plugins/percol/percol.plugin.zsh b/plugins/percol/percol.plugin.zsh new file mode 100644 index 000000000..c6adf4e1e --- /dev/null +++ b/plugins/percol/percol.plugin.zsh @@ -0,0 +1,22 @@ +if which percol &> /dev/null; then + function percol_select_history() { + local tac + which gtac &> /dev/null && tac="gtac" || { which tac &> /dev/null && tac="tac" || { tac="tail -r" } } + BUFFER=$(fc -l -n 1 | eval $tac | percol --query "$LBUFFER") + CURSOR=$#BUFFER + zle -R -c + } + + zle -N percol_select_history + bindkey '^R' percol_select_history + + if which marks &> /dev/null; then + function percol_select_marks() { + BUFFER=$(marks | percol --query "$LBUFFER" | awk '{print $3}') + CURSOR=$#BUFFER # move cursor + zle -R -c # refresh + } + zle -N percol_select_marks + bindkey '^B' percol_select_marks + fi +fi diff --git a/plugins/perms/README.md b/plugins/perms/README.md index 873c21d42..324b3f3cc 100644 --- a/plugins/perms/README.md +++ b/plugins/perms/README.md @@ -4,6 +4,6 @@ Plugin to handle some unix filesystem permissions quickly ### Usage -* `set755` recursively sets all directories located within the current working directory and sub directories to octal 755. -* `set644` recursively sets all files located within the current working directory and sub directories to octal 644. -* `fixperms` is a wrapper around `set755` and `set644` applied to a specified directory or the current directory otherwise. It also prompts prior to execution unlike the other two aliases.
\ No newline at end of file +* `set755` recursively sets all given directories (default to .) to octal 755. +* `set644` recursively sets all given files (default to .) to octal 644. +* `fixperms` is a wrapper around `set755` and `set644` applied to a specified directory or the current directory otherwise. It also prompts prior to execution unlike the other two aliases. diff --git a/plugins/perms/perms.plugin.zsh b/plugins/perms/perms.plugin.zsh index 7cdebab7f..1a7472c1c 100644 --- a/plugins/perms/perms.plugin.zsh +++ b/plugins/perms/perms.plugin.zsh @@ -6,10 +6,14 @@ ### Aliases # Set all files' permissions to 644 recursively in a directory -alias set644='find . -type f ! -perm 644 -print0 | xargs -0 chmod 644' +set644() { + find "${@:-.}" -type f ! -perm 644 -print0 | xargs -0 chmod 644 +} # Set all directories' permissions to 755 recursively in a directory -alias set755='find . -type d ! -perm 755 -print0 | xargs -0 chmod 755' +set755() { + find "${@:-.}" -type d ! -perm 755 -print0 | xargs -0 chmod 755 +} ### Functions diff --git a/plugins/python/_python b/plugins/python/_python deleted file mode 100644 index f517d4806..000000000 --- a/plugins/python/_python +++ /dev/null @@ -1,54 +0,0 @@ -#compdef python - -# Python 2.6 -# Python 3.0 - -local curcontext="$curcontext" state line expl -typeset -A opt_args - -local -a args - -if _pick_variant python3=Python\ 3 python2 --version; then - args=( - '(-bb)-b[issue warnings about str(bytes_instance), str(bytearray_instance) and comparing bytes/bytearray with str]' - '(-b)-bb[issue errors about str(bytes_instance), str(bytearray_instance) and comparing bytes/bytearray with str]' - ) -else - args=( - '-Q+[division options]:division option:(old warn warnall new)' - '(-tt)-t[issue warnings about inconsistent tab usage]' - '(-t)-tt[issue errors about inconsistent tab usage]' - '-3[warn about Python 3.x incompatibilities]' - ) -fi - -_arguments -C -s -S "$args[@]" \ - "-B[don't write .py\[co\] files on import]" \ - '(1 -)-c+[program passed in as string (terminates option list)]:python command:' \ - '-d[debug output from parser]' \ - '-E[ignore PYTHON* environment variables (such as PYTHONPATH)]' \ - '(1 * -)-h[display help information]' \ - '-i[inspect interactively after running script]' \ - '(1 * -)-m[run library module as a script (terminates option list)]:module:->modules' \ - '-O[optimize generated bytecode slightly]' \ - '-OO[remove doc-strings in addition to the -O optimizations]' \ - "-s[don't add user site directory to sys.path]" \ - "-S[don't imply 'import site' on initialization]" \ - '-u[unbuffered binary stdout and stderr]' \ - '-v[verbose (trace import statements)]' \ - '(1 * -)'{-V,--version}'[display version information]' \ - '-W+[warning control]:warning filter (action\:message\:category\:module\:lineno):(default always ignore module once error)' \ - '-x[skip first line of source, allowing use of non-Unix forms of #!cmd]' \ - '(-)1:script file:_files -g "*.py(|c|o)(-.)"' \ - '*::script argument: _normal' && return - -if [[ "$state" = modules ]]; then - local -a modules - modules=( - ${${=${(f)"$(_call_program modules $words[1] -c \ - 'from\ pydoc\ import\ help\;\ help\(\"modules\"\)')"}[2,-3]}:#\(package\)} - ) - _wanted modules expl module compadd -a modules && return -fi - -return 1 diff --git a/plugins/rand-quote/README.md b/plugins/rand-quote/README.md new file mode 100644 index 000000000..c387aaa22 --- /dev/null +++ b/plugins/rand-quote/README.md @@ -0,0 +1,15 @@ +# rand-quote plugin + +Displays a random quote taken from [quotationspage.com](http://www.quotationspage.com/random.php) + +Created by [Eduardo San Martin Morote, aka Posva](https://posva.github.io) + +## Usage + +Add the plugin to the plugins array in your zshrc file and restart zsh: + +```zsh +plugins=(... rand-quote) +``` + +Then, run `quote` to get a new random quote. diff --git a/plugins/rand-quote/rand-quote.plugin.zsh b/plugins/rand-quote/rand-quote.plugin.zsh index 8f345d9aa..371b997d3 100644 --- a/plugins/rand-quote/rand-quote.plugin.zsh +++ b/plugins/rand-quote/rand-quote.plugin.zsh @@ -1,26 +1,14 @@ -# Get a random quote fron the site http://www.quotationspage.com/random.php3 -# Created by Eduardo San Martin Morote aka Posva -# http://posva.github.io -# Sun Jun 09 10:59:36 CEST 2013 -# Don't remove this header, thank you -# Usage: quote - -WHO_COLOR="\e[0;33m" -TEXT_COLOR="\e[0;35m" -COLON_COLOR="\e[0;35m" -END_COLOR="\e[m" - -if [[ -x `which curl` ]]; then - function quote() - { - Q=$(curl -s --connect-timeout 2 "http://www.quotationspage.com/random.php3" | iconv -c -f ISO-8859-1 -t UTF-8 | grep -m 1 "dt ") - TXT=$(echo "$Q" | sed -e 's/<\/dt>.*//g' -e 's/.*html//g' -e 's/^[^a-zA-Z]*//' -e 's/<\/a..*$//g') - W=$(echo "$Q" | sed -e 's/.*\/quotes\///g' -e 's/<.*//g' -e 's/.*">//g') - if [ "$W" -a "$TXT" ]; then - echo "${WHO_COLOR}${W}${COLON_COLOR}: ${TEXT_COLOR}“${TXT}”${END_COLOR}" - fi - } - #quote -else +if ! (( $+commands[curl] )); then echo "rand-quote plugin needs curl to work" >&2 + return fi + +function quote { + emulate -L zsh + Q=$(curl -s --connect-timeout 2 "http://www.quotationspage.com/random.php" | iconv -c -f ISO-8859-1 -t UTF-8 | grep -m 1 "dt ") + + TXT=$(echo "$Q" | sed -e 's/<\/dt>.*//g' -e 's/.*html//g' -e 's/^[^a-zA-Z]*//' -e 's/<\/a..*$//g') + WHO=$(echo "$Q" | sed -e 's/.*\/quotes\///g' -e 's/<.*//g' -e 's/.*">//g') + + [[ -n "$WHO" && -n "$TXT" ]] && print -P "%F{3}${WHO}%f: “%F{5}${TXT}%f”" +} diff --git a/plugins/sbt/_sbt b/plugins/sbt/_sbt index 91372aa72..a601c9b97 100644 --- a/plugins/sbt/_sbt +++ b/plugins/sbt/_sbt @@ -17,6 +17,7 @@ _sbt_commands=( 'package-src:produce a source artifact, such as a jar containing sources' 'publish:publish artifacts to a repository' 'publish-local:publish artifacts to the local repository' + 'publish-m2:publish artifacts to the local Maven 2 repository' 'run:run a main class' 'run-main:run the main class selected by the first argument' 'test:execute all tests' diff --git a/plugins/sbt/sbt.plugin.zsh b/plugins/sbt/sbt.plugin.zsh index 15acfec4f..8fabf0add 100644 --- a/plugins/sbt/sbt.plugin.zsh +++ b/plugins/sbt/sbt.plugin.zsh @@ -7,6 +7,7 @@ # aliases - mnemonic: prefix is 'sb' alias sbc='sbt compile' +alias sbcc='sbt clean compile' alias sbco='sbt console' alias sbcq='sbt console-quick' alias sbcl='sbt clean' diff --git a/plugins/ssh-agent/ssh-agent.plugin.zsh b/plugins/ssh-agent/ssh-agent.plugin.zsh index 20f97c6f1..fe4946c6d 100644 --- a/plugins/ssh-agent/ssh-agent.plugin.zsh +++ b/plugins/ssh-agent/ssh-agent.plugin.zsh @@ -30,7 +30,12 @@ if [[ $_agent_forwarding == "yes" && -n "$SSH_AUTH_SOCK" ]]; then elif [[ -f "$_ssh_env_cache" ]]; then # Source SSH settings, if applicable . $_ssh_env_cache > /dev/null - ps x | grep ssh-agent | grep -q $SSH_AGENT_PID || { + if [[ $USER == "root" ]]; then + FILTER="ax" + else + FILTER="x" + fi + ps $FILTER | grep ssh-agent | grep -q $SSH_AGENT_PID || { _start_agent } else diff --git a/plugins/thefuck/thefuck.plugin.zsh b/plugins/thefuck/thefuck.plugin.zsh index 765e2b9a5..ac88e67de 100644 --- a/plugins/thefuck/thefuck.plugin.zsh +++ b/plugins/thefuck/thefuck.plugin.zsh @@ -1,6 +1,7 @@ if [[ -z $commands[thefuck] ]]; then - echo 'thefuck is not installed, you should "pip install thefuck" first' - return -1 + echo 'thefuck is not installed, you should "pip install thefuck" or "brew install thefuck" first.' + echo 'See https://github.com/nvbn/thefuck#installation' + return 1 fi # Register alias diff --git a/plugins/tmuxinator/_tmuxinator b/plugins/tmuxinator/_tmuxinator index 551267ed2..37032f8d8 100644 --- a/plugins/tmuxinator/_tmuxinator +++ b/plugins/tmuxinator/_tmuxinator @@ -1,40 +1,21 @@ -#compdef tmuxinator mux -#autoload +_tmuxinator() { + local commands projects + commands=(${(f)"$(tmuxinator commands zsh)"}) + projects=(${(f)"$(tmuxinator completions start)"}) -local curcontext="$curcontext" state line ret=1 -local -a _configs - -_arguments -C \ - '1: :->cmds' \ - '2:: :->args' && ret=0 - -_configs=(${$(echo ~/.tmuxinator/*.yml):r:t}) - -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]" \ - "help[shows this help document]" \ - "version[shows tmuxinator version number]" \ - $_configs - ret=0 - ;; - args) - case $line[1] in - start|open|copy|delete|debug) - [[ -n "$_configs" ]] && _values 'configs' $_configs - ret=0 - ;; + if (( CURRENT == 2 )); then + _describe -t commands "tmuxinator subcommands" commands + _describe -t projects "tmuxinator projects" projects + elif (( CURRENT == 3)); then + case $words[2] in + copy|debug|delete|open|start) + _arguments '*:projects:($projects)' + ;; esac - ;; -esac + fi + + return +} -return ret +compdef _tmuxinator tmuxinator mux +alias mux="tmuxinator" diff --git a/plugins/tmuxinator/tmuxinator.plugin.zsh b/plugins/tmuxinator/tmuxinator.plugin.zsh new file mode 100644 index 000000000..166fa9881 --- /dev/null +++ b/plugins/tmuxinator/tmuxinator.plugin.zsh @@ -0,0 +1,5 @@ +# aliases +alias txs='tmuxinator start' +alias txo='tmuxinator open' +alias txn='tmuxinator new' +alias txl='tmuxinator list' diff --git a/plugins/ufw/_ufw b/plugins/ufw/_ufw new file mode 100644 index 000000000..f5ad03377 --- /dev/null +++ b/plugins/ufw/_ufw @@ -0,0 +1,115 @@ +#compdef ufw +#autoload + +typeset -A opt_args + +function _ufw_delete_rules { + if ufw status &> /dev/null ; then + ufw status numbered \ + | perl -n -e'/\[ +(\d+)\] +([^ ].+)/ && print "\"$1\[$2\]\" "' + fi +} + +function _ufw_app_profiles { + grep -rhoP "(?<=\[)[^\]]+" /etc/ufw/applications.d/ \ + | awk '{ print "\""$0"\""}' \ + | tr '\n' ' ' +} + +local -a _1st_arguments +_1st_arguments=( + 'allow:add allow rule' + 'app:Application profile commands' + 'default:set default policy' + 'delete:delete RULE' + 'deny:add deny rule' + 'disable:disables the firewall' + 'enable:enables the firewall' + 'insert:insert RULE at NUM' + 'limit:add limit rule' + 'logging:set logging to LEVEL' + 'reject:add reject rule' + 'reload:reloads firewall' + 'reset:reset firewall' + 'show:show firewall report' + 'status:show firewall status' + 'version:display version information' +) + +local context state line curcontext="$curcontext" + +_arguments -C \ + '(--dry-run)--dry-run[dry run]' \ + '1:: :->cmds' \ + '2:: :->subcmds' \ + '3:: :->subsubcmds' \ +&& return 0 + +local rules + +case "$state" in + (cmds) + _describe -t commands "ufw commands" _1st_arguments + return 0 + ;; + (subcmds) + case "$line[1]" in + (app) + _values 'app' \ + 'list[list application profiles]' \ + 'info[show information on PROFILE]' \ + 'update[update PROFILE]' \ + 'default[set default application policy]' \ + && ret=0 + ;; + (status) + _values 'status' \ + 'numbered[show firewall status as numbered list of RULES]' \ + 'verbose[show verbose firewall status]' \ + && ret=0 + ;; + (logging) + _values 'logging' \ + 'on' 'off' 'low' 'medium' 'high' 'full' \ + && ret=0 + ;; + (default) + _values 'default' \ + 'allow' 'deny' 'reject' \ + && ret=0 + ;; + (show) + _values 'show' \ + 'raw' 'builtins' 'before-rules' 'user-rules' 'after-rules' 'logging-rules' 'listening' 'added' \ + && ret=0 + ;; + (delete) + rules="$(_ufw_delete_rules)" + if [[ -n "$rules" ]] ; then + _values 'delete' \ + ${(Q)${(z)"$(_ufw_delete_rules)"}} \ + && ret=0 + fi + ;; + esac + ;; + (subsubcmds) + case "$line[1]" in + (app) + case "$line[2]" in + (info|update) + _values 'profiles' \ + ${(Q)${(z)"$(_ufw_app_profiles)"}} \ + && ret=0 + ;; + esac + ;; + (default) + _values 'default-direction' \ + 'incoming' 'outgoing' \ + && ret=0 + ;; + esac +esac + +return diff --git a/plugins/vagrant-prompt/README.md b/plugins/vagrant-prompt/README.md new file mode 100644 index 000000000..c5bc55d17 --- /dev/null +++ b/plugins/vagrant-prompt/README.md @@ -0,0 +1,6 @@ +This plugin prompts the status of the Vagrant VMs. It supports single-host and +multi-host configurations as well. + +Look inside the source for documentation about custom variables. + +Alberto Re <alberto.re@gmail.com> diff --git a/plugins/vagrant-prompt/vagrant-prompt.plugin.zsh b/plugins/vagrant-prompt/vagrant-prompt.plugin.zsh new file mode 100644 index 000000000..28bf31f91 --- /dev/null +++ b/plugins/vagrant-prompt/vagrant-prompt.plugin.zsh @@ -0,0 +1,38 @@ +# vim:ft=zsh ts=2 sw=2 sts=2 +# +# To display Vagrant infos on your prompt add the vagrant_prompt_info to the +# $PROMPT variable in your theme. Example: +# +# PROMPT='%{$fg[$NCOLOR]%}%B%n%b%{$reset_color%}:%{$fg[blue]%}%B%c/%b%{$reset_color%} $(vagrant_prompt_info)$(svn_prompt_info)$(git_prompt_info)%(!.#.$) ' +# +# `vagrant_prompt_info` makes use of some custom variables. This is an example +# definition: +# +# ZSH_THEME_VAGRANT_PROMPT_PREFIX="%{$fg_bold[blue]%}[" +# ZSH_THEME_VAGRANT_PROMPT_SUFFIX="%{$fg_bold[blue]%}]%{$reset_color%} " +# ZSH_THEME_VAGRANT_PROMPT_RUNNING="%{$fg_no_bold[green]%}●" +# ZSH_THEME_VAGRANT_PROMPT_POWEROFF="%{$fg_no_bold[red]%}●" +# ZSH_THEME_VAGRANT_PROMPT_SUSPENDED="%{$fg_no_bold[yellow]%}●" +# ZSH_THEME_VAGRANT_PROMPT_NOT_CREATED="%{$fg_no_bold[white]%}○" + +function vagrant_prompt_info() { + test -d .vagrant && test -f Vagrantfile + if [[ "$?" == "0" ]]; then + statuses=$(vagrant status 2> /dev/null | grep -P "\w+\s+[\w\s]+\s\(\w+\)") + statuses=("${(f)statuses}") + printf '%s' $ZSH_THEME_VAGRANT_PROMPT_PREFIX + for vm_details in $statuses; do + vm_state=$(echo $vm_details | grep -o -E "saved|poweroff|not created|running") + if [[ "$vm_state" == "running" ]]; then + printf '%s' $ZSH_THEME_VAGRANT_PROMPT_RUNNING + elif [[ "$vm_state" == "saved" ]]; then + printf '%s' $ZSH_THEME_VAGRANT_PROMPT_SUSPENDED + elif [[ "$vm_state" == "not created" ]]; then + printf '%s' $ZSH_THEME_VAGRANT_PROMPT_NOT_CREATED + elif [[ "$vm_state" == "poweroff" ]]; then + printf '%s' $ZSH_THEME_VAGRANT_PROMPT_POWEROFF + fi + done + printf '%s' $ZSH_THEME_VAGRANT_PROMPT_SUFFIX + fi +} diff --git a/plugins/vim-interaction/vim-interaction.plugin.zsh b/plugins/vim-interaction/vim-interaction.plugin.zsh index b774be342..010f998d3 100644 --- a/plugins/vim-interaction/vim-interaction.plugin.zsh +++ b/plugins/vim-interaction/vim-interaction.plugin.zsh @@ -8,10 +8,11 @@ function callvim { if [[ $# == 0 ]]; then cat <<EOH -usage: callvim [-b cmd] [-a cmd] [file ... fileN] +usage: callvim [-b cmd] [-a cmd] [-n name] [file ... fileN] -b cmd Run this command in GVIM before editing the first file -a cmd Run this command in GVIM after editing the first file + -n name Name of the GVIM server to connect to file The file to edit ... fileN The other files to add to the argslist EOH @@ -21,13 +22,16 @@ EOH local cmd="" local before="<esc>" local after="" - while getopts ":b:a:" option + local name="GVIM" + while getopts ":b:a:n:" option do case $option in a) after="$OPTARG" ;; b) before="$OPTARG" ;; + n) name="$OPTARG" + ;; esac done shift $((OPTIND-1)) @@ -43,7 +47,7 @@ EOH files=':args! '"${@:A:q}<cr>" fi cmd="$before$files$after" - gvim --remote-send "$cmd" + gvim --servername "$name" --remote-send "$cmd" if typeset -f postCallVim > /dev/null; then postCallVim fi diff --git a/plugins/vscode/README.md b/plugins/vscode/README.md new file mode 100644 index 000000000..ef1fdea30 --- /dev/null +++ b/plugins/vscode/README.md @@ -0,0 +1,38 @@ +# VS code + +This plugin makes interaction between the command line and the code editor easier. + +To start using it, add the `vscode` plugin to your `plugins` array in `~/.zshrc`: + +```zsh +plugins=(... vscode) +``` + +## Common aliases + +| Alias | Command | Description | +| ----------------------- | ------------------------------ | ----------------------------------------------------------------------------------------------------------- | +| vsc | code . | Open the current folder in VS code | +| vsca `dir` | code --add `dir` | Add folder(s) to the last active window | +| vscd `file` `file` | code --diff `file` `file` | Compare two files with each other. | +| vscg `file:line[:char]` | code --goto `file:line[:char]` | Open a file at the path on the specified line and character position. | +| vscn | code --new-window | Force to open a new window. | +| vscr | code --reuse-window | Force to open a file or folder in the last active window. | +| vscw | code --wait | Wait for the files to be closed before returning. | +| vscu `dir` | code --user-data-dir `dir` | Specifies the directory that user data is kept in. Can be used to open multiple distinct instances of Code. | + +## Extensions aliases + +| Alias | Command | Description | +| ----------------------- | ---------------------------------------------------------------- | --------------------------------- | +| vsce `dir` | code --extensions-dir `dir` | Set the root path for extensions. | +| vscie `id or vsix-path` | code --install-extension `extension-id> or <extension-vsix-path` | Installs an extension. | +| vscue `id or vsix-path` | code --uninstall-extension `id or vsix-path` | Uninstalls an extension. | + +## Other options: + +| Alias | Command | Description | +| ------------ | ------------------------- | --------------------------------------------------------------------------------------------------------------------- | +| vscv | code --verbose | Print verbose output (implies --wait). | +| vscl `level` | code --log `level` | Log level to use. Default is 'info'. Allowed values are 'critical', 'error', 'warn', 'info', 'debug', 'trace', 'off'. | +| vsced | code --disable-extensions | Disable all installed extensions. | diff --git a/plugins/vscode/vscode.plugin.zsh b/plugins/vscode/vscode.plugin.zsh new file mode 100644 index 000000000..d0aad3b33 --- /dev/null +++ b/plugins/vscode/vscode.plugin.zsh @@ -0,0 +1,19 @@ +# VScode zsh plugin +# author: https://github.com/MarsiBarsi + +alias vsc='code .' +alias vsca='code --add' +alias vscd='code --diff' +alias vscg='code --goto' +alias vscn='code --new-window' +alias vscr='code --reuse-window' +alias vscw='code --wait' +alias vscu='code --user-data-dir' + +alias vsce='code --extensions-dir' +alias vscie='code --install-extension' +alias vscue='code --uninstall-extension' + +alias vscv='code --verbose' +alias vscl='code --log' +alias vsced='code --disable-extensions'
\ No newline at end of file diff --git a/plugins/yarn/yarn.plugin.zsh b/plugins/yarn/yarn.plugin.zsh index 5fa512377..eee811b16 100644 --- a/plugins/yarn/yarn.plugin.zsh +++ b/plugins/yarn/yarn.plugin.zsh @@ -4,7 +4,7 @@ alias y="yarn " alias ya="yarn add" alias ycc="yarn cache clean" alias yh="yarn help" -alias yo="yarn outdated" +alias yout="yarn outdated" alias yui="yarn upgrade-interactive" _yarn () @@ -28,24 +28,30 @@ _yarn () _production=('(--production)--production[Do not install project devDependencies]') + _upgrade=( + '(--exact)--exact[Install exact version]' + '(--tilde)--tilde[Install most recent release with the same minor version]' + ) + _1st_arguments=( 'help:Display help information about yarn' \ - 'init:Initialize for the development of a package.' \ - 'add:Add a package to use in your current package.' \ - 'install:Install all the dependencies listed within package.json in the local node_modules folder.' \ - 'publish:Publish a package to a package manager.' \ - 'remove:Remove a package that will no longer be used in your current package.' \ - 'cache:Clear the local cache. It will be populated again the next time yarn or yarn install is run.' \ - 'clean:Frees up space by removing unnecessary files and folders from dependencies.' \ - 'check:Verifies that versions of the package dependencies in the current project’s package.json matches that of yarn’s lock file.' \ - 'ls:List all installed packages.' \ - 'global:Makes binaries available to use on your operating system.' \ - 'info:<package> [<field>] - fetch information about a package and return it in a tree format.' \ - 'outdated:Checks for outdated package dependencies.' \ - 'run:Runs a defined package script.' \ - 'self-update:Updates Yarn to the latest version.' \ - 'upgrade:Upgrades packages to their latest version based on the specified range.' \ - 'why:<query> - Show information about why a package is installed.' + 'init:Initialize for the development of a package' \ + 'add:Add a package to use in your current package' \ + 'install:Install all the dependencies listed within package.json in the local node_modules folder' \ + 'publish:Publish a package to a package manager' \ + 'remove:Remove a package that will no longer be used in your current package' \ + 'cache:Clear the local cache. It will be populated again the next time yarn or yarn install is run' \ + 'clean:Frees up space by removing unnecessary files and folders from dependencies' \ + 'check:Verifies that versions of the package dependencies in the current project’s package.json matches that of yarn’s lock file' \ + 'ls:List all installed packages' \ + 'global:Makes binaries available to use on your operating system' \ + 'info:<package> [<field>] - fetch information about a package and return it in a tree format' \ + 'outdated:Checks for outdated package dependencies' \ + 'run:Runs a defined package script' \ + 'self-update:Updates Yarn to the latest version' \ + 'upgrade:Upgrades packages to their latest version based on the specified range' \ + 'upgrade-interactive:Selectively upgrades specific packages in a simple way' \ + 'why:<query> - Show information about why a package is installed' ) _arguments \ '*:: :->subcmds' && return 0 @@ -78,6 +84,10 @@ _yarn () _arguments \ $_dopts ;; + upgrade-interactive) + _arguments \ + $_upgrade + ;; *) _arguments \ ;; diff --git a/plugins/zeus/_zeus b/plugins/zeus/_zeus index 5a13bd9ec..78f0c545e 100644 --- a/plugins/zeus/_zeus +++ b/plugins/zeus/_zeus @@ -2,33 +2,97 @@ #autoload # in order to make this work, you will need to have the gem zeus installed - -# zeus zsh completion, based on adb completion +# zeus zsh completion local -a _1st_arguments -_1st_arguments=( -'console:Lets you interact with your Rails application from the command line. (alias = c)' -'cucumber:Runs cucumber.' -'dbconsole:Figures out which database you are using and drops you into whichever command line interface.' -'destroy:Figures out what generate did, and undoes it. (alias = d)' -'generate:Uses templates to create a whole lot of things. (alias = g)' -'rake:Execute rake tasks.' -'runner:Runs Ruby code in the context of Rails non-interactively. (alias = r)' -'server:Launches a small web server named WEBrick which comes bundled with Ruby. (alias = s)' -'start:Preloads the zeus environment' -'test:Runs RSpec tests. (alias = rspec, testrb)' -'version:Shows the version number.' -) +if [[ -e .zeus.sock ]]; then + _1st_arguments=( + 'console:Lets you interact with your Rails application from the command line. (alias = c)' + 'cucumber:Runs cucumber.' + 'dbconsole:Figures out which database you are using and drops you into whichever command line interface.' + 'destroy:Figures out what generate did, and undoes it. (alias = d)' + 'generate:Uses templates to create a whole lot of things. (alias = g)' + 'rake:Execute rake tasks.' + 'runner:Runs Ruby code in the context of Rails non-interactively. (alias = r)' + 'server:Launches a small web server named WEBrick which comes bundled with Ruby. (alias = s)' + 'test:Runs RSpec tests. (alias = rspec, testrb)' + 'version:Shows the version number.' + ) +else + _1st_arguments=( + 'start:Preloads the zeus environment' + 'init:Generate a zeus.json file' + ) +fi + +_rails_generate_arguments() { + generate_arguments=( + controller + generator + helper + integration_test + mailer + migration + model + observer + performance_test + plugin + resource + scaffold + scaffold_controller + session_migration + stylesheets + ) +} + +_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) + return $(expr $accurate '>=' $changed) + fi +} + +_zrake () +{ + local expl + declare -a tasks + + if [ -f Rakefile ]; then + if _rake_does_task_list_need_generating; then + echo "\nGenerating .rake_tasks..." > /dev/stderr + rake --silent --tasks | cut -d " " -f 2 > .rake_tasks + fi + tasks=(`cat .rake_tasks`) + _wanted tasks expl 'rake' compadd $tasks + fi +} local expl -local -a pkgs installed_pkgs +local curcontext="$curcontext" state line +typeset -A opt_args -_arguments \ - '*:: :->subcmds' && return 0 +_arguments -C \ + ':command:->command' \ + '*::options:->options' -if (( CURRENT == 1 )); then - _describe -t commands "zeus subcommand" _1st_arguments - return -fi -_files +case $state in + (command) + _describe -t commands "zeus subcommand" _1st_arguments + return + ;; + + (options) + case $line[1] in + (rake) + _zrake + ;; + (generate|g|destroy|d) + _rails_generate_arguments + _wanted generate_arguments expl 'all generate' compadd -a generate_arguments + ;; + esac + ;; +esac |