From 1335bbb25118a0ecd500bfdcb1e3436116cbd7f4 Mon Sep 17 00:00:00 2001 From: EeeeKa Date: Fri, 16 Oct 2020 10:09:40 +0500 Subject: [PATCH] Add upstream oh_my_zsh repo --- install.sh | 2 +- zsh/.editorconfig | 10 + zsh/.github/CODEOWNERS | 4 + zsh/.github/FUNDING.yml | 2 + zsh/.github/ISSUE_TEMPLATE/bug_report.md | 45 + zsh/.github/ISSUE_TEMPLATE/config.yml | 5 + zsh/.github/ISSUE_TEMPLATE/feature_request.md | 29 + zsh/.github/ISSUE_TEMPLATE/support.md | 10 + zsh/.github/PULL_REQUEST_TEMPLATE.md | 19 + zsh/.github/workflows/main.yml | 36 + zsh/.gitignore | 8 + zsh/.gitpod.Dockerfile | 5 + zsh/.gitpod.yml | 9 + zsh/CODE_OF_CONDUCT.md | 76 + zsh/CONTRIBUTING.md | 125 + zsh/LICENSE.txt | 5 +- zsh/README.md | 96 +- zsh/lib/cli.zsh | 354 ++ zsh/lib/clipboard.zsh | 125 +- zsh/lib/completion.zsh | 20 +- zsh/lib/diagnostics.zsh | 8 +- zsh/lib/functions.zsh | 29 +- zsh/lib/git.zsh | 214 +- zsh/lib/grep.zsh | 61 +- zsh/lib/history.zsh | 6 +- zsh/lib/key-bindings.zsh | 133 +- zsh/lib/misc.zsh | 22 +- zsh/lib/nvm.zsh | 9 +- zsh/lib/spectrum.zsh | 26 +- zsh/lib/termsupport.zsh | 84 +- zsh/lib/theme-and-appearance.zsh | 5 + zsh/oh-my-zsh.sh | 63 +- .../alias-finder/alias-finder.plugin.zsh | 7 +- zsh/plugins/apache2-macports/README.md | 26 +- zsh/plugins/arcanist/README.md | 40 +- zsh/plugins/arcanist/arcanist.plugin.zsh | 18 +- zsh/plugins/archlinux/README.md | 10 +- zsh/plugins/archlinux/archlinux.plugin.zsh | 8 +- zsh/plugins/asdf/asdf.plugin.zsh | 2 +- zsh/plugins/autoenv/README.md | 20 + zsh/plugins/autoenv/autoenv.plugin.zsh | 60 +- zsh/plugins/autojump/README.md | 2 +- zsh/plugins/autojump/autojump.plugin.zsh | 2 +- zsh/plugins/aws/aws.plugin.zsh | 78 +- zsh/plugins/battery/README.md | 11 +- zsh/plugins/battery/battery.plugin.zsh | 191 +- zsh/plugins/bazel/README.md | 5 + zsh/plugins/bazel/_bazel | 341 ++ zsh/plugins/bgnotify/bgnotify.plugin.zsh | 2 +- zsh/plugins/bower/README.md | 3 +- zsh/plugins/brew/README.md | 31 +- zsh/plugins/brew/brew.plugin.zsh | 21 +- zsh/plugins/bundler/README.md | 78 +- zsh/plugins/bundler/bundler.plugin.zsh | 117 +- zsh/plugins/cake/README.md | 2 +- zsh/plugins/cakephp3/README.md | 16 + zsh/plugins/cargo/_cargo | 789 ++--- zsh/plugins/catimg/README.md | 24 +- zsh/plugins/chruby/README.md | 20 + zsh/plugins/chucknorris/README.md | 28 +- zsh/plugins/chucknorris/fortunes/chucknorris | 3014 +++-------------- zsh/plugins/cloudapp/README.md | 26 + zsh/plugins/cloudapp/cloudapp.plugin.zsh | 10 +- zsh/plugins/cloudapp/cloudapp.rb | 60 - zsh/plugins/codeclimate/README.md | 8 + zsh/plugins/coffee/README.md | 2 +- zsh/plugins/colemak/README.md | 48 + zsh/plugins/colored-man-pages/README.md | 3 + .../colored-man-pages.plugin.zsh | 9 +- zsh/plugins/colorize/README.md | 53 +- zsh/plugins/colorize/colorize.plugin.zsh | 128 +- .../command-not-found.plugin.zsh | 6 +- .../common-aliases/common-aliases.plugin.zsh | 9 +- zsh/plugins/compleat/README.md | 9 + zsh/plugins/composer/README.md | 32 +- zsh/plugins/composer/composer.plugin.zsh | 40 +- zsh/plugins/copybuffer/copybuffer.plugin.zsh | 4 +- zsh/plugins/copyfile/README.md | 3 +- zsh/plugins/cpanm/README.md | 6 +- zsh/plugins/dash/README.md | 28 + zsh/plugins/dash/dash.plugin.zsh | 52 +- zsh/plugins/dircycle/README.md | 4 +- zsh/plugins/direnv/README.md | 15 + zsh/plugins/direnv/direnv.plugin.zsh | 16 + zsh/plugins/dirhistory/README.md | 22 + zsh/plugins/dirhistory/dirhistory.plugin.zsh | 3 +- zsh/plugins/dirpersist/README.md | 3 +- zsh/plugins/dirpersist/dirpersist.plugin.zsh | 3 +- zsh/plugins/django/README.md | 20 - zsh/plugins/django/django.plugin.zsh | 3 +- zsh/plugins/dnf/README.md | 14 +- zsh/plugins/docker-compose/README.md | 4 +- .../docker-compose/docker-compose.plugin.zsh | 1 + zsh/plugins/docker/README.md | 37 +- zsh/plugins/docker/_docker | 18 +- zsh/plugins/dotenv/README.md | 44 +- zsh/plugins/dotenv/dotenv.plugin.zsh | 53 +- zsh/plugins/dotnet/README.md | 23 + zsh/plugins/dotnet/dotnet.plugin.zsh | 32 + zsh/plugins/eecms/README.md | 11 + zsh/plugins/emacs/emacs.plugin.zsh | 10 + zsh/plugins/emacs/emacsclient.sh | 3 +- .../emoji-clock/emoji-clock.plugin.zsh | 2 +- zsh/plugins/emotty/README.md | 39 + zsh/plugins/encode64/README.md | 27 +- zsh/plugins/extract/README.md | 10 + zsh/plugins/extract/_extract | 2 +- zsh/plugins/extract/extract.plugin.zsh | 15 +- zsh/plugins/fabric/README.md | 2 +- zsh/plugins/fabric/_fab | 19 +- .../fancy-ctrl-z/fancy-ctrl-z.plugin.zsh | 6 +- zsh/plugins/fasd/README.md | 21 + zsh/plugins/fasd/fasd.plugin.zsh | 26 +- zsh/plugins/fastfile/README.md | 84 + zsh/plugins/fastfile/fastfile.plugin.zsh | 41 +- zsh/plugins/fbterm/README.md | 10 + zsh/plugins/fedora/README.md | 2 +- zsh/plugins/fedora/fedora.plugin.zsh | 4 +- .../firewalld/{readme.md => README.md} | 0 zsh/plugins/flutter/README.md | 21 + zsh/plugins/flutter/_flutter | 37 + zsh/plugins/flutter/flutter.plugin.zsh | 7 + zsh/plugins/forklift/README.md | 18 +- zsh/plugins/forklift/forklift.plugin.zsh | 19 +- zsh/plugins/frontend-search/README.md | 1 + .../frontend-search/_frontend-search.sh | 4 + .../frontend-search.plugin.zsh | 6 +- zsh/plugins/fzf/README.md | 30 +- zsh/plugins/fzf/fzf.plugin.zsh | 161 +- zsh/plugins/gas/README.md | 10 + zsh/plugins/gcloud/README.md | 24 + zsh/plugins/gcloud/gcloud.plugin.zsh | 33 + zsh/plugins/geeknote/README.md | 16 +- zsh/plugins/geeknote/_geeknote | 267 +- .../git-auto-fetch/git-auto-fetch.plugin.zsh | 11 +- zsh/plugins/git-escape-magic/README.md | 6 +- zsh/plugins/git-extras/README.md | 10 +- zsh/plugins/git-flow/README.md | 13 +- zsh/plugins/git-lfs/README.md | 24 + zsh/plugins/git-lfs/git-lfs.plugin.zsh | 17 + zsh/plugins/git-prompt/README.md | 3 + zsh/plugins/git-prompt/git-prompt.plugin.zsh | 21 +- zsh/plugins/git-prompt/gitstatus.py | 31 +- .../git-remote-branch.plugin.zsh | 19 - zsh/plugins/git/README.md | 377 ++- zsh/plugins/git/git.plugin.zsh | 66 +- zsh/plugins/gitfast/README.md | 4 +- zsh/plugins/gitfast/_git | 19 +- zsh/plugins/gitfast/git-completion.bash | 1353 ++++---- zsh/plugins/gitfast/git-prompt.sh | 12 +- zsh/plugins/github/README.md | 10 +- zsh/plugins/gitignore/gitignore.plugin.zsh | 2 +- zsh/plugins/glassfish/README.md | 9 + zsh/plugins/glassfish/glassfish.plugin.zsh | 3 - zsh/plugins/globalias/README.md | 19 +- zsh/plugins/globalias/globalias.plugin.zsh | 10 +- zsh/plugins/gnu-utils/README.md | 38 + zsh/plugins/gnu-utils/gnu-utils.plugin.zsh | 148 +- zsh/plugins/go/README.md | 2 +- zsh/plugins/go/go.plugin.zsh | 4 +- zsh/plugins/gpg-agent/README.md | 3 +- zsh/plugins/gradle/README.md | 13 +- zsh/plugins/gradle/_gradle | 421 ++- zsh/plugins/gradle/_gradlew | 1 - zsh/plugins/gradle/gradle.plugin.zsh | 199 +- zsh/plugins/grails/README.md | 55 - .../history-substring-search/README.md | 175 +- .../history-substring-search.plugin.zsh | 17 +- .../history-substring-search.zsh | 546 ++- zsh/plugins/history/README.md | 20 +- zsh/plugins/history/history.plugin.zsh | 9 +- zsh/plugins/hitokoto/README.md | 15 + zsh/plugins/hitokoto/hitokoto.plugin.zsh | 14 + zsh/plugins/httpie/README.md | 5 + zsh/plugins/httpie/httpie.plugin.zsh | 7 + zsh/plugins/ionic/README.md | 30 + zsh/plugins/ionic/ionic.plugin.zsh | 15 + zsh/plugins/ipfs/LICENSE | 22 + zsh/plugins/ipfs/README.md | 17 + zsh/plugins/ipfs/_ipfs | 717 ++++ zsh/plugins/jenv/jenv.plugin.zsh | 4 +- zsh/plugins/jfrog/README.md | 11 + zsh/plugins/jfrog/jfrog.plugin.zsh | 10 + zsh/plugins/jhbuild/README.md | 34 +- zsh/plugins/jhbuild/jhbuild.plugin.zsh | 16 +- zsh/plugins/jira/README.md | 4 + zsh/plugins/jira/_jira | 1 + zsh/plugins/jira/jira.plugin.zsh | 31 +- zsh/plugins/jruby/README.md | 21 + zsh/plugins/jsontools/README.md | 38 +- zsh/plugins/jsontools/jsontools.plugin.zsh | 13 +- zsh/plugins/jump/README.md | 12 + zsh/plugins/jump/jump.plugin.zsh | 31 +- zsh/plugins/keychain/keychain.plugin.zsh | 14 +- zsh/plugins/kitchen/_kitchen | 2 +- zsh/plugins/knife/README.md | 25 + zsh/plugins/knife/_knife | 226 +- zsh/plugins/knife_ssh/README.md | 14 + zsh/plugins/knife_ssh/knife_ssh.plugin.zsh | 8 +- zsh/plugins/kube-ps1/README.md | 252 +- zsh/plugins/kube-ps1/kube-ps1.plugin.zsh | 322 +- zsh/plugins/kubectl/README.md | 11 +- zsh/plugins/kubectl/kubectl.plugin.zsh | 29 +- zsh/plugins/lando/LICENSE | 21 + zsh/plugins/lando/README.md | 37 + zsh/plugins/lando/lando.plugin.zsh | 40 + zsh/plugins/laravel/README.md | 17 + zsh/plugins/laravel/laravel.plugin.zsh | 15 + zsh/plugins/laravel4/README.md | 12 +- zsh/plugins/laravel5/laravel5.plugin.zsh | 19 +- zsh/plugins/last-working-dir/README.md | 8 +- .../last-working-dir.plugin.zsh | 3 +- zsh/plugins/lein/README.md | 9 + zsh/plugins/lighthouse/README.md | 5 +- zsh/plugins/lol/README.md | 104 +- zsh/plugins/lol/lol.plugin.zsh | 2 +- zsh/plugins/lxd/README.md | 9 + zsh/plugins/lxd/lxd.plugin.zsh | 26 + zsh/plugins/macports/_port | 2 + zsh/plugins/magic-enter/README.md | 17 + zsh/plugins/magic-enter/Readme.md | 14 - .../magic-enter/magic-enter.plugin.zsh | 7 +- zsh/plugins/man/man.plugin.zsh | 26 +- zsh/plugins/mercurial/README.md | 96 +- zsh/plugins/mercurial/mercurial.plugin.zsh | 13 +- zsh/plugins/meteor/README.md | 5 +- zsh/plugins/microk8s/README.md | 24 + zsh/plugins/microk8s/microk8s.plugin.zsh | 82 + zsh/plugins/minikube/minikube.plugin.zsh | 11 +- zsh/plugins/mix-fast/mix-fast.plugin.zsh | 5 +- zsh/plugins/mix/_mix | 3 +- zsh/plugins/mvn/README.md | 5 +- zsh/plugins/mvn/mvn.plugin.zsh | 12 +- zsh/plugins/mysql-macports/README.md | 20 + zsh/plugins/n98-magerun/README.md | 21 + zsh/plugins/ng/README.md | 37 +- zsh/plugins/nmap/README.md | 54 +- zsh/plugins/nmap/nmap.plugin.zsh | 2 +- zsh/plugins/node/README.md | 9 +- zsh/plugins/npm/README.md | 5 +- zsh/plugins/npm/npm.plugin.zsh | 20 +- zsh/plugins/nvm/README.md | 19 +- zsh/plugins/nvm/_nvm | 1 + zsh/plugins/nvm/nvm.plugin.zsh | 83 +- zsh/plugins/nyan/README.md | 5 - zsh/plugins/nyan/nyan.plugin.zsh | 10 - zsh/plugins/oc/README.md | 13 + zsh/plugins/osx/README.md | 49 +- zsh/plugins/osx/_security | 90 + zsh/plugins/osx/music | 170 + zsh/plugins/osx/osx.plugin.zsh | 285 +- zsh/plugins/osx/spotify | 17 +- zsh/plugins/otp/README.md | 22 + zsh/plugins/otp/otp.plugin.zsh | 19 +- zsh/plugins/pass/README.md | 22 + zsh/plugins/pass/_pass | 8 + zsh/plugins/paver/README.md | 12 + zsh/plugins/paver/paver.plugin.zsh | 6 +- zsh/plugins/percol/README.md | 4 +- zsh/plugins/perl/README.md | 37 + zsh/plugins/perms/README.md | 14 +- zsh/plugins/phing/README.md | 9 + zsh/plugins/pip/README.md | 19 + zsh/plugins/pip/_pip | 1 + zsh/plugins/pip/pip.plugin.zsh | 6 +- zsh/plugins/pipenv/pipenv.plugin.zsh | 10 +- zsh/plugins/pod/README.md | 10 + zsh/plugins/pow/README.md | 21 + zsh/plugins/powder/README.md | 8 + zsh/plugins/powify/README.md | 10 + zsh/plugins/profiles/README.md | 25 + zsh/plugins/pyenv/README.md | 16 + zsh/plugins/pyenv/pyenv.plugin.zsh | 9 +- zsh/plugins/pylint/README.md | 7 +- zsh/plugins/pylint/pylint.plugin.zsh | 2 - zsh/plugins/python/README.md | 2 + zsh/plugins/python/python.plugin.zsh | 40 +- zsh/plugins/rails/README.md | 5 +- zsh/plugins/rails/rails.plugin.zsh | 2 +- zsh/plugins/rake/README.md | 37 + zsh/plugins/rbenv/README.md | 26 + zsh/plugins/rbenv/rbenv.plugin.zsh | 17 +- zsh/plugins/rbfu/README.md | 17 + zsh/plugins/react-native/README.md | 3 + .../react-native/react-native.plugin.zsh | 4 + zsh/plugins/rebar/README.md | 9 + zsh/plugins/redis-cli/README.md | 15 + zsh/plugins/repo/README.md | 28 +- zsh/plugins/repo/_repo | 2 - zsh/plugins/repo/repo.plugin.zsh | 16 +- zsh/plugins/ros/{README.mkd => README.md} | 0 zsh/plugins/rust/README.md | 9 + zsh/plugins/rustup/README.md | 9 + zsh/plugins/rustup/_rustup | 1143 +++++++ zsh/plugins/rvm/README.md | 20 + zsh/plugins/safe-paste/README.md | 9 + zsh/plugins/safe-paste/safe-paste.plugin.zsh | 122 +- zsh/plugins/salt/_salt | 2 +- zsh/plugins/sbt/README.md | 10 +- zsh/plugins/sbt/_sbt | 20 +- zsh/plugins/sbt/sbt.plugin.zsh | 10 +- zsh/plugins/scala/README.md | 13 +- zsh/plugins/scd/README.md | 54 +- zsh/plugins/scd/_scd | 60 + zsh/plugins/scd/scd | 347 +- zsh/plugins/scd/scd.plugin.zsh | 16 +- zsh/plugins/screen/README.md | 10 + zsh/plugins/sdk/README.md | 8 +- zsh/plugins/sdk/sdk.plugin.zsh | 130 +- zsh/plugins/sfffe/README.md | 17 + zsh/plugins/sfffe/sfffe.plugin.zsh | 6 +- zsh/plugins/shell-proxy/README.md | 52 + zsh/plugins/shell-proxy/proxy.py | 72 + .../shell-proxy/shell-proxy.plugin.zsh | 16 + zsh/plugins/shell-proxy/ssh-agent.py | 16 + zsh/plugins/shell-proxy/ssh-proxy.py | 18 + zsh/plugins/shrink-path/README.md | 23 +- .../shrink-path/shrink-path.plugin.zsh | 52 +- zsh/plugins/singlechar/README.md | 118 + zsh/plugins/singlechar/singlechar.plugin.zsh | 12 +- zsh/plugins/sprunge/README.md | 32 + zsh/plugins/sprunge/sprunge.plugin.zsh | 76 +- zsh/plugins/stack/stack.plugin.zsh | 39 +- zsh/plugins/sublime-merge/README.md | 17 + .../sublime-merge/sublime-merge.plugin.zsh | 55 + zsh/plugins/sublime/sublime.plugin.zsh | 10 +- zsh/plugins/sudo/README.md | 22 +- zsh/plugins/sudo/sudo.plugin.zsh | 40 +- zsh/plugins/supervisor/README.md | 13 + zsh/plugins/supervisor/_supervisorctl | 7 + zsh/plugins/svn-fast-info/README.md | 56 + .../svn-fast-info/svn-fast-info.plugin.zsh | 42 +- zsh/plugins/swiftpm/README.md | 2 +- zsh/plugins/swiftpm/_swift | 234 +- zsh/plugins/systemadmin/README.md | 4 +- .../systemadmin/systemadmin.plugin.zsh | 8 +- zsh/plugins/systemd/README.md | 41 + zsh/plugins/systemd/systemd.plugin.zsh | 80 +- zsh/plugins/taskwarrior/README.md | 7 +- zsh/plugins/taskwarrior/_task | 4 +- .../terminalapp/terminalapp.plugin.zsh | 6 - zsh/plugins/terminitor/README.md | 9 + zsh/plugins/terraform/README.md | 3 +- zsh/plugins/terraform/_terraform | 98 +- zsh/plugins/terraform/terraform.plugin.zsh | 2 + zsh/plugins/textmate/README.md | 3 +- zsh/plugins/thefuck/README.md | 2 +- zsh/plugins/themes/_theme | 3 - zsh/plugins/themes/themes.plugin.zsh | 45 +- zsh/plugins/thor/README.md | 10 + zsh/plugins/tig/README.md | 2 +- zsh/plugins/timer/README.md | 1 + zsh/plugins/timer/timer.plugin.zsh | 18 +- zsh/plugins/tmux-cssh/README.md | 10 + zsh/plugins/tmux-cssh/_tmux-cssh | 24 +- zsh/plugins/tmux/README.md | 8 +- zsh/plugins/tmux/tmux.extra.conf | 2 +- zsh/plugins/tmux/tmux.plugin.zsh | 14 +- zsh/plugins/tmuxinator/README.md | 12 +- zsh/plugins/tugboat/README.md | 12 + zsh/plugins/ufw/README.md | 18 + zsh/plugins/urltools/README.md | 8 +- zsh/plugins/urltools/urltools.plugin.zsh | 8 +- .../vagrant-prompt/vagrant-prompt.plugin.zsh | 25 +- zsh/plugins/vagrant/README.md | 30 + zsh/plugins/vagrant/_vagrant | 6 +- zsh/plugins/vagrant/vagrant.plugin.zsh | 33 + zsh/plugins/virtualenvwrapper/README.md | 38 + .../virtualenvwrapper.plugin.zsh | 76 +- zsh/plugins/vscode/README.md | 37 +- zsh/plugins/vscode/vscode.plugin.zsh | 27 +- zsh/plugins/wakeonlan/{README => README.md} | 24 +- zsh/plugins/wd/README.md | 247 +- zsh/plugins/wd/_wd.sh | 17 +- zsh/plugins/wd/wd.plugin.zsh | 5 +- zsh/plugins/wd/wd.sh | 202 +- zsh/plugins/web-search/README.md | 27 + zsh/plugins/web-search/web-search.plugin.zsh | 19 +- zsh/plugins/yarn/README.md | 59 +- zsh/plugins/yarn/_yarn | 34 +- zsh/plugins/yarn/yarn.plugin.zsh | 7 + zsh/plugins/yii/README.md | 15 + zsh/plugins/yii2/yii2.plugin.zsh | 2 +- zsh/plugins/yum/README.md | 2 +- zsh/plugins/z/README | 8 +- zsh/plugins/z/README.md | 23 + zsh/plugins/z/z.1 | 3 + zsh/plugins/z/z.sh | 44 +- zsh/plugins/zeus/README.md | 96 +- zsh/plugins/zeus/zeus.plugin.zsh | 1 + zsh/plugins/zsh-interactive-cd/README.md | 23 + .../zsh-interactive-cd.plugin.zsh | 148 + zsh/plugins/zsh-navigation-tools/LICENSE | 8 +- zsh/plugins/zsh-navigation-tools/Makefile | 35 + zsh/plugins/zsh-navigation-tools/README.md | 379 ++- zsh/plugins/zsh-navigation-tools/_n-kill | 6 +- zsh/plugins/zsh-navigation-tools/n-kill | 4 +- zsh/plugins/zsh-navigation-tools/n-list | 2 + .../zsh-navigation-tools.plugin.zsh | 25 +- zsh/plugins/zsh_reload/zsh_reload.plugin.zsh | 16 +- zsh/templates/zshrc.zsh-template | 10 +- zsh/themes/af-magic.zsh-theme | 44 +- zsh/themes/agnoster.zsh-theme | 46 +- zsh/themes/arrow.zsh-theme | 2 +- zsh/themes/avit.zsh-theme | 79 +- zsh/themes/awesomepanda.zsh-theme | 2 +- zsh/themes/bira.zsh-theme | 2 +- zsh/themes/candy-kingdom.zsh-theme | 24 +- zsh/themes/cloud.zsh-theme | 2 +- zsh/themes/edvardm.zsh-theme | 2 +- zsh/themes/eof.zsh-theme | 38 - zsh/themes/fino-time.zsh-theme | 10 +- zsh/themes/fino.zsh-theme | 29 +- zsh/themes/fishy.zsh-theme | 18 +- zsh/themes/fwalch.zsh-theme | 2 +- zsh/themes/gallifrey.zsh-theme | 2 +- zsh/themes/gozilla.zsh-theme | 2 +- zsh/themes/jbergantine.zsh-theme | 2 +- zsh/themes/jnrowe.zsh-theme | 2 +- zsh/themes/jtriley.zsh-theme | 6 - zsh/themes/kafeitu.zsh-theme | 2 +- zsh/themes/kiwi.zsh-theme | 4 +- zsh/themes/linuxonly.zsh-theme | 30 +- zsh/themes/mlh.zsh-theme | 59 + zsh/themes/muse.zsh-theme | 39 +- zsh/themes/nebirhos.zsh-theme | 2 +- zsh/themes/norm.zsh-theme | 5 +- zsh/themes/peepcode.zsh-theme | 19 +- zsh/themes/pygmalion-virtualenv.zsh-theme | 15 +- zsh/themes/pygmalion.zsh-theme | 22 +- zsh/themes/random.zsh-theme | 47 + zsh/themes/smt.zsh-theme | 71 +- zsh/themes/sunrise.zsh-theme | 2 +- zsh/themes/trapd00r.zsh-theme | 10 +- zsh/themes/wedisagree.zsh-theme | 39 +- zsh/tools/check_for_upgrade.sh | 132 +- zsh/tools/install.sh | 52 +- zsh/tools/uninstall.sh | 10 +- zsh/tools/upgrade.sh | 89 +- zsh/zshrc | 122 - 440 files changed, 14454 insertions(+), 8085 deletions(-) create mode 100644 zsh/.editorconfig create mode 100644 zsh/.github/CODEOWNERS create mode 100644 zsh/.github/FUNDING.yml create mode 100644 zsh/.github/ISSUE_TEMPLATE/bug_report.md create mode 100644 zsh/.github/ISSUE_TEMPLATE/config.yml create mode 100644 zsh/.github/ISSUE_TEMPLATE/feature_request.md create mode 100644 zsh/.github/ISSUE_TEMPLATE/support.md create mode 100644 zsh/.github/PULL_REQUEST_TEMPLATE.md create mode 100644 zsh/.github/workflows/main.yml create mode 100644 zsh/.gitignore create mode 100644 zsh/.gitpod.Dockerfile create mode 100644 zsh/.gitpod.yml create mode 100644 zsh/CODE_OF_CONDUCT.md create mode 100644 zsh/CONTRIBUTING.md create mode 100644 zsh/lib/cli.zsh create mode 100644 zsh/plugins/autoenv/README.md create mode 100644 zsh/plugins/bazel/README.md create mode 100644 zsh/plugins/bazel/_bazel create mode 100644 zsh/plugins/cakephp3/README.md create mode 100644 zsh/plugins/chruby/README.md create mode 100644 zsh/plugins/cloudapp/README.md delete mode 100755 zsh/plugins/cloudapp/cloudapp.rb create mode 100644 zsh/plugins/codeclimate/README.md create mode 100644 zsh/plugins/colemak/README.md create mode 100644 zsh/plugins/compleat/README.md create mode 100644 zsh/plugins/dash/README.md create mode 100644 zsh/plugins/direnv/README.md create mode 100644 zsh/plugins/direnv/direnv.plugin.zsh create mode 100644 zsh/plugins/dotnet/README.md create mode 100644 zsh/plugins/dotnet/dotnet.plugin.zsh create mode 100644 zsh/plugins/eecms/README.md create mode 100644 zsh/plugins/emotty/README.md create mode 100644 zsh/plugins/fasd/README.md create mode 100644 zsh/plugins/fastfile/README.md create mode 100644 zsh/plugins/fbterm/README.md mode change 120000 => 100644 zsh/plugins/fedora/fedora.plugin.zsh rename zsh/plugins/firewalld/{readme.md => README.md} (100%) create mode 100644 zsh/plugins/flutter/README.md create mode 100644 zsh/plugins/flutter/_flutter create mode 100644 zsh/plugins/flutter/flutter.plugin.zsh create mode 100644 zsh/plugins/gas/README.md create mode 100644 zsh/plugins/gcloud/README.md create mode 100644 zsh/plugins/gcloud/gcloud.plugin.zsh create mode 100644 zsh/plugins/git-lfs/README.md create mode 100644 zsh/plugins/git-lfs/git-lfs.plugin.zsh delete mode 100644 zsh/plugins/git-remote-branch/git-remote-branch.plugin.zsh create mode 100644 zsh/plugins/glassfish/README.md create mode 100644 zsh/plugins/gnu-utils/README.md mode change 120000 => 100644 zsh/plugins/go/go.plugin.zsh mode change 120000 => 100644 zsh/plugins/gradle/_gradle delete mode 120000 zsh/plugins/gradle/_gradlew create mode 100644 zsh/plugins/hitokoto/README.md create mode 100644 zsh/plugins/hitokoto/hitokoto.plugin.zsh create mode 100644 zsh/plugins/httpie/httpie.plugin.zsh create mode 100644 zsh/plugins/ionic/README.md create mode 100644 zsh/plugins/ionic/ionic.plugin.zsh create mode 100644 zsh/plugins/ipfs/LICENSE create mode 100644 zsh/plugins/ipfs/README.md create mode 100644 zsh/plugins/ipfs/_ipfs create mode 100644 zsh/plugins/jfrog/README.md create mode 100644 zsh/plugins/jfrog/jfrog.plugin.zsh create mode 100644 zsh/plugins/jruby/README.md create mode 100644 zsh/plugins/knife/README.md create mode 100644 zsh/plugins/knife_ssh/README.md create mode 100644 zsh/plugins/lando/LICENSE create mode 100644 zsh/plugins/lando/README.md create mode 100644 zsh/plugins/lando/lando.plugin.zsh create mode 100644 zsh/plugins/lein/README.md create mode 100644 zsh/plugins/lxd/README.md create mode 100644 zsh/plugins/lxd/lxd.plugin.zsh create mode 100644 zsh/plugins/magic-enter/README.md delete mode 100644 zsh/plugins/magic-enter/Readme.md create mode 100644 zsh/plugins/microk8s/README.md create mode 100644 zsh/plugins/microk8s/microk8s.plugin.zsh create mode 100644 zsh/plugins/mysql-macports/README.md create mode 100644 zsh/plugins/n98-magerun/README.md delete mode 100644 zsh/plugins/nyan/README.md delete mode 100644 zsh/plugins/nyan/nyan.plugin.zsh create mode 100644 zsh/plugins/oc/README.md create mode 100644 zsh/plugins/osx/_security create mode 100644 zsh/plugins/osx/music create mode 100644 zsh/plugins/otp/README.md create mode 100644 zsh/plugins/pass/README.md create mode 100644 zsh/plugins/paver/README.md create mode 100644 zsh/plugins/perl/README.md create mode 100644 zsh/plugins/phing/README.md create mode 100644 zsh/plugins/pip/README.md create mode 100644 zsh/plugins/pod/README.md create mode 100644 zsh/plugins/pow/README.md create mode 100644 zsh/plugins/powder/README.md create mode 100644 zsh/plugins/powify/README.md create mode 100644 zsh/plugins/profiles/README.md create mode 100644 zsh/plugins/pyenv/README.md create mode 100644 zsh/plugins/rake/README.md create mode 100644 zsh/plugins/rbenv/README.md create mode 100644 zsh/plugins/rbfu/README.md create mode 100644 zsh/plugins/rebar/README.md create mode 100644 zsh/plugins/redis-cli/README.md rename zsh/plugins/ros/{README.mkd => README.md} (100%) create mode 100644 zsh/plugins/rust/README.md create mode 100644 zsh/plugins/rustup/README.md create mode 100644 zsh/plugins/rustup/_rustup create mode 100644 zsh/plugins/rvm/README.md create mode 100644 zsh/plugins/safe-paste/README.md create mode 100644 zsh/plugins/scd/_scd mode change 100644 => 100755 zsh/plugins/scd/scd create mode 100644 zsh/plugins/screen/README.md create mode 100644 zsh/plugins/sfffe/README.md create mode 100644 zsh/plugins/shell-proxy/README.md create mode 100755 zsh/plugins/shell-proxy/proxy.py create mode 100644 zsh/plugins/shell-proxy/shell-proxy.plugin.zsh create mode 100755 zsh/plugins/shell-proxy/ssh-agent.py create mode 100755 zsh/plugins/shell-proxy/ssh-proxy.py create mode 100644 zsh/plugins/singlechar/README.md create mode 100644 zsh/plugins/sprunge/README.md create mode 100644 zsh/plugins/sublime-merge/README.md create mode 100644 zsh/plugins/sublime-merge/sublime-merge.plugin.zsh create mode 100644 zsh/plugins/supervisor/README.md create mode 100644 zsh/plugins/svn-fast-info/README.md delete mode 100644 zsh/plugins/terminalapp/terminalapp.plugin.zsh create mode 100644 zsh/plugins/terminitor/README.md delete mode 100644 zsh/plugins/themes/_theme create mode 100644 zsh/plugins/thor/README.md create mode 100644 zsh/plugins/tmux-cssh/README.md create mode 100644 zsh/plugins/tugboat/README.md create mode 100644 zsh/plugins/ufw/README.md create mode 100644 zsh/plugins/vagrant/vagrant.plugin.zsh create mode 100644 zsh/plugins/virtualenvwrapper/README.md rename zsh/plugins/wakeonlan/{README => README.md} (67%) create mode 100644 zsh/plugins/yii/README.md create mode 100644 zsh/plugins/z/README.md create mode 100644 zsh/plugins/zsh-interactive-cd/README.md create mode 100644 zsh/plugins/zsh-interactive-cd/zsh-interactive-cd.plugin.zsh create mode 100644 zsh/plugins/zsh-navigation-tools/Makefile delete mode 100644 zsh/themes/eof.zsh-theme create mode 100644 zsh/themes/mlh.zsh-theme create mode 100644 zsh/themes/random.zsh-theme delete mode 100644 zsh/zshrc diff --git a/install.sh b/install.sh index b1c95ae..3174557 100755 --- a/install.sh +++ b/install.sh @@ -23,7 +23,7 @@ cp -f "$HOME/.vimrc" "$HOME/.vimrc.bak" 2>/dev/null || true # Create symlinks ln -sf .dots/tmux/tmux.conf "$HOME"/.tmux.conf -ln -sf .dots/zsh/zshrc "$HOME"/.zshrc +ln -sf .dots/zsh/custom/zshrc "$HOME"/.zshrc ln -sf .dots/vim/vimrc "$HOME"/.vimrc printf "OK: Completed\n" diff --git a/zsh/.editorconfig b/zsh/.editorconfig new file mode 100644 index 0000000..aa18e0e --- /dev/null +++ b/zsh/.editorconfig @@ -0,0 +1,10 @@ +root = true + +[*] +end_of_line = lf +insert_final_newline = true +charset = utf-8 + +[*.sh] +indent_size = 4 +indent_style = tab diff --git a/zsh/.github/CODEOWNERS b/zsh/.github/CODEOWNERS new file mode 100644 index 0000000..c3990c4 --- /dev/null +++ b/zsh/.github/CODEOWNERS @@ -0,0 +1,4 @@ +# Plugin owners +plugins/gitfast/ @felipec +plugins/sdk/ @rgoldberg +plugins/git-lfs/ @vietduc01100001 diff --git a/zsh/.github/FUNDING.yml b/zsh/.github/FUNDING.yml new file mode 100644 index 0000000..c44bb24 --- /dev/null +++ b/zsh/.github/FUNDING.yml @@ -0,0 +1,2 @@ +github: [robbyrussell, mcornella, larson-carter] +open_collective: ohmyzsh diff --git a/zsh/.github/ISSUE_TEMPLATE/bug_report.md b/zsh/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 0000000..611d8eb --- /dev/null +++ b/zsh/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,45 @@ +--- +name: Bug report +about: Create a report to help us improve Oh My Zsh + +--- + + + +**Describe the bug** +A clear description of what the bug is. + +**To Reproduce** +Steps to reproduce the behavior, for example: +1. Enable this plugin '...' +2. Run command '...' or try the autocomplete command '...' +3. See error + +**Expected behavior** +A brief description of what should happen. + +**Screenshots and/or Recordings** +If applicable, add screenshots to help explain your problem. +You can also record an asciinema session: https://asciinema.org/ + +**Self Check** + +- Have you tried reaching out on the [Discord server](https://discord.gg/ohmyzsh)? + This can help cut down on filling up issues. We always have a few people + online that are in a variety of timezones that are willing to help you! + +- Also searching existing [GitHub Issues](https://github.com/ohmyzsh/ohmyzsh/issues?q=) might help you get quicker support + +**Desktop (please complete the following information):** + + - OS / Distro: [e.g. Arch Linux, macOS] + - If on Windows what version of WSL: [e.g. WSL1, WSL2] + - Latest ohmyzsh update?: [e.g. Yes/No] + - ZSH Version: [e.g. 5.6] + - Terminal emulator: [e.g. iTerm2] + +**Additional context** +Add any other context about the problem here. This can be themes, plugins, custom configs. diff --git a/zsh/.github/ISSUE_TEMPLATE/config.yml b/zsh/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 0000000..c6b4cef --- /dev/null +++ b/zsh/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1,5 @@ +blank_issues_enabled: true +contact_links: + - name: Get help on Discord + url: https://discord.gg/ohmyzsh + about: Have a quick question? Join the Discord server and ask on the appropriate channel. diff --git a/zsh/.github/ISSUE_TEMPLATE/feature_request.md b/zsh/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 0000000..8c20544 --- /dev/null +++ b/zsh/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,29 @@ +--- +name: Feature request +about: Suggest a feature for Oh My Zsh +labels: 'feature' + +--- + + + +**Is your feature request related to a particular plugin or theme? If so, specify it.** +The name of the plugin, theme or alias that you would like us to improve. [...] + +**Is your feature request related to a problem? Please describe.** +A description of what the problem is. Ex. I'm always frustrated when [...] + +**Describe the solution you'd like** +A description of what you want to happen. [...] + +**Describe alternatives you've considered** +A description of any alternative solutions or features you've considered. This can also include other plugins or themes. + +**Additional context** +Add any other context, screenshots or discord conversations about the feature request here. Also if you have any PRs related to this issue that are already open that you would like us to look at. + +**Related Issues** +Is there any open or closed issues that is related to this feature request? If so please link them below! [...] diff --git a/zsh/.github/ISSUE_TEMPLATE/support.md b/zsh/.github/ISSUE_TEMPLATE/support.md new file mode 100644 index 0000000..697f0c0 --- /dev/null +++ b/zsh/.github/ISSUE_TEMPLATE/support.md @@ -0,0 +1,10 @@ +--- +name: Support +about: Request support for any problem you're having with Oh My Zsh +labels: 'support' + +--- + +1. Look for similar issues already posted (including closed ones) +2. Include as much relevant information as possible +3. Try to make sure the issue is due to Oh My Zsh diff --git a/zsh/.github/PULL_REQUEST_TEMPLATE.md b/zsh/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000..1abae89 --- /dev/null +++ b/zsh/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,19 @@ +## Standards checklist: + + + +- [ ] The PR title is descriptive. +- [ ] The PR doesn't replicate another PR which is already open. +- [ ] I have read the contribution guide and followed all the instructions. +- [ ] The code follows the code style guide detailed in the wiki. +- [ ] The code is mine or it's from somewhere with an MIT-compatible license. +- [ ] The code is efficient, to the best of my ability, and does not waste computer resources. +- [ ] The code is stable and I have tested it myself, to the best of my abilities. + +## Changes: + +- [...] + +## Other comments: + +... diff --git a/zsh/.github/workflows/main.yml b/zsh/.github/workflows/main.yml new file mode 100644 index 0000000..7ab7efd --- /dev/null +++ b/zsh/.github/workflows/main.yml @@ -0,0 +1,36 @@ +name: CI +on: + pull_request: + types: + - opened + - synchronize + branches: + - master + push: + branches: + - master + +jobs: + tests: + name: Run tests + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, macos-latest] + steps: + - name: Set up git repository + uses: actions/checkout@v2 + - name: Install zsh + if: runner.os == 'Linux' + run: sudo apt-get update; sudo apt-get install zsh + - name: Test installer + run: sh ./tools/install.sh + - name: Check syntax + run: | + for file in ./oh-my-zsh.sh \ + ./lib/*.zsh \ + ./plugins/*/*.plugin.zsh \ + ./plugins/*/_* \ + ./themes/*.zsh-theme; do + zsh -n "$file" || return 1 + done diff --git a/zsh/.gitignore b/zsh/.gitignore new file mode 100644 index 0000000..ec24a19 --- /dev/null +++ b/zsh/.gitignore @@ -0,0 +1,8 @@ +# custom files +custom/ + +# temp files directories +cache/ +log/ +*.swp +.DS_Store diff --git a/zsh/.gitpod.Dockerfile b/zsh/.gitpod.Dockerfile new file mode 100644 index 0000000..b35c80d --- /dev/null +++ b/zsh/.gitpod.Dockerfile @@ -0,0 +1,5 @@ +FROM gitpod/workspace-full + +RUN sudo apt-get update && \ + sudo apt-get install -y zsh && \ + sudo rm -rf /var/lib/apt/lists/* diff --git a/zsh/.gitpod.yml b/zsh/.gitpod.yml new file mode 100644 index 0000000..ccc5724 --- /dev/null +++ b/zsh/.gitpod.yml @@ -0,0 +1,9 @@ +image: + file: .gitpod.Dockerfile + +tasks: + - init: | + export EDITOR="command gp open -w" VISUAL="command gp open -w" + cp -f /workspace/ohmyzsh/templates/zshrc.zsh-template ~/.zshrc + ln -sf /workspace/ohmyzsh ~/.oh-my-zsh + command: exec zsh diff --git a/zsh/CODE_OF_CONDUCT.md b/zsh/CODE_OF_CONDUCT.md new file mode 100644 index 0000000..20ad1cc --- /dev/null +++ b/zsh/CODE_OF_CONDUCT.md @@ -0,0 +1,76 @@ +# Contributor Covenant Code of Conduct + +## Our Pledge + +In the interest of fostering an open and welcoming environment, we as +contributors and maintainers pledge to making participation in our project and +our community a harassment-free experience for everyone, regardless of age, body +size, disability, ethnicity, sex characteristics, gender identity and expression, +level of experience, education, socio-economic status, nationality, personal +appearance, race, religion, or sexual identity and orientation. + +## Our Standards + +Examples of behavior that contributes to creating a positive environment +include: + +* Using welcoming and inclusive language +* Being respectful of differing viewpoints and experiences +* Gracefully accepting constructive criticism +* Focusing on what is best for the community +* Showing empathy towards other community members + +Examples of unacceptable behavior by participants include: + +* The use of sexualized language or imagery and unwelcome sexual attention or + advances +* Trolling, insulting/derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or electronic + address, without explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Our Responsibilities + +Project maintainers are responsible for clarifying the standards of acceptable +behavior and are expected to take appropriate and fair corrective action in +response to any instances of unacceptable behavior. + +Project maintainers have the right and responsibility to remove, edit, or +reject comments, commits, code, wiki edits, issues, and other contributions +that are not aligned to this Code of Conduct, or to ban temporarily or +permanently any contributor for other behaviors that they deem inappropriate, +threatening, offensive, or harmful. + +## Scope + +This Code of Conduct applies within all project spaces, and it also applies when +an individual is representing the project or its community in public spaces. +Examples of representing a project or community include using an official +project e-mail address, posting via an official social media account, or acting +as an appointed representative at an online or offline event. Representation of +a project may be further defined and clarified by project maintainers. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported by contacting the project team at ohmyzsh@planetargon.com. All +complaints will be reviewed and investigated and will result in a response that +is deemed necessary and appropriate to the circumstances. The project team is +obligated to maintain confidentiality with regard to the reporter of an incident. +Further details of specific enforcement policies may be posted separately. + +Project maintainers who do not follow or enforce the Code of Conduct in good +faith may face temporary or permanent repercussions as determined by other +members of the project's leadership. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, +available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html + +[homepage]: https://www.contributor-covenant.org + +For answers to common questions about this code of conduct, see +https://www.contributor-covenant.org/faq diff --git a/zsh/CONTRIBUTING.md b/zsh/CONTRIBUTING.md new file mode 100644 index 0000000..be67e93 --- /dev/null +++ b/zsh/CONTRIBUTING.md @@ -0,0 +1,125 @@ +# CONTRIBUTING GUIDELINES + +Oh-My-Zsh is a community-driven project. Contribution is welcome, encouraged, and appreciated. +It is also essential for the development of the project. + +First, please take a moment to review our [code of conduct](CODE_OF_CONDUCT.md). + +These guidelines are an attempt at better addressing the huge amount of pending +issues and pull requests. Please read them closely. + +Foremost, be so kind as to [search](#use-the-search-luke). This ensures any contribution +you would make is not already covered. + +* [Issues](#reporting-issues) + * [You have a problem](#you-have-a-problem) + * [You have a suggestion](#you-have-a-suggestion) +* [Pull Requests](#submitting-pull-requests) + * [Getting started](#getting-started) + * [You have a solution](#you-have-a-solution) + * [You have an addition](#you-have-an-addition) +* [Information sources (_aka_ search)](#use-the-search-luke) + +**BONUS:** [Volunteering](#you-have-spare-time-to-volunteer) + +## Reporting Issues + +### You have a problem + +Please be so kind as to [search](#use-the-search-luke) for any open issue already covering +your problem. + +If you find one, comment on it so we can know there are more people experiencing it. + +If not, look at the [Troubleshooting](https://github.com/ohmyzsh/ohmyzsh/wiki/Troubleshooting) +page for instructions on how to gather data to better debug your problem. + +Then, you can go ahead and create an issue with as much detail as you can provide. +It should include the data gathered as indicated above, along with: + +1. How to reproduce the problem +2. What the correct behavior should be +3. What the actual behavior is + +Please copy to anyone relevant (_eg_ plugin maintainers) by mentioning their GitHub handle +(starting with `@`) in your message. + +We will do our very best to help you. + +### You have a suggestion + +Please be so kind as to [search](#use-the-search-luke) for any open issue already covering +your suggestion. + +If you find one, comment on it so we can know there are more people supporting it. + +If not, you can go ahead and create an issue. Please copy to anyone relevant (_eg_ plugin +maintainers) by mentioning their GitHub handle (starting with `@`) in your message. + +## Submitting Pull Requests + +### Getting started + +You should be familiar with the basics of +[contributing on GitHub](https://help.github.com/articles/using-pull-requests) and have a fork +[properly set up](https://github.com/ohmyzsh/ohmyzsh/wiki/Contribution-Technical-Practices). + +You MUST always create PRs with _a dedicated branch_ based on the latest upstream tree. + +If you create your own PR, please make sure you do it right. Also be so kind as to reference +any issue that would be solved in the PR description body, +[for instance](https://help.github.com/articles/closing-issues-via-commit-messages/) +_"Fixes #XXXX"_ for issue number XXXX. + +### You have a solution + +Please be so kind as to [search](#use-the-search-luke) for any open issue already covering +your [problem](#you-have-a-problem), and any pending/merged/rejected PR covering your solution. + +If the solution is already reported, try it out and +1 the pull request if the +solution works ok. On the other hand, if you think your solution is better, post +it with a reference to the other one so we can have both solutions to compare. + +If not, then go ahead and submit a PR. Please copy to anyone relevant (e.g. plugin +maintainers) by mentioning their GitHub handle (starting with `@`) in your message. + +### You have an addition + +Please [do not](https://github.com/ohmyzsh/ohmyzsh/wiki/Themes#dont-send-us-your-theme-for-now) +send themes for now. + +Please be so kind as to [search](#use-the-search-luke) for any pending, merged or rejected Pull Requests +covering or related to what you want to add. + +If you find one, try it out and work with the author on a common solution. + +If not, then go ahead and submit a PR. Please copy to anyone relevant (_eg_ plugin +maintainers) by mentioning their GitHub handle (starting with `@`) in your message. + +For any extensive change, _eg_ a new plugin, you will have to find testers to +1 your PR. + +---- + +## Use the Search, Luke + +_May the Force (of past experiences) be with you_ + +GitHub offers [many search features](https://help.github.com/articles/searching-github/) +to help you check whether a similar contribution to yours already exists. Please search +before making any contribution, it avoids duplicates and eases maintenance. Trust me, +that works 90% of the time. + +You can also take a look at the [FAQ](https://github.com/ohmyzsh/ohmyzsh/wiki/FAQ) +to be sure your contribution has not already come up. + +If all fails, your thing has probably not been reported yet, so you can go ahead +and [create an issue](#reporting-issues) or [submit a PR](#submitting-pull-requests). + +---- + +### You have spare time to volunteer + +Very nice!! :) + +Please have a look at the [Volunteer](https://github.com/ohmyzsh/ohmyzsh/wiki/Volunteers) +page for instructions on where to start and more. diff --git a/zsh/LICENSE.txt b/zsh/LICENSE.txt index 4d465b1..45ba85a 100644 --- a/zsh/LICENSE.txt +++ b/zsh/LICENSE.txt @@ -1,7 +1,6 @@ -The MIT License (MIT) +MIT License -Copyright (c) 2009-2019 Robby Russell and contributors -See the full list at https://github.com/robbyrussell/oh-my-zsh/contributors +Copyright (c) 2009-2020 Robby Russell and contributors (https://github.com/ohmyzsh/ohmyzsh/contributors) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/zsh/README.md b/zsh/README.md index 78a5b56..86037f1 100644 --- a/zsh/README.md +++ b/zsh/README.md @@ -1,45 +1,40 @@ -

- Oh My Zsh -

+

Oh My Zsh

Oh My Zsh is an open source, community-driven framework for managing your [zsh](https://www.zsh.org/) configuration. Sounds boring. Let's try again. -__Oh My Zsh will not make you a 10x developer...but you may feel like one.__ +**Oh My Zsh will not make you a 10x developer...but you may feel like one.** Once installed, your terminal shell will become the talk of the town _or your money back!_ With each keystroke in your command prompt, you'll take advantage of the hundreds of powerful plugins and beautiful themes. Strangers will come up to you in cafés and ask you, _"that is amazing! are you some sort of genius?"_ Finally, you'll begin to get the sort of attention that you have always felt you deserved. ...or maybe you'll use the time that you're saving to start flossing more often. 😬 -To learn more, visit [ohmyz.sh](https://ohmyz.sh) and follow [@ohmyzsh](https://twitter.com/ohmyzsh) on Twitter. +To learn more, visit [ohmyz.sh](https://ohmyz.sh), follow [@ohmyzsh](https://twitter.com/ohmyzsh) on Twitter, and join us on [Discord](https://discord.gg/ohmyzsh). + +[![CI](https://github.com/ohmyzsh/ohmyzsh/workflows/CI/badge.svg)](https://github.com/ohmyzsh/ohmyzsh/actions?query=workflow%3ACI) +[![Follow @ohmyzsh](https://img.shields.io/twitter/follow/ohmyzsh?label=Follow+@ohmyzsh&style=flat)](https://twitter.com/intent/follow?screen_name=ohmyzsh) +[![Discord server](https://img.shields.io/discord/642496866407284746)](https://discord.gg/ohmyzsh) +[![Gitpod ready](https://img.shields.io/badge/Gitpod-ready-blue?logo=gitpod)](https://gitpod.io/#https://github.com/ohmyzsh/ohmyzsh) ## Getting Started ### Prerequisites -__Disclaimer:__ _Oh My Zsh works best on macOS and Linux._ - -* Unix-like operating system (macOS or Linux) -* [Zsh](https://www.zsh.org) should be installed (v4.3.9 or more recent). If not pre-installed (`zsh --version` to confirm), check the following instruction here: [Installing ZSH](https://github.com/robbyrussell/oh-my-zsh/wiki/Installing-ZSH) -* `curl` or `wget` should be installed -* `git` should be installed +- A Unix-like operating system: macOS, Linux, BSD. On Windows: WSL2 is preferred, but cygwin or msys also mostly work. +- [Zsh](https://www.zsh.org) should be installed (v4.3.9 or more recent is fine but we prefer 5.0.8 and newer). If not pre-installed (run `zsh --version` to confirm), check the following wiki instructions here: [Installing ZSH](https://github.com/ohmyzsh/ohmyzsh/wiki/Installing-ZSH) +- `curl` or `wget` should be installed +- `git` should be installed (recommended v2.4.11 or higher) ### Basic Installation -Oh My Zsh is installed by running one of the following commands in your terminal. You can install this via the command-line with either `curl` or `wget`. +Oh My Zsh is installed by running one of the following commands in your terminal. You can install this via the command-line with either `curl`, `wget` or another similar tool. -#### via curl - -```shell -sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)" -``` - -#### via wget - -```shell -sh -c "$(wget -O- https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)" -``` +| Method | Command | +|:----------|:--------------------------------------------------------------------------------------------------| +| **curl** | `sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"` | +| **wget** | `sh -c "$(wget -O- https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"` | +| **fetch** | `sh -c "$(fetch -o - https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"` | #### Manual inspection @@ -48,7 +43,7 @@ that by downloading the install script first, looking through it so everything l then running it: ```shell -curl -Lo install.sh https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh +wget https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh sh install.sh ``` @@ -56,7 +51,7 @@ sh install.sh ### Plugins -Oh My Zsh comes with a shitload of plugins to take advantage of. You can take a look in the [plugins](https://github.com/robbyrussell/oh-my-zsh/tree/master/plugins) directory and/or the [wiki](https://github.com/robbyrussell/oh-my-zsh/wiki/Plugins) to see what's currently available. +Oh My Zsh comes with a shitload of plugins for you to take advantage of. You can take a look in the [plugins](https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins) directory and/or the [wiki](https://github.com/ohmyzsh/ohmyzsh/wiki/Plugins) to see what's currently available. #### Enabling Plugins @@ -80,15 +75,15 @@ plugins=( ) ``` -_Note that the plugins are separated by whitespace. **Do not** use commas between them._ +_Note that the plugins are separated by whitespace (spaces, tabs, new lines...). **Do not** use commas between them or it will break._ #### Using Plugins -Most plugins (should! we're working on this) include a __README__, which documents how to use them. +Each plugin includes a __README__, documenting it. This README should show the aliases (if the plugin adds any) and extra goodies that are included in that particular plugin. ### Themes -We'll admit it. Early in the Oh My Zsh world, we may have gotten a bit too theme happy. We have over one hundred themes now bundled. Most of them have [screenshots](https://github.com/robbyrussell/oh-my-zsh/wiki/Themes) on the wiki. Check them out! +We'll admit it. Early in the Oh My Zsh world, we may have gotten a bit too theme happy. We have over one hundred and fifty themes now bundled. Most of them have [screenshots](https://github.com/ohmyzsh/ohmyzsh/wiki/Themes) on the wiki (We are working on updating this!). Check them out! #### Selecting a Theme @@ -104,7 +99,7 @@ To use a different theme, simply change the value to match the name of your desi ```shell ZSH_THEME="agnoster" # (this is one of the fancy ones) -# see https://github.com/robbyrussell/oh-my-zsh/wiki/Themes#agnoster +# see https://github.com/ohmyzsh/ohmyzsh/wiki/Themes#agnoster ``` _Note: many themes require installing the [Powerline Fonts](https://github.com/powerline/fonts) in order to render properly._ @@ -113,11 +108,10 @@ Open up a new terminal window and your prompt should look something like this: ![Agnoster theme](https://cloud.githubusercontent.com/assets/2618447/6316862/70f58fb6-ba03-11e4-82c9-c083bf9a6574.png) -In case you did not find a suitable theme for your needs, please have a look at the wiki for [more of them](https://github.com/robbyrussell/oh-my-zsh/wiki/External-themes). +In case you did not find a suitable theme for your needs, please have a look at the wiki for [more of them](https://github.com/ohmyzsh/ohmyzsh/wiki/External-themes). If you're feeling feisty, you can let the computer select one randomly for you each time you open a new terminal window. - ```shell ZSH_THEME="random" # (...please let it be pie... please be some pie..) ``` @@ -131,6 +125,16 @@ ZSH_THEME_RANDOM_CANDIDATES=( ) ``` +If you only know which themes you don't like, you can add them similarly to an ignored list: + +```shell +ZSH_THEME_RANDOM_IGNORED=(pygmalion tjkirch_mod) +``` + +### FAQ + +If you have some more questions or issues, you might find a solution in our [FAQ](https://github.com/ohmyzsh/ohmyzsh/wiki/FAQ). + ## Advanced Topics If you're the type that likes to get their hands dirty, these sections might resonate. @@ -142,7 +146,7 @@ the installer accepts (these settings are also documented at the top of the inst #### Custom 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 access it with `cd ~/.oh-my-zsh`) If you'd like to 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 @@ -159,14 +163,14 @@ flag `--unattended` to the `install.sh` script. This will have the effect of not the default shell, and also won't run `zsh` when the installation has finished. ```shell -sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)" "" --unattended +sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" "" --unattended ``` #### Installing from a forked repository The install script also accepts these variables to allow installation of a different repository: -- `REPO` (default: `robbyrussell/oh-my-zsh`): this takes the form of `owner/repository`. If you set +- `REPO` (default: `ohmyzsh/ohmyzsh`): this takes the form of `owner/repository`. If you set this variable, the installer will look for a repository at `https://github.com/{owner}/{repository}`. - `REMOTE` (default: `https://github.com/${REPO}.git`): this is the full URL of the git repository @@ -187,13 +191,13 @@ REPO=apjanke/oh-my-zsh BRANCH=edge sh install.sh #### Manual Installation -##### 1. Clone the repository: +##### 1. Clone the repository ```shell -git clone https://github.com/robbyrussell/oh-my-zsh.git ~/.oh-my-zsh +git clone https://github.com/ohmyzsh/ohmyzsh.git ~/.oh-my-zsh ``` -##### 2. *Optionally*, backup your existing `~/.zshrc` file: +##### 2. *Optionally*, backup your existing `~/.zshrc` file ```shell cp ~/.zshrc ~/.zshrc.orig @@ -223,9 +227,9 @@ Once you open up a new terminal window, it should load zsh with Oh My Zsh's conf If you have any hiccups installing, here are a few common fixes. -* You _might_ need to modify your `PATH` in `~/.zshrc` if you're not able to find some commands after +- 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 the `ZSH` environment variable in +- If you installed manually or changed the install location, check the `ZSH` environment variable in `~/.zshrc`. ### Custom Plugins and Themes @@ -255,7 +259,7 @@ DISABLE_AUTO_UPDATE=true If you'd like to upgrade at any point in time (maybe someone just released a new plugin and you don't want to wait a week?) you just need to run: ```shell -upgrade_oh_my_zsh +omz update ``` Magic! 🎉 @@ -272,13 +276,13 @@ Before you participate in our delightful community, please read the [code of con I'm far from being a [Zsh](https://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! -We also need people to test out pull-requests. So take a look through [the open issues](https://github.com/robbyrussell/oh-my-zsh/issues) and help where you can. +We also need people to test out pull-requests. So take a look through [the open issues](https://github.com/ohmyzsh/ohmyzsh/issues) and help where you can. See [Contributing](CONTRIBUTING.md) for more details. ### Do NOT send us themes -We have (more than) enough themes for the time being. Please add your theme to the [external themes](https://github.com/robbyrussell/oh-my-zsh/wiki/External-themes) wiki page. +We have (more than) enough themes for the time being. Please add your theme to the [external themes](https://github.com/ohmyzsh/ohmyzsh/wiki/External-themes) wiki page. ## Contributors @@ -288,10 +292,12 @@ Thank you so much! ## Follow Us -We're on the social media. +We're on social media: -* [@ohmyzsh](https://twitter.com/ohmyzsh) on Twitter. You should follow it. -* [Oh My Zsh](https://www.facebook.com/Oh-My-Zsh-296616263819290/) on Facebook. +- [@ohmyzsh](https://twitter.com/ohmyzsh) on Twitter. You should follow it. +- [FaceBook](https://www.facebook.com/Oh-My-Zsh-296616263819290/) poke us. +- [Instagram](https://www.instagram.com/_ohmyzsh/) tag us in your post showing Oh My Zsh! +- [Discord](https://discord.gg/ohmyzsh) to chat with us! ## Merchandise diff --git a/zsh/lib/cli.zsh b/zsh/lib/cli.zsh new file mode 100644 index 0000000..ff86509 --- /dev/null +++ b/zsh/lib/cli.zsh @@ -0,0 +1,354 @@ +#!/usr/bin/env zsh + +function omz { + [[ $# -gt 0 ]] || { + _omz::help + return 1 + } + + local command="$1" + shift + + # Subcommand functions start with _ so that they don't + # appear as completion entries when looking for `omz` + (( $+functions[_omz::$command] )) || { + _omz::help + return 1 + } + + _omz::$command "$@" +} + +function _omz { + local -a cmds subcmds + cmds=( + 'help:Usage information' + 'plugin:Commands for Oh My Zsh plugins management' + 'pr:Commands for Oh My Zsh Pull Requests management' + 'theme:Commands for Oh My Zsh themes management' + 'update:Update Oh My Zsh' + ) + + if (( CURRENT == 2 )); then + _describe 'command' cmds + elif (( CURRENT == 3 )); then + case "$words[2]" in + plugin) subcmds=('list:List plugins') + _describe 'command' subcmds ;; + pr) subcmds=('test:Test a Pull Request' 'clean:Delete all Pull Request branches') + _describe 'command' subcmds ;; + theme) subcmds=('use:Load a theme' 'list:List themes') + _describe 'command' subcmds ;; + esac + elif (( CURRENT == 4 )); then + case "$words[2]::$words[3]" in + theme::use) compadd "$ZSH"/themes/*.zsh-theme(.N:t:r) \ + "$ZSH_CUSTOM"/**/*.zsh-theme(.N:r:gs:"$ZSH_CUSTOM"/themes/:::gs:"$ZSH_CUSTOM"/:::) ;; + esac + fi + + return 0 +} + +compdef _omz omz + + +function _omz::help { + cat < [options] + +Available commands: + + help Print this help message + plugin Manage plugins + pr Manage Oh My Zsh Pull Requests + theme Manage themes + update Update Oh My Zsh + +EOF +} + +function _omz::confirm { + # If question supplied, ask it before reading the answer + # NOTE: uses the logname of the caller function + if [[ -n "$1" ]]; then + _omz::log prompt "$1" "${${functrace[1]#_}%:*}" + fi + + # Read one character + read -r -k 1 + + # If no newline entered, add a newline + if [[ "$REPLY" != $'\n' ]]; then + echo + fi +} + +function _omz::log { + # if promptsubst is set, a message with `` or $() + # will be run even if quoted due to `print -P` + setopt localoptions nopromptsubst + + # $1 = info|warn|error|debug + # $2 = text + # $3 = (optional) name of the logger + + local logtype=$1 + local logname=${3:-${${functrace[1]#_}%:*}} + + # Don't print anything if debug is not active + if [[ $logtype = debug && -z $_OMZ_DEBUG ]]; then + return + fi + + # Choose coloring based on log type + case "$logtype" in + prompt) print -Pn "%S%F{blue}$logname%f%s: $2" ;; + debug) print -P "%F{white}$logname%f: $2" ;; + info) print -P "%F{green}$logname%f: $2" ;; + warn) print -P "%S%F{yellow}$logname%f%s: $2" ;; + error) print -P "%S%F{red}$logname%f%s: $2" ;; + esac >&2 +} + +function _omz::plugin { + (( $# > 0 && $+functions[_omz::plugin::$1] )) || { + cat < [options] + +Available commands: + + list List all available Oh My Zsh plugins + +EOF + return 1 + } + + local command="$1" + shift + + _omz::plugin::$command "$@" +} + +function _omz::plugin::list { + local -a custom_plugins builtin_plugins + custom_plugins=("$ZSH_CUSTOM"/plugins/*(/N:t)) + builtin_plugins=("$ZSH"/plugins/*(/N:t)) + + { + (( ${#custom_plugins} )) && { + print -Pn "%U%BCustom plugins%b%u: " + print -l ${(q-)custom_plugins} + } + + (( ${#builtin_plugins} )) && { + # add a line of separation + (( ${#custom_plugins} )) && echo + + print -Pn "%U%BBuilt-in plugins%b%u: " + print -l ${(q-)builtin_plugins} + } + } | fmt -w $COLUMNS | sed -E $'s/\e?(\\[[0-9]*m)/\e\\1/g' # deal with fmt removing ESC +} + +function _omz::pr { + (( $# > 0 && $+functions[_omz::pr::$1] )) || { + cat < [options] + +Available commands: + + clean Delete all PR branches (ohmyzsh/pull-*) + test Fetch PR #NUMBER and rebase against master + +EOF + return 1 + } + + local command="$1" + shift + + _omz::pr::$command "$@" +} + +function _omz::pr::clean { + ( + set -e + builtin cd -q "$ZSH" + + # Check if there are PR branches + local fmt branches + fmt="%(color:bold blue)%(align:18,right)%(refname:short)%(end)%(color:reset) %(color:dim bold red)%(objectname:short)%(color:reset) %(color:yellow)%(contents:subject)" + branches="$(command git for-each-ref --sort=-committerdate --color --format="$fmt" "refs/heads/ohmyzsh/pull-*")" + + # Exit if there are no PR branches + if [[ -z "$branches" ]]; then + _omz::log info "there are no Pull Request branches to remove." + return + fi + + # Print found PR branches + echo "$branches\n" + # Confirm before removing the branches + _omz::confirm "do you want remove these Pull Request branches? [Y/n] " + # Only proceed if the answer is a valid yes option + [[ "$REPLY" != [yY$'\n'] ]] && return + + _omz::log info "removing all Oh My Zsh Pull Request branches..." + command git branch --list 'ohmyzsh/pull-*' | while read branch; do + command git branch -D "$branch" + done + ) +} + +function _omz::pr::test { + # Allow $1 to be a URL to the pull request + if [[ "$1" = https://* ]]; then + 1="${1:t}" + fi + + # Check the input + if ! [[ -n "$1" && "$1" =~ ^[[:digit:]]+$ ]]; then + echo >&2 "Usage: omz pr test " + return 1 + fi + + # Save current git HEAD + local branch + branch=$(builtin cd -q "$ZSH"; git symbolic-ref --short HEAD) || { + _omz::log error "error when getting the current git branch. Aborting..." + return 1 + } + + + # Fetch PR onto ohmyzsh/pull- branch and rebase against master + # If any of these operations fail, undo the changes made + ( + set -e + builtin cd -q "$ZSH" + + # Get the ohmyzsh git remote + command git remote -v | while read remote url _; do + case "$url" in + https://github.com/ohmyzsh/ohmyzsh(|.git)) found=1; break ;; + git@github.com:ohmyzsh/ohmyzsh(|.git)) found=1; break ;; + esac + done + + (( $found )) || { + _omz::log error "could not found the ohmyzsh git remote. Aborting..." + return 1 + } + + # Fetch pull request head + _omz::log info "fetching PR #$1 to ohmyzsh/pull-$1..." + command git fetch -f "$remote" refs/pull/$1/head:ohmyzsh/pull-$1 || { + _omz::log error "error when trying to fetch PR #$1." + return 1 + } + + # Rebase pull request branch against the current master + _omz::log info "rebasing PR #$1..." + command git rebase master ohmyzsh/pull-$1 || { + command git rebase --abort &>/dev/null + _omz::log warn "could not rebase PR #$1 on top of master." + _omz::log warn "you might not see the latest stable changes." + _omz::log info "run \`zsh\` to test the changes." + return 1 + } + + _omz::log info "fetch of PR #${1} successful." + ) + + # If there was an error, abort running zsh to test the PR + [[ $? -eq 0 ]] || return 1 + + # Run zsh to test the changes + _omz::log info "running \`zsh\` to test the changes. Run \`exit\` to go back." + command zsh -l + + # After testing, go back to the previous HEAD if the user wants + _omz::confirm "do you want to go back to the previous branch? [Y/n] " + # Only proceed if the answer is a valid yes option + [[ "$REPLY" != [yY$'\n'] ]] && return + + ( + set -e + builtin cd -q "$ZSH" + + command git checkout "$branch" -- || { + _omz::log error "could not go back to the previous branch ('$branch')." + return 1 + } + ) +} + +function _omz::theme { + (( $# > 0 && $+functions[_omz::theme::$1] )) || { + cat < [options] + +Available commands: + + list List all available Oh My Zsh themes + use Load an Oh My Zsh theme + +EOF + return 1 + } + + local command="$1" + shift + + _omz::theme::$command "$@" +} + +function _omz::theme::list { + local -a custom_themes builtin_themes + custom_themes=("$ZSH_CUSTOM"/**/*.zsh-theme(.N:r:gs:"$ZSH_CUSTOM"/themes/:::gs:"$ZSH_CUSTOM"/:::)) + builtin_themes=("$ZSH"/themes/*.zsh-theme(.N:t:r)) + + { + (( ${#custom_themes} )) && { + print -Pn "%U%BCustom themes%b%u: " + print -l ${(q-)custom_themes} + } + + (( ${#builtin_themes} )) && { + # add a line of separation + (( ${#custom_themes} )) && echo + + print -Pn "%U%BBuilt-in themes%b%u: " + print -l ${(q-)builtin_themes} + } + } | fmt -w $COLUMNS | sed -E $'s/\e?(\\[[0-9]*m)/\e\\1/g' # deal with fmt removing ESC +} + +function _omz::theme::use { + if [[ -z "$1" ]]; then + echo >&2 "Usage: omz theme use " + return 1 + fi + + # Respect compatibility with old lookup order + if [[ -f "$ZSH_CUSTOM/$1.zsh-theme" ]]; then + source "$ZSH_CUSTOM/$1.zsh-theme" + elif [[ -f "$ZSH_CUSTOM/themes/$1.zsh-theme" ]]; then + source "$ZSH_CUSTOM/themes/$1.zsh-theme" + elif [[ -f "$ZSH/themes/$1.zsh-theme" ]]; then + source "$ZSH/themes/$1.zsh-theme" + else + _omz::log error "theme '$1' not found" + return 1 + fi +} + +function _omz::update { + # Run update script + env ZSH="$ZSH" sh "$ZSH/tools/upgrade.sh" + # Update last updated file + zmodload zsh/datetime + echo "LAST_EPOCH=$(( EPOCHSECONDS / 60 / 60 / 24 ))" >! "${ZSH_CACHE_DIR}/.zsh-update" + # Remove update lock if it exists + command rm -rf "$ZSH/log/update.lock" +} diff --git a/zsh/lib/clipboard.zsh b/zsh/lib/clipboard.zsh index 2c93d1b..122145f 100644 --- a/zsh/lib/clipboard.zsh +++ b/zsh/lib/clipboard.zsh @@ -3,10 +3,23 @@ # This file has support for doing system clipboard copy and paste operations # from the command line in a generic cross-platform fashion. # -# On OS X and Windows, the main system clipboard or "pasteboard" is used. On other -# Unix-like OSes, this considers the X Windows CLIPBOARD selection to be the -# "system clipboard", and the X Windows `xclip` command must be installed. - +# This is uses essentially the same heuristic as neovim, with the additional +# special support for Cygwin. +# See: https://github.com/neovim/neovim/blob/e682d799fa3cf2e80a02d00c6ea874599d58f0e7/runtime/autoload/provider/clipboard.vim#L55-L121 +# +# - pbcopy, pbpaste (macOS) +# - cygwin (Windows running Cygwin) +# - wl-copy, wl-paste (if $WAYLAND_DISPLAY is set) +# - xclip (if $DISPLAY is set) +# - xsel (if $DISPLAY is set) +# - lemonade (for SSH) https://github.com/pocke/lemonade +# - doitclient (for SSH) http://www.chiark.greenend.org.uk/~sgtatham/doit/ +# - win32yank (Windows) +# - tmux (if $TMUX is set) +# +# Defines two functions, clipcopy and clippaste, based on the detected platform. +## +# # clipcopy - Copy data to clipboard # # Usage: @@ -15,41 +28,8 @@ # # clipcopy - copies a file's contents to clipboard # -function clipcopy() { - emulate -L zsh - local file=$1 - if [[ $OSTYPE == darwin* ]]; then - if [[ -z $file ]]; then - pbcopy - else - cat $file | pbcopy - fi - elif [[ $OSTYPE == cygwin* ]]; then - if [[ -z $file ]]; then - cat > /dev/clipboard - else - cat $file > /dev/clipboard - fi - else - if (( $+commands[xclip] )); then - if [[ -z $file ]]; then - xclip -in -selection clipboard - else - xclip -in -selection clipboard $file - fi - elif (( $+commands[xsel] )); then - if [[ -z $file ]]; then - xsel --clipboard --input - else - cat "$file" | xsel --clipboard --input - fi - else - print "clipcopy: Platform $OSTYPE not supported or xclip/xsel not installed" >&2 - return 1 - fi - fi -} - +## +# # clippaste - "Paste" data from clipboard to stdout # # Usage: @@ -67,20 +47,61 @@ function clipcopy() { # # # Paste to a file # clippaste > file.txt -function clippaste() { +# +function detect-clipboard() { emulate -L zsh - if [[ $OSTYPE == darwin* ]]; then - pbpaste - elif [[ $OSTYPE == cygwin* ]]; then - cat /dev/clipboard + + if [[ "${OSTYPE}" == darwin* ]] && (( ${+commands[pbcopy]} )) && (( ${+commands[pbpaste]} )); then + function clipcopy() { pbcopy < "${1:-/dev/stdin}"; } + function clippaste() { pbpaste; } + elif [[ "${OSTYPE}" == (cygwin|msys)* ]]; then + function clipcopy() { cat "${1:-/dev/stdin}" > /dev/clipboard; } + function clippaste() { cat /dev/clipboard; } + elif [ -n "${WAYLAND_DISPLAY:-}" ] && (( ${+commands[wl-copy]} )) && (( ${+commands[wl-paste]} )); then + function clipcopy() { wl-copy < "${1:-/dev/stdin}"; } + function clippaste() { wl-paste; } + elif [ -n "${DISPLAY:-}" ] && (( ${+commands[xclip]} )); then + function clipcopy() { xclip -in -selection clipboard < "${1:-/dev/stdin}"; } + function clippaste() { xclip -out -selection clipboard; } + elif [ -n "${DISPLAY:-}" ] && (( ${+commands[xsel]} )); then + function clipcopy() { xsel --clipboard --input < "${1:-/dev/stdin}"; } + function clippaste() { xsel --clipboard --output; } + elif (( ${+commands[lemonade]} )); then + function clipcopy() { lemonade copy < "${1:-/dev/stdin}"; } + function clippaste() { lemonade paste; } + elif (( ${+commands[doitclient]} )); then + function clipcopy() { doitclient wclip < "${1:-/dev/stdin}"; } + function clippaste() { doitclient wclip -r; } + elif (( ${+commands[win32yank]} )); then + function clipcopy() { win32yank -i < "${1:-/dev/stdin}"; } + function clippaste() { win32yank -o; } + elif [[ $OSTYPE == linux-android* ]] && (( $+commands[termux-clipboard-set] )); then + function clipcopy() { termux-clipboard-set "${1:-/dev/stdin}"; } + function clippaste() { termux-clipboard-get; } + elif [ -n "${TMUX:-}" ] && (( ${+commands[tmux]} )); then + function clipcopy() { tmux load-buffer "${1:--}"; } + function clippaste() { tmux save-buffer -; } + elif [[ $(uname -r) = *icrosoft* ]]; then + function clipcopy() { clip.exe < "${1:-/dev/stdin}"; } + function clippaste() { powershell.exe -noprofile -command Get-Clipboard; } else - if (( $+commands[xclip] )); then - xclip -out -selection clipboard - elif (( $+commands[xsel] )); then - xsel --clipboard --output - else - print "clipcopy: Platform $OSTYPE not supported or xclip/xsel not installed" >&2 - return 1 - fi + function _retry_clipboard_detection_or_fail() { + local clipcmd="${1}"; shift + if detect-clipboard; then + "${clipcmd}" "$@" + else + print "${clipcmd}: Platform $OSTYPE not supported or xclip/xsel not installed" >&2 + return 1 + fi + } + function clipcopy() { _retry_clipboard_detection_or_fail clipcopy "$@"; } + function clippaste() { _retry_clipboard_detection_or_fail clippaste "$@"; } + return 1 fi } + +# Detect at startup. A non-zero exit here indicates that the dummy clipboards were set, +# which is not really an error. If the user calls them, they will attempt to redetect +# (for example, perhaps the user has now installed xclip) and then either print an error +# or proceed successfully. +detect-clipboard || true diff --git a/zsh/lib/completion.zsh b/zsh/lib/completion.zsh index c7db2eb..a3873cd 100644 --- a/zsh/lib/completion.zsh +++ b/zsh/lib/completion.zsh @@ -1,7 +1,7 @@ # fixme - the load process here seems a bit bizarre zmodload -i zsh/complist -WORDCHARS='' +WORDCHARS='_-' unsetopt menu_complete # do not autoselect the first completion entry unsetopt flowcontrol @@ -41,8 +41,8 @@ fi zstyle ':completion:*:cd:*' tag-order local-directories directory-stack path-directories # Use caching so that commands like apt and dpkg complete are useable -zstyle ':completion::complete:*' use-cache 1 -zstyle ':completion::complete:*' cache-path $ZSH_CACHE_DIR +zstyle ':completion:*' use-cache yes +zstyle ':completion:*' cache-path $ZSH_CACHE_DIR # Don't complete uninteresting users zstyle ':completion:*:*:*:users' ignored-patterns \ @@ -60,14 +60,16 @@ zstyle '*' single-ignored show if [[ $COMPLETION_WAITING_DOTS = true ]]; then expand-or-complete-with-dots() { - # toggle line-wrapping off and back on again - [[ -n "$terminfo[rmam]" && -n "$terminfo[smam]" ]] && echoti rmam - print -Pn "%{%F{red}......%f%}" - [[ -n "$terminfo[rmam]" && -n "$terminfo[smam]" ]] && echoti smam - + print -Pn "%F{red}…%f" zle expand-or-complete zle redisplay } zle -N expand-or-complete-with-dots - bindkey "^I" expand-or-complete-with-dots + # Set the function as the default tab completion widget + bindkey -M emacs "^I" expand-or-complete-with-dots + bindkey -M viins "^I" expand-or-complete-with-dots + bindkey -M vicmd "^I" expand-or-complete-with-dots fi + +# automatically load bash completion functions +autoload -U +X bashcompinit && bashcompinit diff --git a/zsh/lib/diagnostics.zsh b/zsh/lib/diagnostics.zsh index 9c9905e..001de42 100644 --- a/zsh/lib/diagnostics.zsh +++ b/zsh/lib/diagnostics.zsh @@ -192,19 +192,19 @@ function _omz_diag_dump_one_big_text() { command ls -ld ~/.oh* builtin echo builtin echo oh-my-zsh git state: - (cd $ZSH && builtin echo "HEAD: $(git rev-parse HEAD)" && git remote -v && git status | command grep "[^[:space:]]") + (builtin cd $ZSH && builtin echo "HEAD: $(git rev-parse HEAD)" && git remote -v && git status | command grep "[^[:space:]]") if [[ $verbose -ge 1 ]]; then - (cd $ZSH && git reflog --date=default | command grep pull) + (builtin cd $ZSH && git reflog --date=default | command grep pull) fi builtin echo if [[ -e $ZSH_CUSTOM ]]; then local custom_dir=$ZSH_CUSTOM if [[ -h $custom_dir ]]; then - custom_dir=$(cd $custom_dir && pwd -P) + custom_dir=$(builtin cd $custom_dir && pwd -P) fi builtin echo "oh-my-zsh custom dir:" builtin echo " $ZSH_CUSTOM ($custom_dir)" - (cd ${custom_dir:h} && command find ${custom_dir:t} -name .git -prune -o -print) + (builtin cd ${custom_dir:h} && command find ${custom_dir:t} -name .git -prune -o -print) builtin echo fi diff --git a/zsh/lib/functions.zsh b/zsh/lib/functions.zsh index 9f8736b..58f0e3f 100644 --- a/zsh/lib/functions.zsh +++ b/zsh/lib/functions.zsh @@ -1,13 +1,25 @@ function zsh_stats() { - 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 + fc -l 1 \ + | awk '{ CMD[$2]++; count++; } END { for (a in CMD) print CMD[a] " " CMD[a]*100/count "% " a }' \ + | grep -v "./" | sort -nr | head -n20 | column -c3 -s " " -t | nl } function uninstall_oh_my_zsh() { - env ZSH=$ZSH sh $ZSH/tools/uninstall.sh + env ZSH="$ZSH" sh "$ZSH/tools/uninstall.sh" } function upgrade_oh_my_zsh() { - env ZSH=$ZSH sh $ZSH/tools/upgrade.sh + if (( $+functions[_omz::update] )); then + echo >&2 "${fg[yellow]}Note: \`$0\` is deprecated. Use \`omz update\` instead.$reset_color" + fi + + # Run update script + env ZSH="$ZSH" sh "$ZSH/tools/upgrade.sh" + # Update last updated file + zmodload zsh/datetime + echo "LAST_EPOCH=$(( EPOCHSECONDS / 60 / 60 / 24 ))" >! "${ZSH_CACHE_DIR}/.zsh-update" + # Remove update lock if it exists + command rm -rf "$ZSH/log/update.lock" } function take() { @@ -21,7 +33,7 @@ function open_command() { case "$OSTYPE" in darwin*) open_cmd='open' ;; cygwin*) open_cmd='cygstart' ;; - linux*) ! [[ $(uname -a) =~ "Microsoft" ]] && open_cmd='xdg-open' || { + linux*) [[ "$(uname -r)" != *icrosoft* ]] && open_cmd='nohup xdg-open' || { open_cmd='cmd.exe /c start ""' [[ -e "$1" ]] && { 1="$(wslpath -w "${1:a}")" || return 1 } } ;; @@ -31,12 +43,7 @@ function open_command() { ;; esac - # don't use nohup on OSX - if [[ "$OSTYPE" == darwin* ]]; then - ${=open_cmd} "$@" &>/dev/null - else - nohup ${=open_cmd} "$@" &>/dev/null - fi + ${=open_cmd} "$@" &>/dev/null } # @@ -93,7 +100,7 @@ function default() { # 0 if the env variable exists, 3 if it was set # function env_default() { - (( ${${(@f):-$(typeset +xg)}[(I)$1]} )) && return 0 + [[ ${parameters[$1]} = *-export* ]] && return 0 export "$1=$2" && return 3 } diff --git a/zsh/lib/git.zsh b/zsh/lib/git.zsh index 640561e..53d3960 100644 --- a/zsh/lib/git.zsh +++ b/zsh/lib/git.zsh @@ -1,9 +1,20 @@ +# The git prompt's git commands are read-only and should not interfere with +# other processes. This environment variable is equivalent to running with `git +# --no-optional-locks`, but falls back gracefully for older versions of git. +# See git(1) for and git-status(1) for a description of that flag. +# +# We wrap in a local function instead of exporting the variable directly in +# order to avoid interfering with manually-run git commands by the user. +function __git_prompt_git() { + GIT_OPTIONAL_LOCKS=0 command git "$@" +} + # Outputs current branch info in prompt format function git_prompt_info() { local ref - 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 0 + if [[ "$(__git_prompt_git config --get oh-my-zsh.hide-status 2>/dev/null)" != "1" ]]; then + ref=$(__git_prompt_git symbolic-ref HEAD 2> /dev/null) || \ + ref=$(__git_prompt_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 } @@ -12,12 +23,22 @@ function git_prompt_info() { function parse_git_dirty() { local STATUS local -a FLAGS - FLAGS=('--porcelain' '--ignore-submodules=dirty') - if [[ "$(command git config --get oh-my-zsh.hide-dirty)" != "1" ]]; then - if [[ "$DISABLE_UNTRACKED_FILES_DIRTY" == "true" ]]; then + FLAGS=('--porcelain') + if [[ "$(__git_prompt_git config --get oh-my-zsh.hide-dirty)" != "1" ]]; then + if [[ "${DISABLE_UNTRACKED_FILES_DIRTY:-}" == "true" ]]; then FLAGS+='--untracked-files=no' fi - STATUS=$(command git status ${FLAGS} 2> /dev/null | tail -n1) + case "${GIT_STATUS_IGNORE_SUBMODULES:-}" in + git) + # let git decide (this respects per-repo config in .gitmodules) + ;; + *) + # if unset: ignore dirty submodules + # other values are passed to --ignore-submodules + FLAGS+="--ignore-submodules=${GIT_STATUS_IGNORE_SUBMODULES:-dirty}" + ;; + esac + STATUS=$(__git_prompt_git status ${FLAGS} 2> /dev/null | tail -n1) fi if [[ -n $STATUS ]]; then echo "$ZSH_THEME_GIT_PROMPT_DIRTY" @@ -29,10 +50,10 @@ function parse_git_dirty() { # Gets the difference between the local and remote branches function git_remote_status() { local remote ahead behind git_remote_status git_remote_status_detailed - remote=${$(command git rev-parse --verify ${hook_com[branch]}@{upstream} --symbolic-full-name 2>/dev/null)/refs\/remotes\/} + remote=${$(__git_prompt_git rev-parse --verify ${hook_com[branch]}@{upstream} --symbolic-full-name 2>/dev/null)/refs\/remotes\/} if [[ -n ${remote} ]]; then - ahead=$(command git rev-list ${hook_com[branch]}@{upstream}..HEAD 2>/dev/null | wc -l) - behind=$(command git rev-list HEAD..${hook_com[branch]}@{upstream} 2>/dev/null | wc -l) + ahead=$(__git_prompt_git rev-list ${hook_com[branch]}@{upstream}..HEAD 2>/dev/null | wc -l) + behind=$(__git_prompt_git rev-list HEAD..${hook_com[branch]}@{upstream} 2>/dev/null | wc -l) if [[ $ahead -eq 0 ]] && [[ $behind -eq 0 ]]; then git_remote_status="$ZSH_THEME_GIT_PROMPT_EQUAL_REMOTE" @@ -61,11 +82,11 @@ function git_remote_status() { # it's not a symbolic ref, but in a Git repo. function git_current_branch() { local ref - ref=$(command git symbolic-ref --quiet HEAD 2> /dev/null) + ref=$(__git_prompt_git symbolic-ref --quiet HEAD 2> /dev/null) local ret=$? if [[ $ret != 0 ]]; then [[ $ret == 128 ]] && return # no git repo. - ref=$(command git rev-parse --short HEAD 2> /dev/null) || return + ref=$(__git_prompt_git rev-parse --short HEAD 2> /dev/null) || return fi echo ${ref#refs/heads/} } @@ -73,8 +94,8 @@ function git_current_branch() { # Gets the number of commits ahead from remote function git_commits_ahead() { - if command git rev-parse --git-dir &>/dev/null; then - local commits="$(git rev-list --count @{upstream}..HEAD 2>/dev/null)" + if __git_prompt_git rev-parse --git-dir &>/dev/null; then + local commits="$(__git_prompt_git rev-list --count @{upstream}..HEAD 2>/dev/null)" if [[ -n "$commits" && "$commits" != 0 ]]; then echo "$ZSH_THEME_GIT_COMMITS_AHEAD_PREFIX$commits$ZSH_THEME_GIT_COMMITS_AHEAD_SUFFIX" fi @@ -83,8 +104,8 @@ function git_commits_ahead() { # Gets the number of commits behind remote function git_commits_behind() { - if command git rev-parse --git-dir &>/dev/null; then - local commits="$(git rev-list --count HEAD..@{upstream} 2>/dev/null)" + if __git_prompt_git rev-parse --git-dir &>/dev/null; then + local commits="$(__git_prompt_git rev-list --count HEAD..@{upstream} 2>/dev/null)" if [[ -n "$commits" && "$commits" != 0 ]]; then echo "$ZSH_THEME_GIT_COMMITS_BEHIND_PREFIX$commits$ZSH_THEME_GIT_COMMITS_BEHIND_SUFFIX" fi @@ -93,21 +114,21 @@ function git_commits_behind() { # Outputs if current branch is ahead of remote function git_prompt_ahead() { - if [[ -n "$(command git rev-list origin/$(git_current_branch)..HEAD 2> /dev/null)" ]]; then + if [[ -n "$(__git_prompt_git rev-list origin/$(git_current_branch)..HEAD 2> /dev/null)" ]]; then echo "$ZSH_THEME_GIT_PROMPT_AHEAD" fi } # Outputs if current branch is behind remote function git_prompt_behind() { - if [[ -n "$(command git rev-list HEAD..origin/$(git_current_branch) 2> /dev/null)" ]]; then + if [[ -n "$(__git_prompt_git rev-list HEAD..origin/$(git_current_branch) 2> /dev/null)" ]]; then echo "$ZSH_THEME_GIT_PROMPT_BEHIND" fi } # Outputs if current branch exists on remote or not function git_prompt_remote() { - if [[ -n "$(command git show-ref origin/$(git_current_branch) 2> /dev/null)" ]]; then + if [[ -n "$(__git_prompt_git show-ref origin/$(git_current_branch) 2> /dev/null)" ]]; then echo "$ZSH_THEME_GIT_PROMPT_REMOTE_EXISTS" else echo "$ZSH_THEME_GIT_PROMPT_REMOTE_MISSING" @@ -117,75 +138,130 @@ function git_prompt_remote() { # Formats prompt string for current git commit short SHA function git_prompt_short_sha() { local 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" + SHA=$(__git_prompt_git rev-parse --short HEAD 2> /dev/null) && echo "$ZSH_THEME_GIT_PROMPT_SHA_BEFORE$SHA$ZSH_THEME_GIT_PROMPT_SHA_AFTER" } # Formats prompt string for current git commit long SHA function git_prompt_long_sha() { local SHA - SHA=$(command git rev-parse HEAD 2> /dev/null) && echo "$ZSH_THEME_GIT_PROMPT_SHA_BEFORE$SHA$ZSH_THEME_GIT_PROMPT_SHA_AFTER" + SHA=$(__git_prompt_git rev-parse HEAD 2> /dev/null) && echo "$ZSH_THEME_GIT_PROMPT_SHA_BEFORE$SHA$ZSH_THEME_GIT_PROMPT_SHA_AFTER" } -# Get the status of the working tree function git_prompt_status() { - local INDEX STATUS - INDEX=$(command git status --porcelain -b 2> /dev/null) - STATUS="" - if $(echo "$INDEX" | command grep -E '^\?\? ' &> /dev/null); then - STATUS="$ZSH_THEME_GIT_PROMPT_UNTRACKED$STATUS" + [[ "$(__git_prompt_git config --get oh-my-zsh.hide-status 2>/dev/null)" = 1 ]] && return + + # Maps a git status prefix to an internal constant + # This cannot use the prompt constants, as they may be empty + local -A prefix_constant_map + prefix_constant_map=( + '\?\? ' 'UNTRACKED' + 'A ' 'ADDED' + 'M ' 'ADDED' + 'MM ' 'ADDED' + ' M ' 'MODIFIED' + 'AM ' 'MODIFIED' + ' T ' 'MODIFIED' + 'R ' 'RENAMED' + ' D ' 'DELETED' + 'D ' 'DELETED' + 'UU ' 'UNMERGED' + 'ahead' 'AHEAD' + 'behind' 'BEHIND' + 'diverged' 'DIVERGED' + 'stashed' 'STASHED' + ) + + # Maps the internal constant to the prompt theme + local -A constant_prompt_map + constant_prompt_map=( + 'UNTRACKED' "$ZSH_THEME_GIT_PROMPT_UNTRACKED" + 'ADDED' "$ZSH_THEME_GIT_PROMPT_ADDED" + 'MODIFIED' "$ZSH_THEME_GIT_PROMPT_MODIFIED" + 'RENAMED' "$ZSH_THEME_GIT_PROMPT_RENAMED" + 'DELETED' "$ZSH_THEME_GIT_PROMPT_DELETED" + 'UNMERGED' "$ZSH_THEME_GIT_PROMPT_UNMERGED" + 'AHEAD' "$ZSH_THEME_GIT_PROMPT_AHEAD" + 'BEHIND' "$ZSH_THEME_GIT_PROMPT_BEHIND" + 'DIVERGED' "$ZSH_THEME_GIT_PROMPT_DIVERGED" + 'STASHED' "$ZSH_THEME_GIT_PROMPT_STASHED" + ) + + # The order that the prompt displays should be added to the prompt + local status_constants + status_constants=( + UNTRACKED ADDED MODIFIED RENAMED DELETED + STASHED UNMERGED AHEAD BEHIND DIVERGED + ) + + local status_text="$(__git_prompt_git status --porcelain -b 2> /dev/null)" + + # Don't continue on a catastrophic failure + if [[ $? -eq 128 ]]; then + return 1 fi - if $(echo "$INDEX" | grep '^A ' &> /dev/null); then - STATUS="$ZSH_THEME_GIT_PROMPT_ADDED$STATUS" - elif $(echo "$INDEX" | grep '^M ' &> /dev/null); then - STATUS="$ZSH_THEME_GIT_PROMPT_ADDED$STATUS" - elif $(echo "$INDEX" | grep '^MM ' &> /dev/null); then - STATUS="$ZSH_THEME_GIT_PROMPT_ADDED$STATUS" + + # A lookup table of each git status encountered + local -A statuses_seen + + if __git_prompt_git rev-parse --verify refs/stash &>/dev/null; then + statuses_seen[STASHED]=1 fi - if $(echo "$INDEX" | grep '^ M ' &> /dev/null); then - STATUS="$ZSH_THEME_GIT_PROMPT_MODIFIED$STATUS" - elif $(echo "$INDEX" | grep '^AM ' &> /dev/null); then - STATUS="$ZSH_THEME_GIT_PROMPT_MODIFIED$STATUS" - elif $(echo "$INDEX" | grep '^MM ' &> /dev/null); then - STATUS="$ZSH_THEME_GIT_PROMPT_MODIFIED$STATUS" - elif $(echo "$INDEX" | grep '^ T ' &> /dev/null); then - STATUS="$ZSH_THEME_GIT_PROMPT_MODIFIED$STATUS" + + local status_lines + status_lines=("${(@f)${status_text}}") + + # If the tracking line exists, get and parse it + if [[ "$status_lines[1]" =~ "^## [^ ]+ \[(.*)\]" ]]; then + local branch_statuses + branch_statuses=("${(@s/,/)match}") + for branch_status in $branch_statuses; do + if [[ ! $branch_status =~ "(behind|diverged|ahead) ([0-9]+)?" ]]; then + continue + fi + local last_parsed_status=$prefix_constant_map[$match[1]] + statuses_seen[$last_parsed_status]=$match[2] + done fi - if $(echo "$INDEX" | grep '^R ' &> /dev/null); then - STATUS="$ZSH_THEME_GIT_PROMPT_RENAMED$STATUS" - fi - if $(echo "$INDEX" | grep '^ D ' &> /dev/null); then - STATUS="$ZSH_THEME_GIT_PROMPT_DELETED$STATUS" - elif $(echo "$INDEX" | grep '^D ' &> /dev/null); then - STATUS="$ZSH_THEME_GIT_PROMPT_DELETED$STATUS" - elif $(echo "$INDEX" | grep '^AD ' &> /dev/null); then - STATUS="$ZSH_THEME_GIT_PROMPT_DELETED$STATUS" - fi - if $(command git rev-parse --verify refs/stash >/dev/null 2>&1); then - STATUS="$ZSH_THEME_GIT_PROMPT_STASHED$STATUS" - fi - if $(echo "$INDEX" | grep '^UU ' &> /dev/null); then - STATUS="$ZSH_THEME_GIT_PROMPT_UNMERGED$STATUS" - fi - if $(echo "$INDEX" | grep '^## [^ ]\+ .*ahead' &> /dev/null); then - STATUS="$ZSH_THEME_GIT_PROMPT_AHEAD$STATUS" - fi - if $(echo "$INDEX" | grep '^## [^ ]\+ .*behind' &> /dev/null); then - STATUS="$ZSH_THEME_GIT_PROMPT_BEHIND$STATUS" - fi - if $(echo "$INDEX" | grep '^## [^ ]\+ .*diverged' &> /dev/null); then - STATUS="$ZSH_THEME_GIT_PROMPT_DIVERGED$STATUS" - fi - echo $STATUS + + # For each status prefix, do a regex comparison + for status_prefix in ${(k)prefix_constant_map}; do + local status_constant="${prefix_constant_map[$status_prefix]}" + local status_regex=$'(^|\n)'"$status_prefix" + + if [[ "$status_text" =~ $status_regex ]]; then + statuses_seen[$status_constant]=1 + fi + done + + # Display the seen statuses in the order specified + local status_prompt + for status_constant in $status_constants; do + if (( ${+statuses_seen[$status_constant]} )); then + local next_display=$constant_prompt_map[$status_constant] + status_prompt="$next_display$status_prompt" + fi + done + + echo $status_prompt } # Outputs the name of the current user # Usage example: $(git_current_user_name) function git_current_user_name() { - command git config user.name 2>/dev/null + __git_prompt_git config user.name 2>/dev/null } # Outputs the email of the current user # Usage example: $(git_current_user_email) function git_current_user_email() { - command git config user.email 2>/dev/null + __git_prompt_git config user.email 2>/dev/null +} + +# Output the name of the root directory of the git repository +# Usage example: $(git_repo_name) +function git_repo_name() { + local repo_path + if repo_path="$(__git_prompt_git rev-parse --show-toplevel 2>/dev/null)" && [[ -n "$repo_path" ]]; then + echo ${repo_path:t} + fi } diff --git a/zsh/lib/grep.zsh b/zsh/lib/grep.zsh index abc1650..a725e0f 100644 --- a/zsh/lib/grep.zsh +++ b/zsh/lib/grep.zsh @@ -1,28 +1,41 @@ -# is x grep argument available? -grep-flag-available() { - echo | grep $1 "" >/dev/null 2>&1 -} +__GREP_CACHE_FILE="$ZSH_CACHE_DIR"/grep-alias -GREP_OPTIONS="" +# See if there's a cache file modified in the last day +__GREP_ALIAS_CACHES=("$__GREP_CACHE_FILE"(Nm-1)) +if [[ -n "$__GREP_ALIAS_CACHES" ]]; then + source "$__GREP_CACHE_FILE" +else + grep-flags-available() { + command grep "$@" "" &>/dev/null <<< "" + } -# color grep results -if grep-flag-available --color=auto; then - GREP_OPTIONS+=" --color=auto" + # Ignore these folders (if the necessary grep flags are available) + EXC_FOLDERS="{.bzr,CVS,.git,.hg,.svn,.idea,.tox}" + + # Check for --exclude-dir, otherwise check for --exclude. If --exclude + # isn't available, --color won't be either (they were released at the same + # time (v2.5): https://git.savannah.gnu.org/cgit/grep.git/tree/NEWS?id=1236f007 + if grep-flags-available --color=auto --exclude-dir=.cvs; then + GREP_OPTIONS="--color=auto --exclude-dir=$EXC_FOLDERS" + elif grep-flags-available --color=auto --exclude=.cvs; then + GREP_OPTIONS="--color=auto --exclude=$EXC_FOLDERS" + fi + + if [[ -n "$GREP_OPTIONS" ]]; then + # export grep, egrep and fgrep settings + alias grep="grep $GREP_OPTIONS" + alias egrep="egrep $GREP_OPTIONS" + alias fgrep="fgrep $GREP_OPTIONS" + + # write to cache file if cache directory is writable + if [[ -w "$ZSH_CACHE_DIR" ]]; then + alias -L grep egrep fgrep >| "$__GREP_CACHE_FILE" + fi + fi + + # Clean up + unset GREP_OPTIONS EXC_FOLDERS + unfunction grep-flags-available fi -# ignore VCS folders (if the necessary grep flags are available) -VCS_FOLDERS="{.bzr,CVS,.git,.hg,.svn}" - -if grep-flag-available --exclude-dir=.cvs; then - GREP_OPTIONS+=" --exclude-dir=$VCS_FOLDERS" -elif grep-flag-available --exclude=.cvs; then - GREP_OPTIONS+=" --exclude=$VCS_FOLDERS" -fi - -# export grep settings -alias grep="grep $GREP_OPTIONS" - -# clean up -unset GREP_OPTIONS -unset VCS_FOLDERS -unfunction grep-flag-available +unset __GREP_CACHE_FILE __GREP_ALIAS_CACHES diff --git a/zsh/lib/history.zsh b/zsh/lib/history.zsh index 52e45bf..8d922a3 100644 --- a/zsh/lib/history.zsh +++ b/zsh/lib/history.zsh @@ -27,8 +27,8 @@ esac ## History file configuration [ -z "$HISTFILE" ] && HISTFILE="$HOME/.zsh_history" -HISTSIZE=50000 -SAVEHIST=10000 +[ "$HISTSIZE" -lt 50000 ] && HISTSIZE=50000 +[ "$SAVEHIST" -lt 10000 ] && SAVEHIST=10000 ## History command configuration setopt extended_history # record timestamp of command in HISTFILE @@ -36,5 +36,3 @@ setopt hist_expire_dups_first # delete duplicates first when HISTFILE size excee setopt hist_ignore_dups # ignore duplicated commands history list setopt hist_ignore_space # ignore commands that start with space setopt hist_verify # show command with history expansion to user before running it -setopt inc_append_history # add commands to HISTFILE in order of execution -setopt share_history # share command history data diff --git a/zsh/lib/key-bindings.zsh b/zsh/lib/key-bindings.zsh index 0e056dc..aaa7304 100644 --- a/zsh/lib/key-bindings.zsh +++ b/zsh/lib/key-bindings.zsh @@ -15,55 +15,100 @@ if (( ${+terminfo[smkx]} )) && (( ${+terminfo[rmkx]} )); then zle -N zle-line-finish fi -bindkey -e # Use emacs key bindings +# Use emacs key bindings +bindkey -e + +# [PageUp] - Up a line of history +if [[ -n "${terminfo[kpp]}" ]]; then + bindkey -M emacs "${terminfo[kpp]}" up-line-or-history + bindkey -M viins "${terminfo[kpp]}" up-line-or-history + bindkey -M vicmd "${terminfo[kpp]}" up-line-or-history +fi +# [PageDown] - Down a line of history +if [[ -n "${terminfo[knp]}" ]]; then + bindkey -M emacs "${terminfo[knp]}" down-line-or-history + bindkey -M viins "${terminfo[knp]}" down-line-or-history + bindkey -M vicmd "${terminfo[knp]}" down-line-or-history +fi + +# Start typing + [Up-Arrow] - fuzzy find history forward +if [[ -n "${terminfo[kcuu1]}" ]]; then + autoload -U up-line-or-beginning-search + zle -N up-line-or-beginning-search + + bindkey -M emacs "${terminfo[kcuu1]}" up-line-or-beginning-search + bindkey -M viins "${terminfo[kcuu1]}" up-line-or-beginning-search + bindkey -M vicmd "${terminfo[kcuu1]}" up-line-or-beginning-search +fi +# Start typing + [Down-Arrow] - fuzzy find history backward +if [[ -n "${terminfo[kcud1]}" ]]; then + autoload -U down-line-or-beginning-search + zle -N down-line-or-beginning-search + + bindkey -M emacs "${terminfo[kcud1]}" down-line-or-beginning-search + bindkey -M viins "${terminfo[kcud1]}" down-line-or-beginning-search + bindkey -M vicmd "${terminfo[kcud1]}" down-line-or-beginning-search +fi + +# [Home] - Go to beginning of line +if [[ -n "${terminfo[khome]}" ]]; then + bindkey -M emacs "${terminfo[khome]}" beginning-of-line + bindkey -M viins "${terminfo[khome]}" beginning-of-line + bindkey -M vicmd "${terminfo[khome]}" beginning-of-line +fi +# [End] - Go to end of line +if [[ -n "${terminfo[kend]}" ]]; then + bindkey -M emacs "${terminfo[kend]}" end-of-line + bindkey -M viins "${terminfo[kend]}" end-of-line + bindkey -M vicmd "${terminfo[kend]}" end-of-line +fi + +# [Shift-Tab] - move through the completion menu backwards +if [[ -n "${terminfo[kcbt]}" ]]; then + bindkey -M emacs "${terminfo[kcbt]}" reverse-menu-complete + bindkey -M viins "${terminfo[kcbt]}" reverse-menu-complete + bindkey -M vicmd "${terminfo[kcbt]}" reverse-menu-complete +fi + +# [Backspace] - delete backward +bindkey -M emacs '^?' backward-delete-char +bindkey -M viins '^?' backward-delete-char +bindkey -M vicmd '^?' backward-delete-char +# [Delete] - delete forward +if [[ -n "${terminfo[kdch1]}" ]]; then + bindkey -M emacs "${terminfo[kdch1]}" delete-char + bindkey -M viins "${terminfo[kdch1]}" delete-char + bindkey -M vicmd "${terminfo[kdch1]}" delete-char +else + bindkey -M emacs "^[[3~" delete-char + bindkey -M viins "^[[3~" delete-char + bindkey -M vicmd "^[[3~" delete-char + + bindkey -M emacs "^[3;5~" delete-char + bindkey -M viins "^[3;5~" delete-char + bindkey -M vicmd "^[3;5~" delete-char +fi + +# [Ctrl-Delete] - delete whole forward-word +bindkey -M emacs '^[[3;5~' kill-word +bindkey -M viins '^[[3;5~' kill-word +bindkey -M vicmd '^[[3;5~' kill-word + +# [Ctrl-RightArrow] - move forward one word +bindkey -M emacs '^[[1;5C' forward-word +bindkey -M viins '^[[1;5C' forward-word +bindkey -M vicmd '^[[1;5C' forward-word +# [Ctrl-LeftArrow] - move backward one word +bindkey -M emacs '^[[1;5D' backward-word +bindkey -M viins '^[[1;5D' backward-word +bindkey -M vicmd '^[[1;5D' backward-word + bindkey '\ew' kill-region # [Esc-w] - Kill from the cursor to the mark bindkey -s '\el' 'ls\n' # [Esc-l] - run command: ls bindkey '^r' history-incremental-search-backward # [Ctrl-r] - Search backward incrementally for a specified string. The string may begin with ^ to anchor the search to the beginning of the line. -if [[ "${terminfo[kpp]}" != "" ]]; then - bindkey "${terminfo[kpp]}" up-line-or-history # [PageUp] - Up a line of history -fi -if [[ "${terminfo[knp]}" != "" ]]; then - bindkey "${terminfo[knp]}" down-line-or-history # [PageDown] - Down a line of history -fi +bindkey ' ' magic-space # [Space] - don't do history expansion -# start typing + [Up-Arrow] - fuzzy find history forward -if [[ "${terminfo[kcuu1]}" != "" ]]; then - autoload -U up-line-or-beginning-search - zle -N up-line-or-beginning-search - bindkey "${terminfo[kcuu1]}" up-line-or-beginning-search -fi -# start typing + [Down-Arrow] - fuzzy find history backward -if [[ "${terminfo[kcud1]}" != "" ]]; then - autoload -U down-line-or-beginning-search - zle -N down-line-or-beginning-search - bindkey "${terminfo[kcud1]}" down-line-or-beginning-search -fi - -if [[ "${terminfo[khome]}" != "" ]]; then - bindkey "${terminfo[khome]}" beginning-of-line # [Home] - Go to beginning of line -fi -if [[ "${terminfo[kend]}" != "" ]]; then - bindkey "${terminfo[kend]}" end-of-line # [End] - Go to end of line -fi - -bindkey ' ' magic-space # [Space] - do history expansion - -bindkey '^[[1;5C' forward-word # [Ctrl-RightArrow] - move forward one word -bindkey '^[[1;5D' backward-word # [Ctrl-LeftArrow] - move backward one word - -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 -if [[ "${terminfo[kdch1]}" != "" ]]; then - bindkey "${terminfo[kdch1]}" delete-char # [Delete] - delete forward -else - bindkey "^[[3~" delete-char - bindkey "^[3;5~" delete-char - bindkey "\e[3~" delete-char -fi # Edit the current command line in $EDITOR autoload -U edit-command-line diff --git a/zsh/lib/misc.zsh b/zsh/lib/misc.zsh index 36c3ae2..a5d3af9 100644 --- a/zsh/lib/misc.zsh +++ b/zsh/lib/misc.zsh @@ -3,15 +3,15 @@ autoload -Uz is-at-least # *-magic is known buggy in some versions; disable if so if [[ $DISABLE_MAGIC_FUNCTIONS != true ]]; then for d in $fpath; do - if [[ -e "$d/url-quote-magic" ]]; then - if is-at-least 5.1; then - autoload -Uz bracketed-paste-magic - zle -N bracketed-paste bracketed-paste-magic - fi - autoload -Uz url-quote-magic - zle -N self-insert url-quote-magic - break - fi + if [[ -e "$d/url-quote-magic" ]]; then + if is-at-least 5.1; then + autoload -Uz bracketed-paste-magic + zle -N bracketed-paste bracketed-paste-magic + fi + autoload -Uz url-quote-magic + zle -N self-insert url-quote-magic + break + fi done fi @@ -22,10 +22,10 @@ env_default 'PAGER' 'less' env_default 'LESS' '-R' ## super user alias -alias _='sudo' +alias _='sudo ' ## more intelligent acking for ubuntu users -if which ack-grep &> /dev/null; then +if (( $+commands[ack-grep] )); then alias afind='ack-grep -il' else alias afind='ack -il' diff --git a/zsh/lib/nvm.zsh b/zsh/lib/nvm.zsh index 4a8b681..2fe57a8 100644 --- a/zsh/lib/nvm.zsh +++ b/zsh/lib/nvm.zsh @@ -1,9 +1,6 @@ -# get the node.js version +# get the nvm-controlled node.js version function nvm_prompt_info() { - [[ -f "$NVM_DIR/nvm.sh" ]] || return - local nvm_prompt - nvm_prompt=$(node -v 2>/dev/null) - [[ "${nvm_prompt}x" == "x" ]] && return - nvm_prompt=${nvm_prompt:1} + which nvm &>/dev/null || return + local nvm_prompt=${$(nvm current)#v} echo "${ZSH_THEME_NVM_PROMPT_PREFIX}${nvm_prompt}${ZSH_THEME_NVM_PROMPT_SUFFIX}" } diff --git a/zsh/lib/spectrum.zsh b/zsh/lib/spectrum.zsh index 312ab22..d5c22a8 100644 --- a/zsh/lib/spectrum.zsh +++ b/zsh/lib/spectrum.zsh @@ -1,4 +1,3 @@ -#! /bin/zsh # A script to make using 256 colors in zsh less painful. # P.C. Shyamshankar # Copied from https://github.com/sykora/etc/blob/master/zsh/functions/spectrum/ @@ -6,32 +5,31 @@ typeset -AHg FX FG BG FX=( - reset "%{%}" - bold "%{%}" no-bold "%{%}" - italic "%{%}" no-italic "%{%}" - underline "%{%}" no-underline "%{%}" - blink "%{%}" no-blink "%{%}" - reverse "%{%}" no-reverse "%{%}" + reset "%{%}" + bold "%{%}" no-bold "%{%}" + italic "%{%}" no-italic "%{%}" + underline "%{%}" no-underline "%{%}" + blink "%{%}" no-blink "%{%}" + reverse "%{%}" no-reverse "%{%}" ) for color in {000..255}; do - FG[$color]="%{[38;5;${color}m%}" - BG[$color]="%{[48;5;${color}m%}" + FG[$color]="%{[38;5;${color}m%}" + BG[$color]="%{[48;5;${color}m%}" done - -ZSH_SPECTRUM_TEXT=${ZSH_SPECTRUM_TEXT:-Arma virumque cano Troiae qui primus ab oris} - # Show all 256 colors with color number function spectrum_ls() { + local ZSH_SPECTRUM_TEXT=${ZSH_SPECTRUM_TEXT:-Arma virumque cano Troiae qui primus ab oris} for code in {000..255}; do - print -P -- "$code: %{$FG[$code]%}$ZSH_SPECTRUM_TEXT%{$reset_color%}" + print -P -- "$code: $FG[$code]$ZSH_SPECTRUM_TEXT%{$reset_color%}" done } # Show all 256 colors where the background is set to specific color function spectrum_bls() { + local ZSH_SPECTRUM_TEXT=${ZSH_SPECTRUM_TEXT:-Arma virumque cano Troiae qui primus ab oris} for code in {000..255}; do - print -P -- "$code: %{$BG[$code]%}$ZSH_SPECTRUM_TEXT%{$reset_color%}" + print -P -- "$code: $BG[$code]$ZSH_SPECTRUM_TEXT%{$reset_color%}" done } diff --git a/zsh/lib/termsupport.zsh b/zsh/lib/termsupport.zsh index aa14f3f..778f12b 100644 --- a/zsh/lib/termsupport.zsh +++ b/zsh/lib/termsupport.zsh @@ -17,32 +17,32 @@ function title { : ${2=$1} case "$TERM" in - cygwin|xterm*|putty*|rxvt*|ansi) - print -Pn "\e]2;$2:q\a" # set window name - print -Pn "\e]1;$1:q\a" # set tab name + cygwin|xterm*|putty*|rxvt*|konsole*|ansi|mlterm*|alacritty|st*) + print -Pn "\e]2;${2:q}\a" # set window name + print -Pn "\e]1;${1:q}\a" # set tab name ;; screen*|tmux*) - print -Pn "\ek$1:q\e\\" # set screen hardstatus + print -Pn "\ek${1:q}\e\\" # set screen hardstatus ;; *) if [[ "$TERM_PROGRAM" == "iTerm.app" ]]; then - print -Pn "\e]2;$2:q\a" # set window name - print -Pn "\e]1;$1:q\a" # set tab name + print -Pn "\e]2;${2:q}\a" # set window name + print -Pn "\e]1;${1:q}\a" # set tab name else # Try to use terminfo to set the title # If the feature is available set title if [[ -n "$terminfo[fsl]" ]] && [[ -n "$terminfo[tsl]" ]]; then - echoti tsl - print -Pn "$1" - echoti fsl - fi + echoti tsl + print -Pn "$1" + echoti fsl + fi fi ;; esac } ZSH_THEME_TERM_TAB_TITLE_IDLE="%15<..<%~%<<" #15 char left truncated PWD -ZSH_THEME_TERM_TITLE_IDLE="%n@%m: %~" +ZSH_THEME_TERM_TITLE_IDLE="%n@%m:%~" # Avoid duplication of directory in terminals with independent dir display if [[ "$TERM_PROGRAM" == Apple_Terminal ]]; then ZSH_THEME_TERM_TITLE_IDLE="%n@%m" @@ -50,22 +50,52 @@ fi # Runs before showing the prompt function omz_termsupport_precmd { - emulate -L zsh - - if [[ "$DISABLE_AUTO_TITLE" == true ]]; then - return - fi - + [[ "${DISABLE_AUTO_TITLE:-}" == true ]] && return title $ZSH_THEME_TERM_TAB_TITLE_IDLE $ZSH_THEME_TERM_TITLE_IDLE } # Runs before executing the command function omz_termsupport_preexec { + [[ "${DISABLE_AUTO_TITLE:-}" == true ]] && return + emulate -L zsh setopt extended_glob - if [[ "$DISABLE_AUTO_TITLE" == true ]]; then - return + # split command into array of arguments + local -a cmdargs + cmdargs=("${(z)2}") + # if running fg, extract the command from the job description + if [[ "${cmdargs[1]}" = fg ]]; then + # get the job id from the first argument passed to the fg command + local job_id jobspec="${cmdargs[2]#%}" + # logic based on jobs arguments: + # http://zsh.sourceforge.net/Doc/Release/Jobs-_0026-Signals.html#Jobs + # https://www.zsh.org/mla/users/2007/msg00704.html + case "$jobspec" in + <->) # %number argument: + # use the same passed as an argument + job_id=${jobspec} ;; + ""|%|+) # empty, %% or %+ argument: + # use the current job, which appears with a + in $jobstates: + # suspended:+:5071=suspended (tty output) + job_id=${(k)jobstates[(r)*:+:*]} ;; + -) # %- argument: + # use the previous job, which appears with a - in $jobstates: + # suspended:-:6493=suspended (signal) + job_id=${(k)jobstates[(r)*:-:*]} ;; + [?]*) # %?string argument: + # use $jobtexts to match for a job whose command *contains* + job_id=${(k)jobtexts[(r)*${(Q)jobspec}*]} ;; + *) # %string argument: + # use $jobtexts to match for a job whose command *starts with* + job_id=${(k)jobtexts[(r)${(Q)jobspec}*]} ;; + esac + + # override preexec function arguments with job command + if [[ -n "${jobtexts[$job_id]}" ]]; then + 1="${jobtexts[$job_id]}" + 2="${jobtexts[$job_id]}" + fi fi # cmd name only, or if this is sudo or ssh, the next cmd @@ -75,8 +105,9 @@ function omz_termsupport_preexec { title '$CMD' '%100>...>$LINE%<<' } -precmd_functions+=(omz_termsupport_precmd) -preexec_functions+=(omz_termsupport_preexec) +autoload -U add-zsh-hook +add-zsh-hook precmd omz_termsupport_precmd +add-zsh-hook preexec omz_termsupport_preexec # Keep Apple Terminal.app's current working directory updated @@ -90,16 +121,17 @@ if [[ "$TERM_PROGRAM" == "Apple_Terminal" ]] && [[ -z "$INSIDE_EMACS" ]]; then function update_terminalapp_cwd() { emulate -L zsh - # Percent-encode the pathname. - local URL_PATH="$(omz_urlencode -P $PWD)" - [[ $? != 0 ]] && return 1 + # Percent-encode the host and path names. + local URL_HOST URL_PATH + URL_HOST="$(omz_urlencode -P $HOST)" || return 1 + URL_PATH="$(omz_urlencode -P $PWD)" || return 1 # Undocumented Terminal.app-specific control sequence - printf '\e]7;%s\a' "file://$HOST$URL_PATH" + printf '\e]7;%s\a' "file://$URL_HOST$URL_PATH" } # Use a precmd hook instead of a chpwd hook to avoid contaminating output - precmd_functions+=(update_terminalapp_cwd) + add-zsh-hook precmd update_terminalapp_cwd # Run once to get initial cwd set update_terminalapp_cwd fi diff --git a/zsh/lib/theme-and-appearance.zsh b/zsh/lib/theme-and-appearance.zsh index 5016d86..0b71de3 100644 --- a/zsh/lib/theme-and-appearance.zsh +++ b/zsh/lib/theme-and-appearance.zsh @@ -39,6 +39,11 @@ if [[ "$DISABLE_LS_COLORS" != "true" ]]; then fi fi +# enable diff color if possible. +if command diff --color . . &>/dev/null; then + alias diff='diff --color' +fi + setopt auto_cd setopt multios setopt prompt_subst diff --git a/zsh/oh-my-zsh.sh b/zsh/oh-my-zsh.sh index 6b2662d..16e244b 100644 --- a/zsh/oh-my-zsh.sh +++ b/zsh/oh-my-zsh.sh @@ -1,17 +1,15 @@ +# If ZSH is not defined, use the current script's directory. +[[ -z "$ZSH" ]] && export ZSH="${${(%):-%x}:a:h}" + # Set ZSH_CACHE_DIR to the path where cache files should be created # or else we will use the default cache/ if [[ -z "$ZSH_CACHE_DIR" ]]; then ZSH_CACHE_DIR="$ZSH/cache" fi -# Migrate .zsh-update file to $ZSH_CACHE_DIR -if [ -f ~/.zsh-update ] && [ ! -f ${ZSH_CACHE_DIR}/.zsh-update ]; then - mv ~/.zsh-update ${ZSH_CACHE_DIR}/.zsh-update -fi - # Check for updates on initial load... if [ "$DISABLE_AUTO_UPDATE" != "true" ]; then - env ZSH=$ZSH ZSH_CACHE_DIR=$ZSH_CACHE_DIR DISABLE_UPDATE_PROMPT=$DISABLE_UPDATE_PROMPT zsh -f $ZSH/tools/check_for_upgrade.sh + source $ZSH/tools/check_for_upgrade.sh fi # Initializes Oh My Zsh @@ -32,8 +30,8 @@ fi is_plugin() { local base_dir=$1 local name=$2 - test -f $base_dir/plugins/$name/$name.plugin.zsh \ - || test -f $base_dir/plugins/$name/_$name + builtin test -f $base_dir/plugins/$name/$name.plugin.zsh \ + || builtin test -f $base_dir/plugins/$name/_$name } # Add all defined plugins to fpath. This must be done @@ -61,6 +59,17 @@ if [ -z "$ZSH_COMPDUMP" ]; then ZSH_COMPDUMP="${ZDOTDIR:-${HOME}}/.zcompdump-${SHORT_HOST}-${ZSH_VERSION}" fi +# Construct zcompdump OMZ metadata +zcompdump_revision="#omz revision: $(builtin cd -q "$ZSH"; git rev-parse HEAD 2>/dev/null)" +zcompdump_fpath="#omz fpath: $fpath" + +# Delete the zcompdump file if OMZ zcompdump metadata changed +if ! command grep -q -Fx "$zcompdump_revision" "$ZSH_COMPDUMP" 2>/dev/null \ + || ! command grep -q -Fx "$zcompdump_fpath" "$ZSH_COMPDUMP" 2>/dev/null; then + command rm -f "$ZSH_COMPDUMP" + zcompdump_refresh=1 +fi + if [[ $ZSH_DISABLE_COMPFIX != true ]]; then source $ZSH/lib/compfix.zsh # If completion insecurities exist, warn the user @@ -72,6 +81,19 @@ else compinit -u -C -d "${ZSH_COMPDUMP}" fi +# Append zcompdump metadata if missing +if (( $zcompdump_refresh )); then + # Use `tee` in case the $ZSH_COMPDUMP filename is invalid, to silence the error + # See https://github.com/ohmyzsh/ohmyzsh/commit/dd1a7269#commitcomment-39003489 + tee -a "$ZSH_COMPDUMP" &>/dev/null <` as well as ``. + +| Function | Command | +| ------------------------- | --------------------------------- | +| ardu [URL or revision_id] | `arc diff --update` [revision_id] | +| arpa [URL or revision_id] | `arc patch` [revision_id] | diff --git a/zsh/plugins/arcanist/arcanist.plugin.zsh b/zsh/plugins/arcanist/arcanist.plugin.zsh index 3f4eb07..88e6713 100644 --- a/zsh/plugins/arcanist/arcanist.plugin.zsh +++ b/zsh/plugins/arcanist/arcanist.plugin.zsh @@ -9,13 +9,29 @@ alias arco='arc cover' alias arci='arc commit' alias ard='arc diff' +alias ardc='arc diff --create' alias ardnu='arc diff --nounit' alias ardnupc='arc diff --nounit --plan-changes' alias ardpc='arc diff --plan-changes' +alias ardp='arc diff --preview' # creates a new diff in the phab interface alias are='arc export' alias arh='arc help' alias arl='arc land' alias arli='arc lint' alias arls='arc list' -alias arpa='arc patch' + +# +# Functions +# (sorted alphabetically) +# + +ardu() { + # Both `ardu https://arcanist-url.com/`, and `ardu ` work. + arc diff --update "${1:t}" +} + +arpa() { + # Both `arpa https://arcanist-url.com/`, and `arpa ` work. + arc patch "${1:t}" +} diff --git a/zsh/plugins/archlinux/README.md b/zsh/plugins/archlinux/README.md index ff2b6a4..5882c76 100644 --- a/zsh/plugins/archlinux/README.md +++ b/zsh/plugins/archlinux/README.md @@ -1,5 +1,13 @@ # Archlinux plugin +This plugin adds some aliases and functions to work with Arch Linux. + +To use it, add `archlinux` to the plugins array in your zshrc file: + +```zsh +plugins=(... archlinux) +``` + ## Features #### YAY @@ -119,7 +127,7 @@ | pacupg | sudo pacman -Syu | Sync with repositories before upgrading packages | | upgrade | sudo pacman -Syu | Sync with repositories before upgrading packages | | pacfileupg | sudo pacman -Fy | Download fresh package databases from the server | -| pacfiles | pacman -Fs | Search package file names for matching strings | +| pacfiles | pacman -F | Search package file names for matching strings | | pacls | pacman -Ql | List files in a package | | pacown | pacman -Qo | Show which package owns a file | diff --git a/zsh/plugins/archlinux/archlinux.plugin.zsh b/zsh/plugins/archlinux/archlinux.plugin.zsh index e0101c7..4d39bd8 100644 --- a/zsh/plugins/archlinux/archlinux.plugin.zsh +++ b/zsh/plugins/archlinux/archlinux.plugin.zsh @@ -149,7 +149,7 @@ alias pacmir='sudo pacman -Syy' alias paclsorphans='sudo pacman -Qdt' alias pacrmorphans='sudo pacman -Rs $(pacman -Qtdq)' alias pacfileupg='sudo pacman -Fy' -alias pacfiles='pacman -Fs' +alias pacfiles='pacman -F' alias pacls='pacman -Ql' alias pacown='pacman -Qo' @@ -208,12 +208,12 @@ function pacmansignkeys() { if (( $+commands[xdg-open] )); then function pacweb() { pkg="$1" - infos="$(pacman -Si "$pkg")" + infos="$(LANG=C pacman -Si "$pkg")" if [[ -z "$infos" ]]; then return fi - repo="$(grep '^Repo' <<< "$infos" | grep -oP '[^ ]+$')" - arch="$(grep '^Arch' <<< "$infos" | grep -oP '[^ ]+$')" + repo="$(grep -m 1 '^Repo' <<< "$infos" | grep -oP '[^ ]+$')" + arch="$(grep -m 1 '^Arch' <<< "$infos" | grep -oP '[^ ]+$')" xdg-open "https://www.archlinux.org/packages/$repo/$arch/$pkg/" &>/dev/null } fi diff --git a/zsh/plugins/asdf/asdf.plugin.zsh b/zsh/plugins/asdf/asdf.plugin.zsh index 38b2255..c386d57 100644 --- a/zsh/plugins/asdf/asdf.plugin.zsh +++ b/zsh/plugins/asdf/asdf.plugin.zsh @@ -3,7 +3,7 @@ ASDF_DIR="${ASDF_DIR:-$HOME/.asdf}" ASDF_COMPLETIONS="$ASDF_DIR/completions" # If not found, check for Homebrew package -if [[ ! -f "$ASDF_DIR/asdf.sh" ]] && (( $+commands[brew] )); then +if [[ ! -f "$ASDF_DIR/asdf.sh" || ! -f "$ASDF_COMPLETIONS/asdf.bash" ]] && (( $+commands[brew] )); then ASDF_DIR="$(brew --prefix asdf)" ASDF_COMPLETIONS="$ASDF_DIR/etc/bash_completion.d" fi diff --git a/zsh/plugins/autoenv/README.md b/zsh/plugins/autoenv/README.md new file mode 100644 index 0000000..5dfb5fb --- /dev/null +++ b/zsh/plugins/autoenv/README.md @@ -0,0 +1,20 @@ +# Autoenv plugin + +This plugin loads the [Autoenv](https://github.com/inishchith/autoenv). + +To use it, add `autoenv` to the plugins array in your zshrc file: + +```zsh +plugins=(... autoenv) +``` + +## Functions + +* `use_env()`: creates and/or activates a virtualenv. For use in `.env` files. + See the source code for details. + +## Requirements + +In order to make this work, you will need to have the autoenv installed. + +More info on the usage and install at [the project's homepage](https://github.com/inishchith/autoenv). diff --git a/zsh/plugins/autoenv/autoenv.plugin.zsh b/zsh/plugins/autoenv/autoenv.plugin.zsh index 3c1b0fa..bd03cf4 100644 --- a/zsh/plugins/autoenv/autoenv.plugin.zsh +++ b/zsh/plugins/autoenv/autoenv.plugin.zsh @@ -1,12 +1,39 @@ -# Activates autoenv or reports its failure +# Initialization: activate autoenv or report its absence () { +local d autoenv_dir install_locations if ! type autoenv_init >/dev/null; then - for d (~/.autoenv ~/.local/bin /usr/local/opt/autoenv /usr/local/bin); do + # Check if activate.sh is in $PATH + if (( $+commands[activate.sh] )); then + autoenv_dir="${commands[activate.sh]:h}" + fi + + # Locate autoenv installation + if [[ -z $autoenv_dir ]]; then + install_locations=( + ~/.autoenv + ~/.local/bin + /usr/local/opt/autoenv + /usr/local/bin + /usr/share/autoenv-git + ~/Library/Python/bin + ) + for d ( $install_locations ); do + if [[ -e $d/activate.sh ]]; then + autoenv_dir=$d + break + fi + done + fi + + # Look for Homebrew path as a last resort + if [[ -z "$autoenv_dir" ]] && (( $+commands[brew] )); then + d=$(brew --prefix)/opt/autoenv if [[ -e $d/activate.sh ]]; then autoenv_dir=$d - break fi - done + fi + + # Complain if autoenv is not installed if [[ -z $autoenv_dir ]]; then cat <&2 -------- AUTOENV --------- @@ -17,6 +44,7 @@ In the meantime the autoenv plugin is DISABLED. END return 1 fi + # Load autoenv source $autoenv_dir/activate.sh fi } @@ -27,17 +55,17 @@ fi # It only performs an action if the requested virtualenv is not the current one. use_env() { - typeset venv - venv="$1" - if [[ "${VIRTUAL_ENV:t}" != "$venv" ]]; then - if workon | grep -q "$venv"; then - workon "$venv" - else - echo -n "Create virtualenv $venv now? (Yn) " - read answer - if [[ "$answer" == "Y" ]]; then - mkvirtualenv "$venv" - fi - fi + local venv + venv="$1" + if [[ "${VIRTUAL_ENV:t}" != "$venv" ]]; then + if workon | grep -q "$venv"; then + workon "$venv" + else + echo -n "Create virtualenv $venv now? (Yn) " + read answer + if [[ "$answer" == "Y" ]]; then + mkvirtualenv "$venv" + fi fi + fi } diff --git a/zsh/plugins/autojump/README.md b/zsh/plugins/autojump/README.md index 18ff793..750ff56 100644 --- a/zsh/plugins/autojump/README.md +++ b/zsh/plugins/autojump/README.md @@ -8,4 +8,4 @@ To use it, add `autojump` to the plugins array in your zshrc file: plugins=(... autojump) ``` -More info on the usage: https://github.com/wting/autojump +**Note:** you have to [install autojump](https://github.com/wting/autojump#installation) first. diff --git a/zsh/plugins/autojump/autojump.plugin.zsh b/zsh/plugins/autojump/autojump.plugin.zsh index d80c888..f40b0e9 100644 --- a/zsh/plugins/autojump/autojump.plugin.zsh +++ b/zsh/plugins/autojump/autojump.plugin.zsh @@ -29,6 +29,6 @@ if (( ! found && $+commands[brew] )); then fi fi -(( ! found )) && echo '[oh-my-zsh] autojump script not found' +(( ! found )) && echo '[oh-my-zsh] autojump not found. Please install it first.' unset autojump_paths file found diff --git a/zsh/plugins/aws/aws.plugin.zsh b/zsh/plugins/aws/aws.plugin.zsh index 231ac5a..7994963 100644 --- a/zsh/plugins/aws/aws.plugin.zsh +++ b/zsh/plugins/aws/aws.plugin.zsh @@ -10,7 +10,8 @@ function asp() { return fi - local available_profiles=($(aws_profiles)) + local -a available_profiles + available_profiles=($(aws_profiles)) if [[ -z "${available_profiles[(r)$1]}" ]]; then echo "${fg[red]}Profile '$1' not found in '${AWS_CONFIG_FILE:-$HOME/.aws/config}'" >&2 echo "Available profiles: ${(j:, :)available_profiles:-no profiles found}${reset_color}" >&2 @@ -30,17 +31,17 @@ function aws_change_access_key() { echo Insert the credentials when asked. asp "$1" || return 1 - aws iam create-access-key - aws configure --profile "$1" + AWS_PAGER="" aws iam create-access-key + AWS_PAGER="" aws configure --profile "$1" echo You can now safely delete the old access key running \`aws iam delete-access-key --access-key-id ID\` echo Your current keys are: - aws iam list-access-keys + AWS_PAGER="" aws iam list-access-keys } function aws_profiles() { [[ -r "${AWS_CONFIG_FILE:-$HOME/.aws/config}" ]] || return 1 - grep '\[profile' "${AWS_CONFIG_FILE:-$HOME/.aws/config}"|sed -e 's/.*profile \([a-zA-Z0-9_\.-]*\).*/\1/' + grep '\[profile' "${AWS_CONFIG_FILE:-$HOME/.aws/config}"|sed -e 's/.*profile \([a-zA-Z0-9@_\.-]*\).*/\1/' } function _aws_profiles() { @@ -61,36 +62,45 @@ fi # Load awscli completions -function _awscli-homebrew-installed() { - # check if Homebrew is installed - (( $+commands[brew] )) || return 1 +# AWS CLI v2 comes with its own autocompletion. Check if that is there, otherwise fall back +if command -v aws_completer &> /dev/null; then + autoload -Uz bashcompinit && bashcompinit + complete -C aws_completer aws +else + function _awscli-homebrew-installed() { + # check if Homebrew is installed + (( $+commands[brew] )) || return 1 - # speculatively check default brew prefix - if [ -h /usr/local/opt/awscli ]; then - _brew_prefix=/usr/local/opt/awscli - else - # ok, it is not in the default prefix - # this call to brew is expensive (about 400 ms), so at least let's make it only once - _brew_prefix=$(brew --prefix awscli) + # speculatively check default brew prefix + if [ -h /usr/local/opt/awscli ]; then + _brew_prefix=/usr/local/opt/awscli + else + # ok, it is not in the default prefix + # this call to brew is expensive (about 400 ms), so at least let's make it only once + _brew_prefix=$(brew --prefix awscli) + fi + } + + # get aws_zsh_completer.sh location from $PATH + _aws_zsh_completer_path="$commands[aws_zsh_completer.sh]" + + # otherwise check common locations + if [[ -z $_aws_zsh_completer_path ]]; then + # Homebrew + if _awscli-homebrew-installed; then + _aws_zsh_completer_path=$_brew_prefix/libexec/bin/aws_zsh_completer.sh + # Ubuntu + elif [[ -e /usr/share/zsh/vendor-completions/_awscli ]]; then + _aws_zsh_completer_path=/usr/share/zsh/vendor-completions/_awscli + # NixOS + elif [[ -e "${commands[aws]:P:h:h}/share/zsh/site-functions/aws_zsh_completer.sh" ]]; then + _aws_zsh_completer_path="${commands[aws]:P:h:h}/share/zsh/site-functions/aws_zsh_completer.sh" + # RPM + else + _aws_zsh_completer_path=/usr/share/zsh/site-functions/aws_zsh_completer.sh + fi fi -} -# get aws_zsh_completer.sh location from $PATH -_aws_zsh_completer_path="$commands[aws_zsh_completer.sh]" - -# otherwise check common locations -if [[ -z $_aws_zsh_completer_path ]]; then - # Homebrew - if _awscli-homebrew-installed; then - _aws_zsh_completer_path=$_brew_prefix/libexec/bin/aws_zsh_completer.sh - # Ubuntu - elif [[ -e /usr/share/zsh/vendor-completions/_awscli ]]; then - _aws_zsh_completer_path=/usr/share/zsh/vendor-completions/_awscli - # RPM - else - _aws_zsh_completer_path=/usr/share/zsh/site-functions/aws_zsh_completer.sh - fi + [[ -r $_aws_zsh_completer_path ]] && source $_aws_zsh_completer_path + unset _aws_zsh_completer_path _brew_prefix fi - -[[ -r $_aws_zsh_completer_path ]] && source $_aws_zsh_completer_path -unset _aws_zsh_completer_path _brew_prefix diff --git a/zsh/plugins/battery/README.md b/zsh/plugins/battery/README.md index b7a13a7..c2554a3 100644 --- a/zsh/plugins/battery/README.md +++ b/zsh/plugins/battery/README.md @@ -9,5 +9,14 @@ To use, add `battery` to the list of plugins in your `.zshrc` file: Then, add the `battery_pct_prompt` function to your custom theme. For example: ``` -RPROMPT='$(battery_pct_prompt)' +RPROMPT='$(battery_pct_prompt) ...' +``` + +## Requirements + +On Linux, you must have the `acpi` tool installed on your operating system. + +Here's an example of how to install with apt: +``` +sudo apt-get install acpi ``` diff --git a/zsh/plugins/battery/battery.plugin.zsh b/zsh/plugins/battery/battery.plugin.zsh index 8f398cf..755ec8d 100644 --- a/zsh/plugins/battery/battery.plugin.zsh +++ b/zsh/plugins/battery/battery.plugin.zsh @@ -7,23 +7,25 @@ # Email: neuralsandwich@gmail.com # # Modified to add support for Apple Mac # ########################################### +# Author: J (927589452) # +# Modified to add support for FreeBSD # +########################################### -if [[ "$OSTYPE" = darwin* ]] ; then +if [[ "$OSTYPE" = darwin* ]]; then - function battery_pct() { - local smart_battery_status="$(ioreg -rc "AppleSmartBattery")" - typeset -F maxcapacity=$(echo $smart_battery_status | grep '^.*"MaxCapacity"\ =\ ' | sed -e 's/^.*"MaxCapacity"\ =\ //') - typeset -F currentcapacity=$(echo $smart_battery_status | grep '^.*"CurrentCapacity"\ =\ ' | sed -e 's/^.*CurrentCapacity"\ =\ //') - integer i=$(((currentcapacity/maxcapacity) * 100)) - echo $i + function battery_is_charging() { + ioreg -rc AppleSmartBattery | command grep -q '^.*"ExternalConnected"\ =\ Yes' } - function plugged_in() { - [ $(ioreg -rc AppleSmartBattery | grep -c '^.*"ExternalConnected"\ =\ Yes') -eq 1 ] + function battery_pct() { + local battery_status="$(ioreg -rc AppleSmartBattery)" + local -i capacity=$(sed -n -e '/MaxCapacity/s/^.*"MaxCapacity"\ =\ //p' <<< $battery_status) + local -i current=$(sed -n -e '/CurrentCapacity/s/^.*"CurrentCapacity"\ =\ //p' <<< $battery_status) + echo $(( current * 100 / capacity )) } function battery_pct_remaining() { - if plugged_in ; then + if battery_is_charging; then echo "External Power" else battery_pct @@ -32,9 +34,9 @@ if [[ "$OSTYPE" = darwin* ]] ; then function battery_time_remaining() { local smart_battery_status="$(ioreg -rc "AppleSmartBattery")" - if [[ $(echo $smart_battery_status | grep -c '^.*"ExternalConnected"\ =\ No') -eq 1 ]] ; then - timeremaining=$(echo $smart_battery_status | grep '^.*"AvgTimeToEmpty"\ =\ ' | sed -e 's/^.*"AvgTimeToEmpty"\ =\ //') - if [ $timeremaining -gt 720 ] ; then + if [[ $(echo $smart_battery_status | command grep -c '^.*"ExternalConnected"\ =\ No') -eq 1 ]]; then + timeremaining=$(echo $smart_battery_status | command grep '^.*"AvgTimeToEmpty"\ =\ ' | sed -e 's/^.*"AvgTimeToEmpty"\ =\ //') + if [ $timeremaining -gt 720 ]; then echo "::" else echo "~$((timeremaining / 60)):$((timeremaining % 60))" @@ -45,39 +47,36 @@ if [[ "$OSTYPE" = darwin* ]] ; then } function battery_pct_prompt () { - if [[ $(ioreg -rc AppleSmartBattery | grep -c '^.*"ExternalConnected"\ =\ No') -eq 1 ]] ; then - b=$(battery_pct_remaining) - if [ $b -gt 50 ] ; then + local battery_pct color + if ioreg -rc AppleSmartBattery | command grep -q '^.*"ExternalConnected"\ =\ No'; then + battery_pct=$(battery_pct_remaining) + if [[ $battery_pct -gt 50 ]]; then color='green' - elif [ $b -gt 20 ] ; then + elif [[ $battery_pct -gt 20 ]]; then color='yellow' else color='red' fi - echo "%{$fg[$color]%}[$(battery_pct_remaining)%%]%{$reset_color%}" + echo "%{$fg[$color]%}[${battery_pct}%%]%{$reset_color%}" else echo "∞" fi } - function battery_is_charging() { - [[ $(ioreg -rc "AppleSmartBattery"| grep '^.*"IsCharging"\ =\ ' | sed -e 's/^.*"IsCharging"\ =\ //') == "Yes" ]] - } - -elif [[ "$OSTYPE" = linux* ]] ; then +elif [[ "$OSTYPE" = freebsd* ]]; then function battery_is_charging() { - ! [[ $(acpi 2>/dev/null | grep -c '^Battery.*Discharging') -gt 0 ]] + [[ $(sysctl -n hw.acpi.battery.state) -eq 2 ]] } function battery_pct() { - if (( $+commands[acpi] )) ; then - echo "$(acpi 2>/dev/null | cut -f2 -d ',' | tr -cd '[:digit:]')" + if (( $+commands[sysctl] )); then + sysctl -n hw.acpi.battery.life fi } function battery_pct_remaining() { - if [ ! $(battery_is_charging) ] ; then + if ! battery_is_charging; then battery_pct else echo "External Power" @@ -85,76 +84,128 @@ elif [[ "$OSTYPE" = linux* ]] ; then } function battery_time_remaining() { - if [[ $(acpi 2>/dev/null | grep -c '^Battery.*Discharging') -gt 0 ]] ; then - echo $(acpi 2>/dev/null | cut -f3 -d ',') + local remaining_time + remaining_time=$(sysctl -n hw.acpi.battery.time) + if [[ $remaining_time -ge 0 ]]; then + ((hour = $remaining_time / 60 )) + ((minute = $remaining_time % 60 )) + printf %02d:%02d $hour $minute fi } function battery_pct_prompt() { - b=$(battery_pct_remaining) - if [[ $(acpi 2>/dev/null | grep -c '^Battery.*Discharging') -gt 0 ]] ; then - if [ $b -gt 50 ] ; then + local battery_pct color + battery_pct=$(battery_pct_remaining) + if battery_is_charging; then + echo "∞" + else + if [[ $battery_pct -gt 50 ]]; then color='green' - elif [ $b -gt 20 ] ; then + elif [[ $battery_pct -gt 20 ]]; then color='yellow' else color='red' fi - echo "%{$fg[$color]%}$(battery_pct_remaining)%%%{$reset_color%}" + echo "%{$fg[$color]%}${battery_pct}%%%{$reset_color%}" + fi + } + +elif [[ "$OSTYPE" = linux* ]]; then + + function battery_is_charging() { + ! acpi 2>/dev/null | command grep -v "rate information unavailable" | command grep -q '^Battery.*Discharging' + } + + function battery_pct() { + if (( $+commands[acpi] )); then + acpi 2>/dev/null | command grep -v "rate information unavailable" | command grep -E '^Battery.*(Full|(Disc|C)harging)' | cut -f2 -d ',' | tr -cd '[:digit:]' + fi + } + + function battery_pct_remaining() { + if ! battery_is_charging; then + battery_pct else + echo "External Power" + fi + } + + function battery_time_remaining() { + if ! battery_is_charging; then + acpi 2>/dev/null | command grep -v "rate information unavailable" | cut -f3 -d ',' + fi + } + + function battery_pct_prompt() { + local battery_pct color + battery_pct=$(battery_pct_remaining) + if battery_is_charging; then echo "∞" + else + if [[ $battery_pct -gt 50 ]]; then + color='green' + elif [[ $battery_pct -gt 20 ]]; then + color='yellow' + else + color='red' + fi + echo "%{$fg[$color]%}${battery_pct}%%%{$reset_color%}" fi } else # Empty functions so we don't cause errors in prompts - function battery_pct_remaining() { - } - - function battery_time_remaining() { - } - - function battery_pct_prompt() { - } + function battery_is_charging { false } + function battery_pct \ + battery_pct_remaining \ + battery_time_remaining \ + battery_pct_prompt { } fi function battery_level_gauge() { - local gauge_slots=${BATTERY_GAUGE_SLOTS:-10}; - local green_threshold=${BATTERY_GREEN_THRESHOLD:-6}; - local yellow_threshold=${BATTERY_YELLOW_THRESHOLD:-4}; - local color_green=${BATTERY_COLOR_GREEN:-%F{green}}; - local color_yellow=${BATTERY_COLOR_YELLOW:-%F{yellow}}; - local color_red=${BATTERY_COLOR_RED:-%F{red}}; - local color_reset=${BATTERY_COLOR_RESET:-%{%f%k%b%}}; - local battery_prefix=${BATTERY_GAUGE_PREFIX:-'['}; - local battery_suffix=${BATTERY_GAUGE_SUFFIX:-']'}; - local filled_symbol=${BATTERY_GAUGE_FILLED_SYMBOL:-'▶'}; - local empty_symbol=${BATTERY_GAUGE_EMPTY_SYMBOL:-'▷'}; - local charging_color=${BATTERY_CHARGING_COLOR:-$color_yellow}; - local charging_symbol=${BATTERY_CHARGING_SYMBOL:-'⚡'}; + local gauge_slots=${BATTERY_GAUGE_SLOTS:-10} + local green_threshold=${BATTERY_GREEN_THRESHOLD:-$(( gauge_slots * 0.6 ))} + local yellow_threshold=${BATTERY_YELLOW_THRESHOLD:-$(( gauge_slots * 0.4 ))} + local color_green=${BATTERY_COLOR_GREEN:-%F{green}} + local color_yellow=${BATTERY_COLOR_YELLOW:-%F{yellow}} + local color_red=${BATTERY_COLOR_RED:-%F{red}} + local color_reset=${BATTERY_COLOR_RESET:-%{%f%k%b%}} + local battery_prefix=${BATTERY_GAUGE_PREFIX:-'['} + local battery_suffix=${BATTERY_GAUGE_SUFFIX:-']'} + local filled_symbol=${BATTERY_GAUGE_FILLED_SYMBOL:-'▶'} + local empty_symbol=${BATTERY_GAUGE_EMPTY_SYMBOL:-'▷'} + local charging_color=${BATTERY_CHARGING_COLOR:-$color_yellow} + local charging_symbol=${BATTERY_CHARGING_SYMBOL:-'⚡'} - local battery_remaining_percentage=$(battery_pct); + local battery_remaining_percentage=$(battery_pct) + local filled empty gauge_color if [[ $battery_remaining_percentage =~ [0-9]+ ]]; then - local filled=$(((( $battery_remaining_percentage + $gauge_slots - 1) / $gauge_slots))); - local empty=$(($gauge_slots - $filled)); + filled=$(( ($battery_remaining_percentage * $gauge_slots) / 100 )) + empty=$(( $gauge_slots - $filled )) - if [[ $filled -gt $green_threshold ]]; then local gauge_color=$color_green; - elif [[ $filled -gt $yellow_threshold ]]; then local gauge_color=$color_yellow; - else local gauge_color=$color_red; + if [[ $filled -gt $green_threshold ]]; then + gauge_color=$color_green + elif [[ $filled -gt $yellow_threshold ]]; then + gauge_color=$color_yellow + else + gauge_color=$color_red fi else - local filled=$gauge_slots; - local empty=0; - filled_symbol=${BATTERY_UNKNOWN_SYMBOL:-'.'}; + filled=$gauge_slots + empty=0 + filled_symbol=${BATTERY_UNKNOWN_SYMBOL:-'.'} fi - local charging=' ' && battery_is_charging && charging=$charging_symbol; + local charging=' ' + battery_is_charging && charging=$charging_symbol - printf ${charging_color//\%/\%\%}$charging${color_reset//\%/\%\%}${battery_prefix//\%/\%\%}${gauge_color//\%/\%\%} - printf ${filled_symbol//\%/\%\%}'%.0s' {1..$filled} + # Charging status and prefix + print -n ${charging_color}${charging}${color_reset}${battery_prefix}${gauge_color} + # Filled slots + [[ $filled -gt 0 ]] && printf ${filled_symbol//\%/\%\%}'%.0s' {1..$filled} + # Empty slots [[ $filled -lt $gauge_slots ]] && printf ${empty_symbol//\%/\%\%}'%.0s' {1..$empty} - printf ${color_reset//\%/\%\%}${battery_suffix//\%/\%\%}${color_reset//\%/\%\%} + # Suffix + print -n ${color_reset}${battery_suffix}${color_reset} } - - diff --git a/zsh/plugins/bazel/README.md b/zsh/plugins/bazel/README.md new file mode 100644 index 0000000..e5ffe6e --- /dev/null +++ b/zsh/plugins/bazel/README.md @@ -0,0 +1,5 @@ +## Bazel autocomplete plugin + +A copy of the completion script from the +[bazelbuild/bazel](https://github.com/bazelbuild/bazel/master/scripts/zsh_completion/_bazel) +git repo. diff --git a/zsh/plugins/bazel/_bazel b/zsh/plugins/bazel/_bazel new file mode 100644 index 0000000..827ce54 --- /dev/null +++ b/zsh/plugins/bazel/_bazel @@ -0,0 +1,341 @@ +#compdef bazel + +# Copyright 2015 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Installation +# ------------ +# +# 1. Add this script to a directory on your $fpath: +# fpath[1,0]=~/.zsh/completion/ +# mkdir -p ~/.zsh/completion/ +# cp scripts/zsh_completion/_bazel ~/.zsh/completion +# +# 2. Optionally, add the following to your .zshrc. +# zstyle ':completion:*' use-cache on +# zstyle ':completion:*' cache-path ~/.zsh/cache +# +# This way, the completion script does not have to parse Bazel's options +# repeatedly. The directory in cache-path must be created manually. +# +# 3. Restart the shell +# +# Options +# ------- +# completion:init:bazel:* cache-lifetime +# Lifetime for the completion cache (if turned on, default: 1 week) + +local curcontext="$curcontext" state line + +: ${BAZEL_COMPLETION_PACKAGE_PATH:=%workspace%} +: ${BAZEL:=bazel} +_bazel_b() { ${BAZEL} --noblock_for_lock "$@" 2>/dev/null; } + +# Default cache lifetime is 1 week +zstyle -s ":completion:${curcontext}:" cache-lifetime lifetime +if [[ -z "${lifetime}" ]]; then + lifetime=$((60*60*24*7)) +fi + +_bazel_cache_policy() { + local -a oldp + oldp=( "$1"(Nms+${lifetime}) ) + (( $#oldp )) +} + +_set_cache_policy() { + zstyle -s ":completion:*:$curcontext*" cache-policy update_policy + + if [[ -z "$update_policy" ]]; then + zstyle ":completion:$curcontext*" cache-policy _bazel_cache_policy + fi +} + +# Skips over all global arguments. After invocation, OFFSET contains the +# position of the bazel command in $words. +_adapt_subcommand_offset() { + OFFSET=2 + for w in ${words[2,-1]}; do + if [[ $w == (#b)-* ]]; then + (( OFFSET++ )) + else + return + fi + done +} + +# Retrieve the cache but also check that the value is not empty. +_bazel_safe_retrieve_cache() { + _retrieve_cache $1 && [[ ${(P)#2} -gt 0 ]] +} + +# Puts the name of the variable that contains the options for the bazel +# subcommand handed in as the first argument into the global variable +# _bazel_cmd_options. +_bazel_get_options() { + local lcmd=$1 + _bazel_cmd_options=_bazel_${lcmd}_options + _bazel_cmd_args=_bazel_${lcmd}_args + if [[ ${(P)#_bazel_cmd_options} != 0 ]]; then + return + fi + if _cache_invalid BAZEL_${lcmd}_options || _cache_invalid BAZEL_${lcmd}_args \ + || ! _bazel_safe_retrieve_cache BAZEL_${lcmd}_options ${_bazel_cmd_options} \ + || ! _retrieve_cache BAZEL_${lcmd}_args ${_bazel_cmd_args}; then + if ! eval "$(_bazel_b help completion)"; then + return + fi + local opts_var + if [[ $lcmd == "startup_options" ]]; then + opts_var="BAZEL_STARTUP_OPTIONS" + else + opts_var="BAZEL_COMMAND_${lcmd:u}_FLAGS" + fi + local -a raw_options + if ! eval "raw_options=(\${(@f)$opts_var})"; then + return + fi + + local -a option_list + for opt in $raw_options; do + case $opt in + --*"={"*) + local lst="${${opt##*"={"}%"}"}" + local opt="${opt%%=*}=" + option_list+=("${opt}:string:_values '' ${lst//,/ }") ;; + --*=path) + option_list+=("${opt%path}:path:_files") ;; + --*=label) + option_list+=("${opt%label}:target:_bazel_complete_target") ;; + --*=*) + option_list+=("${opt}:string:") ;; + *) + option_list+=("$opt") ;; + esac + done + + local -a cmd_args + local cmd_type + if eval "cmd_type=\${BAZEL_COMMAND_${lcmd:u}_ARGUMENT}" && [[ -n $cmd_type ]]; then + case $cmd_type in + label|label-*) + cmd_args+=("*::${cmd_type}:_bazel_complete_target_${cmd_type//-/_}") ;; + info-key) + cmd_args+=('1::key:_bazel_info_key') ;; + path) + cmd_args+=('1::profile:_path_files') ;; + "command|{"*"}") + local lst=${${cmd_type#"command|{"}%"}"} + cmd_args+=("1::topic:_bazel_help_topic -- ${lst//,/ }") ;; + esac + fi + + typeset -g "${_bazel_cmd_options}"="${(pj:|:)option_list[*]}" + _store_cache BAZEL_${lcmd}_options ${_bazel_cmd_options} + typeset -g "${_bazel_cmd_args}"="${(pj:|:)cmd_args[*]}" + _store_cache BAZEL_${lcmd}_args ${_bazel_cmd_args} + fi +} + +_get_build_targets() { + local pkg=$1 + local rule_re + typeset -a completions + case $target_type in + test) + rule_re=".*_test" + ;; + build) + rule_re=".*" + ;; + bin) + rule_re=".*_test|.*_binary" + ;; + esac + completions=(${$(_bazel_b query "kind(\"${rule_re}\", ${pkg}:all)" 2>/dev/null)##*:}) + if ( (( ${#completions} > 0 )) && [[ $target_type != run ]] ); then + completions+=(all) + fi + echo ${completions[*]} +} + +# Returns all packages that match $PREFIX. PREFIX may start with //, in which +# case the workspace roots are searched. Otherwise, they are completed based on +# PWD. +_get_build_packages() { + local workspace pfx + typeset -a package_roots paths final_paths + workspace=$PWD + package_roots=(${(ps.:.)BAZEL_COMPLETION_PACKAGE_PATH}) + package_roots=(${^package_roots//\%workspace\%/$workspace}) + if [[ "${(e)PREFIX}" == //* ]]; then + pfx=${(e)PREFIX[2,-1]} + else + pfx=${(e)PREFIX} + fi + paths=(${^package_roots}/${pfx}*(/)) + for p in ${paths[*]}; do + if [[ -f ${p}/BUILD || -f ${p}/BUILD.bazel ]]; then + final_paths+=(${p##*/}:) + fi + final_paths+=(${p##*/}/) + done + echo ${final_paths[*]} +} + +_package_remove_slash() { + if [[ $KEYS == ':' && $LBUFFER == */ ]]; then + LBUFFER=${LBUFFER[1,-2]} + fi +} + +# Completion function for BUILD targets, called by the completion system. +_bazel_complete_target() { + local expl + typeset -a packages targets + if [[ "${(e)PREFIX}" != *:* ]]; then + # There is no : in the prefix, completion can be either + # a package or a target, if the cwd is a package itself. + if [[ -f $PWD/BUILD || -f $PWD/BUILD.bazel ]]; then + targets=($(_get_build_targets "")) + _description build_target expl "BUILD target" + compadd "${expl[@]}" -a targets + fi + packages=($(_get_build_packages)) + _description build_package expl "BUILD package" + # Chop of the leading path segments from the prefix for display. + compset -P '*/' + compadd -R _package_remove_slash -S '' "${expl[@]}" -a packages + else + targets=($(_get_build_targets "${${(e)PREFIX}%:*}")) + _description build_target expl "BUILD target" + # Ignore the current prefix for the upcoming completion, since we only list + # the names of the targets, not the full path. + compset -P '*:' + compadd "${expl[@]}" -a targets + fi +} + +_bazel_complete_target_label() { + typeset -g target_type=build + _bazel_complete_target +} + +_bazel_complete_target_label_test() { + typeset -g target_type=test + _bazel_complete_target +} + +_bazel_complete_target_label_bin() { + typeset -g target_type=bin + _bazel_complete_target +} + +### Actual completion commands + +_bazel() { + _adapt_subcommand_offset + if (( CURRENT - OFFSET > 0 )); then + # Remember the subcommand name, stored globally so we can access it + # from any subsequent function + cmd=${words[OFFSET]//-/_} + + # Set the context for the subcommand. + curcontext="${curcontext%:*:*}:bazel-$cmd:" + _set_cache_policy + + # Narrow the range of words we are looking at to exclude cmd + # name and any leading options + (( CURRENT = CURRENT - OFFSET + 1 )) + shift $((OFFSET - 1)) words + # Run the completion for the subcommand + _bazel_get_options $cmd + _arguments : \ + ${(Pps:|:)_bazel_cmd_options} \ + ${(Pps:|:)_bazel_cmd_args} + else + _set_cache_policy + # Start special handling for global options, + # which can be retrieved by calling + # $ bazel help startup_options + _bazel_get_options startup_options + _arguments : \ + ${(Pps:|:)_bazel_cmd_options} \ + "*:commands:_bazel_commands" + fi + return +} + +_get_commands() { + # bazel_cmd_list is a global (g) array (a) + typeset -ga _bazel_cmd_list + # Use `bazel help` instead of `bazel help completion` to get command + # descriptions. + if _bazel_cmd_list=("${(@f)$(_bazel_b help | awk ' +/Available commands/ { command=1; } +/ [-a-z]+[ \t]+.+/ { if (command) { printf "%s:", $1; for (i=2; i<=NF; i++) printf "%s ", $i; print "" } } +/^$/ { command=0; }')}"); then + _store_cache BAZEL_commands _bazel_cmd_list + fi +} + +# Completion function for bazel subcommands, called by the completion system. +_bazel_commands() { + if [[ ${#_bazel_cmd_list} == 0 ]]; then + if _cache_invalid BAZEL_commands \ + || ! _bazel_safe_retrieve_cache BAZEL_commands _bazel_cmd_list; then + _get_commands + fi + fi + + _describe -t bazel-commands 'Bazel command' _bazel_cmd_list +} + +# Completion function for bazel help options, called by the completion system. +_bazel_help_topic() { + if [[ ${#_bazel_cmd_list} == 0 ]]; then + if _cache_invalid BAZEL_commands \ + || ! _bazel_safe_retrieve_cache BAZEL_commands _bazel_cmd_list; then + _get_commands + fi + fi + + while [[ $# -gt 0 ]]; do + if [[ $1 == -- ]]; then + shift + break + fi + shift + done + _bazel_help_list=($@) + _bazel_help_list+=($_bazel_cmd_list) + _describe -t bazel-help 'Help topic' _bazel_help_list +} + +# Completion function for bazel info keys, called by the completion system. +_bazel_info_key() { + if [[ ${#_bazel_info_keys_list} == 0 ]]; then + if _cache_invalid BAZEL_info_keys \ + || ! _bazel_safe_retrieve_cache BAZEL_info_keys _bazel_info_keys_list; then + typeset -ga _bazel_info_keys_list + # Use `bazel help` instead of `bazel help completion` to get info-key + # descriptions. + if _bazel_info_keys_list=("${(@f)$(_bazel_b help info-keys | awk ' + { printf "%s:", $1; for (i=2; i<=NF; i++) printf "%s ", $i; print "" }')}"); then + _store_cache BAZEL_info_keys _bazel_info_keys_list + fi + fi + fi + _describe -t bazel-info 'Key' _bazel_info_keys_list +} diff --git a/zsh/plugins/bgnotify/bgnotify.plugin.zsh b/zsh/plugins/bgnotify/bgnotify.plugin.zsh index b3a6890..aecde20 100644 --- a/zsh/plugins/bgnotify/bgnotify.plugin.zsh +++ b/zsh/plugins/bgnotify/bgnotify.plugin.zsh @@ -53,7 +53,7 @@ bgnotify () { ## args: (title, subtitle) bgnotify_begin() { bgnotify_timestamp=$EPOCHSECONDS - bgnotify_lastcmd="$1" + bgnotify_lastcmd="${1:-$2}" bgnotify_windowid=$(currentWindowId) } diff --git a/zsh/plugins/bower/README.md b/zsh/plugins/bower/README.md index 743b6a0..8877fbd 100644 --- a/zsh/plugins/bower/README.md +++ b/zsh/plugins/bower/README.md @@ -4,7 +4,7 @@ This plugin adds completion for [Bower](https://bower.io/) and a few useful alia To use it, add `bower` to the plugins array in your zshrc file: -``` +```zsh plugins=(... bower) ``` @@ -15,4 +15,3 @@ plugins=(... bower) | bi | `bower install` | Installs the project dependencies listed in bower.json | | bl | `bower list` | List local packages and possible updates | | bs | `bower search` | Finds all packages or a specific package. | - diff --git a/zsh/plugins/brew/README.md b/zsh/plugins/brew/README.md index c129a76..b714b7a 100644 --- a/zsh/plugins/brew/README.md +++ b/zsh/plugins/brew/README.md @@ -3,19 +3,28 @@ The plugin adds several aliases for common [brew](https://brew.sh) commands. To use it, add `brew` to the plugins array of your zshrc file: -``` + +```zsh plugins=(... brew) ``` ## Aliases -| Alias | Command | Description | -|--------|----------------------|---------------| -| brewp | `brew pin` | Pin a specified formulae, preventing them from being upgraded when issuing the brew upgrade command. | -| brews | `brew list -1` | List installed formulae, one entry per line, or the installed files for a given formulae. | -| brewsp | `brew list --pinned` | Show the versions of pinned formulae, or only the specified (pinned) formulae if formulae are given. | -| bubo | `brew update && brew outdated` | Fetch the newest version of Homebrew and all formulae, then list outdated formulae. | -| bubc | `brew upgrade && brew cleanup` | Upgrade outdated, unpinned brews (with existing install options), then removes stale lock files and outdated downloads for formulae and casks, and removes old versions of installed formulae. | -| bubu | `bubo && bubc` | Updates Homebrew, lists outdated formulae, upgrades oudated and unpinned formulae, and removes stale and outdated downloads and versions. | -| bcubo | `brew update && brew cask outdated` | Fetch the newest version of Homebrew and all formulae, then list outdated casks. | -| bcubc | `brew cask reinstall $(brew cask outdated) && brew cleanup` | Updates outdated casks, then runs cleanup. | \ No newline at end of file +| Alias | Command | Description | +|----------|------------------------------------------------------------- |---------------------------------------------------------------------| +| `brewp` | `brew pin` | Pin a specified formula so that it's not upgraded. | +| `brews` | `brew list -1` | List installed formulae or the installed files for a given formula. | +| `brewsp` | `brew list --pinned` | List pinned formulae, or show the version of a given formula. | +| `bubo` | `brew update && brew outdated` | Update Homebrew data, then list outdated formulae and casks. | +| `bubc` | `brew upgrade && brew cleanup` | Upgrade outdated formulae and casks, then run cleanup. | +| `bubu` | `bubo && bubc` | Do the last two operations above. | +| `buf` | `brew upgrade --formula` | Upgrade only formulas (not casks). | +| `bcubo` | `brew update && brew outdated --cask` | Update Homebrew data, then list outdated casks. | +| `bcubc` | `brew cask reinstall $(brew outdated --cask) && brew cleanup` | Update outdated casks, then run cleanup. | + +## Completion + +With the release of Homebrew 1.0, they decided to bundle the zsh completion as part of the +brew installation, so we no longer ship it with the brew plugin; now it only has brew +aliases. If you find that brew completion no longer works, make sure you have your Homebrew +installation fully up to date. diff --git a/zsh/plugins/brew/brew.plugin.zsh b/zsh/plugins/brew/brew.plugin.zsh index cfbaa34..30eb135 100644 --- a/zsh/plugins/brew/brew.plugin.zsh +++ b/zsh/plugins/brew/brew.plugin.zsh @@ -4,21 +4,6 @@ alias brewsp='brew list --pinned' alias bubo='brew update && brew outdated' alias bubc='brew upgrade && brew cleanup' alias bubu='bubo && bubc' -alias bcubo='brew update && brew cask outdated' -alias bcubc='brew cask reinstall $(brew cask outdated) && brew cleanup' - -if command mkdir "$ZSH_CACHE_DIR/.brew-completion-message" 2>/dev/null; then - print -P '%F{yellow}'Oh My Zsh brew plugin: - cat <<-'EOF' - - With the advent of their 1.0 release, Homebrew has decided to bundle - the zsh completion as part of the brew installation, so we no longer - ship it with the brew plugin; now it only has brew aliases. - - If you find that brew completion no longer works, make sure you have - your Homebrew installation fully up to date. - - You will only see this message once. - EOF - print -P '%f' -fi +alias buf='brew upgrade --formula' +alias bcubo='brew update && brew outdated --cask' +alias bcubc='brew cask reinstall $(brew outdated --cask) && brew cleanup' diff --git a/zsh/plugins/bundler/README.md b/zsh/plugins/bundler/README.md index dc2f170..7b79cbc 100644 --- a/zsh/plugins/bundler/README.md +++ b/zsh/plugins/bundler/README.md @@ -1,52 +1,74 @@ # Bundler -- adds completion for basic bundler commands -- adds short aliases for common bundler commands - - `be` aliased to `bundle exec`. - It also supports aliases (if `rs` is `rails server`, `be rs` will bundle-exec `rails server`). - - `bl` aliased to `bundle list` - - `bp` aliased to `bundle package` - - `bo` aliased to `bundle open` - - `bout` aliased to `bundle outdated` - - `bu` aliased to `bundle update` - - `bi` aliased to `bundle install --jobs=` (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 ` otherwise +This plugin adds completion for basic bundler commands, as well as aliases and helper functions for +an easier experience with bundler. + +To use it, add `bundler` to the plugins array in your zshrc file: + +```zsh +plugins=(... bundler) +``` + +## Aliases + +| Alias | Command | Description | +|--------|--------------------------------------|------------------------------------------------------------------------------------------| +| `ba` | `bundle add` | Add gem to the Gemfile and run bundle install | +| `bck` | `bundle check` | Verifies if dependencies are satisfied by installed gems | +| `bcn` | `bundle clean` | Cleans up unused gems in your bundler directory | +| `be` | `bundle exec` | Execute a command in the context of the bundle | +| `bi` | `bundle install --jobs=` | Install the dependencies specified in your Gemfile (using all cores in bundler >= 1.4.0) | +| `bl` | `bundle list` | List all the gems in the bundle | +| `bo` | `bundle open` | Opens the source directory for a gem in your bundle | +| `bout` | `bundle outdated` | List installed gems with newer versions available | +| `bp` | `bundle package` | Package your needed .gem files into your application | +| `bu` | `bundle update` | Update your gems to the latest available versions | + +## Gem wrapper + +The plugin adds a wrapper for common gems, which: + +- Looks for a binstub under `./bin/` and executes it if present. +- Calls `bundle exec ` otherwise. Common gems wrapped by default (by name of the executable): -`annotate`, `cap`, `capify`, `cucumber`, `foodcritic`, `guard`, `hanami`, `irb`, `jekyll`, `kitchen`, `knife`, `middleman`, `nanoc`, `pry`, `puma`, `rackup`, `rainbows`, `rake`, `rspec`, `shotgun`, `sidekiq`, `spec`, `spork`, `spring`, `strainer`, `tailor`, `taps`, `thin`, `thor`, `unicorn` and `unicorn_rails`. -## Configuration +`annotate`, `cap`, `capify`, `cucumber`, `foodcritic`, `guard`, `hanami`, `irb`, `jekyll`, `kitchen`, `knife`, `middleman`, `nanoc`, `pry`, `puma`, `rackup`, `rainbows`, `rake`, `rspec`, `rubocop`, `shotgun`, `sidekiq`, `spec`, `spork`, `spring`, `strainer`, `tailor`, `taps`, `thin`, `thor`, `unicorn` and `unicorn_rails`. -Please use the exact name of the executable and not the gem name. +### Settings -### Add additional gems to be wrapped +You can add or remove gems from the list of wrapped commands. +Please **use the exact name of the executable** and not the gem name. + +#### Include gems to be wrapped (`BUNDLED_COMMANDS`) + +Add this before the plugin list in your `.zshrc`: -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 (`UNBUNDLED_COMMANDS`) -### Exclude gems from being wrapped +Add this before the plugin list in your `.zshrc`: -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 +### Excluded gems -These gems should not be called with `bundle exec`. Please see [issue #2923](https://github.com/robbyrussell/oh-my-zsh/pull/2923) on GitHub for clarification. +These gems should not be called with `bundle exec`. Please see [issue #2923](https://github.com/ohmyzsh/ohmyzsh/pull/2923) on GitHub for clarification: -`berks` -`foreman` -`mailcatcher` -`rails` -`ruby` -`spin` +- `berks` +- `foreman` +- `mailcatcher` +- `rails` +- `ruby` +- `spin` diff --git a/zsh/plugins/bundler/bundler.plugin.zsh b/zsh/plugins/bundler/bundler.plugin.zsh index 668e15d..6293dc2 100644 --- a/zsh/plugins/bundler/bundler.plugin.zsh +++ b/zsh/plugins/bundler/bundler.plugin.zsh @@ -1,11 +1,49 @@ +## Aliases + +alias ba="bundle add" +alias bck="bundle check" +alias bcn="bundle clean" alias be="bundle exec" +alias bi="bundle_install" alias bl="bundle list" -alias bp="bundle package" alias bo="bundle open" alias bout="bundle outdated" +alias bp="bundle package" alias bu="bundle update" -alias bi="bundle_install" -alias bcn="bundle clean" + +## Functions + +bundle_install() { + # Bail out if bundler is not installed + if (( ! $+commands[bundle] )); then + echo "Bundler is not installed" + return 1 + fi + + # Bail out if not in a bundled project + if ! _within-bundled-project; then + echo "Can't 'bundle install' outside a bundled project" + return 1 + fi + + # Check the bundler version is at least 1.4.0 + autoload -Uz is-at-least + local bundler_version=$(bundle version | cut -d' ' -f3) + if ! is-at-least 1.4.0 "$bundler_version"; then + bundle install "$@" + return $? + fi + + # If bundler is at least 1.4.0, use all the CPU cores to bundle install + if [[ "$OSTYPE" = (darwin|freebsd)* ]]; then + local cores_num="$(sysctl -n hw.ncpu)" + else + local cores_num="$(nproc)" + fi + bundle install --jobs="$cores_num" "$@" +} + +## Gem wrapper bundled_commands=( annotate @@ -27,6 +65,7 @@ bundled_commands=( rainbows rake rspec + rubocop shotgun sidekiq spec @@ -51,65 +90,41 @@ for cmd in $BUNDLED_COMMANDS; do bundled_commands+=($cmd); done -## Functions - -bundle_install() { - if ! _bundler-installed; then - echo "Bundler is not installed" - elif ! _within-bundled-project; then - echo "Can't 'bundle install' outside a bundled project" - else - local bundler_version=`bundle version | cut -d' ' -f3` - if [[ $bundler_version > '1.4.0' || $bundler_version = '1.4.0' ]]; then - if [[ "$OSTYPE" = (darwin|freebsd)* ]] - then - local cores_num="$(sysctl -n hw.ncpu)" - else - local cores_num="$(nproc)" - fi - bundle install --jobs=$cores_num $@ - else - bundle install $@ - fi - fi -} - -_bundler-installed() { - which bundle > /dev/null 2>&1 -} - +# Check if in the root or a subdirectory of a bundled project _within-bundled-project() { local check_dir="$PWD" - while [ "$check_dir" != "/" ]; do - [ -f "$check_dir/Gemfile" ] && return - check_dir="$(dirname $check_dir)" + while [[ "$check_dir" != "/" ]]; do + if [[ -f "$check_dir/Gemfile" || -f "$check_dir/gems.rb" ]]; then + return 0 + fi + check_dir="${check_dir:h}" done - false -} - -_binstubbed() { - [ -f "./bin/${1}" ] + return 1 } _run-with-bundler() { - if _bundler-installed && _within-bundled-project; then - if _binstubbed $1; then - ./bin/$@ - else - bundle exec $@ - fi + if (( ! $+commands[bundle] )) || ! _within-bundled-project; then + "$@" + return $? + fi + + if [[ -f "./bin/${1}" ]]; then + ./bin/${^^@} else - $@ + bundle exec "$@" fi } -## Main program for cmd in $bundled_commands; do - eval "function unbundled_$cmd () { $cmd \$@ }" - eval "function bundled_$cmd () { _run-with-bundler $cmd \$@}" - alias $cmd=bundled_$cmd + # Create wrappers for bundled and unbundled execution + eval "function unbundled_$cmd () { \"$cmd\" \"\$@\"; }" + eval "function bundled_$cmd () { _run-with-bundler \"$cmd\" \"\$@\"; }" + alias "$cmd"="bundled_$cmd" - if which _$cmd > /dev/null 2>&1; then - compdef _$cmd bundled_$cmd=$cmd + # Bind completion function to wrapped gem if available + if (( $+functions[_$cmd] )); then + compdef "_$cmd" "bundled_$cmd"="$cmd" fi done + +unset cmd bundled_commands diff --git a/zsh/plugins/cake/README.md b/zsh/plugins/cake/README.md index aad92a3..2c2a280 100644 --- a/zsh/plugins/cake/README.md +++ b/zsh/plugins/cake/README.md @@ -10,6 +10,6 @@ plugins=(... cake) ## Note -This plugin generates a cache file of the cake tasks found, named `.cake_task_cache`, in the current working directory. +This plugin generates a cache file of the cake tasks found, named `.cake_task_cache`, in the current working directory. It is regenerated when the Cakefile is newer than the cache file. It is advised that you add the cake file to your `.gitignore` files. diff --git a/zsh/plugins/cakephp3/README.md b/zsh/plugins/cakephp3/README.md new file mode 100644 index 0000000..7e8f664 --- /dev/null +++ b/zsh/plugins/cakephp3/README.md @@ -0,0 +1,16 @@ +# cakephp3 plugin + +The plugin adds aliases and autocompletion for [cakephp3](https://book.cakephp.org/3.0/en/index.html). + +To use it, add `cakephp3` to the plugins array of your zshrc file: +``` +plugins=(... cakephp3) +``` + +## Aliases + +| Alias | Command | +|-----------|-------------------------------| +| c3 | `bin/cake` | +| c3cache | `bin/cake orm_cache clear` | +| c3migrate | `bin/cake migrations migrate` | diff --git a/zsh/plugins/cargo/_cargo b/zsh/plugins/cargo/_cargo index 395c517..1269490 100644 --- a/zsh/plugins/cargo/_cargo +++ b/zsh/plugins/cargo/_cargo @@ -2,489 +2,367 @@ autoload -U regexp-replace -zstyle -T ':completion:*:*:cargo:*' tag-order && \ - zstyle ':completion:*:*:cargo:*' tag-order 'common-commands' - _cargo() { -local context state state_descr line -typeset -A opt_args + local curcontext="$curcontext" ret=1 + local -a command_scope_spec common parallel features msgfmt triple target registry + local -a state line state_descr # These are set by _arguments + typeset -A opt_args -# leading items in parentheses are an exclusion list for the arguments following that arg -# See: http://zsh.sourceforge.net/Doc/Release/Completion-System.html#Completion-Functions -# - => exclude all other options -# 1 => exclude positional arg 1 -# * => exclude all other args -# +blah => exclude +blah -_arguments \ - '(- 1 *)'{-h,--help}'[show help message]' \ - '(- 1 *)--list[list installed commands]' \ - '(- 1 *)'{-V,--version}'[show version information]' \ - {-v,--verbose}'[use verbose output]' \ - --color'[colorization option]' \ - '(+beta +nightly)+stable[use the stable toolchain]' \ - '(+stable +nightly)+beta[use the beta toolchain]' \ - '(+stable +beta)+nightly[use the nightly toolchain]' \ - '1: :->command' \ - '*:: :->args' + common=( + '(-q --quiet)*'{-v,--verbose}'[use verbose output]' + '(-q --quiet -v --verbose)'{-q,--quiet}'[no output printed to stdout]' + '-Z+[pass unstable (nightly-only) flags to cargo]: :_cargo_unstable_flags' + '--frozen[require that Cargo.lock and cache are up-to-date]' + '--locked[require that Cargo.lock is up-to-date]' + '--color=[specify colorization option]:coloring:(auto always never)' + '(- 1 *)'{-h,--help}'[show help message]' + ) -case $state in - command) - _alternative 'common-commands:common:_cargo_cmds' 'all-commands:all:_cargo_all_cmds' - ;; + # leading items in parentheses are an exclusion list for the arguments following that arg + # See: http://zsh.sourceforge.net/Doc/Release/Completion-System.html#Completion-Functions + # - => exclude all other options + # 1 => exclude positional arg 1 + # * => exclude all other args + # +blah => exclude +blah + _arguments -s -S -C $common \ + '(- 1 *)--list[list installed commands]' \ + '(- 1 *)--explain=[provide a detailed explanation of an error message]:error code' \ + '(- 1 *)'{-V,--version}'[show version information]' \ + '(+beta +nightly)+stable[use the stable toolchain]' \ + '(+stable +nightly)+beta[use the beta toolchain]' \ + '(+stable +beta)+nightly[use the nightly toolchain]' \ + '1: :_cargo_cmds' \ + '*:: :->args' - args) - case $words[1] in - bench) - _arguments \ - '--features=[space separated feature list]' \ - '--all-features[enable all available features]' \ - '(-h, --help)'{-h,--help}'[show help message]' \ - '(-j, --jobs)'{-j,--jobs}'[number of parallel jobs, defaults to # of CPUs]' \ - "${command_scope_spec[@]}" \ - '--manifest-path=[path to manifest]: :_files -/' \ - '--no-default-features[do not build the default features]' \ - '--no-run[compile but do not run]' \ - '(-p,--package)'{-p=,--package=}'[package to run benchmarks for]:packages:_get_package_names' \ - '--target=[target triple]' \ - '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \ - '(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \ - '--color=:colorization option:(auto always never)' \ - ;; + # These flags are mutually exclusive specifiers for the scope of a command; as + # they are used in multiple places without change, they are expanded into the + # appropriate command's `_arguments` where appropriate. + command_scope_spec=( + '(--bin --example --test --lib)--bench=[specify benchmark name]: :_cargo_benchmark_names' + '(--bench --bin --test --lib)--example=[specify example name]:example name' + '(--bench --example --test --lib)--bin=[specify binary name]:binary name' + '(--bench --bin --example --test)--lib=[specify library name]:library name' + '(--bench --bin --example --lib)--test=[specify test name]:test name' + ) - build) - _arguments \ - '--features=[space separated feature list]' \ - '--all-features[enable all available features]' \ - '(-h, --help)'{-h,--help}'[show help message]' \ - '(-j, --jobs)'{-j,--jobs}'[number of parallel jobs, defaults to # of CPUs]' \ - "${command_scope_spec[@]}" \ - '--manifest-path=[path to manifest]: :_files -/' \ - '--no-default-features[do not build the default features]' \ - '(-p,--package)'{-p=,--package=}'[package to build]:packages:_get_package_names' \ - '--release=[build in release mode]' \ - '--target=[target triple]' \ - '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \ - '(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \ - '--color=:colorization option:(auto always never)' \ - ;; + parallel=( + '(-j --jobs)'{-j+,--jobs=}'[specify number of parallel jobs]:jobs [# of CPUs]' + ) - check) - _arguments \ - '--features=[space separated feature list]' \ - '--all-features[enable all available features]' \ - '(-h, --help)'{-h,--help}'[show help message]' \ - '(-j, --jobs)'{-j,--jobs}'[number of parallel jobs, defaults to # of CPUs]' \ - "${command_scope_spec[@]}" \ - '--manifest-path=[path to manifest]: :_files -/' \ - '--no-default-features[do not check the default features]' \ - '(-p,--package)'{-p=,--package=}'[package to check]:packages:_get_package_names' \ - '--release=[check in release mode]' \ - '--target=[target triple]' \ - '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \ - '(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \ - '--color=:colorization option:(auto always never)' \ - ;; + features=( + '(--all-features)--features=[specify features to activate]:feature' + '(--features)--all-features[activate all available features]' + "--no-default-features[don't build the default features]" + ) - clean) - _arguments \ - '(-h, --help)'{-h,--help}'[show help message]' \ - '--manifest-path=[path to manifest]: :_files -/' \ - '(-p,--package)'{-p=,--package=}'[package to clean]:packages:_get_package_names' \ - '(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \ - '--release[whether or not to clean release artifacts]' \ - '--target=[target triple(default:all)]' \ - '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \ - '--color=:colorization option:(auto always never)' \ - ;; + msgfmt='--message-format=[specify error format]:error format [human]:(human json short)' + triple='--target=[specify target triple]:target triple' + target='--target-dir=[specify directory for all generated artifacts]:directory:_directories' + manifest='--manifest-path=[specify path to manifest]:path:_directories' + registry='--registry=[specify registry to use]:registry' - doc) - _arguments \ - '--features=[space separated feature list]' \ - '--all-features[enable all available features]' \ - '(-h, --help)'{-h,--help}'[show help message]' \ - '(-j, --jobs)'{-j,--jobs}'[number of parallel jobs, defaults to # of CPUs]' \ - '--manifest-path=[path to manifest]: :_files -/' \ - '--no-deps[do not build docs for dependencies]' \ - '--no-default-features[do not build the default features]' \ - '--open[open docs in browser after the build]' \ - '(-p, --package)'{-p,--package}'=[package to document]' \ - '(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \ - '--release[build artifacts in release mode, with optimizations]' \ - '--target=[build for the target triple]' \ - '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \ - '--color=:colorization option:(auto always never)' \ - ;; + case $state in + args) + curcontext="${curcontext%:*}-${words[1]}:" + case ${words[1]} in + bench) + _arguments -s -A "^--" $common $parallel $features $msgfmt $triple $target $manifest \ + "${command_scope_spec[@]}" \ + '--all-targets[benchmark all targets]' \ + "--no-run[compile but don't run]" \ + '(-p --package)'{-p+,--package=}'[specify package to run benchmarks for]:package:_cargo_package_names' \ + '--exclude=[exclude packages from the benchmark]:spec' \ + '--no-fail-fast[run all benchmarks regardless of failure]' \ + '1: :_guard "^-*" "bench name"' \ + '*:args:_default' + ;; - fetch) - _arguments \ - '(-h, --help)'{-h,--help}'[show help message]' \ - '--manifest-path=[path to manifest]: :_files -/' \ - '(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \ - '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \ - '--color=:colorization option:(auto always never)' \ - ;; + build) + _arguments -s -S $common $parallel $features $msgfmt $triple $target $manifest \ + '--all-targets[equivalent to specifying --lib --bins --tests --benches --examples]' \ + "${command_scope_spec[@]}" \ + '(-p --package)'{-p+,--package=}'[specify package to build]:package:_cargo_package_names' \ + '--release[build in release mode]' \ + '--build-plan[output the build plan in JSON]' \ + ;; - generate-lockfile) - _arguments \ - '(-h, --help)'{-h,--help}'[show help message]' \ - '--manifest-path=[path to manifest]: :_files -/' \ - '(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \ - '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \ - '--color=:colorization option:(auto always never)' \ - ;; + check) + _arguments -s -S $common $parallel $features $msgfmt $triple $target $manifest \ + '--all-targets[equivalent to specifying --lib --bins --tests --benches --examples]' \ + "${command_scope_spec[@]}" \ + '(-p --package)'{-p+,--package=}'[specify package to check]:package:_cargo_package_names' \ + '--release[check in release mode]' \ + ;; - git-checkout) - _arguments \ - '(-h, --help)'{-h,--help}'[show help message]' \ - '(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \ - '--reference=[REF]' \ - '--url=[URL]' \ - '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \ - '--color=:colorization option:(auto always never)' \ - ;; + clean) + _arguments -s -S $common $triple $target $manifest \ + '(-p --package)'{-p+,--package=}'[specify package to clean]:package:_cargo_package_names' \ + '--release[clean release artifacts]' \ + '--doc[clean just the documentation directory]' + ;; - help) - _arguments \ - '(-h, --help)'{-h,--help}'[show help message]' \ - '*: :_cargo_cmds' \ - ;; + doc) + _arguments -s -S $common $parallel $features $msgfmt $triple $target $manifest \ + '--no-deps[do not build docs for dependencies]' \ + '--document-private-items[include non-public items in the documentation]' \ + '--open[open docs in browser after the build]' \ + '(-p --package)'{-p+,--package=}'[specify package to document]:package:_cargo_package_names' \ + '--release[build artifacts in release mode, with optimizations]' \ + ;; - init) - _arguments \ - '--bin[use binary template]' \ - '--vcs:initialize a new repo with a given VCS:(git hg none)' \ - '(-h, --help)'{-h,--help}'[show help message]' \ - '--name=[set the resulting package name]' \ - '(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \ - '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \ - '--color=:colorization option:(auto always never)' \ - ;; + fetch) + _arguments -s -S $common $triple $manifest + ;; - install) - _arguments \ - '--bin=[only install the specified binary]' \ - '--branch=[branch to use when installing from git]' \ - '--color=:colorization option:(auto always never)' \ - '--debug[build in debug mode instead of release mode]' \ - '--example[install the specified example instead of binaries]' \ - '--features=[space separated feature list]' \ - '--all-features[enable all available features]' \ - '--git=[URL from which to install the crate]' \ - '(-h, --help)'{-h,--help}'[show help message]' \ - '(-j, --jobs)'{-j,--jobs}'[number of parallel jobs, defaults to # of CPUs]' \ - '--no-default-features[do not build the default features]' \ - '--path=[local filesystem path to crate to install]: :_files -/' \ - '(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \ - '--rev=[specific commit to use when installing from git]' \ - '--root=[directory to install packages into]: :_files -/' \ - '--tag=[tag to use when installing from git]' \ - '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \ - '--vers=[version to install from crates.io]' \ - ;; + fix) + _arguments -s -S $common $parallel $features $msgfmt $triple $target $manifest \ + "${command_scope_spec[@]}" \ + '--broken-code[fix code even if it already has compiler errors]' \ + '--edition[fix in preparation for the next edition]' \ + '--edition-idioms[fix warnings to migrate to the idioms of an edition]' \ + '--allow-no-vcs[fix code even if a VCS was not detected]' \ + '--allow-dirty[fix code even if the working directory is dirty]' \ + '--allow-staged[fix code even if the working directory has staged changes]' + ;; - locate-project) - _arguments \ - '(-h, --help)'{-h,--help}'[show help message]' \ - '--manifest-path=[path to manifest]: :_files -/' \ - ;; + generate-lockfile) + _arguments -s -S $common $manifest + ;; - login) - _arguments \ - '(-h, --help)'{-h,--help}'[show help message]' \ - '--host=[Host to set the token for]' \ - '(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \ - '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \ - '--color=:colorization option:(auto always never)' \ - ;; + git-checkout) + _arguments -s -S $common \ + '--reference=:reference' \ + '--url=:url:_urls' + ;; - metadata) - _arguments \ - '(-h, --help)'{-h,--help}'[show help message]' \ - '(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \ - '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \ - "--no-deps[output information only about the root package and don't fetch dependencies]" \ - '--no-default-features[do not include the default feature]' \ - '--manifest-path=[path to manifest]: :_files -/' \ - '--features=[space separated feature list]' \ - '--all-features[enable all available features]' \ - '--format-version=[format version(default: 1)]' \ - '--color=:colorization option:(auto always never)' \ - ;; + help) + _cargo_cmds + ;; - new) - _arguments \ - '--bin[use binary template]' \ - '--vcs:initialize a new repo with a given VCS:(git hg none)' \ - '(-h, --help)'{-h,--help}'[show help message]' \ - '--name=[set the resulting package name]' \ - '(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \ - '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \ - '--color=:colorization option:(auto always never)' \ - ;; + init) + _arguments -s -S $common $registry \ + '--lib[use library template]' \ + '--edition=[specify edition to set for the crate generated]:edition:(2015 2018)' \ + '--vcs=[initialize a new repo with a given VCS]:vcs:(git hg pijul fossil none)' \ + '--name=[set the resulting package name]:name' \ + '1:path:_directories' + ;; - owner) - _arguments \ - '(-a, --add)'{-a,--add}'[add owner LOGIN]' \ - '(-h, --help)'{-h,--help}'[show help message]' \ - '--index[registry index]' \ - '(-l, --list)'{-l,--list}'[list owners of a crate]' \ - '(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \ - '(-r, --remove)'{-r,--remove}'[remove owner LOGIN]' \ - '--token[API token to use when authenticating]' \ - '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \ - '--color=:colorization option:(auto always never)' \ - ;; + install) + _arguments -s -S $common $parallel $features $triple $registry \ + '(-f --force)'{-f,--force}'[force overwriting of existing crates or binaries]' \ + '--bin=[only install the specified binary]:binary' \ + '--branch=[branch to use when installing from git]:branch' \ + '--debug[build in debug mode instead of release mode]' \ + '--example=[install the specified example instead of binaries]:example' \ + '--git=[specify URL from which to install the crate]:url:_urls' \ + '--path=[local filesystem path to crate to install]: :_directories' \ + '--rev=[specific commit to use when installing from git]:commit' \ + '--root=[directory to install packages into]: :_directories' \ + '--tag=[tag to use when installing from git]:tag' \ + '--vers=[version to install from crates.io]:version' \ + '--list[list all installed packages and their versions]' \ + '*: :_guard "^-*" "crate"' + ;; - package) - _arguments \ - '(-h, --help)'{-h,--help}'[show help message]' \ - '(-l, --list)'{-l,--list}'[print files included in a package without making one]' \ - '--manifest-path=[path to manifest]: :_files -/' \ - '--no-metadata[ignore warnings about a lack of human-usable metadata]' \ - '--no-verify[do not build to verify contents]' \ - '(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \ - '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \ - '--color=:colorization option:(auto always never)' \ - ;; + locate-project) + _arguments -s -S $common $manifest + ;; - pkgid) - _arguments \ - '(-h, --help)'{-h,--help}'[show help message]' \ - '--manifest-path=[path to manifest]: :_files -/' \ - '(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \ - '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \ - '--color=:colorization option:(auto always never)' \ - ;; + login) + _arguments -s -S $common $registry \ + '*: :_guard "^-*" "token"' + ;; - publish) - _arguments \ - '(-h, --help)'{-h,--help}'[show help message]' \ - '--host=[Host to set the token for]' \ - '--manifest-path=[path to manifest]: :_files -/' \ - '--no-verify[Do not verify tarball until before publish]' \ - '(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \ - '--token[token to use when uploading]' \ - '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \ - '--color=:colorization option:(auto always never)' \ - ;; + metadata) + _arguments -s -S $common $features $manifest \ + "--no-deps[output information only about the root package and don't fetch dependencies]" \ + '--format-version=[specify format version]:version [1]:(1)' + ;; - read-manifest) - _arguments \ - '(-h, --help)'{-h,--help}'[show help message]' \ - '--manifest-path=[path to manifest]: :_files -/' \ - '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \ - '--color=:colorization option:(auto always never)' \ - ;; + new) + _arguments -s -S $common $registry \ + '--lib[use library template]' \ + '--vcs:initialize a new repo with a given VCS:(git hg none)' \ + '--name=[set the resulting package name]' + ;; - run) - _arguments \ - '--example=[name of the bin target]' \ - '--features=[space separated feature list]' \ - '--all-features[enable all available features]' \ - '(-h, --help)'{-h,--help}'[show help message]' \ - '(-j, --jobs)'{-j,--jobs}'[number of parallel jobs, defaults to # of CPUs]' \ - '--manifest-path=[path to manifest]: :_files -/' \ - '--bin=[name of the bin target]' \ - '--no-default-features[do not build the default features]' \ - '(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \ - '--release=[build in release mode]' \ - '--target=[target triple]' \ - '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \ - '--color=:colorization option:(auto always never)' \ - '*: :_normal' \ - ;; + owner) + _arguments -s -S $common $registry \ + '(-a --add)'{-a,--add}'[specify name of a user or team to invite as an owner]:name' \ + '--index=[specify registry index]:index' \ + '(-l --list)'{-l,--list}'[list owners of a crate]' \ + '(-r --remove)'{-r,--remove}'[specify name of a user or team to remove as an owner]:name' \ + '--token=[specify API token to use when authenticating]:token' \ + '*: :_guard "^-*" "crate"' + ;; - rustc) - _arguments \ - '--color=:colorization option:(auto always never)' \ - '--features=[features to compile for the package]' \ - '--all-features[enable all available features]' \ - '(-h, --help)'{-h,--help}'[show help message]' \ - '(-j, --jobs)'{-j,--jobs}'=[number of parallel jobs, defaults to # of CPUs]' \ - '--manifest-path=[path to the manifest to fetch dependencies for]: :_files -/' \ - '--no-default-features[do not compile default features for the package]' \ - '(-p, --package)'{-p,--package}'=[profile to compile for]' \ - '--profile=[profile to build the selected target for]' \ - '(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \ - '--release[build artifacts in release mode, with optimizations]' \ - '--target=[target triple which compiles will be for]' \ - '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \ - "${command_scope_spec[@]}" \ - ;; + package) + _arguments -s -S $common $parallel $features $triple $target $manifest \ + '(-l --list)'{-l,--list}'[print files included in a package without making one]' \ + '--no-metadata[ignore warnings about a lack of human-usable metadata]' \ + '--allow-dirty[allow dirty working directories to be packaged]' \ + "--no-verify[don't build to verify contents]" + ;; - rustdoc) - _arguments \ - '--color=:colorization option:(auto always never)' \ - '--features=[space-separated list of features to also build]' \ - '--all-features[enable all available features]' \ - '(-h, --help)'{-h,--help}'[show help message]' \ - '(-j, --jobs)'{-j,--jobs}'=[number of parallel jobs, defaults to # of CPUs]' \ - '--manifest-path=[path to the manifest to document]: :_files -/' \ - '--no-default-features[do not build the `default` feature]' \ - '--open[open the docs in a browser after the operation]' \ - '(-p, --package)'{-p,--package}'=[package to document]' \ - '(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \ - '--release[build artifacts in release mode, with optimizations]' \ - '--target=[build for the target triple]' \ - '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \ - "${command_scope_spec[@]}" \ - ;; + pkgid) + _arguments -s -S $common $manifest \ + '(-p --package)'{-p+,--package=}'[specify package to get ID specifier for]:package:_cargo_package_names' \ + '*: :_guard "^-*" "spec"' + ;; - search) - _arguments \ - '--color=:colorization option:(auto always never)' \ - '(-h, --help)'{-h,--help}'[show help message]' \ - '--host=[host of a registry to search in]' \ - '--limit=[limit the number of results]' \ - '(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \ - '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \ - ;; + publish) + _arguments -s -S $common $parallel $features $triple $target $manifest $registry \ + '--index=[specify registry index]:index' \ + '--allow-dirty[allow dirty working directories to be packaged]' \ + "--no-verify[don't verify the contents by building them]" \ + '--token=[specify token to use when uploading]:token' \ + '--dry-run[perform all checks without uploading]' + ;; - test) - _arguments \ - '--features=[space separated feature list]' \ - '--all-features[enable all available features]' \ - '(-h, --help)'{-h,--help}'[show help message]' \ - '(-j, --jobs)'{-j,--jobs}'[number of parallel jobs, defaults to # of CPUs]' \ - '--manifest-path=[path to manifest]: :_files -/' \ - '--test=[test name]: :_test_names' \ - '--no-default-features[do not build the default features]' \ - '--no-fail-fast[run all tests regardless of failure]' \ - '--no-run[compile but do not run]' \ - '(-p,--package)'{-p=,--package=}'[package to run tests for]:packages:_get_package_names' \ - '(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \ - '--release[build artifacts in release mode, with optimizations]' \ - '--target=[target triple]' \ - '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \ - '--color=:colorization option:(auto always never)' \ - '1: :_test_names' \ - '(--doc --bin --example --test --bench)--lib[only test library]' \ - '(--lib --bin --example --test --bench)--doc[only test documentation]' \ - '(--lib --doc --example --test --bench)--bin=[binary name]' \ - '(--lib --doc --bin --test --bench)--example=[example name]' \ - '(--lib --doc --bin --example --bench)--test=[test name]' \ - '(--lib --doc --bin --example --test)--bench=[benchmark name]' \ - '--message-format:error format:(human json short)' \ - '--frozen[require lock and cache up to date]' \ - '--locked[require lock up to date]' - ;; + read-manifest) + _arguments -s -S $common $manifest + ;; - uninstall) - _arguments \ - '--bin=[only uninstall the binary NAME]' \ - '--color=:colorization option:(auto always never)' \ - '(-h, --help)'{-h,--help}'[show help message]' \ - '(-q, --quiet)'{-q,--quiet}'[less output printed to stdout]' \ - '--root=[directory to uninstall packages from]: :_files -/' \ - '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \ - ;; + run) + _arguments -s -S $common $parallel $features $msgfmt $triple $target $manifest \ + '--example=[name of the bin target]:name' \ + '--bin=[name of the bin target]:name' \ + '(-p --package)'{-p+,--package=}'[specify package with the target to run]:package:_cargo_package_names' \ + '--release[build in release mode]' \ + '*: :_default' + ;; - update) - _arguments \ - '--aggressive=[force dependency update]' \ - '(-h, --help)'{-h,--help}'[show help message]' \ - '--manifest-path=[path to manifest]: :_files -/' \ - '(-p,--package)'{-p=,--package=}'[package to update]:packages:__get_package_names' \ - '--precise=[update single dependency to PRECISE]: :' \ - '(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \ - '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \ - '--color=:colorization option:(auto always never)' \ - ;; + rustc) + _arguments -s -S $common $parallel $features $msgfmt $triple $target $manifest \ + '(-p --package)'{-p+,--package=}'[specify package to build]:package:_cargo_package_names' \ + '--profile=[specify profile to build the selected target for]:profile' \ + '--release[build artifacts in release mode, with optimizations]' \ + "${command_scope_spec[@]}" \ + '*: : _dispatch rustc rustc -default-' + ;; - verify-project) - _arguments \ - '(-h, --help)'{-h,--help}'[show help message]' \ - '--manifest-path=[path to manifest]: :_files -/' \ - '(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \ - '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \ - '--color=:colorization option:(auto always never)' \ - ;; + rustdoc) + _arguments -s -S $common $parallel $features $msgfmt $triple $target $manifest \ + '--document-private-items[include non-public items in the documentation]' \ + '--open[open the docs in a browser after the operation]' \ + '(-p --package)'{-p+,--package=}'[specify package to document]:package:_cargo_package_names' \ + '--release[build artifacts in release mode, with optimizations]' \ + "${command_scope_spec[@]}" \ + '*: : _dispatch rustdoc rustdoc -default-' + ;; - version) - _arguments \ - '(-h, --help)'{-h,--help}'[show help message]' \ - '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \ - '--color=:colorization option:(auto always never)' \ - ;; + search) + _arguments -s -S $common $registry \ + '--index=[specify registry index]:index' \ + '--limit=[limit the number of results]:results [10]' \ + '*: :_guard "^-*" "query"' + ;; - yank) - _arguments \ - '(-h, --help)'{-h,--help}'[show help message]' \ - '--index[registry index]' \ - '(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \ - '--token[API token to use when authenticating]' \ - '--undo[undo a yank, putting a version back into the index]' \ - '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \ - '--color=:colorization option:(auto always never)' \ - '--vers[yank version]' \ - ;; - esac - ;; -esac + test) + _arguments -s -S $common $parallel $features $msgfmt $triple $target $manifest \ + '--test=[test name]: :_cargo_test_names' \ + '--no-fail-fast[run all tests regardless of failure]' \ + '--no-run[compile but do not run]' \ + '(-p --package)'{-p+,--package=}'[package to run tests for]:package:_cargo_package_names' \ + '--all[test all packages in the workspace]' \ + '--release[build artifacts in release mode, with optimizations]' \ + '1: :_cargo_test_names' \ + '(--doc --bin --example --test --bench)--lib[only test library]' \ + '(--lib --bin --example --test --bench)--doc[only test documentation]' \ + '(--lib --doc --example --test --bench)--bin=[binary name]' \ + '(--lib --doc --bin --test --bench)--example=[example name]' \ + '(--lib --doc --bin --example --bench)--test=[test name]' \ + '(--lib --doc --bin --example --test)--bench=[benchmark name]' \ + '*: :_default' + ;; + + uninstall) + _arguments -s -S $common \ + '(-p --package)'{-p+,--package=}'[specify package to uninstall]:package:_cargo_package_names' \ + '--bin=[only uninstall the specified binary]:name' \ + '--root=[directory to uninstall packages from]: :_files -/' \ + '*:crate:_cargo_installed_crates -F line' + ;; + + update) + _arguments -s -S $common $manifest \ + '--aggressive=[force dependency update]' \ + "--dry-run[don't actually write the lockfile]" \ + '(-p --package)'{-p+,--package=}'[specify package to update]:package:_cargo_package_names' \ + '--precise=[update single dependency to precise release]:release' + ;; + + verify-project) + _arguments -s -S $common $manifest + ;; + + version) + _arguments -s -S $common + ;; + + yank) + _arguments -s -S $common $registry \ + '--vers=[specify yank version]:version' \ + '--undo[undo a yank, putting a version back into the index]' \ + '--index=[specify registry index to yank from]:registry index' \ + '--token=[specify API token to use when authenticating]:token' \ + '*: :_guard "^-*" "crate"' + ;; + *) + # allow plugins to define their own functions + if ! _call_function ret _cargo-${words[1]}; then + # fallback on default completion for unknown commands + _default && ret=0 + fi + (( ! ret )) + ;; + esac + ;; + esac } -_cargo_cmds(){ -local -a commands;commands=( -'bench:execute all benchmarks of a local package' -'build:compile the current package' -'check:check the current package without compiling' -'clean:remove generated artifacts' -'doc:build package documentation' -'fetch:fetch package dependencies' -'generate-lockfile:create lockfile' -'git-checkout:git checkout' -'help:get help for commands' -'init:create new package in current directory' -'install:install a Rust binary' -'locate-project:print "Cargo.toml" location' -'login:login to remote server' -'metadata:the metadata for a package in json' -'new:create a new package' -'owner:manage the owners of a crate on the registry' -'package:assemble local package into a distributable tarball' -'pkgid:print a fully qualified package specification' -'publish:upload package to the registry' -'read-manifest:print manifest in JSON format' -'run:run the main binary of the local package' -'rustc:compile a package and all of its dependencies' -'rustdoc:build documentation for a package' -'search:search packages on crates.io' -'test:execute all unit and tests of a local package' -'uninstall:remove a Rust binary' -'update:update dependencies' -'verify-project:check Cargo.toml' -'version:show version information' -'yank:remove pushed file from index' -) -_describe -t common-commands 'common commands' commands +_cargo_unstable_flags() { + local flags + flags=( help ${${${(M)${(f)"$(_call_program flags cargo -Z help)"}:#*--*}/ #-- #/:}##*-Z } ) + _describe -t flags 'unstable flag' flags } -_cargo_all_cmds(){ -local -a commands;commands=($(cargo --list)) -_describe -t all-commands 'all commands' commands +_cargo_installed_crates() { + local expl + _description crates expl 'crate' + compadd "$@" "$expl[@]" - ${${${(f)"$(cargo install --list)"}:# *}%% *} +} + +_cargo_cmds() { + local -a commands + # This uses Parameter Expansion Flags, which are a built-in Zsh feature. + # See more: http://zsh.sourceforge.net/Doc/Release/Expansion.html#Parameter-Expansion-Flags + # and http://zsh.sourceforge.net/Doc/Release/Expansion.html#Parameter-Expansion + # + # # How this work? + # + # First it splits the result of `cargo --list` at newline, then it removes the first line. + # Then it removes indentation (4 whitespaces) before each items. (Note the x## pattern [1]). + # Then it replaces those spaces between item and description with a `:` + # + # [1]: https://github.com/zsh-users/zsh-completions/blob/master/zsh-completions-howto.org#patterns + commands=( ${${${(M)"${(f)$(_call_program commands cargo --list)}":# *}/ ##/}/ ##/:} ) + _describe -t commands 'command' commands } #FIXME: Disabled until fixed #gets package names from the manifest file -_get_package_names() -{ -} - -#TODO:see if it makes sense to have 'locate-project' to have non-json output. -#strips package name from json stuff -_locate_manifest(){ -local manifest=`cargo locate-project 2>/dev/null` -regexp-replace manifest '\{"root":"|"\}' '' -echo $manifest +_cargo_package_names() { + _message -e packages package } # Extracts the values of "name" from the array given in $1 and shows them as # command line options for completion -_get_names_from_array() -{ - local -a filelist; - local manifest=$(_locate_manifest) +_cargo_names_from_array() { + # strip json from the path + local manifest=${${${"$(cargo locate-project)"}%\"\}}##*\"} if [[ -z $manifest ]]; then return 0 fi @@ -494,51 +372,36 @@ _get_names_from_array() local in_block=false local block_name=$1 names=() - while read line - do + while read -r line; do if [[ $last_line == "[[$block_name]]" ]]; then in_block=true else - if [[ $last_line =~ '.*\[\[.*' ]]; then + if [[ $last_line =~ '\s*\[\[.*' ]]; then in_block=false fi fi if [[ $in_block == true ]]; then - if [[ $line =~ '.*name.*=' ]]; then - regexp-replace line '^.*name *= *|"' "" - names+=$line + if [[ $line =~ '\s*name\s*=' ]]; then + regexp-replace line '^\s*name\s*=\s*|"' '' + names+=( "$line" ) fi fi last_line=$line - done < $manifest - _describe $block_name names + done < "$manifest" + _describe "$block_name" names } #Gets the test names from the manifest file -_test_names() -{ - _get_names_from_array "test" +_cargo_test_names() { + _cargo_names_from_array "test" } #Gets the bench names from the manifest file -_benchmark_names() -{ - _get_names_from_array "bench" +_cargo_benchmark_names() { + _cargo_names_from_array "bench" } -# These flags are mutually exclusive specifiers for the scope of a command; as -# they are used in multiple places without change, they are expanded into the -# appropriate command's `_arguments` where appropriate. -set command_scope_spec -command_scope_spec=( - '(--bin --example --test --lib)--bench=[benchmark name]: :_benchmark_names' - '(--bench --bin --test --lib)--example=[example name]' - '(--bench --example --test --lib)--bin=[binary name]' - '(--bench --bin --example --test)--lib=[library name]' - '(--bench --bin --example --lib)--test=[test name]' -) - _cargo diff --git a/zsh/plugins/catimg/README.md b/zsh/plugins/catimg/README.md index 2fc28a1..8f26880 100644 --- a/zsh/plugins/catimg/README.md +++ b/zsh/plugins/catimg/README.md @@ -2,28 +2,16 @@ Plugin for displaying images on the terminal using the the `catimg.sh` script provided by [posva](https://github.com/posva/catimg) +To use it, add `catimg` to the plugins array in your zshrc file: + +```zsh +plugins=(... catimg) +``` + ## Requirements - `convert` (ImageMagick) -## Enabling the plugin - -1. Open your `.zshrc` file and add `catimg` in the plugins section: - - ```zsh - plugins=( - # all your enabled plugins - catimg - ) - ``` - -2. Reload the source file or restart your Terminal session: - - ```console - $ source ~/.zshrc - $ - ``` - ## Functions | Function | Description | diff --git a/zsh/plugins/chruby/README.md b/zsh/plugins/chruby/README.md new file mode 100644 index 0000000..d373006 --- /dev/null +++ b/zsh/plugins/chruby/README.md @@ -0,0 +1,20 @@ +# chruby plugin + +This plugin loads [chruby](https://github.com/postmodern/chruby), a tool that changes the +current Ruby version, and completion and a prompt function to display the Ruby version. +Supports brew and manual installation of chruby. + +To use it, add `chruby` to the plugins array in your zshrc file: +```zsh +plugins=(... chruby) +``` + +## Usage + +If you'd prefer to specify an explicit path to load chruby from +you can set variables like so: + +``` +zstyle :omz:plugins:chruby path /local/path/to/chruby.sh +zstyle :omz:plugins:chruby auto /local/path/to/auto.sh +``` diff --git a/zsh/plugins/chucknorris/README.md b/zsh/plugins/chucknorris/README.md index be7b97e..35f9891 100644 --- a/zsh/plugins/chucknorris/README.md +++ b/zsh/plugins/chucknorris/README.md @@ -1,6 +1,6 @@ # chucknorris -Chuck Norris fortunes plugin for oh-my-zsh +Chuck Norris fortunes plugin for oh-my-zsh. Perfectly suitable as MOTD. **Maintainers**: [apjanke](https://github.com/apjanke) [maff](https://github.com/maff) @@ -10,11 +10,31 @@ To use it add `chucknorris` to the plugins array in you zshrc file. plugins=(... chucknorris) ``` - -Depends on fortune (and cowsay if using chuck_cow) being installed (available via homebrew, apt, ...). Perfectly suitable as MOTD. - +## Usage | Command | Description | | ----------- | ------------------------------- | | `chuck` | Print random Chuck Norris quote | | `chuck_cow` | Print quote in cowthink | + +Example: output of `chuck_cow`: + +``` +Last login: Fri Jan 30 23:12:26 on ttys001 + ______________________________________ +( When Chuck Norris plays Monopoly, it ) +( affects the actual world economy. ) + -------------------------------------- + o ^__^ + o (oo)\_______ + (__)\ )\/\ + ||----w | + || || +``` + +## Requirements + +- `fortune` +- `cowsay` if using `chuck_cow` + +Available via homebrew, apt, ... diff --git a/zsh/plugins/chucknorris/fortunes/chucknorris b/zsh/plugins/chucknorris/fortunes/chucknorris index 2a13b06..0eb6e2e 100644 --- a/zsh/plugins/chucknorris/fortunes/chucknorris +++ b/zsh/plugins/chucknorris/fortunes/chucknorris @@ -1,2544 +1,560 @@ -When the Boogeyman goes to sleep every night, he checks his closet for Chuck Norris. -% -Chuck Norris doesn't read books. He stares them down until he gets the information he wants. -% -There is no theory of evolution. Just a list of creatures Chuck Norris has allowed to live. -% -Outer space exists because it's afraid to be on the same planet with Chuck Norris. -% -Chuck Norris does not sleep. He waits. -% -Chuck Norris is currently suing NBC, claiming Law and Order are trademarked names for his left and right legs. -% -Chuck Norris is the reason why Waldo is hiding. -% -Chuck Norris counted to infinity - twice. -% -There is no chin behind Chuck Norris’ beard. There is only another fist. -% -In fine print on the last page of the Guinness Book of World Records it notes that all world records are held by Chuck Norris, and those listed in the book are simply the closest anyone else has ever gotten. -% -There is no chin behind Chuck Norris' beard. There is only another fist. -% -Chuck Norris does not teabag the ladies. He potato-sacks them. -% -Pluto is actually an orbiting group of British soldiers from the American Revolution who entered space after the Chuck gave them a roundhouse kick to the face. -% -When Chuck Norris does a pushup, he isn't lifting himself up, he's pushing the Earth down. -% -Chuck Norris is so fast, he can run around the world and punch himself in the back of the head. -% -Chuck Norris' hand is the only hand that can beat a Royal Flush. -% -Chuck Norris can lead a horse to water AND make it drink. -% -Chuck Norris doesn’t wear a watch. HE decides what time it is. -% -Chuck Norris can slam a revolving door. -% -Chuck Norris does not get frostbite. Chuck Norris bites frost. -% -Remember the Soviet Union? They decided to quit after watching a DeltaForce marathon on Satellite TV. -% -Contrary to popular belief, America is not a democracy, it is a Chucktatorship. -% -If you spell Chuck Norris in Scrabble, you win. Forever. -% -Guns don't kill people. Chuck Norris kills people. -% -There is no theory of evolution. Just a list of animals Chuck Norris allows to live. -% -The chief export of Chuck Norris is Pain. -% -Chuck Norris has two speeds. Walk, and Kill. -% -The leading causes of death in the United States are: 1. Heart Disease 2. Chuck Norris 3. Cancer. -% -Chuck Norris drives an ice cream truck covered in human skulls. -% -Chuck Norris is my Homeboy. -% -Chuck Norris doesn't go hunting.... CHUCK NORRIS GOES KILLING. -% -Chuck Norris uses pepper spray to spice up his steaks. -% -Chuck Norris once roundhouse kicked someone so hard that his foot broke the speed of light, went back in time, and killed Amelia Earhart while she was flying over the Pacific Ocean. -% -Crop circles are Chuck Norris' way of telling the world that sometimes corn needs to lie down. -% -Chuck Norris is ten feet tall, weighs two-tons, breathes fire, and could eat a hammer and take a shotgun blast standing. -% -The Great Wall of China was originally created to keep Chuck Norris out. It failed miserably. -% -Contrary to popular belief, Chuck Norris, not the box jellyfish of northern Australia, is the most venomous creature on earth. -% -Most people have 23 pairs of chromosomes. Chuck Norris has 72... and they're all poisonous. -% -If you ask Chuck Norris what time it is, he always says, "Two seconds 'til." After you ask, "Two seconds 'til what?" he roundhouse kicks you in the face. -% -When Chuck Norris sends in his taxes, he sends blank forms and includes only a picture of himself, crouched and ready to attack. Chuck Norris has not had to pay taxes, ever. -% -The quickest way to a man's heart is with Chuck Norris' fist. -% -Chuck Norris invented Kentucky Fried Chicken's famous secret recipe, with eleven herbs and spices. But nobody ever mentions the twelfth ingredient: Fear. -% -CNN was originally created as the "Chuck Norris Network" to update Americans with on-the-spot ass kicking in real-time. -% -Chuck Norris can win a game of Connect Four in only three moves. -% -What was going through the minds of all of Chuck Norris' victims before they died? His shoe. -% -Chuck Norris is the only man to ever defeat a brick wall in a game of tennis. -% -Police label anyone attacking Chuck Norris as a Code 45-11.... a suicide. -% -Chuck Norris doesn't churn butter. He roundhouse kicks the cows and the butter comes straight out. -% -Chuck Norris doesn’t wash his clothes, he disembowels them. -% -A Handicapped parking sign does not signify that this spot is for handicapped people. It is actually in fact a warning, that the spot belongs to Chuck Norris and that you will be handicapped if you park there. -% -Chuck Norris will attain statehood in 2009. His state flower will be the Magnolia. -% -Someone once videotaped Chuck Norris getting pissed off. It was called Walker: Texas Chain Saw Massacre. -% -Chuck Norris originally appeared in the "Street Fighter II" video game, but was removed by Beta Testers because every button caused him to do a roundhouse kick. When asked bout this "glitch," Norris replied, "That's no glitch." -% -Fool me once, shame on you. Fool Chuck Norris once and he will roundhouse you in the face. -% -Chuck Norris can win in a top spinning tournament with a cube -% -Beware of dogs... Dogs, beware of Chuck Norris. -% -Chuck Norris can dig a hole in air. -% -The apple falls far from the tree, when a roundhouse kick is taken to the trunk. -% -Chuck Norris - the new standard. -% -Chuck Norris told me to put this here. -% -Chuck Norris doesn't exhale. The air runs desperately scared out of his lungs. -% -Fear of spiders is aracnaphobia, fear of tight spaces is chlaustraphobia, fear of Chuck Norris is called Logic -% -When Chuck Norris goes to rodeos, bulls ride him. -% -Chuck Norris once walked down a street with his fists in his pockets. He was then arrested for concealing two deadly weapons. -% -The meaning of life is Chuck Norris -% -Chuck Norris is the meaning of life. Too bad he's also the meaning of death. -% -If God doesn't know, Chuck does -% -Chuck Norris doesn't bowl strikes, he just knocks down one pin and the other nine faint. -% -The show Survivor had the original premise of putting people on an island with Chuck Norris. There were no survivors, and nobody is brave enough to go to the island to retrieve the footage. -% -When the Boogeyman goes to sleep every night, he checks his closet for Chuck Norris. -% -Chuck Norris doesn't read books. He stares them down until he gets the information he wants. -% -There is no theory of evolution. Just a list of creatures Chuck Norris has allowed to live. -% -Outer space exists because it's afraid to be on the same planet with Chuck Norris. -% -Chuck Norris does not sleep. He waits. -% -Chuck Norris is currently suing NBC, claiming Law and Order are trademarked names for his left and right legs. -% -Chuck Norris is the reason why Waldo is hiding. -% -Chuck Norris counted to infinity - twice. -% -There is no chin behind Chuck Norris’ beard. There is only another fist. -% -When Chuck Norris does a pushup, he isn't lifting himself up, he's pushing the Earth down. -% -Chuck Norris is so fast, he can run around the world and punch himself in the back of the head. -% -Chuck Norris' hand is the only hand that can beat a Royal Flush. -% -Chuck Norris can lead a horse to water AND make it drink. -% -Chuck Norris doesn’t wear a watch. HE decides what time it is. -% -Chuck Norris can slam a revolving door. -% -Chuck Norris does not get frostbite. Chuck Norris bites frost. -% -Remember the Soviet Union? They decided to quit after watching a DeltaForce marathon on Satellite TV. -% -Contrary to popular belief, America is not a democracy, it is a Chucktatorship. -% -If you spell Chuck Norris in Scrabble, you win. Forever. -% -Guns don't kill people. Chuck Norris kills people. -% -There is no theory of evolution. Just a list of animals Chuck Norris allows to live. -% -The chief export of Chuck Norris is Pain. -% -Chuck Norris has two speeds. Walk, and Kill. -% -The leading causes of death in the United States are: 1. Heart Disease 2. Chuck Norris 3. Cancer. -% -Chuck Norris drives an ice cream truck covered in human skulls. -% -Chuck Norris is my Homeboy. -% -Chuck Norris doesn't go hunting.... CHUCK NORRIS GOES KILLING. -% -Chuck Norris uses pepper spray to spice up his steaks. -% -Chuck Norris once roundhouse kicked someone so hard that his foot broke the speed of light, went back in time, and killed Amelia Earhart while she was flying over the Pacific Ocean. -% -Crop circles are Chuck Norris' way of telling the world that sometimes corn needs to lie down. -% -Chuck Norris is ten feet tall, weighs two-tons, breathes fire, and could eat a hammer and take a shotgun blast standing. -% -The Great Wall of China was originally created to keep Chuck Norris out. It failed miserably. -% -Contrary to popular belief, Chuck Norris, not the box jellyfish of northern Australia, is the most venomous creature on earth. -% -Most people have 23 pairs of chromosomes. Chuck Norris has 72... and they're all poisonous. -% -If you ask Chuck Norris what time it is, he always says, "Two seconds 'til." After you ask, "Two seconds 'til what?" he roundhouse kicks you in the face. -% -When Chuck Norris sends in his taxes, he sends blank forms and includes only a picture of himself, crouched and ready to attack. Chuck Norris has not had to pay taxes, ever. -% -The quickest way to a man's heart is with Chuck Norris' fist. -% -Chuck Norris invented Kentucky Fried Chicken's famous secret recipe, with eleven herbs and spices. But nobody ever mentions the twelfth ingredient: Fear. -% -CNN was originally created as the "Chuck Norris Network" to update Americans with on-the-spot ass kicking in real-time. -% -Chuck Norris can win a game of Connect Four in only three moves. -% -What was going through the minds of all of Chuck Norris' victims before they died? His shoe. -% -Chuck Norris is the only man to ever defeat a brick wall in a game of tennis. -% -Police label anyone attacking Chuck Norris as a Code 45-11.... a suicide. -% -Chuck Norris doesn't churn butter. He roundhouse kicks the cows and the butter comes straight out. -% -Chuck Norris doesn’t wash his clothes, he disembowels them. -% -A Handicapped parking sign does not signify that this spot is for handicapped people. It is actually in fact a warning, that the spot belongs to Chuck Norris and that you will be handicapped if you park there. -% -Chuck Norris will attain statehood in 2009. His state flower will be the Magnolia. -% -Someone once videotaped Chuck Norris getting pissed off. It was called Walker: Texas Chain Saw Massacre. -% -Chuck Norris originally appeared in the "Street Fighter II" video game, but was removed by Beta Testers because every button caused him to do a roundhouse kick. When asked bout this "glitch," Norris replied, "That's no glitch." -% -Fool me once, shame on you. Fool Chuck Norris once and he will roundhouse you in the face. -% -When God said "Let there be light!", Chuck Norris said "Only for half the day -% -Chuck Norris went up the creek without a paddle... or a canoe -% -Chuck Norris once asked a man to turn down his music, he refused, that man's baby was born deaf. -% -Chuck Norris found the hay in the needle stack. -% -Chuck Norris doesn't need to brush his teeth, his spit acts as a bleach. -% -Chuck Norris once had a street named after him. But the name removed at once, because nobody crosses Chuck Norris, and lives -% -The planes in 9/11 were not hijacked. Chuck Norris was just playing with his old radio controller. -% -Machiavelli said it is better to be feared than loved because he was inspired by Chuck Norris. -% -Chuck Norris Can Play the Theme from the Twilight Zone with His Beard -% -Chuck Norris pees Adamantium -% -The Beatles are on iTunes because Chuck Norris bought a Mac. -% -Chuck Norris once rounhouse kicked a football ...... it is now considered as a planet -% -Chuck Norris yells at Drill Sergeants -% -When the Boogeyman goes to sleep every night, he checks his closet for Chuck Norris. -% -Chuck Norris doesn't read books. He stares them down until he gets the information he wants. -% -There is no theory of evolution. Just a list of creatures Chuck Norris has allowed to live. -% -Outer space exists because it's afraid to be on the same planet with Chuck Norris. -% -Chuck Norris does not sleep. He waits. -% -Chuck Norris is currently suing NBC, claiming Law and Order are trademarked names for his left and right legs. -% -Chuck Norris is the reason why Waldo is hiding. -% -Chuck Norris counted to infinity - twice. -% -There is no chin behind Chuck Norris’ beard. There is only another fist. -% -When Chuck Norris does a pushup, he isn't lifting himself up, he's pushing the Earth down. -% -Chuck Norris is so fast, he can run around the world and punch himself in the back of the head. -% -Chuck Norris' hand is the only hand that can beat a Royal Flush. -% -If at first you don't succeed, you're not Chuck Norris. -% -If Chuck Norris were a calendar, every month would be named Chucktober, and every day he'd kick your ass. -% -Chuck Norris can lead a horse to water AND make it drink. -% -Chuck Norris doesn’t wear a watch. HE decides what time it is. -% -Chuck Norris can slam a revolving door. -% -Chuck Norris does not get frostbite. Chuck Norris bites frost. -% -Remember the Soviet Union? They decided to quit after watching a DeltaForce marathon on Satellite TV. -% -Contrary to popular belief, America is not a democracy, it is a Chucktatorship. -% -If you spell Chuck Norris in Scrabble, you win. Forever. -% -Guns don't kill people. Chuck Norris kills people. -% -There is no theory of evolution. Just a list of animals Chuck Norris allows to live. -% -The chief export of Chuck Norris is Pain. -% -Chuck Norris has two speeds. Walk, and Kill. -% -The leading causes of death in the United States are: 1. Heart Disease 2. Chuck Norris 3. Cancer. -% -Chuck Norris drives an ice cream truck covered in human skulls. -% -Chuck Norris is my Homeboy. -% -Chuck Norris doesn't go hunting.... CHUCK NORRIS GOES KILLING. -% -Chuck Norris uses pepper spray to spice up his steaks. -% -Chuck Norris once roundhouse kicked someone so hard that his foot broke the speed of light, went back in time, and killed Amelia Earhart while she was flying over the Pacific Ocean. -% -Crop circles are Chuck Norris' way of telling the world that sometimes corn needs to lie down. -% -Chuck Norris is ten feet tall, weighs two-tons, breathes fire, and could eat a hammer and take a shotgun blast standing. -% -The Great Wall of China was originally created to keep Chuck Norris out. It failed miserably. -% -Contrary to popular belief, Chuck Norris, not the box jellyfish of northern Australia, is the most venomous creature on earth. -% -Most people have 23 pairs of chromosomes. Chuck Norris has 72... and they're all poisonous. -% -If you ask Chuck Norris what time it is, he always says, "Two seconds 'til." After you ask, "Two seconds 'til what?" he roundhouse kicks you in the face. -% -When Chuck Norris sends in his taxes, he sends blank forms and includes only a picture of himself, crouched and ready to attack. Chuck Norris has not had to pay taxes, ever. -% -The quickest way to a man's heart is with Chuck Norris' fist. -% -Chuck Norris invented Kentucky Fried Chicken's famous secret recipe, with eleven herbs and spices. But nobody ever mentions the twelfth ingredient: Fear. -% -CNN was originally created as the "Chuck Norris Network" to update Americans with on-the-spot ass kicking in real-time. -% -Chuck Norris can win a game of Connect Four in only three moves. -% -What was going through the minds of all of Chuck Norris' victims before they died? His shoe. -% -Chuck Norris is the only man to ever defeat a brick wall in a game of tennis. -% -Police label anyone attacking Chuck Norris as a Code 45-11.... a suicide. -% -Chuck Norris doesn't churn butter. He roundhouse kicks the cows and the butter comes straight out. -% -Chuck Norris doesn’t wash his clothes, he disembowels them. -% -Since 1940, the year Chuck Norris was born, roundhouse-kick related deaths have increased 13,000 percent.? -% -A Handicapped parking sign does not signify that this spot is for handicapped people. It is actually in fact a warning, that the spot belongs to Chuck Norris and that you will be handicapped if you park there. -% -Chuck Norris will attain statehood in 2009. His state flower will be the Magnolia. -% -Someone once videotaped Chuck Norris getting pissed off. It was called Walker: Texas Chain Saw Massacre. -% -Chuck Norris originally appeared in the "Street Fighter II" video game, but was removed by Beta Testers because every button caused him to do a roundhouse kick. When asked bout this "glitch," Norris replied, "That's no glitch." -% -Fool me once, shame on you. Fool Chuck Norris once and he will roundhouse you in the face. -% -There is no such thing as being hard its called the Chuck Norris factor. -% -When Chuck Norris goes to the library, he looks for the guinness book of records in the comedy section. -% -Chuck Norris can shoot a person 28 times with an unloaded gun. -% -Chuck Norris' personal airplane is called Air Force Chuck -% -The letters in Chuck Norris cannot be unscrambled. -% -Cops don't need a badges in their wallets but only a picture of Chuck Norris. -% -Chuck Norris was the reason why the Great Wall of China was constructed. It failed miserably. -% -If you see a man in the street who looks like Chuck Norris, but isn't, run: you don't want to be caught in the resulting roundhouse kick to his face. -% -The red phone in the oval office...Rings directly to Chuck Norris Cell Phone -% -The only way sharks will come near CN underwater is when CN is inside of a cage. -% -Chuck Norris uses a real mouse to move the cursor, type on the keyboard, write e-mails, code entire websites, use photoshop, bring coffee. -% -If Chuck Norris were to get into a fight with another Chuck Norris, Chuck Norris would win. +King Kong climbed the Empire State building in fear of Chuck Norris who was downstairs at the time. % "2012" is code for, Chuck Norris when he is pissed. % -When the Boogeyman goes to sleep every night, he checks his closet for Chuck Norris. -% -Chuck Norris doesn't read books. He stares them down until he gets the information he wants. -% -There is no theory of evolution. Just a list of creatures Chuck Norris has allowed to live. -% -Outer space exists because it's afraid to be on the same planet with Chuck Norris. -% -Chuck Norris does not sleep. He waits. -% -Chuck Norris is currently suing NBC, claiming Law and Order are trademarked names for his left and right legs. -% -Chuck Norris is the reason why Waldo is hiding. -% -Chuck Norris counted to infinity - twice. -% -There is no chin behind Chuck Norris’ beard. There is only another fist. -% -When Chuck Norris does a pushup, he isn't lifting himself up, he's pushing the Earth down. -% -Chuck Norris is so fast, he can run around the world and punch himself in the back of the head. -% -Chuck Norris' hand is the only hand that can beat a Royal Flush. -% -Chuck Norris can lead a horse to water AND make it drink. -% -Chuck Norris doesn’t wear a watch. HE decides what time it is. -% -Chuck Norris can slam a revolving door. -% -Chuck Norris does not get frostbite. Chuck Norris bites frost. -% -Remember the Soviet Union? They decided to quit after watching a DeltaForce marathon on Satellite TV. -% -Contrary to popular belief, America is not a democracy, it is a Chucktatorship. -% -If you spell Chuck Norris in Scrabble, you win. Forever. -% -Guns don't kill people. Chuck Norris kills people. -% -There is no theory of evolution. Just a list of animals Chuck Norris allows to live. -% -The chief export of Chuck Norris is Pain. -% -Chuck Norris has two speeds. Walk, and Kill. -% -The leading causes of death in the United States are: 1. Heart Disease 2. Chuck Norris 3. Cancer. -% -Chuck Norris drives an ice cream truck covered in human skulls. -% -Chuck Norris is my Homeboy. -% -Chuck Norris doesn't go hunting.... CHUCK NORRIS GOES KILLING. -% -Chuck Norris uses pepper spray to spice up his steaks. -% -Chuck Norris once roundhouse kicked someone so hard that his foot broke the speed of light, went back in time, and killed Amelia Earhart while she was flying over the Pacific Ocean. -% -Crop circles are Chuck Norris' way of telling the world that sometimes corn needs to lie down. -% -Chuck Norris is ten feet tall, weighs two-tons, breathes fire, and could eat a hammer and take a shotgun blast standing. -% -The Great Wall of China was originally created to keep Chuck Norris out. It failed miserably. -% -Contrary to popular belief, Chuck Norris, not the box jellyfish of northern Australia, is the most venomous creature on earth. -% -Most people have 23 pairs of chromosomes. Chuck Norris has 72... and they're all poisonous. -% -If you ask Chuck Norris what time it is, he always says, "Two seconds 'til." After you ask, "Two seconds 'til what?" he roundhouse kicks you in the face. -% -When Chuck Norris sends in his taxes, he sends blank forms and includes only a picture of himself, crouched and ready to attack. Chuck Norris has not had to pay taxes, ever. -% -The quickest way to a man's heart is with Chuck Norris' fist. -% -Chuck Norris invented Kentucky Fried Chicken's famous secret recipe, with eleven herbs and spices. But nobody ever mentions the twelfth ingredient: Fear. -% -CNN was originally created as the "Chuck Norris Network" to update Americans with on-the-spot ass kicking in real-time. -% -Chuck Norris can win a game of Connect Four in only three moves. -% -What was going through the minds of all of Chuck Norris' victims before they died? His shoe. -% -Chuck Norris is the only man to ever defeat a brick wall in a game of tennis. -% -Police label anyone attacking Chuck Norris as a Code 45-11.... a suicide. -% -Chuck Norris doesn't churn butter. He roundhouse kicks the cows and the butter comes straight out. -% -Chuck Norris doesn’t wash his clothes, he disembowels them. -% -A Handicapped parking sign does not signify that this spot is for handicapped people. It is actually in fact a warning, that the spot belongs to Chuck Norris and that you will be handicapped if you park there. -% -Chuck Norris will attain statehood in 2009. His state flower will be the Magnolia. -% -Someone once videotaped Chuck Norris getting pissed off. It was called Walker: Texas Chain Saw Massacre. -% -Chuck Norris originally appeared in the "Street Fighter II" video game, but was removed by Beta Testers because every button caused him to do a roundhouse kick. When asked bout this "glitch," Norris replied, "That's no glitch." -% -Fool me once, shame on you. Fool Chuck Norris once and he will roundhouse you in the face. -% -In the back of the book of world records, it says "All records are held by Chuck Norris. The ones listed are in second place." -% -The only place where the Starship Enterprise refuses to boldly go is Chuck Norris' planet...which is all of them. -% -Chuck Norris once had a pet monkey........his name was KING KONG -% -Chuck Norris can make his own megazord "The Chuck Norris Roundhouse Kickers Ultimate Super Awesome Megazord" -% -Simon doesn't say...Chuck Norris says. -% -When does Chuck Norris run out of shotgun bullets?.....whenever he wants to. -% -The only sure things are Death and Taxes, and when Chuck Norris goes to work for the IRS, they'll be the same thing. -% -Chuck Norris' first job was as a paperboy. There were no survivors. -% -Chuck Norris can turn toast back into bread -% -Chuck Norris started Chuck Norris. -% -Ever wonder what really happened to the dinosaurs? They all dug their own graves when they heard Chuck Norris was coming -% -Chuck Norris killed Kemper -% -Did you here about the boy who cried Chuck Norris? -% -Chuck Norris can't perform Hadoukens, he IS a Hadouken -% -Behind every successful man is Chuck Norris -% -When the Boogeyman goes to sleep every night, he checks his closet for Chuck Norris. -% -Chuck Norris doesn't read books. He stares them down until he gets the information he wants. -% -There is no theory of evolution. Just a list of creatures Chuck Norris has allowed to live. -% -Outer space exists because it's afraid to be on the same planet with Chuck Norris. -% -Chuck Norris does not sleep. He waits. -% -Chuck Norris is currently suing NBC, claiming Law and Order are trademarked names for his left and right legs. -% -Chuck Norris is the reason why Waldo is hiding. -% -Chuck Norris counted to infinity - twice. -% -MacGyver immediately tried to make a bomb out of some Q-Tips and Gatorade, but Chuck Norris roundhouse-kicked him in the solar plexus. MacGyver promptly threw up his own heart. -% -There is no chin behind Chuck Norris’ beard. There is only another fist. -% -When Chuck Norris does a pushup, he isn't lifting himself up, he's pushing the Earth down. -% -Chuck Norris is so fast, he can run around the world and punch himself in the back of the head. -% -Chuck Norris' hand is the only hand that can beat a Royal Flush. -% -Chuck Norris can lead a horse to water AND make it drink. -% -Chuck Norris doesn’t wear a watch. HE decides what time it is. -% -Chuck Norris can slam a revolving door. -% -Chuck Norris does not get frostbite. Chuck Norris bites frost. -% -Remember the Soviet Union? They decided to quit after watching a DeltaForce marathon on Satellite TV. -% -Contrary to popular belief, America is not a democracy, it is a Chucktatorship. -% -If you spell Chuck Norris in Scrabble, you win. Forever. -% -Guns don't kill people. Chuck Norris kills people. -% -There is no theory of evolution. Just a list of animals Chuck Norris allows to live. -% -The chief export of Chuck Norris is Pain. -% -Chuck Norris has two speeds. Walk, and Kill. -% -The leading causes of death in the United States are: 1. Heart Disease 2. Chuck Norris 3. Cancer. -% -Chuck Norris drives an ice cream truck covered in human skulls. -% -Chuck Norris is my Homeboy. -% -Chuck Norris doesn't go hunting.... CHUCK NORRIS GOES KILLING. -% -Chuck Norris uses pepper spray to spice up his steaks. -% -Chuck Norris once roundhouse kicked someone so hard that his foot broke the speed of light, went back in time, and killed Amelia Earhart while she was flying over the Pacific Ocean. -% -Crop circles are Chuck Norris' way of telling the world that sometimes corn needs to lie down. -% -Chuck Norris is ten feet tall, weighs two-tons, breathes fire, and could eat a hammer and take a shotgun blast standing. -% -The Great Wall of China was originally created to keep Chuck Norris out. It failed miserably. -% -Contrary to popular belief, Chuck Norris, not the box jellyfish of northern Australia, is the most venomous creature on earth. -% -Most people have 23 pairs of chromosomes. Chuck Norris has 72... and they're all poisonous. -% -If you ask Chuck Norris what time it is, he always says, "Two seconds 'til." After you ask, "Two seconds 'til what?" he roundhouse kicks you in the face. -% -When Chuck Norris sends in his taxes, he sends blank forms and includes only a picture of himself, crouched and ready to attack. Chuck Norris has not had to pay taxes, ever. -% -The quickest way to a man's heart is with Chuck Norris' fist. -% -Chuck Norris invented Kentucky Fried Chicken's famous secret recipe, with eleven herbs and spices. But nobody ever mentions the twelfth ingredient: Fear. -% -CNN was originally created as the "Chuck Norris Network" to update Americans with on-the-spot ass kicking in real-time. -% -Chuck Norris can win a game of Connect Four in only three moves. -% -What was going through the minds of all of Chuck Norris' victims before they died? His shoe. -% -Chuck Norris is the only man to ever defeat a brick wall in a game of tennis. -% -Police label anyone attacking Chuck Norris as a Code 45-11.... a suicide. -% -Chuck Norris doesn't churn butter. He roundhouse kicks the cows and the butter comes straight out. -% -Chuck Norris doesn’t wash his clothes, he disembowels them. -% -A Handicapped parking sign does not signify that this spot is for handicapped people. It is actually in fact a warning, that the spot belongs to Chuck Norris and that you will be handicapped if you park there. -% -Chuck Norris will attain statehood in 2009. His state flower will be the Magnolia. -% -Someone once videotaped Chuck Norris getting pissed off. It was called Walker: Texas Chain Saw Massacre. -% -Chuck Norris originally appeared in the "Street Fighter II" video game, but was removed by Beta Testers because every button caused him to do a roundhouse kick. When asked bout this "glitch," Norris replied, "That's no glitch." -% -Fool me once, shame on you. Fool Chuck Norris once and he will roundhouse you in the face. -% -The square root of Chuck Norris is pain. Do not try to square Chuck Norris. The result is death -% -Chuck Norris doesn't read. He just stares at the book until he gets the information he wants. -% -Why didn't the chicken cross the road? Because Chuck Norris got to it first. -% -When taking the SAT, write "Chuck Norris" for every answer. You will score over 8000. -% -Chuck Norris can milk an alligator -% -Chuck Norris doesn't eat, he just sucks the energy out of food by staring at it -% -Chuck Norris once proved p^~p by induction on his beard hairs. -% -The reason why batman only comes out at night is because he's afraid he might encounter Chuck Norris in the Morning and afternoon. -% -Chuck Norris can bake in a Freezer. -% -Chuck Norris is currently suing any broadway theater that plays "The Nutcracker". He claims its an infringement on his "other" roundhouse kick. -% -Chuck Norris once had a weak moment, just to know what it felt like. -% -Note to everyone: Please do not give beans to Chuck Norris or do you want another atombomb on hiroshima? -% -Chuck Norris has made a 148 break a snooker. -% -When the Boogeyman goes to sleep every night, he checks his closet for Chuck Norris. -% -Chuck Norris doesn't read books. He stares them down until he gets the information he wants. -% -There is no theory of evolution. Just a list of creatures Chuck Norris has allowed to live. -% -Outer space exists because it's afraid to be on the same planet with Chuck Norris. -% -Chuck Norris does not sleep. He waits. -% -Chuck Norris is currently suing NBC, claiming Law and Order are trademarked names for his left and right legs. -% -Chuck Norris is the reason why Waldo is hiding. -% -Chuck Norris counted to infinity - twice. -% -There is no chin behind Chuck Norris’ beard. There is only another fist. -% -When Chuck Norris does a pushup, he isn't lifting himself up, he's pushing the Earth down. -% -Chuck Norris is so fast, he can run around the world and punch himself in the back of the head. -% -Chuck Norris' hand is the only hand that can beat a Royal Flush. -% -Chuck Norris can lead a horse to water AND make it drink. -% -Chuck Norris doesn’t wear a watch. HE decides what time it is. -% -Chuck Norris can slam a revolving door. -% -Chuck Norris does not get frostbite. Chuck Norris bites frost. -% -Remember the Soviet Union? They decided to quit after watching a DeltaForce marathon on Satellite TV. -% -Contrary to popular belief, America is not a democracy, it is a Chucktatorship. -% -If you spell Chuck Norris in Scrabble, you win. Forever. -% -Guns don't kill people. Chuck Norris kills people. -% -There is no theory of evolution. Just a list of animals Chuck Norris allows to live. -% -The chief export of Chuck Norris is Pain. -% -Chuck Norris has two speeds. Walk, and Kill. -% -The leading causes of death in the United States are: 1. Heart Disease 2. Chuck Norris 3. Cancer. -% -Chuck Norris drives an ice cream truck covered in human skulls. -% -Chuck Norris is my Homeboy. -% -Chuck Norris doesn't go hunting.... CHUCK NORRIS GOES KILLING. -% -Chuck Norris uses pepper spray to spice up his steaks. -% -Chuck Norris once roundhouse kicked someone so hard that his foot broke the speed of light, went back in time, and killed Amelia Earhart while she was flying over the Pacific Ocean. -% -Crop circles are Chuck Norris' way of telling the world that sometimes corn needs to lie down. -% -Chuck Norris is ten feet tall, weighs two-tons, breathes fire, and could eat a hammer and take a shotgun blast standing. -% -The Great Wall of China was originally created to keep Chuck Norris out. It failed miserably. -% -Contrary to popular belief, Chuck Norris, not the box jellyfish of northern Australia, is the most venomous creature on earth. -% -Most people have 23 pairs of chromosomes. Chuck Norris has 72... and they're all poisonous. -% -If you ask Chuck Norris what time it is, he always says, "Two seconds 'til." After you ask, "Two seconds 'til what?" he roundhouse kicks you in the face. -% -When Chuck Norris sends in his taxes, he sends blank forms and includes only a picture of himself, crouched and ready to attack. Chuck Norris has not had to pay taxes, ever. -% -The quickest way to a man's heart is with Chuck Norris' fist. -% -Chuck Norris invented Kentucky Fried Chicken's famous secret recipe, with eleven herbs and spices. But nobody ever mentions the twelfth ingredient: Fear. -% -CNN was originally created as the "Chuck Norris Network" to update Americans with on-the-spot ass kicking in real-time. -% -Chuck Norris can win a game of Connect Four in only three moves. -% -What was going through the minds of all of Chuck Norris' victims before they died? His shoe. -% -Chuck Norris is the only man to ever defeat a brick wall in a game of tennis. -% -Police label anyone attacking Chuck Norris as a Code 45-11.... a suicide. -% -Chuck Norris doesn't churn butter. He roundhouse kicks the cows and the butter comes straight out. -% -Chuck Norris doesn’t wash his clothes, he disembowels them. -% -A Handicapped parking sign does not signify that this spot is for handicapped people. It is actually in fact a warning, that the spot belongs to Chuck Norris and that you will be handicapped if you park there. -% -Chuck Norris will attain statehood in 2009. His state flower will be the Magnolia. -% -Someone once videotaped Chuck Norris getting pissed off. It was called Walker: Texas Chain Saw Massacre. -% -Chuck Norris originally appeared in the "Street Fighter II" video game, but was removed by Beta Testers because every button caused him to do a roundhouse kick. When asked bout this "glitch," Norris replied, "That's no glitch." -% -Fool me once, shame on you. Fool Chuck Norris once and he will roundhouse you in the face. -% -http://chucknorrisfacts.com/ is built in Drupal because Chuck Norris knows a good CMS when he sees one. -% -The producers of the movie "The Last Airbender" are now in talks with Chuck Norris in Order to star him in their next sequal "The Last Skull Bender". -% -Some boots were made for walking. Some boots may walk all over you, but Chuck Norris' boot walk THROUGH you. -% -World War II began because Chuck Norris took a nap. When he woke up, Hitler found out and killed himself out of fear Chuck Norris would kill him. -% -The best part of waking up is not Folgers in your cup, it's knowing that Chuck Norris let you live. -% -Only Chuck Norris can win the mind game, 'cause he never minds. -% -Do you know why Chuck Norris didn't star in The Expandebles? Because all the others guys would have surrended at the beginning. -% -Bruce Lee didn't defeat Chuck Norris. Chuck hit Bruce with a Delayed roundhouse kick that was so fast that Lee only felt the impact a year later! -% -Chuck Norris doesn't need a bulletproof vest to be bulletproof -% -When Chuck Norris goes to Vegas, he doesn't have to gamble. The casinos just give him stacks of money. -% -Merlin was Chuck Norris' assistant. -% -If you put in the correct cheat code in Halo 2, you can have Master Cheif play without his helmet; revealing to be Chuck Norris. -% -Those who ignore history, are doomed by Chuck Norris. -% -When the Boogeyman goes to sleep every night, he checks his closet for Chuck Norris. -% -Chuck Norris doesn't read books. He stares them down until he gets the information he wants. -% -There is no theory of evolution. Just a list of creatures Chuck Norris has allowed to live. -% -Outer space exists because it's afraid to be on the same planet with Chuck Norris. -% -Chuck Norris does not sleep. He waits. -% -Chuck Norris is currently suing NBC, claiming Law and Order are trademarked names for his left and right legs. -% -Chuck Norris is the reason why Waldo is hiding. -% -Chuck Norris counted to infinity - twice. -% -There is no chin behind Chuck Norris’ beard. There is only another fist. -% -When Chuck Norris does a pushup, he isn't lifting himself up, he's pushing the Earth down. -% -Chuck Norris is so fast, he can run around the world and punch himself in the back of the head. -% -Chuck Norris' hand is the only hand that can beat a Royal Flush. -% -Chuck Norris can lead a horse to water AND make it drink. -% -Chuck Norris doesn’t wear a watch. HE decides what time it is. -% -Chuck Norris can slam a revolving door. -% -Chuck Norris does not get frostbite. Chuck Norris bites frost. -% -Remember the Soviet Union? They decided to quit after watching a DeltaForce marathon on Satellite TV. -% -Contrary to popular belief, America is not a democracy, it is a Chucktatorship. -% -If you spell Chuck Norris in Scrabble, you win. Forever. -% -Guns don't kill people. Chuck Norris kills people. -% -There is no theory of evolution. Just a list of animals Chuck Norris allows to live. -% -The chief export of Chuck Norris is Pain. -% -Chuck Norris has two speeds. Walk, and Kill. -% -The leading causes of death in the United States are: 1. Heart Disease 2. Chuck Norris 3. Cancer. -% -Chuck Norris drives an ice cream truck covered in human skulls. -% -Chuck Norris is my Homeboy. -% -Chuck Norris doesn't go hunting.... CHUCK NORRIS GOES KILLING. -% -Chuck Norris uses pepper spray to spice up his steaks. -% -Chuck Norris once roundhouse kicked someone so hard that his foot broke the speed of light, went back in time, and killed Amelia Earhart while she was flying over the Pacific Ocean. -% -Crop circles are Chuck Norris' way of telling the world that sometimes corn needs to lie down. -% -Chuck Norris is ten feet tall, weighs two-tons, breathes fire, and could eat a hammer and take a shotgun blast standing. -% -The Great Wall of China was originally created to keep Chuck Norris out. It failed miserably. -% -Contrary to popular belief, Chuck Norris, not the box jellyfish of northern Australia, is the most venomous creature on earth. -% -Most people have 23 pairs of chromosomes. Chuck Norris has 72... and they're all poisonous. -% -If you ask Chuck Norris what time it is, he always says, "Two seconds 'til." After you ask, "Two seconds 'til what?" he roundhouse kicks you in the face. -% -When Chuck Norris sends in his taxes, he sends blank forms and includes only a picture of himself, crouched and ready to attack. Chuck Norris has not had to pay taxes, ever. -% -The quickest way to a man's heart is with Chuck Norris' fist. -% -Chuck Norris invented Kentucky Fried Chicken's famous secret recipe, with eleven herbs and spices. But nobody ever mentions the twelfth ingredient: Fear. -% -CNN was originally created as the "Chuck Norris Network" to update Americans with on-the-spot ass kicking in real-time. -% -Chuck Norris can win a game of Connect Four in only three moves. -% -What was going through the minds of all of Chuck Norris' victims before they died? His shoe. -% -Chuck Norris is the only man to ever defeat a brick wall in a game of tennis. -% -Police label anyone attacking Chuck Norris as a Code 45-11.... a suicide. -% -Chuck Norris doesn't churn butter. He roundhouse kicks the cows and the butter comes straight out. -% -Chuck Norris doesn’t wash his clothes, he disembowels them. -% -A Handicapped parking sign does not signify that this spot is for handicapped people. It is actually in fact a warning, that the spot belongs to Chuck Norris and that you will be handicapped if you park there. -% -Chuck Norris will attain statehood in 2009. His state flower will be the Magnolia. -% -Someone once videotaped Chuck Norris getting pissed off. It was called Walker: Texas Chain Saw Massacre. -% -Chuck Norris originally appeared in the "Street Fighter II" video game, but was removed by Beta Testers because every button caused him to do a roundhouse kick. When asked bout this "glitch," Norris replied, "That's no glitch." -% -Fool me once, shame on you. Fool Chuck Norris once and he will roundhouse you in the face. -% -Some kids pee their name in snow. Chuck Norris pees his name in concrete. -% -The Matrix Trilogy would have ended on the first movie if Keanu Reeves said, “I know Chuck Norris.” -% -Chuck Norris created Heavy Metal when he was upset -% -Some people ask for a Kleenex when they sneeze, Chuck Norris asks for a body bag. -% -When things go bump in the night.... it's Chuck Norris -% -Chuck Norris fed the Hunger Games -% -Chuck Norris played "Got your Nose" with Voldemort and won. -% -Chuck Norris had a knife thrown at him............ the knife didn't impale him, he impaled the knife -% -Chuck Norris doesn't let it go. -% -You know Chuck Norris' pet lizard, right? Last I heard, he was in the movie "Godzilla". Oh, and his pet turtle starred in "Gamera" as well. -% -Whatever Chuck Norris wants, it will instantly appear. -% -Chuck Norris once cut a knife with a stick of butter. -% -Chuck Norris shops at Sam's Club, but leaves without having his receipt checked -% -When the Boogeyman goes to sleep every night, he checks his closet for Chuck Norris. -% -Chuck Norris doesn't read books. He stares them down until he gets the information he wants. -% -There is no theory of evolution. Just a list of creatures Chuck Norris has allowed to live. -% -Outer space exists because it's afraid to be on the same planet with Chuck Norris. -% -Chuck Norris does not sleep. He waits. -% -Chuck Norris is currently suing NBC, claiming Law and Order are trademarked names for his left and right legs. -% -Chuck Norris is the reason why Waldo is hiding. -% -Chuck Norris counted to infinity - twice. -% -There is no chin behind Chuck Norris’ beard. There is only another fist. -% -When Chuck Norris does a pushup, he isn't lifting himself up, he's pushing the Earth down. -% -Chuck Norris is so fast, he can run around the world and punch himself in the back of the head. -% -Chuck Norris' hand is the only hand that can beat a Royal Flush. -% -Chuck Norris can lead a horse to water AND make it drink. -% -Chuck Norris doesn’t wear a watch. HE decides what time it is. -% -Chuck Norris can slam a revolving door. -% -Chuck Norris does not get frostbite. Chuck Norris bites frost. -% -Remember the Soviet Union? They decided to quit after watching a DeltaForce marathon on Satellite TV. -% -Contrary to popular belief, America is not a democracy, it is a Chucktatorship. -% -If you spell Chuck Norris in Scrabble, you win. Forever. -% -Guns don't kill people. Chuck Norris kills people. -% -There is no theory of evolution. Just a list of animals Chuck Norris allows to live. -% -The chief export of Chuck Norris is Pain. -% -Chuck Norris has two speeds. Walk, and Kill. -% -The leading causes of death in the United States are: 1. Heart Disease 2. Chuck Norris 3. Cancer. -% -Chuck Norris drives an ice cream truck covered in human skulls. -% -Chuck Norris is my Homeboy. -% -Chuck Norris doesn't go hunting.... CHUCK NORRIS GOES KILLING. -% -Chuck Norris uses pepper spray to spice up his steaks. -% -Chuck Norris once roundhouse kicked someone so hard that his foot broke the speed of light, went back in time, and killed Amelia Earhart while she was flying over the Pacific Ocean. -% -Crop circles are Chuck Norris' way of telling the world that sometimes corn needs to lie down. -% -Chuck Norris is ten feet tall, weighs two-tons, breathes fire, and could eat a hammer and take a shotgun blast standing. -% -The Great Wall of China was originally created to keep Chuck Norris out. It failed miserably. -% -Contrary to popular belief, Chuck Norris, not the box jellyfish of northern Australia, is the most venomous creature on earth. -% -Most people have 23 pairs of chromosomes. Chuck Norris has 72... and they're all poisonous. -% -If you ask Chuck Norris what time it is, he always says, "Two seconds 'til." After you ask, "Two seconds 'til what?" he roundhouse kicks you in the face. -% -When Chuck Norris sends in his taxes, he sends blank forms and includes only a picture of himself, crouched and ready to attack. Chuck Norris has not had to pay taxes, ever. -% -The quickest way to a man's heart is with Chuck Norris' fist. -% -Chuck Norris invented Kentucky Fried Chicken's famous secret recipe, with eleven herbs and spices. But nobody ever mentions the twelfth ingredient: Fear. -% -CNN was originally created as the "Chuck Norris Network" to update Americans with on-the-spot ass kicking in real-time. -% -Chuck Norris can win a game of Connect Four in only three moves. -% -What was going through the minds of all of Chuck Norris' victims before they died? His shoe. -% -Chuck Norris is the only man to ever defeat a brick wall in a game of tennis. -% -Police label anyone attacking Chuck Norris as a Code 45-11.... a suicide. -% -Chuck Norris doesn't churn butter. He roundhouse kicks the cows and the butter comes straight out. -% -Chuck Norris doesn’t wash his clothes, he disembowels them. -% -A Handicapped parking sign does not signify that this spot is for handicapped people. It is actually in fact a warning, that the spot belongs to Chuck Norris and that you will be handicapped if you park there. -% -Chuck Norris will attain statehood in 2009. His state flower will be the Magnolia. -% -Someone once videotaped Chuck Norris getting pissed off. It was called Walker: Texas Chain Saw Massacre. -% -Chuck Norris originally appeared in the "Street Fighter II" video game, but was removed by Beta Testers because every button caused him to do a roundhouse kick. When asked bout this "glitch," Norris replied, "That's no glitch." -% -Fool me once, shame on you. Fool Chuck Norris once and he will roundhouse you in the face. -% -In 1945 The US army asked if they could clone Chuck Norris. instead he said he could sort out the Japanese. -% -One glance from Chuck Norris and snow turns itself yellow. -% -Chuck Norris checks under his bed for Fedor Emelianenko because he takes Fedor to the vet regularly. -% -Chuck Norris was the image used for Papa Smurf. -% -Chuck Norris is so scary he makes Sharks swim backwards away from him -% -When Chuck Norris tosses a coin, it lands on both head and tail. -% -Chuck Norris found the last digit of pie -% -Chuck Norris Watches "the Nat.Geo. Specials" on Discovery Channel -% -James Bond has a license to kill. He got it from Chuck Norris. -% -Chuck Norris is Chuck Norris -% "The Big Chuck Norris Roundhouse-Kick Theory" % -That's not an eclipse....that's the sun hiding from Chuck Norris. -% -Chuck Norris doesn't like Mudkipz -% -When the Boogeyman goes to sleep every night, he checks his closet for Chuck Norris. -% -Chuck Norris doesn't read books. He stares them down until he gets the information he wants. -% -There is no theory of evolution. Just a list of creatures Chuck Norris has allowed to live. -% -Outer space exists because it's afraid to be on the same planet with Chuck Norris. -% -Chuck Norris does not sleep. He waits. -% -Chuck Norris is currently suing NBC, claiming Law and Order are trademarked names for his left and right legs. -% -Chuck Norris is the reason why Waldo is hiding. -% -Chuck Norris counted to infinity - twice. -% -There is no chin behind Chuck Norris’ beard. There is only another fist. -% -When Chuck Norris does a pushup, he isn't lifting himself up, he's pushing the Earth down. -% -Chuck Norris is so fast, he can run around the world and punch himself in the back of the head. -% -Chuck Norris' hand is the only hand that can beat a Royal Flush. -% -Chuck Norris can lead a horse to water AND make it drink. -% -Chuck Norris doesn’t wear a watch. HE decides what time it is. -% -Chuck Norris can slam a revolving door. -% -Chuck Norris does not get frostbite. Chuck Norris bites frost. -% -Remember the Soviet Union? They decided to quit after watching a DeltaForce marathon on Satellite TV. -% -Contrary to popular belief, America is not a democracy, it is a Chucktatorship. -% -If you spell Chuck Norris in Scrabble, you win. Forever. -% -Guns don't kill people. Chuck Norris kills people. -% -There is no theory of evolution. Just a list of animals Chuck Norris allows to live. -% -The chief export of Chuck Norris is Pain. -% -Chuck Norris has two speeds. Walk, and Kill. -% -The leading causes of death in the United States are: 1. Heart Disease 2. Chuck Norris 3. Cancer. -% -Chuck Norris drives an ice cream truck covered in human skulls. -% -Chuck Norris is my Homeboy. -% -Chuck Norris doesn't go hunting.... CHUCK NORRIS GOES KILLING. -% -Chuck Norris uses pepper spray to spice up his steaks. -% -Chuck Norris once roundhouse kicked someone so hard that his foot broke the speed of light, went back in time, and killed Amelia Earhart while she was flying over the Pacific Ocean. -% -Crop circles are Chuck Norris' way of telling the world that sometimes corn needs to lie down. -% -Chuck Norris is ten feet tall, weighs two-tons, breathes fire, and could eat a hammer and take a shotgun blast standing. -% -The Great Wall of China was originally created to keep Chuck Norris out. It failed miserably. -% -Contrary to popular belief, Chuck Norris, not the box jellyfish of northern Australia, is the most venomous creature on earth. -% -Most people have 23 pairs of chromosomes. Chuck Norris has 72... and they're all poisonous. -% -If you ask Chuck Norris what time it is, he always says, "Two seconds 'til." After you ask, "Two seconds 'til what?" he roundhouse kicks you in the face. -% -When Chuck Norris sends in his taxes, he sends blank forms and includes only a picture of himself, crouched and ready to attack. Chuck Norris has not had to pay taxes, ever. -% -The quickest way to a man's heart is with Chuck Norris' fist. -% -Chuck Norris invented Kentucky Fried Chicken's famous secret recipe, with eleven herbs and spices. But nobody ever mentions the twelfth ingredient: Fear. -% -CNN was originally created as the "Chuck Norris Network" to update Americans with on-the-spot ass kicking in real-time. -% -Chuck Norris can win a game of Connect Four in only three moves. -% -What was going through the minds of all of Chuck Norris' victims before they died? His shoe. -% -Chuck Norris is the only man to ever defeat a brick wall in a game of tennis. -% -Police label anyone attacking Chuck Norris as a Code 45-11.... a suicide. -% -Chuck Norris doesn't churn butter. He roundhouse kicks the cows and the butter comes straight out. -% -Chuck Norris doesn’t wash his clothes, he disembowels them. -% -A Handicapped parking sign does not signify that this spot is for handicapped people. It is actually in fact a warning, that the spot belongs to Chuck Norris and that you will be handicapped if you park there. -% -Chuck Norris will attain statehood in 2009. His state flower will be the Magnolia. -% -Someone once videotaped Chuck Norris getting pissed off. It was called Walker: Texas Chain Saw Massacre. -% -Chuck Norris originally appeared in the "Street Fighter II" video game, but was removed by Beta Testers because every button caused him to do a roundhouse kick. When asked bout this "glitch," Norris replied, "That's no glitch." -% -Fool me once, shame on you. Fool Chuck Norris once and he will roundhouse you in the face. -% -Chuck Norris doesn’t eat salad, he eats vegetarians -% -Every time there's an earthquake, you know Chuck Norris is hungry. The earthquake is caused by his stomach growling. -% -Chuck Norris wasn't born on his birthday -% -One time a test cheated on Chuck Norris. -% -Chuck Norris won a stepdance contest by standing on his hands -% -Chuck Norris thretened to kill Michael Jackson, MJ got so scared to turned white. -% -When Steven Seagal kills a ninja, he only takes its hide. When Chuck Norris kills a ninja, he uses every part. -% -Chuck Norris is the life of parties he dosen't attend -% -Chuck Norris can rub two fires together and make a stick! -% -Contrary to popular beleif, Rome WAS built in a day, by Chuck Norris. -% -Chuck Norris rolled a 20 on a 6 sided die. -% -When chuck Norris was in school, he made his PE teacher run laps. -% -Chuck Norris wins NASCAR races with all right turns. -% -When the Boogeyman goes to sleep every night, he checks his closet for Chuck Norris. -% -Chuck Norris doesn't read books. He stares them down until he gets the information he wants. -% -There is no theory of evolution. Just a list of creatures Chuck Norris has allowed to live. -% -Outer space exists because it's afraid to be on the same planet with Chuck Norris. -% -Chuck Norris does not sleep. He waits. -% -Chuck Norris is currently suing NBC, claiming Law and Order are trademarked names for his left and right legs. -% -Chuck Norris is the reason why Waldo is hiding. -% -Chuck Norris counted to infinity - twice. -% -There is no chin behind Chuck Norris’ beard. There is only another fist. -% -When Chuck Norris does a pushup, he isn't lifting himself up, he's pushing the Earth down. -% -Chuck Norris is so fast, he can run around the world and punch himself in the back of the head. -% -Chuck Norris' hand is the only hand that can beat a Royal Flush. -% -Chuck Norris can lead a horse to water AND make it drink. -% -Chuck Norris doesn’t wear a watch. HE decides what time it is. -% -Chuck Norris can slam a revolving door. -% -Chuck Norris does not get frostbite. Chuck Norris bites frost. -% -Remember the Soviet Union? They decided to quit after watching a DeltaForce marathon on Satellite TV. -% -Contrary to popular belief, America is not a democracy, it is a Chucktatorship. -% -If you spell Chuck Norris in Scrabble, you win. Forever. -% -Guns don't kill people. Chuck Norris kills people. -% -There is no theory of evolution. Just a list of animals Chuck Norris allows to live. -% -The chief export of Chuck Norris is Pain. -% -Chuck Norris has two speeds. Walk, and Kill. -% -The leading causes of death in the United States are: 1. Heart Disease 2. Chuck Norris 3. Cancer. -% -Chuck Norris drives an ice cream truck covered in human skulls. -% -Chuck Norris is my Homeboy. -% -Chuck Norris doesn't go hunting.... CHUCK NORRIS GOES KILLING. -% -Chuck Norris uses pepper spray to spice up his steaks. -% -Chuck Norris once roundhouse kicked someone so hard that his foot broke the speed of light, went back in time, and killed Amelia Earhart while she was flying over the Pacific Ocean. -% -Crop circles are Chuck Norris' way of telling the world that sometimes corn needs to lie down. -% -Chuck Norris is ten feet tall, weighs two-tons, breathes fire, and could eat a hammer and take a shotgun blast standing. -% -The Great Wall of China was originally created to keep Chuck Norris out. It failed miserably. -% -Contrary to popular belief, Chuck Norris, not the box jellyfish of northern Australia, is the most venomous creature on earth. -% -Most people have 23 pairs of chromosomes. Chuck Norris has 72... and they're all poisonous. -% -If you ask Chuck Norris what time it is, he always says, "Two seconds 'til." After you ask, "Two seconds 'til what?" he roundhouse kicks you in the face. -% -When Chuck Norris sends in his taxes, he sends blank forms and includes only a picture of himself, crouched and ready to attack. Chuck Norris has not had to pay taxes, ever. -% -The quickest way to a man's heart is with Chuck Norris' fist. -% -Chuck Norris invented Kentucky Fried Chicken's famous secret recipe, with eleven herbs and spices. But nobody ever mentions the twelfth ingredient: Fear. -% -CNN was originally created as the "Chuck Norris Network" to update Americans with on-the-spot ass kicking in real-time. -% -Chuck Norris can win a game of Connect Four in only three moves. -% -What was going through the minds of all of Chuck Norris' victims before they died? His shoe. -% -Chuck Norris is the only man to ever defeat a brick wall in a game of tennis. -% -Police label anyone attacking Chuck Norris as a Code 45-11.... a suicide. -% -Chuck Norris doesn't churn butter. He roundhouse kicks the cows and the butter comes straight out. -% -Chuck Norris doesn’t wash his clothes, he disembowels them. -% -A Handicapped parking sign does not signify that this spot is for handicapped people. It is actually in fact a warning, that the spot belongs to Chuck Norris and that you will be handicapped if you park there. -% -Chuck Norris will attain statehood in 2009. His state flower will be the Magnolia. -% -Someone once videotaped Chuck Norris getting pissed off. It was called Walker: Texas Chain Saw Massacre. -% -Chuck Norris originally appeared in the "Street Fighter II" video game, but was removed by Beta Testers because every button caused him to do a roundhouse kick. When asked bout this "glitch," Norris replied, "That's no glitch." -% -Fool me once, shame on you. Fool Chuck Norris once and he will roundhouse you in the face. -% -Chuck Norris is waiting for Mt. St. Helens to erupt again. He's hoping the lava is hot enough to soften his beard so he can shave for the first time. -% -Chuck Norris is overra... -% -Chuck Norris was originally in Mortal Kombat, but that version was deleted because no one can beat Chuck Norris in a fight. -% -Chuck Norris likes everyone on the earth, cause everyone he didn't like... Is dead... -% -Chunk Norris can make sour milk turn fresh -% -There is no limbo, only a world that doesn't know of Chuck Norris -% -Chuck Norris CAN believe it's not butter -% -Dog the Bounty Hunter can't track Chuck Norris down. -% -Abraham Lincoln didn't die because he was shot, Chuck Norris roundhouse-kicked so fast his foot went back in time and killed Abraham Lincoln. -% -When Chuck Norris inhales helium, his voice doesn't change. -% -When Chuck Norris drinks water, the water automatically pasteurized. -% -Chuck Norris once punched the ground to stop an earthquake. The resulting aftershock caused the BP oil spill -% -Chuck Norris can play the death waltz with his chin. -% -When the Boogeyman goes to sleep every night, he checks his closet for Chuck Norris. -% -Chuck Norris doesn't read books. He stares them down until he gets the information he wants. -% -There is no theory of evolution. Just a list of creatures Chuck Norris has allowed to live. -% -Outer space exists because it's afraid to be on the same planet with Chuck Norris. -% -Chuck Norris does not sleep. He waits. -% -Chuck Norris is currently suing NBC, claiming Law and Order are trademarked names for his left and right legs. -% -Chuck Norris is the reason why Waldo is hiding. -% -Chuck Norris counted to infinity - twice. -% -There is no chin behind Chuck Norris’ beard. There is only another fist. -% -When Chuck Norris does a pushup, he isn't lifting himself up, he's pushing the Earth down. -% -Chuck Norris is so fast, he can run around the world and punch himself in the back of the head. -% -Chuck Norris' hand is the only hand that can beat a Royal Flush. -% -Chuck Norris can lead a horse to water AND make it drink. -% -Chuck Norris doesn’t wear a watch. HE decides what time it is. -% -Chuck Norris can slam a revolving door. -% -Chuck Norris does not get frostbite. Chuck Norris bites frost. -% -Remember the Soviet Union? They decided to quit after watching a DeltaForce marathon on Satellite TV. -% -Contrary to popular belief, America is not a democracy, it is a Chucktatorship. -% -If you spell Chuck Norris in Scrabble, you win. Forever. -% -Guns don't kill people. Chuck Norris kills people. -% -There is no theory of evolution. Just a list of animals Chuck Norris allows to live. -% -The chief export of Chuck Norris is Pain. -% -Chuck Norris has two speeds. Walk, and Kill. -% -The leading causes of death in the United States are: 1. Heart Disease 2. Chuck Norris 3. Cancer. -% -Chuck Norris drives an ice cream truck covered in human skulls. -% -Chuck Norris is my Homeboy. -% -Chuck Norris doesn't go hunting.... CHUCK NORRIS GOES KILLING. -% -Chuck Norris uses pepper spray to spice up his steaks. -% -Chuck Norris once roundhouse kicked someone so hard that his foot broke the speed of light, went back in time, and killed Amelia Earhart while she was flying over the Pacific Ocean. -% -Crop circles are Chuck Norris' way of telling the world that sometimes corn needs to lie down. -% -Chuck Norris is ten feet tall, weighs two-tons, breathes fire, and could eat a hammer and take a shotgun blast standing. -% -The Great Wall of China was originally created to keep Chuck Norris out. It failed miserably. -% -Contrary to popular belief, Chuck Norris, not the box jellyfish of northern Australia, is the most venomous creature on earth. -% -Most people have 23 pairs of chromosomes. Chuck Norris has 72... and they're all poisonous. -% -If you ask Chuck Norris what time it is, he always says, "Two seconds 'til." After you ask, "Two seconds 'til what?" he roundhouse kicks you in the face. -% -When Chuck Norris sends in his taxes, he sends blank forms and includes only a picture of himself, crouched and ready to attack. Chuck Norris has not had to pay taxes, ever. -% -The quickest way to a man's heart is with Chuck Norris' fist. -% -Chuck Norris invented Kentucky Fried Chicken's famous secret recipe, with eleven herbs and spices. But nobody ever mentions the twelfth ingredient: Fear. -% -CNN was originally created as the "Chuck Norris Network" to update Americans with on-the-spot ass kicking in real-time. -% -Chuck Norris can win a game of Connect Four in only three moves. -% -What was going through the minds of all of Chuck Norris' victims before they died? His shoe. -% -Chuck Norris is the only man to ever defeat a brick wall in a game of tennis. -% -Police label anyone attacking Chuck Norris as a Code 45-11.... a suicide. -% -Chuck Norris doesn't churn butter. He roundhouse kicks the cows and the butter comes straight out. -% -Chuck Norris doesn’t wash his clothes, he disembowels them. -% -A Handicapped parking sign does not signify that this spot is for handicapped people. It is actually in fact a warning, that the spot belongs to Chuck Norris and that you will be handicapped if you park there. -% -Chuck Norris will attain statehood in 2009. His state flower will be the Magnolia. -% -Someone once videotaped Chuck Norris getting pissed off. It was called Walker: Texas Chain Saw Massacre. -% -Chuck Norris originally appeared in the "Street Fighter II" video game, but was removed by Beta Testers because every button caused him to do a roundhouse kick. When asked bout this "glitch," Norris replied, "That's no glitch." -% -Fool me once, shame on you. Fool Chuck Norris once and he will roundhouse you in the face. -% -More of a question than a fact: in a fight between Chuck Norris and Gordan Freeman who would win? -% -Chuck Norris once round-house kicked a salesman. Over the phone. -% -Chuck Norris can grill a popsicle -% -Chuck Norris' films are factual documentaries. -% -Casinos pay Chuck Norris not to play at anything or wish anyone good luck. -% -Chuck Norris once got a 200 yard punt return -% -Every line in a Chuck Norris haiku is "A roundhouse kick to the face." And they all have the correct number of syllables. -% -An angry glare from Chuck Norris is known to kill on the spot. -% -Evolution's driving mechanism is nature's desperate attempt to escape Chuck Norris. -% -When President Roosevelt dropped the atomic bomb on Hiroshima, he did so only because it was more human then sending Chuck Norris. -% -Don't get Chuck Norris angry, last time somebody did that Chuck Norris made the Grand Canyon. -% -In Texas, there are five sizes for fountain drinks: small, medium, large, Texas sized, and Chuck Norris Sized. It is a cup made of a human skull. -% -After Chuck counted to infinity the first time, he vowed to count to infinity a second time....by counting the bodies of those previously roundhoused. -% -When the Boogeyman goes to sleep every night, he checks his closet for Chuck Norris. -% -Chuck Norris doesn't read books. He stares them down until he gets the information he wants. -% -There is no theory of evolution. Just a list of creatures Chuck Norris has allowed to live. -% -Outer space exists because it's afraid to be on the same planet with Chuck Norris. -% -Chuck Norris does not sleep. He waits. -% -Chuck Norris is currently suing NBC, claiming Law and Order are trademarked names for his left and right legs. -% -Chuck Norris is the reason why Waldo is hiding. -% -Chuck Norris counted to infinity - twice. -% -There is no chin behind Chuck Norris’ beard. There is only another fist. -% -When Chuck Norris does a pushup, he isn't lifting himself up, he's pushing the Earth down. -% -Chuck Norris is so fast, he can run around the world and punch himself in the back of the head. -% -Chuck Norris' hand is the only hand that can beat a Royal Flush. -% -Chuck Norris can lead a horse to water AND make it drink. -% -Chuck Norris doesn’t wear a watch. HE decides what time it is. -% -Chuck Norris can slam a revolving door. -% -Chuck Norris does not get frostbite. Chuck Norris bites frost. -% -Remember the Soviet Union? They decided to quit after watching a DeltaForce marathon on Satellite TV. -% -Contrary to popular belief, America is not a democracy, it is a Chucktatorship. -% -If you spell Chuck Norris in Scrabble, you win. Forever. -% -Guns don't kill people. Chuck Norris kills people. -% -There is no theory of evolution. Just a list of animals Chuck Norris allows to live. -% -The chief export of Chuck Norris is Pain. -% -Chuck Norris has two speeds. Walk, and Kill. -% -The leading causes of death in the United States are: 1. Heart Disease 2. Chuck Norris 3. Cancer. -% -Chuck Norris drives an ice cream truck covered in human skulls. -% -Chuck Norris is my Homeboy. -% -Chuck Norris doesn't go hunting.... CHUCK NORRIS GOES KILLING. -% -Chuck Norris uses pepper spray to spice up his steaks. -% -Chuck Norris once roundhouse kicked someone so hard that his foot broke the speed of light, went back in time, and killed Amelia Earhart while she was flying over the Pacific Ocean. -% -Crop circles are Chuck Norris' way of telling the world that sometimes corn needs to lie down. -% -Chuck Norris is ten feet tall, weighs two-tons, breathes fire, and could eat a hammer and take a shotgun blast standing. -% -The Great Wall of China was originally created to keep Chuck Norris out. It failed miserably. -% -Contrary to popular belief, Chuck Norris, not the box jellyfish of northern Australia, is the most venomous creature on earth. -% -Most people have 23 pairs of chromosomes. Chuck Norris has 72... and they're all poisonous. -% -If you ask Chuck Norris what time it is, he always says, "Two seconds 'til." After you ask, "Two seconds 'til what?" he roundhouse kicks you in the face. -% -When Chuck Norris sends in his taxes, he sends blank forms and includes only a picture of himself, crouched and ready to attack. Chuck Norris has not had to pay taxes, ever. -% -The quickest way to a man's heart is with Chuck Norris' fist. -% -Chuck Norris invented Kentucky Fried Chicken's famous secret recipe, with eleven herbs and spices. But nobody ever mentions the twelfth ingredient: Fear. -% -CNN was originally created as the "Chuck Norris Network" to update Americans with on-the-spot ass kicking in real-time. -% -Chuck Norris can win a game of Connect Four in only three moves. -% -What was going through the minds of all of Chuck Norris' victims before they died? His shoe. -% -Chuck Norris is the only man to ever defeat a brick wall in a game of tennis. -% -Police label anyone attacking Chuck Norris as a Code 45-11.... a suicide. -% -Chuck Norris doesn't churn butter. He roundhouse kicks the cows and the butter comes straight out. -% -Chuck Norris doesn’t wash his clothes, he disembowels them. -% -A Handicapped parking sign does not signify that this spot is for handicapped people. It is actually in fact a warning, that the spot belongs to Chuck Norris and that you will be handicapped if you park there. -% -Chuck Norris will attain statehood in 2009. His state flower will be the Magnolia. -% -Someone once videotaped Chuck Norris getting pissed off. It was called Walker: Texas Chain Saw Massacre. -% -Chuck Norris originally appeared in the "Street Fighter II" video game, but was removed by Beta Testers because every button caused him to do a roundhouse kick. When asked bout this "glitch," Norris replied, "That's no glitch." -% -Fool me once, shame on you. Fool Chuck Norris once and he will roundhouse you in the face. -% -Taking Karate Lessons = $100, Buying MMA DVD's= $150, Subscribing to a UFC event = $50, Getting a Roundhouse Kick from Chuck Norris = PRICELESS -% -Chuck Norris played the game of thrones and won -% -Chuck Norris doesn't need sunglasses, the sun needs Chuck Norris glasses -% -Chuck Norris doesn't call the wrong number, you just answer the wrong phone. -% -Chuck Norris once won the tour de france riding a " big wheel" -% -May the Force be with Chuck Norris... for it's own good. -% -Chuck Norris once played Duck Duck Goose with a group of Kindergarteners. Only one kid made it to first grade -% -During the Civil War Chuck Norris was a slave, his master would often beg him for mercy -% -Chuck Norris' glass is never half full or half empty. It stays full even after he takes a drink. -% - King Kong climbed the Empire State building in fear of Chuck Norris who was downstairs at the time. -% -Chuck Norris can French kiss his elbow. -% -Chuck Norris never trains, because he's Chuck Norris. -% -Every phobia known to man has a phobia of Chuck Norris -% -When the Boogeyman goes to sleep every night, he checks his closet for Chuck Norris. -% -Chuck Norris doesn't read books. He stares them down until he gets the information he wants. -% -There is no theory of evolution. Just a list of creatures Chuck Norris has allowed to live. -% -Outer space exists because it's afraid to be on the same planet with Chuck Norris. -% -Chuck Norris does not sleep. He waits. -% -Chuck Norris is currently suing NBC, claiming Law and Order are trademarked names for his left and right legs. -% -Chuck Norris is the reason why Waldo is hiding. -% -Chuck Norris counted to infinity - twice. -% -There is no chin behind Chuck Norris’ beard. There is only another fist. -% -When Chuck Norris does a pushup, he isn't lifting himself up, he's pushing the Earth down. -% -Chuck Norris is so fast, he can run around the world and punch himself in the back of the head. -% -Chuck Norris' hand is the only hand that can beat a Royal Flush. -% -Chuck Norris can lead a horse to water AND make it drink. -% -Chuck Norris doesn’t wear a watch. HE decides what time it is. -% -Chuck Norris can slam a revolving door. -% -Chuck Norris does not get frostbite. Chuck Norris bites frost. -% -Remember the Soviet Union? They decided to quit after watching a DeltaForce marathon on Satellite TV. -% -Contrary to popular belief, America is not a democracy, it is a Chucktatorship. -% -If you spell Chuck Norris in Scrabble, you win. Forever. -% -Guns don't kill people. Chuck Norris kills people. -% -There is no theory of evolution. Just a list of animals Chuck Norris allows to live. -% -The chief export of Chuck Norris is Pain. -% -Chuck Norris has two speeds. Walk, and Kill. -% -The leading causes of death in the United States are: 1. Heart Disease 2. Chuck Norris 3. Cancer. -% -Chuck Norris drives an ice cream truck covered in human skulls. -% -Chuck Norris is my Homeboy. -% -Chuck Norris doesn't go hunting.... CHUCK NORRIS GOES KILLING. -% -Chuck Norris uses pepper spray to spice up his steaks. -% -Chuck Norris once roundhouse kicked someone so hard that his foot broke the speed of light, went back in time, and killed Amelia Earhart while she was flying over the Pacific Ocean. -% -Crop circles are Chuck Norris' way of telling the world that sometimes corn needs to lie down. -% -Chuck Norris is ten feet tall, weighs two-tons, breathes fire, and could eat a hammer and take a shotgun blast standing. -% -The Great Wall of China was originally created to keep Chuck Norris out. It failed miserably. -% -Contrary to popular belief, Chuck Norris, not the box jellyfish of northern Australia, is the most venomous creature on earth. -% -Most people have 23 pairs of chromosomes. Chuck Norris has 72... and they're all poisonous. -% -If you ask Chuck Norris what time it is, he always says, "Two seconds 'til." After you ask, "Two seconds 'til what?" he roundhouse kicks you in the face. -% -When Chuck Norris sends in his taxes, he sends blank forms and includes only a picture of himself, crouched and ready to attack. Chuck Norris has not had to pay taxes, ever. -% -The quickest way to a man's heart is with Chuck Norris' fist. -% -Chuck Norris invented Kentucky Fried Chicken's famous secret recipe, with eleven herbs and spices. But nobody ever mentions the twelfth ingredient: Fear. -% -CNN was originally created as the "Chuck Norris Network" to update Americans with on-the-spot ass kicking in real-time. -% -Chuck Norris can win a game of Connect Four in only three moves. -% -What was going through the minds of all of Chuck Norris' victims before they died? His shoe. -% -Chuck Norris is the only man to ever defeat a brick wall in a game of tennis. -% -Police label anyone attacking Chuck Norris as a Code 45-11.... a suicide. -% -Chuck Norris doesn't churn butter. He roundhouse kicks the cows and the butter comes straight out. -% -Chuck Norris doesn’t wash his clothes, he disembowels them. -% -A Handicapped parking sign does not signify that this spot is for handicapped people. It is actually in fact a warning, that the spot belongs to Chuck Norris and that you will be handicapped if you park there. -% -Chuck Norris will attain statehood in 2009. His state flower will be the Magnolia. -% -Someone once videotaped Chuck Norris getting pissed off. It was called Walker: Texas Chain Saw Massacre. -% -Chuck Norris originally appeared in the "Street Fighter II" video game, but was removed by Beta Testers because every button caused him to do a roundhouse kick. When asked bout this "glitch," Norris replied, "That's no glitch." -% -Fool me once, shame on you. Fool Chuck Norris once and he will roundhouse you in the face. -% -Once upon a time, Chuck Norris found himself in a town called Shit Creek.....He opened a Paddle Store. -% -Chuck Norris Can Power Solar Panels. At Night. -% -When Betty White gets angry, she turns into the Hulk. When Valerie Bertinelli gets mad, she turns into Chuck Norris. -% -Chuck Norris is so hard, he uses diamonds as stress balls. -% -Chuck Norris can roundhouse kick someone through a window without breaking the glass -% -Chuck Norris. Enough said. -% -The letters in Chuck Norris cannot be unscrambled. -% -Chuck Norris once taught a class of martial arts.Unfortunately Chuck had forgiven to take elephant tranquilizers and killed every one just by saluting -% -Chuck Norris was heard in a soundproof room! -% -Chuck Norris can see in 3D with just one eye. -% -Chuck Norris owns all number 1 pencils. -% -Staring at Chuck Norris for extended periods of time without proper eye protection will cause blindess, and possibly foot sized brusies on the face. -% -Chuck Norris doesn’t brew up tea. He sucks the bag. -% -When the Boogeyman goes to sleep every night, he checks his closet for Chuck Norris. -% -Chuck Norris doesn't read books. He stares them down until he gets the information he wants. -% -There is no theory of evolution. Just a list of creatures Chuck Norris has allowed to live. -% -Outer space exists because it's afraid to be on the same planet with Chuck Norris. -% -Chuck Norris does not sleep. He waits. -% -Chuck Norris is currently suing NBC, claiming Law and Order are trademarked names for his left and right legs. -% -Chuck Norris is the reason why Waldo is hiding. -% -Chuck Norris counted to infinity - twice. -% -There is no chin behind Chuck Norris’ beard. There is only another fist. -% -When Chuck Norris does a pushup, he isn't lifting himself up, he's pushing the Earth down. -% -Chuck Norris is so fast, he can run around the world and punch himself in the back of the head. -% -Chuck Norris' hand is the only hand that can beat a Royal Flush. -% -Chuck Norris can lead a horse to water AND make it drink. -% -Chuck Norris doesn’t wear a watch. HE decides what time it is. -% -Chuck Norris can slam a revolving door. -% -Chuck Norris does not get frostbite. Chuck Norris bites frost. -% -Remember the Soviet Union? They decided to quit after watching a DeltaForce marathon on Satellite TV. -% -Contrary to popular belief, America is not a democracy, it is a Chucktatorship. -% -If you spell Chuck Norris in Scrabble, you win. Forever. -% -Guns don't kill people. Chuck Norris kills people. -% -There is no theory of evolution. Just a list of animals Chuck Norris allows to live. -% -The chief export of Chuck Norris is Pain. -% -Chuck Norris has two speeds. Walk, and Kill. -% -The leading causes of death in the United States are: 1. Heart Disease 2. Chuck Norris 3. Cancer. -% -Chuck Norris drives an ice cream truck covered in human skulls. -% -Chuck Norris is my Homeboy. -% -Chuck Norris doesn't go hunting.... CHUCK NORRIS GOES KILLING. -% -Chuck Norris uses pepper spray to spice up his steaks. -% -Chuck Norris once roundhouse kicked someone so hard that his foot broke the speed of light, went back in time, and killed Amelia Earhart while she was flying over the Pacific Ocean. -% -Crop circles are Chuck Norris' way of telling the world that sometimes corn needs to lie down. -% -Chuck Norris is ten feet tall, weighs two-tons, breathes fire, and could eat a hammer and take a shotgun blast standing. -% -The Great Wall of China was originally created to keep Chuck Norris out. It failed miserably. -% -Contrary to popular belief, Chuck Norris, not the box jellyfish of northern Australia, is the most venomous creature on earth. -% -Most people have 23 pairs of chromosomes. Chuck Norris has 72... and they're all poisonous. -% -If you ask Chuck Norris what time it is, he always says, "Two seconds 'til." After you ask, "Two seconds 'til what?" he roundhouse kicks you in the face. -% -When Chuck Norris sends in his taxes, he sends blank forms and includes only a picture of himself, crouched and ready to attack. Chuck Norris has not had to pay taxes, ever. -% -The quickest way to a man's heart is with Chuck Norris' fist. -% -Chuck Norris invented Kentucky Fried Chicken's famous secret recipe, with eleven herbs and spices. But nobody ever mentions the twelfth ingredient: Fear. -% -CNN was originally created as the "Chuck Norris Network" to update Americans with on-the-spot ass kicking in real-time. -% -Chuck Norris can win a game of Connect Four in only three moves. -% -What was going through the minds of all of Chuck Norris' victims before they died? His shoe. -% -Chuck Norris is the only man to ever defeat a brick wall in a game of tennis. -% -Police label anyone attacking Chuck Norris as a Code 45-11.... a suicide. -% -Chuck Norris doesn't churn butter. He roundhouse kicks the cows and the butter comes straight out. -% -Chuck Norris doesn’t wash his clothes, he disembowels them. -% -A Handicapped parking sign does not signify that this spot is for handicapped people. It is actually in fact a warning, that the spot belongs to Chuck Norris and that you will be handicapped if you park there. -% -Chuck Norris will attain statehood in 2009. His state flower will be the Magnolia. -% -Someone once videotaped Chuck Norris getting pissed off. It was called Walker: Texas Chain Saw Massacre. -% -Chuck Norris originally appeared in the "Street Fighter II" video game, but was removed by Beta Testers because every button caused him to do a roundhouse kick. When asked bout this "glitch," Norris replied, "That's no glitch." -% -Fool me once, shame on you. Fool Chuck Norris once and he will roundhouse you in the face. -% -They say death by a 1000 lashes was the most painful way to die, that was before they got roundhouse kicked in the face by Chuck Norris -% -Chuck Norris made a statue bleed. -% -Dead bodies were found of people that are still alive. These people will cross Chuck Norris in the future and will be round-house kicked back in time. -% -The reason why batman only comes out at night is because he's afraid he might encounter Chuck Norris in the Morning and afternoon. -% -The kids said when Chuck was eating Trix cereal ´´silly Chuck, Trix are for kids´´...what happened next?..............................Darfur happened. -% -Chuck Norris can roundhouse-kick round houses into squares. -% -Chuck Norris is allowed two carry-ons. -% -Chuck Norris can divide by zero. -% -Chuck Norris does not have a cell phone because he hears everything -% -Chuck Norris isn't appropriate...appropriate isn't Chuck Norris -% -Earth's rotation is purely governed by the direction that Chuck Norris is walking. -% -Chuck Norris drowned a man ON LAND. -% -The Jone's are trying to keep up with Chuck Norris -% -When the Boogeyman goes to sleep every night, he checks his closet for Chuck Norris. -% -Chuck Norris doesn't read books. He stares them down until he gets the information he wants. -% -There is no theory of evolution. Just a list of creatures Chuck Norris has allowed to live. -% -Outer space exists because it's afraid to be on the same planet with Chuck Norris. -% -Chuck Norris does not sleep. He waits. -% -Chuck Norris is currently suing NBC, claiming Law and Order are trademarked names for his left and right legs. -% -Chuck Norris is the reason why Waldo is hiding. -% -Chuck Norris counted to infinity - twice. -% -There is no chin behind Chuck Norris’ beard. There is only another fist. -% -When Chuck Norris does a pushup, he isn't lifting himself up, he's pushing the Earth down. -% -Chuck Norris is so fast, he can run around the world and punch himself in the back of the head. -% -Chuck Norris' hand is the only hand that can beat a Royal Flush. -% -Chuck Norris can lead a horse to water AND make it drink. -% -Chuck Norris doesn’t wear a watch. HE decides what time it is. -% -Chuck Norris can slam a revolving door. -% -Chuck Norris does not get frostbite. Chuck Norris bites frost. -% -Remember the Soviet Union? They decided to quit after watching a DeltaForce marathon on Satellite TV. -% -Contrary to popular belief, America is not a democracy, it is a Chucktatorship. -% -If you spell Chuck Norris in Scrabble, you win. Forever. -% -Guns don't kill people. Chuck Norris kills people. -% -There is no theory of evolution. Just a list of animals Chuck Norris allows to live. -% -The chief export of Chuck Norris is Pain. -% -Chuck Norris has two speeds. Walk, and Kill. -% -The leading causes of death in the United States are: 1. Heart Disease 2. Chuck Norris 3. Cancer. -% -Chuck Norris drives an ice cream truck covered in human skulls. -% -Chuck Norris is my Homeboy. -% -Chuck Norris doesn't go hunting.... CHUCK NORRIS GOES KILLING. -% -Chuck Norris uses pepper spray to spice up his steaks. -% -Chuck Norris once roundhouse kicked someone so hard that his foot broke the speed of light, went back in time, and killed Amelia Earhart while she was flying over the Pacific Ocean. -% -Crop circles are Chuck Norris' way of telling the world that sometimes corn needs to lie down. -% -Chuck Norris is ten feet tall, weighs two-tons, breathes fire, and could eat a hammer and take a shotgun blast standing. -% -The Great Wall of China was originally created to keep Chuck Norris out. It failed miserably. -% -Contrary to popular belief, Chuck Norris, not the box jellyfish of northern Australia, is the most venomous creature on earth. -% -Most people have 23 pairs of chromosomes. Chuck Norris has 72... and they're all poisonous. -% -If you ask Chuck Norris what time it is, he always says, "Two seconds 'til." After you ask, "Two seconds 'til what?" he roundhouse kicks you in the face. -% -When Chuck Norris sends in his taxes, he sends blank forms and includes only a picture of himself, crouched and ready to attack. Chuck Norris has not had to pay taxes, ever. -% -The quickest way to a man's heart is with Chuck Norris' fist. -% -Chuck Norris invented Kentucky Fried Chicken's famous secret recipe, with eleven herbs and spices. But nobody ever mentions the twelfth ingredient: Fear. -% -CNN was originally created as the "Chuck Norris Network" to update Americans with on-the-spot ass kicking in real-time. -% -Chuck Norris can win a game of Connect Four in only three moves. -% -What was going through the minds of all of Chuck Norris' victims before they died? His shoe. -% -Chuck Norris is the only man to ever defeat a brick wall in a game of tennis. -% -Police label anyone attacking Chuck Norris as a Code 45-11.... a suicide. -% -Chuck Norris doesn't churn butter. He roundhouse kicks the cows and the butter comes straight out. -% -Chuck Norris doesn’t wash his clothes, he disembowels them. -% -A Handicapped parking sign does not signify that this spot is for handicapped people. It is actually in fact a warning, that the spot belongs to Chuck Norris and that you will be handicapped if you park there. -% -Chuck Norris will attain statehood in 2009. His state flower will be the Magnolia. -% -Someone once videotaped Chuck Norris getting pissed off. It was called Walker: Texas Chain Saw Massacre. -% -Chuck Norris originally appeared in the "Street Fighter II" video game, but was removed by Beta Testers because every button caused him to do a roundhouse kick. When asked bout this "glitch," Norris replied, "That's no glitch." -% -Fool me once, shame on you. Fool Chuck Norris once and he will roundhouse you in the face. -% -Chuck Norris bowled a 301 after constructing another pin out of his beard hair -% -The only reason that USA lost the 2011 world cup to Japan is because Chuck Norris wasn't there. -% -Unlike Jack Bauer, Chuck Norris doesn't need bullets. A quick roundhouse to the face kills twice as fast. -% -There is no such thing as global warming. Chuck Norris was cold, so he turned the sun up. -% -Chuck Norris' dog pick up after him. -% -Jedis are now taught to use the "Chuck" -% -Chuck Norris dosent carry a list. He always knows what to do. -% -When Chuck Norris performs a roundhouse kick, he's actually measuring the circumference of the universe. -% -Walker: Texas Ranger went into syndication before the first episode was shot. -% -Chuck Norris doesn't throw up if he drinks too much. Chuck Norris throws down! -% -"Walker Texas Ranger: The Movie 3-D" was considered by Warner Brothers; however the technology to create the visual effects will never be possible. -% -When Chuck Norris creates a login, it tells him "password not strong enough", he types in his name and it tells him "password too strong." -% -Chuck Norris isn't allowed at the zoo because when he's there the animals are terriefied to come out their cages -% -When the Boogeyman goes to sleep every night, he checks his closet for Chuck Norris. -% -Chuck Norris doesn't read books. He stares them down until he gets the information he wants. -% -There is no theory of evolution. Just a list of creatures Chuck Norris has allowed to live. -% -Outer space exists because it's afraid to be on the same planet with Chuck Norris. -% -Chuck Norris does not sleep. He waits. -% -Chuck Norris is currently suing NBC, claiming Law and Order are trademarked names for his left and right legs. -% -Chuck Norris is the reason why Waldo is hiding. -% -Chuck Norris counted to infinity - twice. -% -There is no chin behind Chuck Norris’ beard. There is only another fist. -% -When Chuck Norris does a pushup, he isn't lifting himself up, he's pushing the Earth down. -% -Chuck Norris is so fast, he can run around the world and punch himself in the back of the head. -% -Chuck Norris' hand is the only hand that can beat a Royal Flush. -% -Chuck Norris can lead a horse to water AND make it drink. -% -Chuck Norris doesn’t wear a watch. HE decides what time it is. -% -Chuck Norris can slam a revolving door. -% -Chuck Norris does not get frostbite. Chuck Norris bites frost. -% -Remember the Soviet Union? They decided to quit after watching a DeltaForce marathon on Satellite TV. -% -Contrary to popular belief, America is not a democracy, it is a Chucktatorship. -% -If you spell Chuck Norris in Scrabble, you win. Forever. -% -Guns don't kill people. Chuck Norris kills people. -% -There is no theory of evolution. Just a list of animals Chuck Norris allows to live. -% -The chief export of Chuck Norris is Pain. -% -Chuck Norris has two speeds. Walk, and Kill. -% -The leading causes of death in the United States are: 1. Heart Disease 2. Chuck Norris 3. Cancer. -% -Chuck Norris drives an ice cream truck covered in human skulls. -% -Chuck Norris is my Homeboy. -% -Chuck Norris doesn't go hunting.... CHUCK NORRIS GOES KILLING. -% -Chuck Norris uses pepper spray to spice up his steaks. -% -Chuck Norris once roundhouse kicked someone so hard that his foot broke the speed of light, went back in time, and killed Amelia Earhart while she was flying over the Pacific Ocean. -% -Crop circles are Chuck Norris' way of telling the world that sometimes corn needs to lie down. -% -Chuck Norris is ten feet tall, weighs two-tons, breathes fire, and could eat a hammer and take a shotgun blast standing. -% -The Great Wall of China was originally created to keep Chuck Norris out. It failed miserably. -% -Contrary to popular belief, Chuck Norris, not the box jellyfish of northern Australia, is the most venomous creature on earth. -% -Most people have 23 pairs of chromosomes. Chuck Norris has 72... and they're all poisonous. -% -If you ask Chuck Norris what time it is, he always says, "Two seconds 'til." After you ask, "Two seconds 'til what?" he roundhouse kicks you in the face. -% -When Chuck Norris sends in his taxes, he sends blank forms and includes only a picture of himself, crouched and ready to attack. Chuck Norris has not had to pay taxes, ever. -% -The quickest way to a man's heart is with Chuck Norris' fist. -% -Chuck Norris invented Kentucky Fried Chicken's famous secret recipe, with eleven herbs and spices. But nobody ever mentions the twelfth ingredient: Fear. -% -CNN was originally created as the "Chuck Norris Network" to update Americans with on-the-spot ass kicking in real-time. -% -Chuck Norris can win a game of Connect Four in only three moves. -% -What was going through the minds of all of Chuck Norris' victims before they died? His shoe. -% -Chuck Norris is the only man to ever defeat a brick wall in a game of tennis. -% -Police label anyone attacking Chuck Norris as a Code 45-11.... a suicide. -% -Chuck Norris doesn't churn butter. He roundhouse kicks the cows and the butter comes straight out. -% -Chuck Norris doesn’t wash his clothes, he disembowels them. -% -A Handicapped parking sign does not signify that this spot is for handicapped people. It is actually in fact a warning, that the spot belongs to Chuck Norris and that you will be handicapped if you park there. -% -Chuck Norris will attain statehood in 2009. His state flower will be the Magnolia. -% -Someone once videotaped Chuck Norris getting pissed off. It was called Walker: Texas Chain Saw Massacre. -% -Chuck Norris originally appeared in the "Street Fighter II" video game, but was removed by Beta Testers because every button caused him to do a roundhouse kick. When asked bout this "glitch," Norris replied, "That's no glitch." -% -Fool me once, shame on you. Fool Chuck Norris once and he will roundhouse you in the face. -% -Aliens fear that Chuck Norris might abduct them. -% -Chuck Norris splattered tiger blood and Adonis' dna on Charlie Sheen with 1 roundhouse kick! -% -How much wood could a woodchuck chuck if a woodchuck could chuck wood? No woodchuck could chuck Chuck's wood! -% -The sun only rises every morning because Chuck Norris allows it to. -% -Chuck Norris can do a regime change with a roundhouse kick. -% -Chuck Norris CAN spell with an I before E even after C. -% -Ghosts can see Chuck Norris -% -The answer to life, the universe and everything isnt 42. It's Chuck Norris. -% -When Chuck Norris pokes the Pillsbury Doughboy, it's not a laughing matter. -% -Chuck Norris once thought he was wrong. He was, however, mistaken. -% -Ever wonder what really happened to the dinosaurs? They all dug their own graves when they heard Chuck Norris was coming -% "The wind cries Chuck Norris" % -Chuck Norris doesn't need a bulletproof vest. He catches them with his bare hands. -% -When the Boogeyman goes to sleep every night, he checks his closet for Chuck Norris. -% -Chuck Norris doesn't read books. He stares them down until he gets the information he wants. -% -There is no theory of evolution. Just a list of creatures Chuck Norris has allowed to live. -% -Outer space exists because it's afraid to be on the same planet with Chuck Norris. -% -Chuck Norris does not sleep. He waits. -% -Chuck Norris is currently suing NBC, claiming Law and Order are trademarked names for his left and right legs. -% -Chuck Norris is the reason why Waldo is hiding. -% -Chuck Norris counted to infinity - twice. -% -There is no chin behind Chuck Norris’ beard. There is only another fist. -% -When Chuck Norris does a pushup, he isn't lifting himself up, he's pushing the Earth down. -% -Chuck Norris is so fast, he can run around the world and punch himself in the back of the head. -% -Chuck Norris' hand is the only hand that can beat a Royal Flush. -% -Chuck Norris can lead a horse to water AND make it drink. -% -Chuck Norris doesn’t wear a watch. HE decides what time it is. -% -Chuck Norris can slam a revolving door. -% -Chuck Norris does not get frostbite. Chuck Norris bites frost. -% -Remember the Soviet Union? They decided to quit after watching a DeltaForce marathon on Satellite TV. -% -Contrary to popular belief, America is not a democracy, it is a Chucktatorship. -% -If you spell Chuck Norris in Scrabble, you win. Forever. -% -Guns don't kill people. Chuck Norris kills people. -% -There is no theory of evolution. Just a list of animals Chuck Norris allows to live. -% -The chief export of Chuck Norris is Pain. -% -Chuck Norris has two speeds. Walk, and Kill. -% -The leading causes of death in the United States are: 1. Heart Disease 2. Chuck Norris 3. Cancer. -% -Chuck Norris drives an ice cream truck covered in human skulls. -% -Chuck Norris is my Homeboy. -% -Chuck Norris doesn't go hunting.... CHUCK NORRIS GOES KILLING. -% -Chuck Norris uses pepper spray to spice up his steaks. -% -Chuck Norris once roundhouse kicked someone so hard that his foot broke the speed of light, went back in time, and killed Amelia Earhart while she was flying over the Pacific Ocean. -% -Crop circles are Chuck Norris' way of telling the world that sometimes corn needs to lie down. -% -Chuck Norris is ten feet tall, weighs two-tons, breathes fire, and could eat a hammer and take a shotgun blast standing. -% -The Great Wall of China was originally created to keep Chuck Norris out. It failed miserably. -% -Contrary to popular belief, Chuck Norris, not the box jellyfish of northern Australia, is the most venomous creature on earth. -% -Most people have 23 pairs of chromosomes. Chuck Norris has 72... and they're all poisonous. -% -If you ask Chuck Norris what time it is, he always says, "Two seconds 'til." After you ask, "Two seconds 'til what?" he roundhouse kicks you in the face. -% -When Chuck Norris sends in his taxes, he sends blank forms and includes only a picture of himself, crouched and ready to attack. Chuck Norris has not had to pay taxes, ever. -% -The quickest way to a man's heart is with Chuck Norris' fist. -% -Chuck Norris invented Kentucky Fried Chicken's famous secret recipe, with eleven herbs and spices. But nobody ever mentions the twelfth ingredient: Fear. -% -CNN was originally created as the "Chuck Norris Network" to update Americans with on-the-spot ass kicking in real-time. -% -Chuck Norris can win a game of Connect Four in only three moves. -% -What was going through the minds of all of Chuck Norris' victims before they died? His shoe. -% -Chuck Norris is the only man to ever defeat a brick wall in a game of tennis. -% -Police label anyone attacking Chuck Norris as a Code 45-11.... a suicide. -% -Chuck Norris doesn't churn butter. He roundhouse kicks the cows and the butter comes straight out. -% -Chuck Norris doesn’t wash his clothes, he disembowels them. +"Walker Texas Ranger: The Movie 3-D" was considered by Warner Brothers; however the technology to create the visual effects will never be possible. % A Handicapped parking sign does not signify that this spot is for handicapped people. It is actually in fact a warning, that the spot belongs to Chuck Norris and that you will be handicapped if you park there. % -Chuck Norris will attain statehood in 2009. His state flower will be the Magnolia. -% -Someone once videotaped Chuck Norris getting pissed off. It was called Walker: Texas Chain Saw Massacre. -% -Chuck Norris originally appeared in the "Street Fighter II" video game, but was removed by Beta Testers because every button caused him to do a roundhouse kick. When asked bout this "glitch," Norris replied, "That's no glitch." -% -Fool me once, shame on you. Fool Chuck Norris once and he will roundhouse you in the face. -% -Chuck Norris: even Naruto can't believe it -% -Chuck Norris can fit 10 gallons of water in a 5 gallon water bucket -% -Chuck Norris roundhouse kicks people in the face first and asks questions later. -% -Chuck Norris is the only one who can tear a facebook page! -% -Chuck Norris doesn't need air, he is air -% -Chuck Norris once tried to teach a fat, stupid kid Martial Arts. Unsuccessfully. The kid grew up to be Steven Seagal. +Abraham Lincoln didn't die because he was shot, Chuck Norris roundhouse-kicked so fast his foot went back in time and killed Abraham Lincoln. % Achievement Unlocked: Chuck Norris of Death % -Chuck Norris is the ghost in paranormal activity. +After Chuck counted to infinity the first time, he vowed to count to infinity a second time....by counting the bodies of those previously roundhoused. % -Chuck Norris can't get fired by Donald Trump +Aliens fear that Chuck Norris might abduct them. % -Ozzy Osbourne once accidentally bit the head off a live bat - Chuck Norris once deliberately bit the head off a live pterodactyl. +An angry glare from Chuck Norris is known to kill on the spot. % -Note to self: Don’t be the cashier to tell Chuck Norris his coupons have expired. +Behind every successful man is Chuck Norris. % -Chuck Norris was what Willis was talking about. +Beware of dogs... Dogs, beware of Chuck Norris. % -Chuck Norris is entitiled to his own facts. -% -When the Boogeyman goes to sleep every night, he checks his closet for Chuck Norris. -% -Chuck Norris doesn't read books. He stares them down until he gets the information he wants. -% -There is no theory of evolution. Just a list of creatures Chuck Norris has allowed to live. -% -Outer space exists because it's afraid to be on the same planet with Chuck Norris. -% -Chuck Norris does not sleep. He waits. -% -Chuck Norris is currently suing NBC, claiming Law and Order are trademarked names for his left and right legs. -% -Chuck Norris is the reason why Waldo is hiding. -% -Chuck Norris counted to infinity - twice. -% -There is no chin behind Chuck Norris’ beard. There is only another fist. -% -When Chuck Norris does a pushup, he isn't lifting himself up, he's pushing the Earth down. -% -Chuck Norris is so fast, he can run around the world and punch himself in the back of the head. -% -Chuck Norris' hand is the only hand that can beat a Royal Flush. -% -Chuck Norris can lead a horse to water AND make it drink. -% -Chuck Norris doesn’t wear a watch. HE decides what time it is. -% -Chuck Norris can slam a revolving door. -% -Chuck Norris does not get frostbite. Chuck Norris bites frost. -% -Remember the Soviet Union? They decided to quit after watching a DeltaForce marathon on Satellite TV. -% -Contrary to popular belief, America is not a democracy, it is a Chucktatorship. -% -If you spell Chuck Norris in Scrabble, you win. Forever. -% -Guns don't kill people. Chuck Norris kills people. -% -There is no theory of evolution. Just a list of animals Chuck Norris allows to live. -% -The chief export of Chuck Norris is Pain. -% -Chuck Norris has two speeds. Walk, and Kill. -% -The leading causes of death in the United States are: 1. Heart Disease 2. Chuck Norris 3. Cancer. -% -Chuck Norris drives an ice cream truck covered in human skulls. -% -Chuck Norris is my Homeboy. -% -Chuck Norris doesn't go hunting.... CHUCK NORRIS GOES KILLING. -% -Chuck Norris uses pepper spray to spice up his steaks. -% -Chuck Norris once roundhouse kicked someone so hard that his foot broke the speed of light, went back in time, and killed Amelia Earhart while she was flying over the Pacific Ocean. -% -Crop circles are Chuck Norris' way of telling the world that sometimes corn needs to lie down. -% -Chuck Norris is ten feet tall, weighs two-tons, breathes fire, and could eat a hammer and take a shotgun blast standing. -% -The Great Wall of China was originally created to keep Chuck Norris out. It failed miserably. -% -Contrary to popular belief, Chuck Norris, not the box jellyfish of northern Australia, is the most venomous creature on earth. -% -Most people have 23 pairs of chromosomes. Chuck Norris has 72... and they're all poisonous. -% -If you ask Chuck Norris what time it is, he always says, "Two seconds 'til." After you ask, "Two seconds 'til what?" he roundhouse kicks you in the face. -% -When Chuck Norris sends in his taxes, he sends blank forms and includes only a picture of himself, crouched and ready to attack. Chuck Norris has not had to pay taxes, ever. -% -The quickest way to a man's heart is with Chuck Norris' fist. -% -Chuck Norris invented Kentucky Fried Chicken's famous secret recipe, with eleven herbs and spices. But nobody ever mentions the twelfth ingredient: Fear. +Bruce Lee didn't defeat Chuck Norris. Chuck hit Bruce with a Delayed roundhouse kick that was so fast that Lee only felt the impact a year later! % CNN was originally created as the "Chuck Norris Network" to update Americans with on-the-spot ass kicking in real-time. % -Chuck Norris can win a game of Connect Four in only three moves. +Casinos pay Chuck Norris not to play at anything or wish anyone good luck. % -What was going through the minds of all of Chuck Norris' victims before they died? His shoe. -% -Chuck Norris is the only man to ever defeat a brick wall in a game of tennis. -% -Police label anyone attacking Chuck Norris as a Code 45-11.... a suicide. -% -Chuck Norris doesn't churn butter. He roundhouse kicks the cows and the butter comes straight out. -% -Chuck Norris doesn’t wash his clothes, he disembowels them. -% -A Handicapped parking sign does not signify that this spot is for handicapped people. It is actually in fact a warning, that the spot belongs to Chuck Norris and that you will be handicapped if you park there. -% -Chuck Norris will attain statehood in 2009. His state flower will be the Magnolia. -% -Someone once videotaped Chuck Norris getting pissed off. It was called Walker: Texas Chain Saw Massacre. -% -Chuck Norris originally appeared in the "Street Fighter II" video game, but was removed by Beta Testers because every button caused him to do a roundhouse kick. When asked bout this "glitch," Norris replied, "That's no glitch." -% -Fool me once, shame on you. Fool Chuck Norris once and he will roundhouse you in the face. -% -While visiting the hexagon, Chuck Norris was asked to demonstrate his famous roundhouse kick. Henceforth, it has been known as the Pentagon. -% -When Chuck Norris played the card game War with a friend, France surrendered. -% -If Goliath listened to Chuck Norris he would have won. -% -Chuck Norris can defuse bomb even if he cut the wrong wire -% -Chuck Norris sleeps in Seattle. -% -Chuck Norris shot a man with a knife -% -The dictionary references Chuck Norris several times, he is metioned under Fear, Law, Order and Chucktatorship. +Chuck Norris - the new standard. % Chuck Norris CAN balance the light-switch between ON and OFF. % -If Chuck was ever captured, he could win a game of Russian Roulette with six bullets in the revolver, he would shoot everyone else! +Chuck Norris CAN believe it's not butter. % -In a rain storm Chuck Norris stays dry. Rain drops are scared to hit him. +Chuck Norris CAN spell with an I before E even after C. % -Chuck Norris is the reason tumbleweeds tumble +Chuck Norris can play the theme from the Twilight Zone with his beard. % -The Earth was almost destroyed by a 50 km wide asteroid in 1984, but Chuck Norris roundhouse kicked it into the Sun. +Chuck Norris can power solar panels. At night. % -Chuck Norris can terminate a repeating decimal. +Chuck Norris watches "the Nat.Geo. Specials" on Discovery Channel. % -When the Boogeyman goes to sleep every night, he checks his closet for Chuck Norris. -% -Chuck Norris doesn't read books. He stares them down until he gets the information he wants. -% -There is no theory of evolution. Just a list of creatures Chuck Norris has allowed to live. -% -Outer space exists because it's afraid to be on the same planet with Chuck Norris. -% -Chuck Norris does not sleep. He waits. -% -Chuck Norris is currently suing NBC, claiming Law and Order are trademarked names for his left and right legs. -% -Chuck Norris is the reason why Waldo is hiding. -% -Chuck Norris counted to infinity - twice. -% -There is no chin behind Chuck Norris’ beard. There is only another fist. -% -When Chuck Norris does a pushup, he isn't lifting himself up, he's pushing the Earth down. -% -Chuck Norris is so fast, he can run around the world and punch himself in the back of the head. -% -Chuck Norris' hand is the only hand that can beat a Royal Flush. -% -Chuck Norris can lead a horse to water AND make it drink. -% -Chuck Norris doesn’t wear a watch. HE decides what time it is. -% -Chuck Norris can slam a revolving door. -% -Chuck Norris does not get frostbite. Chuck Norris bites frost. -% -Remember the Soviet Union? They decided to quit after watching a DeltaForce marathon on Satellite TV. -% -Contrary to popular belief, America is not a democracy, it is a Chucktatorship. -% -If you spell Chuck Norris in Scrabble, you win. Forever. -% -Guns don't kill people. Chuck Norris kills people. -% -There is no theory of evolution. Just a list of animals Chuck Norris allows to live. -% -The chief export of Chuck Norris is Pain. -% -Chuck Norris has two speeds. Walk, and Kill. -% -The leading causes of death in the United States are: 1. Heart Disease 2. Chuck Norris 3. Cancer. -% -Chuck Norris drives an ice cream truck covered in human skulls. -% -Chuck Norris is my Homeboy. -% -Chuck Norris doesn't go hunting.... CHUCK NORRIS GOES KILLING. -% -Chuck Norris uses pepper spray to spice up his steaks. -% -Chuck Norris once roundhouse kicked someone so hard that his foot broke the speed of light, went back in time, and killed Amelia Earhart while she was flying over the Pacific Ocean. -% -Crop circles are Chuck Norris' way of telling the world that sometimes corn needs to lie down. -% -Chuck Norris is ten feet tall, weighs two-tons, breathes fire, and could eat a hammer and take a shotgun blast standing. -% -The Great Wall of China was originally created to keep Chuck Norris out. It failed miserably. -% -Contrary to popular belief, Chuck Norris, not the box jellyfish of northern Australia, is the most venomous creature on earth. -% -Most people have 23 pairs of chromosomes. Chuck Norris has 72... and they're all poisonous. -% -If you ask Chuck Norris what time it is, he always says, "Two seconds 'til." After you ask, "Two seconds 'til what?" he roundhouse kicks you in the face. -% -When Chuck Norris sends in his taxes, he sends blank forms and includes only a picture of himself, crouched and ready to attack. Chuck Norris has not had to pay taxes, ever. -% -The quickest way to a man's heart is with Chuck Norris' fist. -% -Chuck Norris invented Kentucky Fried Chicken's famous secret recipe, with eleven herbs and spices. But nobody ever mentions the twelfth ingredient: Fear. -% -CNN was originally created as the "Chuck Norris Network" to update Americans with on-the-spot ass kicking in real-time. -% -Chuck Norris can win a game of Connect Four in only three moves. -% -What was going through the minds of all of Chuck Norris' victims before they died? His shoe. -% -Chuck Norris is the only man to ever defeat a brick wall in a game of tennis. -% -Police label anyone attacking Chuck Norris as a Code 45-11.... a suicide. -% -Chuck Norris doesn't churn butter. He roundhouse kicks the cows and the butter comes straight out. -% -Chuck Norris doesn’t wash his clothes, he disembowels them. -% -A Handicapped parking sign does not signify that this spot is for handicapped people. It is actually in fact a warning, that the spot belongs to Chuck Norris and that you will be handicapped if you park there. -% -Chuck Norris will attain statehood in 2009. His state flower will be the Magnolia. -% -Someone once videotaped Chuck Norris getting pissed off. It was called Walker: Texas Chain Saw Massacre. -% -Chuck Norris originally appeared in the "Street Fighter II" video game, but was removed by Beta Testers because every button caused him to do a roundhouse kick. When asked bout this "glitch," Norris replied, "That's no glitch." -% -Fool me once, shame on you. Fool Chuck Norris once and he will roundhouse you in the face. -% -Chuck Norris doesn't look for fun. The fun looks for Chuck Norris. -% -Chuck Norris starts his day with 6 live chickens two cows, three pigs and a boiling hot cup of pure fury -% -The only word that rhymes with orange is Chuck Norris -% -Everyone is so scared of Chuck Norris that they kiss his arse by writing these facts, too right they should -% -gmail@chucknorris.com -% -Chuck Norris play's Texas hold em with Zeus, every second Wednesday of the month -% -Chuck Norris has killed the Dead Sea -% -On the keyboard there is no control button because Chuck Norris is always in control. -% -The truth hurts dosen't it, Chuck Norris' truth kills. -% -Chuck Norris sent a BBM to an iphone. -% -When Presidents speak, their nation listens. When Chuck Norris blinks, the whole World listens. -% -Chuck Norris once cried just to see what it was like. The end result was the creation of life. -% -Chuck Norris is the reason that the world will end in 2012. He was getting bored with the Earth -% -When the Boogeyman goes to sleep every night, he checks his closet for Chuck Norris. -% -Chuck Norris doesn't read books. He stares them down until he gets the information he wants. -% -There is no theory of evolution. Just a list of creatures Chuck Norris has allowed to live. -% -Outer space exists because it's afraid to be on the same planet with Chuck Norris. -% -Chuck Norris does not sleep. He waits. -% -Chuck Norris is currently suing NBC, claiming Law and Order are trademarked names for his left and right legs. -% -Chuck Norris is the reason why Waldo is hiding. -% -Chuck Norris counted to infinity - twice. -% -There is no chin behind Chuck Norris’ beard. There is only another fist. -% -When Chuck Norris does a pushup, he isn't lifting himself up, he's pushing the Earth down. -% -Chuck Norris is so fast, he can run around the world and punch himself in the back of the head. -% -Chuck Norris' hand is the only hand that can beat a Royal Flush. -% -Chuck Norris can lead a horse to water AND make it drink. -% -Chuck Norris doesn’t wear a watch. HE decides what time it is. -% -Chuck Norris can slam a revolving door. -% -Chuck Norris does not get frostbite. Chuck Norris bites frost. -% -Remember the Soviet Union? They decided to quit after watching a DeltaForce marathon on Satellite TV. -% -Contrary to popular belief, America is not a democracy, it is a Chucktatorship. -% -If you spell Chuck Norris in Scrabble, you win. Forever. -% -Guns don't kill people. Chuck Norris kills people. -% -There is no theory of evolution. Just a list of animals Chuck Norris allows to live. -% -The chief export of Chuck Norris is Pain. -% -Chuck Norris has two speeds. Walk, and Kill. -% -The leading causes of death in the United States are: 1. Heart Disease 2. Chuck Norris 3. Cancer. -% -Chuck Norris drives an ice cream truck covered in human skulls. -% -Chuck Norris is my Homeboy. -% -Chuck Norris doesn't go hunting.... CHUCK NORRIS GOES KILLING. -% -Chuck Norris uses pepper spray to spice up his steaks. -% -Chuck Norris once roundhouse kicked someone so hard that his foot broke the speed of light, went back in time, and killed Amelia Earhart while she was flying over the Pacific Ocean. -% -Crop circles are Chuck Norris' way of telling the world that sometimes corn needs to lie down. -% -Chuck Norris is ten feet tall, weighs two-tons, breathes fire, and could eat a hammer and take a shotgun blast standing. -% -The Great Wall of China was originally created to keep Chuck Norris out. It failed miserably. -% -Contrary to popular belief, Chuck Norris, not the box jellyfish of northern Australia, is the most venomous creature on earth. -% -Most people have 23 pairs of chromosomes. Chuck Norris has 72... and they're all poisonous. -% -If you ask Chuck Norris what time it is, he always says, "Two seconds 'til." After you ask, "Two seconds 'til what?" he roundhouse kicks you in the face. -% -When Chuck Norris sends in his taxes, he sends blank forms and includes only a picture of himself, crouched and ready to attack. Chuck Norris has not had to pay taxes, ever. -% -The quickest way to a man's heart is with Chuck Norris' fist. -% -Chuck Norris invented Kentucky Fried Chicken's famous secret recipe, with eleven herbs and spices. But nobody ever mentions the twelfth ingredient: Fear. -% -CNN was originally created as the "Chuck Norris Network" to update Americans with on-the-spot ass kicking in real-time. -% -Chuck Norris can win a game of Connect Four in only three moves. -% -What was going through the minds of all of Chuck Norris' victims before they died? His shoe. -% -Chuck Norris is the only man to ever defeat a brick wall in a game of tennis. -% -Police label anyone attacking Chuck Norris as a Code 45-11.... a suicide. -% -Chuck Norris doesn't churn butter. He roundhouse kicks the cows and the butter comes straight out. -% -Chuck Norris doesn’t wash his clothes, he disembowels them. -% -A Handicapped parking sign does not signify that this spot is for handicapped people. It is actually in fact a warning, that the spot belongs to Chuck Norris and that you will be handicapped if you park there. -% -Chuck Norris will attain statehood in 2009. His state flower will be the Magnolia. -% -Someone once videotaped Chuck Norris getting pissed off. It was called Walker: Texas Chain Saw Massacre. -% -Chuck Norris originally appeared in the "Street Fighter II" video game, but was removed by Beta Testers because every button caused him to do a roundhouse kick. When asked bout this "glitch," Norris replied, "That's no glitch." -% -Fool me once, shame on you. Fool Chuck Norris once and he will roundhouse you in the face. -% -Only Chuck Norris is stronger than an Altoid. -% -Chuck Norris has a battlecruiser AND a car. +Chuck Norris bowled a 301 after constructing another pin out of his beard hair. % Chuck Norris burnt a fire proof vest, UNDERWATER! % -Chuck Norris was once turned down for American Idol. When Simon was questioned about it, he replied "I'm retiring after this season". I wonder why? +Chuck Norris can French kiss his elbow. +% +Chuck Norris can bake in a freezer. +% +Chuck Norris can defuse a bomb by cutting the wrong wire. +% +Chuck Norris can dig a hole in air. +% +Chuck Norris can divide by zero. +% +Chuck Norris can do a regime change with a roundhouse kick. +% +Chuck Norris can fit 10 gallons of water in a 5 gallon bucket. +% +Chuck Norris can grill a popsicle. +% +Chuck Norris can lead a horse to water AND make it drink. +% +Chuck Norris can make his own megazord "The Chuck Norris Roundhouse Kickers Ultimate Super Awesome Megazord". +% +Chuck Norris can milk an alligator. +% +Chuck Norris can play the death waltz with his chin. +% +Chuck Norris can roundhouse kick someone through a window without breaking the glass. +% +Chuck Norris can roundhouse-kick round houses into squares. +% +Chuck Norris can rub two fires together and make a stick! +% +Chuck Norris can see in 3D with just one eye. +% +Chuck Norris can slam a revolving door. +% +Chuck Norris can terminate a repeating decimal. +% +Chuck Norris can turn toast back into bread. +% +Chuck Norris can win a game of Connect Four in only three moves. +% +Chuck Norris can win in a top spinning tournament with a cube. +% +Chuck Norris can't perform Hadoukens, he IS a Hadouken. +% +Chuck Norris checks under his bed for Fedor Emelianenko because he takes Fedor to the vet regularly. +% +Chuck Norris counted to infinity - twice. +% +Chuck Norris created Heavy Metal when he was upset. +% +Chuck Norris does not get frostbite. Chuck Norris bites frost. +% +Chuck Norris does not have a cell phone because he hears everything. +% +Chuck Norris does not sleep. He waits. +% +Chuck Norris doesn't bowl strikes, he just knocks down one pin and the other nine faint. +% +Chuck Norris doesn't call the wrong number, you just answer the wrong phone. % Chuck Norris doesn't cheat death, he beats it fair and square. % -When Chuck Norris roundhouse-kicks you HE decides when you will feel the impact . +Chuck Norris doesn't churn butter. He roundhouse kicks the cows and the butter comes straight out. % -Chuck Norris made the big bang just by clicking his fingers +Chuck Norris doesn't eat, he just sucks the energy out of food by staring at it. % -Trick me once, shame on you, trick Chuck Norris.....rest in peace. +Chuck Norris doesn't exhale. The air runs desperately scared out of his lungs. % -Chuck Norris doesn't fight. He gives motivational seminars to die on their own to avoid a roundhouse kick to the face. +Chuck Norris doesn't go hunting.... CHUCK NORRIS GOES KILLING. % -This one time at band camp... BAM! Chuck Norris. +Chuck Norris doesn't let it go. % -Chuck Norris protects his body guards. +Chuck Norris doesn't like Mudkipz. % -Chuck Norris watched the first steps on the moon... From his summer home on Mars +Chuck Norris doesn't look for fun. The fun looks for Chuck Norris. +% +Chuck Norris doesn't need a bulletproof vest. He catches them with his bare hands. +% +Chuck Norris doesn't need air, he is air. +% +Chuck Norris doesn't need sunglasses, the sun needs Chuck Norris glasses. +% +Chuck Norris doesn't need to brush his teeth, his spit acts as a bleach. +% +Chuck Norris doesn't read books. He stares them down until he gets the information he wants. +% +Chuck Norris doesn't throw up if he drinks too much. Chuck Norris throws down! +% +Chuck Norris doesn't eat salad, he eats vegetarians. +% +Chuck Norris doesn't wash his clothes, he disembowels them. +% +Chuck Norris doesn't wear a watch. HE decides what time it is. +% +Chuck Norris doesn't carry a list. He always knows what to do. +% +Chuck Norris drives an ice cream truck covered in human skulls. +% +Chuck Norris drowned a man ON LAND. +% +Chuck Norris fed the Hunger Games. +% +Chuck Norris found the hay in the needle stack. +% +Chuck Norris found the last digit of pi. +% +Chuck Norris had a knife thrown at him. The knife didn't impale him; he impaled the knife. +% +Chuck Norris has a battle cruiser AND a car. +% +Chuck Norris has killed the Dead Sea. +% +Chuck Norris has made a 148 break at snooker. +% +Chuck Norris invented Kentucky Fried Chicken's famous secret recipe, with eleven herbs and spices. But nobody ever mentions the twelfth ingredient: Fear. +% +Chuck Norris is allowed two carry-ons. +% +Chuck Norris is currently suing NBC, claiming Law and Order are trademarked names for his left and right legs. +% +Chuck Norris is currently suing any broadway theater that plays "The Nutcracker". He claims its an infringement on his "other" roundhouse kick. +% +Chuck Norris is entitled to his own facts. +% +Chuck Norris is my Homeboy. +% +Chuck Norris is so fast, he can run around the world and punch himself in the back of the head. +% +Chuck Norris is so hard, he uses diamonds as stress balls. +% +Chuck Norris is so scary, he makes sharks swim backwards away from him. +% +Chuck Norris is ten feet tall, weighs two-tons, breathes fire, and could eat a hammer and take a shotgun blast standing. +% +Chuck Norris is the ghost in paranormal activity. +% +Chuck Norris is the life of parties he doesn't attend. +% +Chuck Norris is the meaning of life. Too bad he's also the meaning of death. +% +Chuck Norris is the only man to ever defeat a brick wall in a game of tennis. +% +Chuck Norris is the only one who can tear a facebook page! +% +Chuck Norris is the reason that the world will end in 2012. He was getting bored with the Earth. +% +Chuck Norris is the reason tumbleweeds tumble. +% +Chuck Norris is the reason why Waldo is hiding. +% +Chuck Norris is waiting for Mt. St. Helens to erupt again. He's hoping the lava is hot enough to soften his beard so he can shave for the first time. +% +Chuck Norris isn't allowed at the zoo, because when he's there the animals are too terrified to come out of their cages. +% +Chuck Norris made a statue bleed. +% +Chuck Norris made the big bang just by clicking his fingers. +% +Chuck Norris never trains, because he's Chuck Norris. +% +Chuck Norris once cried just to see what it was like. The end result was the creation of life. +% +Chuck Norris once cut a knife with a stick of butter. +% +Chuck Norris once got a 200 yard punt return. +% +Chuck Norris once had a pet monkey named KING KONG. +% +Chuck Norris once had a street named after him. The name removed at once, because nobody crosses Chuck Norris, and lives. +% +Chuck Norris once had a weak moment, just to know what it felt like. +% +Chuck Norris once played Duck Duck Goose with a group of Kindergarteners. Only one kid made it to first grade. +% +Chuck Norris once proved p^~p by induction on his beard hairs. +% +Chuck Norris once punched the ground to stop an earthquake. The resulting aftershock caused the BP oil spill. +% +Chuck Norris once round-house kicked a salesman. Over the phone. +% +Chuck Norris once rounhouse kicked a football. The astronomical society now considers it a planet. +% +Chuck Norris once thought he was wrong. He was, however, mistaken. +% +Chuck Norris once walked down a street with his fists in his pockets. He was then arrested for concealing two deadly weapons. +% +Chuck Norris once won the Tour de France riding a "big wheel". +% +Chuck Norris originally appeared in the "Street Fighter II" video game, but was removed by Beta Testers because every button caused him to do a roundhouse kick. When asked bout this "glitch," Norris replied, "That's no glitch." +% +Chuck Norris owns all number 1 pencils. +% +Chuck Norris pees Adamantium. +% +Chuck Norris plays Texas Hold'Em with Zeus, every second Wednesday of the month. +% +Chuck Norris played "Got your Nose" with Voldemort and won. +% +Chuck Norris played the game of thrones and won. +% +Chuck Norris protects his bodyguards. +% +Chuck Norris rolled a 20 on a 6 sided die. +% +Chuck Norris roundhouse kicks people in the face first and asks questions later. +% +Chuck Norris sent a BBM to an iPhone. +% +Chuck Norris shops at Sam's Club, but leaves without having his receipt checked. +% +Chuck Norris splattered tiger blood and Adonis' DNA on Charlie Sheen with 1 roundhouse kick! +% +Chuck Norris started Chuck Norris. +% +Chuck Norris starts his day with 6 live chickens, two cows, three pigs, and a boiling hot cup of pure fury. +% +Chuck Norris told me to put this here. +% +Chuck Norris uses a real mouse to move the cursor, type on the keyboard, write e-mails, code entire websites, and make coffee. +% +Chuck Norris uses pepper spray to spice up his steaks. +% +Chuck Norris was heard in a soundproof room! +% +Chuck Norris was once turned down for American Idol. When Simon was questioned about it, he replied "I'm retiring after this season". I wonder why? +% +Chuck Norris was originally in Mortal Kombat, but that version was deleted because no one can beat Chuck Norris in a fight. +% +Chuck Norris was the image used for Papa Smurf. +% +Chuck Norris was the reason why the Great Wall of China was constructed. It failed miserably. +% +Chuck Norris was what Willis was talking about. +% +Chuck Norris wasn't born on his birthday. +% +Chuck Norris watched the first steps on the moon... from his summer home on Mars. +% +Chuck Norris went up the creek without a paddle... or a canoe. +% +Chuck Norris will attain statehood in 2009. His state flower will be the Magnolia. +% +Chuck Norris wins NASCAR races with all right turns. +% +Chuck Norris won a stepdance contest by standing on his hands. +% +Chuck Norris yells at drill Sergeants. +% +Chuck Norris' dog picks up after him. +% +Chuck Norris' films are factual documentaries. +% +Chuck Norris' first job was as a paperboy. There were no survivors. +% +Chuck Norris' glass is never half full or half empty. It stays full even after he takes a drink. +% +Chuck Norris' hand is the only hand that can beat a Royal Flush. +% +Chuck Norris' personal airplane is called Air Force Chuck. +% +Chuck Norris. Enough said. +% +Chuck Norris: even Naruto can't believe it. +% +Chunk Norris can make sour milk turn fresh. +% +Contrary to popular belief, Rome WAS built in a day, by Chuck Norris. +% +Contrary to popular belief, America is not a democracy, it is a Chucktatorship. +% +Contrary to popular belief, Chuck Norris, not the box jellyfish of northern Australia, is the most venomous creature on Earth. +% +Cops don't need badges in their wallets, but only a picture of Chuck Norris. +% +Crop circles are Chuck Norris' way of telling the world that sometimes corn needs to lie down. +% +Did you hear about the boy who cried Chuck Norris? +% +Dog the Bounty Hunter can't track Chuck Norris down. +% +Don't get Chuck Norris angry. Last time somebody did that, Chuck Norris made the Grand Canyon. +% +Earth's rotation is purely governed by the direction that Chuck Norris is walking. +% +Ever wonder what really happened to the dinosaurs? They all dug their own graves when they heard Chuck Norris was coming. +% +Every line in a Chuck Norris haiku is "A roundhouse kick to the face." And they all have the correct number of syllables. +% +Every phobia known to man has a phobia of Chuck Norris. +% +Every time there's an earthquake, you know Chuck Norris is hungry. The earthquake is caused by his stomach growling. +% +Evolution's driving mechanism is nature's desperate attempt to escape Chuck Norris. +% +Fear of spiders is arachnaphobia. Fear of tight spaces is claustrophobia. Fear of Chuck Norris is called Logic. +% +Fool me once, shame on you. Fool Chuck Norris once and he will roundhouse you in the face. +% +Ghosts can see Chuck Norris. +% +Guns don't kill people. Chuck Norris kills people. +% +How much wood could a woodchuck chuck if a woodchuck could chuck wood? No woodchuck could chuck Chuck's wood! +% +If Chuck Norris were a calendar, every month would be named Chucktober, and every day he'd kick your ass. +% +If Chuck Norris were to get into a fight with another Chuck Norris, Chuck Norris would win. +% +If God doesn't know, Chuck does. +% +If Goliath listened to Chuck Norris, he would have won. +% +If at first you don't succeed, you're not Chuck Norris. +% +If you ask Chuck Norris what time it is, he always says, "Two seconds 'til." After you ask, "Two seconds 'til what?" he roundhouse kicks you in the face. +% +If you put in the correct cheat code in Halo 2, you can have Master Chief play without his helmet, revealing himself to be Chuck Norris. +% +If you see a man in the street who looks like Chuck Norris, but isn't, run: you don't want to be caught in the resulting roundhouse kick to his face. +% +If you spell Chuck Norris in Scrabble, you win. Forever. +% +In 1945 The US army asked if they could clone Chuck Norris. Instead he said he could sort out the Japanese. +% +In Texas, there are five sizes for fountain drinks: small, medium, large, Texas sized, and Chuck Norris sized. It is a cup made of a human skull. +% +In a rain storm Chuck Norris stays dry. Rain drops are scared to hit him. +% +In the back of the book of world records, it says "All records are held by Chuck Norris. The ones listed are in second place." +% +James Bond has a license to kill. He got it from Chuck Norris. +% +Jedis are now taught to use the "Chuck". +% +MacGyver immediately tried to make a bomb out of some Q-Tips and Gatorade, but Chuck Norris roundhouse-kicked him in the solar plexus. MacGyver promptly threw up his own heart. +% +Machiavelli said it is better to be feared than loved because he was inspired by Chuck Norris. +% +May the Force be with Chuck Norris... for its own good. +% +Merlin was Chuck Norris' assistant. +% +Most people have 23 pairs of chromosomes. Chuck Norris has 72... and they're all poisonous. +% +Note to self: Don't be the cashier to tell Chuck Norris his coupons have expired. +% +Chuck Norris' keyboard has no control key. Chuck Norris is always in control. +% +Once upon a time, Chuck Norris found himself in a town called Shit Creek. He opened a Paddle Store. +% +One glance from Chuck Norris and snow turns itself yellow. +% +One time a test cheated on Chuck Norris. +% +Only Chuck Norris can win the mind game, 'cause he never minds. +% +Only Chuck Norris is stronger than an Altoid. +% +Outer space exists because it's afraid to be on the same planet with Chuck Norris. +% +Ozzy Osbourne once accidentally bit the head off a live bat - Chuck Norris once deliberately bit the head off a live pterodactyl. +% +Pluto is actually an orbiting group of British soldiers from the American Revolution who entered space after the Chuck gave them a roundhouse kick to the face. +% +Police label anyone attacking Chuck Norris as a Code 45-11.... a suicide. +% +Remember the Soviet Union? They decided to quit after watching a DeltaForce marathon on Satellite TV. +% +Simon doesn't say... Chuck Norris says. +% +Some boots were made for walking. Some boots may walk all over you, but Chuck Norris' boots walk THROUGH you. +% +Some kids pee their name in snow. Chuck Norris pees his name in concrete. +% +Some people ask for a Kleenex when they sneeze, Chuck Norris asks for a body bag. +% +Someone once videotaped Chuck Norris getting pissed off. It was called Walker: Texas Chain Saw Massacre. +% +Staring at Chuck Norris for extended periods of time without proper eye protection will cause blindess, and possibly foot sized brusies on the face. +% +Taking Karate Lessons = $100, Buying MMA DVD's = $150, Subscribing to a UFC event = $50, Getting a Roundhouse Kick from Chuck Norris = PRICELESS. +% +That's not an eclipse. That's the sun hiding from Chuck Norris. +% +The Beatles are on iTunes because Chuck Norris bought a Mac. % The Earth is made up of two-thirds water and one-third Chuck Norris. % +The Earth was almost destroyed by a 50 km wide asteroid in 1984, but Chuck Norris roundhouse kicked it into the Sun. +% +The Great Wall of China was originally created to keep Chuck Norris out. It failed miserably. +% +The Joneses are trying to keep up with Chuck Norris. +% +The Matrix Trilogy would have ended on the first movie had Keanu Reeves said, “I know Chuck Norris.” +% +The answer to life, the universe and everything isn't 42. It's Chuck Norris. +% +The apple falls far from the tree, when Chuck's roundhouse kick is taken to the trunk. +% +The best part of waking up is not Folgers in your cup. it's knowing that Chuck Norris let you live. +% +The chief export of Chuck Norris is pain. +% +The dictionary references Chuck Norris several times, he is metioned under Fear, Law, Order and Chucktatorship. +% +The leading causes of death in the United States are: 1. Heart Disease 2. Chuck Norris 3. Cancer. +% +The letters in Chuck Norris cannot be unscrambled. +% +The only place where the Starship Enterprise refuses to boldly go is Chuck Norris' planet... which is all of them. +% +The only reason that USA lost the 2011 world cup to Japan is because Chuck Norris wasn't there. +% +The only sure things are Death and Taxes, and when Chuck Norris goes to work for the IRS, they'll be the same thing. +% +The only way sharks will come near CN underwater is when CN is inside of a cage. +% +The only word that rhymes with orange is Chuck Norris. +% +The producers of the movie "The Last Airbender" are now in talks with Chuck Norris in Order to star him in their next sequal "The Last Skull Bender". +% +The quickest way to a man's heart is with Chuck Norris' fist. +% +The reason why Batman only comes out at night is because he's afraid he might encounter Chuck Norris in the morning and afternoon. +% +The red phone in the oval office rings directly to Chuck Norris' cell phone. +% +The show Survivor had the original premise of putting people on an island with Chuck Norris. There were no survivors, and nobody is brave enough to go to the island to retrieve the footage. +% +The square root of Chuck Norris is pain. Do not try to square Chuck Norris. The result is death. +% +The sun only rises every morning because Chuck Norris allows it to. +% +The truth hurts, doesn't it? Chuck Norris' truth kills. +% +There is no chin behind Chuck Norris' beard. There is only another fist. +% +There is no limbo, only a world that doesn't know of Chuck Norris. +% +There is no such thing as global warming. Chuck Norris was cold, so he turned the sun up. +% +There is no theory of evolution, just a list of creatures Chuck Norris has allowed to live. +% +This one time at band camp... BAM! Chuck Norris. +% +Those who ignore history, are doomed by Chuck Norris. +% +Trick me once, shame on you, trick Chuck Norris.. rest in peace. +% +Unlike Jack Bauer, Chuck Norris doesn't need bullets. A quick roundhouse to the face kills twice as fast. +% +Walker: Texas Ranger went into syndication before the first episode was shot. +% +What was going through the minds of all of Chuck Norris' victims before they died? His shoe. +% +Whatever Chuck Norris wants, it will instantly appear. +% +When Betty White gets angry, she turns into the Hulk. When Valerie Bertinelli gets mad, she turns into Chuck Norris. +% +When Chuck Norris creates a login, it tells him "password not strong enough." He types in his name and it tells him "password too strong." +% +When Chuck Norris does a pushup, he isn't lifting himself up, he's pushing the Earth down. +% +When Chuck Norris drinks water, the water automatically pasteurized. +% +When Chuck Norris goes to Vegas, he doesn't have to gamble. The casinos just give him stacks of money. +% +When Chuck Norris goes to rodeos, bulls ride him. +% +When Chuck Norris goes to the library, he looks for the Guinness book of records in the comedy section. +% +When Chuck Norris inhales helium, his voice doesn't change. +% +When Chuck Norris performs a roundhouse kick, he's actually measuring the circumference of the universe. +% +When Chuck Norris played the card game War with a friend, France surrendered. +% +When Chuck Norris pokes the Pillsbury Doughboy, it's not a laughing matter. +% +When Chuck Norris roundhouse-kicks you, he decides when you will feel the impact. +% +When Chuck Norris sends in his taxes, he sends blank forms and includes only a picture of himself, crouched and ready to attack. Chuck Norris has not had to pay taxes, ever. +% +When Chuck Norris tosses a coin, it lands on both heads and tails. +% +When God said "Let there be light!", Chuck Norris said "Only for half the day." +% +When Presidents speak, their nation listens. When Chuck Norris blinks, the whole world listens. +% +When Steven Seagal kills a ninja, he only takes its hide. When Chuck Norris kills a ninja, he uses every part. +% +When chuck Norris was in school, he made his PE teacher run laps. +% +When does Chuck Norris run out of shotgun bullets? whenever he wants to. +% +When taking the SAT, write "Chuck Norris" for every answer. You will score over 8000. +% +When the Boogeyman goes to sleep every night, he checks his closet for Chuck Norris. +% +When things go bump in the night, it's Chuck Norris +% +While visiting the Hexagon, Chuck Norris was asked to demonstrate his famous roundhouse kick. Henceforth, it has been known as the Pentagon. +% +Why didn't the chicken cross the road? Because Chuck Norris got to it first. +% +You know Chuck Norris' pet lizard, right? Last I heard, he was in the movie "Godzilla". Oh, and his pet turtle starred in "Gamera" as well. +% +http://chucknorrisfacts.com/ is built in Drupal because Chuck Norris knows a good CMS when he sees one. +% diff --git a/zsh/plugins/cloudapp/README.md b/zsh/plugins/cloudapp/README.md new file mode 100644 index 0000000..ef304ed --- /dev/null +++ b/zsh/plugins/cloudapp/README.md @@ -0,0 +1,26 @@ +# CloudApp plugin + +## The CloudApp API is deprecated, so the plugin will be removed shortly + +[CloudApp](https://www.getcloudapp.com) brings screen recording, screenshots, and GIF creation to the cloud, in an easy-to-use enterprise-level app. The CloudApp plugin allows you to upload a file to your CloadApp account from the command line. + +To use it, add `cloudapp` to the plugins array of your `~/.zshrc` file: + +```zsh +plugins=(... cloudapp) +``` + +## Requirements + +1. [Aaron Russell's `cloudapp_api` gem](https://github.com/aaronrussell/cloudapp_api#installation) + +2. That you set your CloudApp credentials in `~/.cloudapp` as a simple text file like below: + ``` + email + password + ``` + +## Usage + +- `cloudapp `: uploads `` to your CloudApp account, and if you're using + macOS, copies the URL to your clipboard. diff --git a/zsh/plugins/cloudapp/cloudapp.plugin.zsh b/zsh/plugins/cloudapp/cloudapp.plugin.zsh index 3b363c8..a4d92a0 100644 --- a/zsh/plugins/cloudapp/cloudapp.plugin.zsh +++ b/zsh/plugins/cloudapp/cloudapp.plugin.zsh @@ -1,6 +1,4 @@ -alias cloudapp="${0:a:h}/cloudapp.rb" - -# Ensure only the owner can access the credentials file -if [[ -f ~/.cloudapp ]]; then - chmod 600 ~/.cloudapp -fi +print -Pn "%F{yellow}" +print "[oh-my-zsh] The CloudApp API no longer works, so the cloudapp plugin will" +print "[oh-my-zsh] be removed shortly. Please remove it from your plugins list." +print -Pn "%f" diff --git a/zsh/plugins/cloudapp/cloudapp.rb b/zsh/plugins/cloudapp/cloudapp.rb deleted file mode 100755 index a11cfdb..0000000 --- a/zsh/plugins/cloudapp/cloudapp.rb +++ /dev/null @@ -1,60 +0,0 @@ -#!/usr/bin/env ruby -# -# cloudapp -# Zach Holman / @holman -# -# Uploads a file from the command line to CloudApp, drops it into your -# clipboard (on a Mac, at least). -# -# Example: -# -# cloudapp drunk-blake.png -# -# This requires Aaron Russell's cloudapp_api gem: -# -# gem install cloudapp_api -# -# Requires you set your CloudApp credentials in ~/.cloudapp as a simple file of: -# -# email -# password - -require 'rubygems' -begin - require 'cloudapp_api' -rescue LoadError - puts "You need to install cloudapp_api: gem install cloudapp_api" - exit!(1) -end - -config_file = "#{ENV['HOME']}/.cloudapp" -unless File.exist?(config_file) - puts "You need to type your email and password (one per line) into "+ - "`~/.cloudapp`" - exit!(1) -end - -email,password = File.read(config_file).split("\n") - -class HTTParty::Response - # Apparently HTTPOK.ok? IS NOT OKAY WTFFFFFFFFFFUUUUUUUUUUUUUU - # LETS MONKEY PATCH IT I FEEL OKAY ABOUT IT - def ok? ; true end -end - -if ARGV[0].nil? - puts "You need to specify a file to upload." - exit!(1) -end - -CloudApp.authenticate(email,password) -url = CloudApp::Item.create(:upload, {:file => ARGV[0]}).url - -# Say it for good measure. -puts "Uploaded to #{url}." - -# Get the embed link. -url = "#{url}/#{ARGV[0].split('/').last}" - -# Copy it to your (Mac's) clipboard. -`echo '#{url}' | tr -d "\n" | pbcopy` diff --git a/zsh/plugins/codeclimate/README.md b/zsh/plugins/codeclimate/README.md new file mode 100644 index 0000000..0d712ac --- /dev/null +++ b/zsh/plugins/codeclimate/README.md @@ -0,0 +1,8 @@ +# codeclimate plugin + +This plugin adds autocompletion for the [`codeclimate` CLI](https://github.com/codeclimate/codeclimate). + +To use it, add `codeclimate` to the plugins array in your zshrc file: +```zsh +plugins=(... codeclimate) +``` diff --git a/zsh/plugins/coffee/README.md b/zsh/plugins/coffee/README.md index d6cd074..2baade8 100644 --- a/zsh/plugins/coffee/README.md +++ b/zsh/plugins/coffee/README.md @@ -1,4 +1,4 @@ -## Coffeescript Plugin +# Coffeescript Plugin This plugin provides aliases for quickly compiling and previewing your coffeescript code. diff --git a/zsh/plugins/colemak/README.md b/zsh/plugins/colemak/README.md new file mode 100644 index 0000000..4da4bc1 --- /dev/null +++ b/zsh/plugins/colemak/README.md @@ -0,0 +1,48 @@ +# Colemak plugin + +This plugin remaps keys in `zsh`'s [`vi`-style navigation mode](http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#Keymaps) +for a [Colemak](https://colemak.com/) keyboard layout, to match the QWERTY position: + +![Colemak layout on a US keyboard](https://colemak.com/wiki/images/6/6c/Colemak2.png) + +To use it, add it to the plugins array in your `~/.zshrc` file: + +``` +plugins=(... colemak) +``` + +You will also need to enable `vi` mode, so add another line to `~/.zshrc`: +``` +bindkey -v +``` + +Restart your shell and hit the `` key to activate `vicmd` (navigation) mode, +and start navigating `zsh` with your new keybindings! + +## Key bindings for vicmd + +| Old | New | Binding | Description | +|------------|------------|---------------------------|----------------------------------------------------| +| `CTRL`+`j` | `CTRL`+`n` | accept-line | Insert new line | +| `j` | `n` | down-line-or-history | Move one line down or command history forwards | +| `k` | `e` | up-line-or-history | Move one line up or command history backwards | +| `l` | `i` | vi-forward-char | Move one character to the right | +| `n` | `k` | vi-repeat-search | Repeat command search forwards | +| `N` | `K` | vi-rev-repeat-search | Repeat command search backwards | +| `i` | `u` | vi-insert | Enter insert mode | +| `I` | `U` | vi-insert-bol | Move to first non-blank char and enter insert mode | +| `` | `l` | vi-undo-change | Undo change | +| `J` | `N` | vi-join | Join the current line with the next one | +| `e` | `j` | vi-forward-word-end | Move to the end of the next word | +| `E` | `J` | vi-forward-blank-word-end | Move to end of the current or next word | + +## Key bindings for less + +| Keyboard shortcut | `less` key binding | +|-------------------|--------------------| +| `n` | forw-line | +| `e` | back-line | +| `k` | repeat-search | +| `ESC`+`k` | repeat-search-all | +| `K` | reverse-search | +| `ESC`+`K` | reverse-search-all | diff --git a/zsh/plugins/colored-man-pages/README.md b/zsh/plugins/colored-man-pages/README.md index d9f6acb..f34941e 100644 --- a/zsh/plugins/colored-man-pages/README.md +++ b/zsh/plugins/colored-man-pages/README.md @@ -8,6 +8,9 @@ To use it, add `colored-man-pages` to the plugins array in your zshrc file: plugins=(... colored-man-pages) ``` +It will also automatically colorize man pages displayed by `dman` or `debman`, +from [`debian-goodies`](https://packages.debian.org/stable/debian-goodies). + You can also try to color other pages by prefixing the respective command with `colored`: ```zsh diff --git a/zsh/plugins/colored-man-pages/colored-man-pages.plugin.zsh b/zsh/plugins/colored-man-pages/colored-man-pages.plugin.zsh index ac6a946..ec51847 100644 --- a/zsh/plugins/colored-man-pages/colored-man-pages.plugin.zsh +++ b/zsh/plugins/colored-man-pages/colored-man-pages.plugin.zsh @@ -17,7 +17,7 @@ EOF fi function colored() { - env \ + command env \ LESS_TERMCAP_mb=$(printf "\e[1;31m") \ LESS_TERMCAP_md=$(printf "\e[1;31m") \ LESS_TERMCAP_me=$(printf "\e[0m") \ @@ -31,6 +31,9 @@ function colored() { "$@" } -function man() { - colored man "$@" +# Colorize man and dman/debman (from debian-goodies) +function man \ + dman \ + debman { + colored $0 "$@" } diff --git a/zsh/plugins/colorize/README.md b/zsh/plugins/colorize/README.md index d1f878e..405bb6d 100644 --- a/zsh/plugins/colorize/README.md +++ b/zsh/plugins/colorize/README.md @@ -6,30 +6,51 @@ Colorize will highlight the content based on the filename extension. If it can't method for a given extension, it will try to find one by looking at the file contents. If no highlight method is found it will just cat the file normally, without syntax highlighting. -To use it, add colorize to the plugins array of your zshrc file: +## Setup + +To use it, add colorize to the plugins array of your `~/.zshrc` file: ``` plugins=(... colorize) ``` -## Styles +## Configuration + +### Requirements + +This plugin requires that at least one of the following tools is installed: + +* [Chroma](https://github.com/alecthomas/chroma) +* [Pygments](https://pygments.org/download/) + +### Colorize tool + +Colorize supports `pygmentize` and `chroma` as syntax highlighter. By default colorize uses `pygmentize` unless it's not installed and `chroma` is. This can be overridden by the `ZSH_COLORIZE_TOOL` environment variable: + +``` +ZSH_COLORIZE_TOOL=chroma +``` + +### Styles Pygments offers multiple styles. By default, the `default` style is used, but you can choose another theme by setting the `ZSH_COLORIZE_STYLE` environment variable: -`ZSH_COLORIZE_STYLE="colorful"` +``` +ZSH_COLORIZE_STYLE="colorful" +``` + +### Chroma Formatter Settings + +Chroma supports terminal output in 8 color, 256 color, and true-color. If you need to change the default terminal output style from the standard 8 color output, set the `ZSH_COLORIZE_CHROMA_FORMATTER` environment variable: + +``` +ZSH_COLORIZE_CHROMA_FORMATTER=terminal256 +``` ## Usage -* `ccat [files]`: colorize the contents of the file (or files, if more than one are provided). - If no arguments are passed it will colorize the standard input or stdin. +* `ccat [files]`: colorize the contents of the file (or files, if more than one are provided). + If no files are passed it will colorize the standard input. -* `cless [files]`: colorize the contents of the file (or files, if more than one are provided) and - open less. If no arguments are passed it will colorize the standard input or stdin. - -Note that `cless` will behave as less when provided more than one file: you have to navigate files with -the commands `:n` for next and `:p` for previous. The downside is that less options are not supported. -But you can circumvent this by either using the LESS environment variable, or by running `ccat file1 file2|less --opts`. -In the latter form, the file contents will be concatenated and presented by less as a single file. - -## Requirements - -You have to install Pygments first: [pygments.org](http://pygments.org/download/) +* `cless [less-options] [files]`: colorize the contents of the file (or files, if more than one are provided) and open less. + If no files are passed it will colorize the standard input. + The LESSOPEN and LESSCLOSE will be overwritten for this to work, but only in a local scope. diff --git a/zsh/plugins/colorize/colorize.plugin.zsh b/zsh/plugins/colorize/colorize.plugin.zsh index 565ba5a..80b6919 100644 --- a/zsh/plugins/colorize/colorize.plugin.zsh +++ b/zsh/plugins/colorize/colorize.plugin.zsh @@ -1,57 +1,113 @@ -# easier alias to use the plugin -alias ccat='colorize_via_pygmentize' -alias cless='colorize_via_pygmentize_less' +# Easier alias to use the plugin +alias ccat="colorize_cat" +alias cless="colorize_less" -colorize_via_pygmentize() { - if ! (( $+commands[pygmentize] )); then - echo "package 'Pygments' is not installed!" +# '$0:A' gets the absolute path of this file +ZSH_COLORIZE_PLUGIN_PATH=$0:A + +colorize_check_requirements() { + local available_tools=("chroma" "pygmentize") + + if [ -z "$ZSH_COLORIZE_TOOL" ]; then + if (( $+commands[pygmentize] )); then + ZSH_COLORIZE_TOOL="pygmentize" + elif (( $+commands[chroma] )); then + ZSH_COLORIZE_TOOL="chroma" + else + echo "Neither 'pygments' nor 'chroma' is installed!" >&2 + return 1 + fi + fi + + if [[ ${available_tools[(Ie)$ZSH_COLORIZE_TOOL]} -eq 0 ]]; then + echo "ZSH_COLORIZE_TOOL '$ZSH_COLORIZE_TOOL' not recognized. Available options are 'pygmentize' and 'chroma'." >&2 + return 1 + elif (( $+commands["$ZSH_COLORIZE_TOOL"] )); then + echo "Package '$ZSH_COLORIZE_TOOL' is not installed!" >&2 + return 1 + fi +} + +colorize_cat() { + if ! colorize_check_requirements; then return 1 fi - # If the environment varianle ZSH_COLORIZE_STYLE + # If the environment variable ZSH_COLORIZE_STYLE # is set, use that theme instead. Otherwise, # use the default. - if [ -z $ZSH_COLORIZE_STYLE ]; then - ZSH_COLORIZE_STYLE="default" + if [ -z "$ZSH_COLORIZE_STYLE" ]; then + # Both pygmentize & chroma support 'emacs' + ZSH_COLORIZE_STYLE="emacs" fi - # pygmentize stdin if no arguments passed + # Use stdin if no arguments have been passed. if [ $# -eq 0 ]; then - pygmentize -O style="$ZSH_COLORIZE_STYLE" -g + if [[ "$ZSH_COLORIZE_TOOL" == "pygmentize" ]]; then + pygmentize -O style="$ZSH_COLORIZE_STYLE" -g + else + chroma --style="$ZSH_COLORIZE_STYLE" --formatter="${ZSH_COLORIZE_CHROMA_FORMATTER:-terminal}" + fi return $? fi - # guess lexer from file extension, or - # guess it from file contents if unsuccessful - + # Guess lexer from file extension, or guess it from file contents if unsuccessful. local FNAME lexer - for FNAME in "$@" - do - lexer=$(pygmentize -N "$FNAME") - if [[ $lexer != text ]]; then - pygmentize -O style="$ZSH_COLORIZE_STYLE" -l "$lexer" "$FNAME" + for FNAME in "$@"; do + if [[ "$ZSH_COLORIZE_TOOL" == "pygmentize" ]]; then + lexer=$(pygmentize -N "$FNAME") + if [[ $lexer != text ]]; then + pygmentize -O style="$ZSH_COLORIZE_STYLE" -l "$lexer" "$FNAME" + else + pygmentize -O style="$ZSH_COLORIZE_STYLE" -g "$FNAME" + fi else - pygmentize -O style="$ZSH_COLORIZE_STYLE" -g "$FNAME" + chroma --style="$ZSH_COLORIZE_STYLE" --formatter="${ZSH_COLORIZE_CHROMA_FORMATTER:-terminal}" "$FNAME" fi done } -colorize_via_pygmentize_less() ( - # this function is a subshell so tmp_files can be shared to cleanup function - declare -a tmp_files +# The less option 'F - Forward forever; like "tail -f".' will not work in this implementation +# caused by the lack of the ability to follow the file within pygmentize. +colorize_less() { + if ! colorize_check_requirements; then + return 1 + fi - cleanup () { - [[ ${#tmp_files} -gt 0 ]] && rm -f "${tmp_files[@]}" - exit + _cless() { + # LESS="-R $LESS" enables raw ANSI colors, while maintain already set options. + local LESS="-R $LESS" + + # This variable tells less to pipe every file through the specified command + # (see the man page of less INPUT PREPROCESSOR). + # 'zsh -ic "colorize_cat %s 2> /dev/null"' would not work for huge files like + # the ~/.zsh_history. For such files the tty of the preprocessor will be supended. + # Therefore we must source this file to make colorize_cat available in the + # preprocessor without the interactive mode. + # `2>/dev/null` will suppress the error for large files 'broken pipe' of the python + # script pygmentize, which will show up if less has not fully "loaded the file" + # (e.g. when not scrolled to the bottom) while already the next file will be displayed. + local LESSOPEN="| zsh -c 'source \"$ZSH_COLORIZE_PLUGIN_PATH\"; \ + ZSH_COLORIZE_TOOL=$ZSH_COLORIZE_TOOL ZSH_COLORIZE_STYLE=$ZSH_COLORIZE_STYLE \ + colorize_cat %s 2> /dev/null'" + + # LESSCLOSE will be set to prevent any errors by executing a user script + # which assumes that his LESSOPEN has been executed. + local LESSCLOSE="" + + LESS="$LESS" LESSOPEN="$LESSOPEN" LESSCLOSE="$LESSCLOSE" less "$@" } - trap 'cleanup' EXIT HUP TERM INT - while (( $# != 0 )); do #TODO: filter out less opts - tmp_file="$(mktemp -t "tmp.colorize.XXXX.$(sed 's/\//./g' <<< "$1")")" - tmp_files+=("$tmp_file") - colorize_via_pygmentize "$1" > "$tmp_file" - shift 1 - done - - less -f "${tmp_files[@]}" -) + if [ -t 0 ]; then + _cless "$@" + else + # The input is not associated with a terminal, therefore colorize_cat will + # colorize this input and pass it to less. + # Less has now to decide what to use. If any files have been provided, less + # will ignore the input by default, otherwise the colorized input will be used. + # If files have been supplied and the input has been redirected, this will + # lead to unnecessary overhead, but retains the ability to use the less options + # without checking for them inside this script. + colorize_cat | _cless "$@" + fi +} diff --git a/zsh/plugins/command-not-found/command-not-found.plugin.zsh b/zsh/plugins/command-not-found/command-not-found.plugin.zsh index dd1186e..81d76e6 100644 --- a/zsh/plugins/command-not-found/command-not-found.plugin.zsh +++ b/zsh/plugins/command-not-found/command-not-found.plugin.zsh @@ -26,10 +26,8 @@ fi # OSX command-not-found support # https://github.com/Homebrew/homebrew-command-not-found -if type brew &> /dev/null; then - if brew command command-not-found-init > /dev/null 2>&1; then - eval "$(brew command-not-found-init)"; - fi +if [[ -s '/usr/local/Homebrew/Library/Taps/homebrew/homebrew-command-not-found/handler.sh' ]]; then + source '/usr/local/Homebrew/Library/Taps/homebrew/homebrew-command-not-found/handler.sh' fi # NixOS command-not-found support diff --git a/zsh/plugins/common-aliases/common-aliases.plugin.zsh b/zsh/plugins/common-aliases/common-aliases.plugin.zsh index 785a09c..a9d4f1a 100644 --- a/zsh/plugins/common-aliases/common-aliases.plugin.zsh +++ b/zsh/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} ${ZDOTDIR:-$HOME}/.zshrc' # Quick access to the .zshrc file alias grep='grep --color' alias sgrep='grep -R -n -H -C 5 --exclude-dir={.git,.svn,CVS} ' @@ -50,19 +50,20 @@ alias mv='mv -i' # zsh is able to auto-do some kungfoo # depends on the SUFFIX :) +autoload -Uz is-at-least if is-at-least 4.2.0; then # open browser on urls if [[ -n "$BROWSER" ]]; then _browser_fts=(htm html de org net com at cx nl se dk) - for ft in $_browser_fts; do alias -s $ft=$BROWSER; done + for ft in $_browser_fts; do alias -s $ft='$BROWSER'; done fi _editor_fts=(cpp cxx cc c hh h inl asc txt TXT tex) - for ft in $_editor_fts; do alias -s $ft=$EDITOR; done + for ft in $_editor_fts; do alias -s $ft='$EDITOR'; done if [[ -n "$XIVIEWER" ]]; then _image_fts=(jpg jpeg png gif mng tiff tif xpm) - for ft in $_image_fts; do alias -s $ft=$XIVIEWER; done + for ft in $_image_fts; do alias -s $ft='$XIVIEWER'; done fi _media_fts=(ape avi flv m4a mkv mov mp3 mpeg mpg ogg ogm rm wav webm) diff --git a/zsh/plugins/compleat/README.md b/zsh/plugins/compleat/README.md new file mode 100644 index 0000000..af0e383 --- /dev/null +++ b/zsh/plugins/compleat/README.md @@ -0,0 +1,9 @@ +# compleat plugin + +This plugin looks for [compleat](https://github.com/mbrubeck/compleat) and loads its completion. + +To use it, add compleat to the plugins array in your zshrc file: + +```zsh +plugins=(... compleat) +``` diff --git a/zsh/plugins/composer/README.md b/zsh/plugins/composer/README.md index 2b4bae5..7a5f725 100644 --- a/zsh/plugins/composer/README.md +++ b/zsh/plugins/composer/README.md @@ -12,18 +12,20 @@ plugins=(... composer) ## Aliases -| Alias | Command | Description | -| ------ | -------------------------------------------- | -------------------------------------------------------------------------------------- | -| `c` | composer | Starts composer | -| `csu` | composer self-update | Updates composer to the latest version | -| `cu` | composer update | Updates composer dependencies and `composer.lock` file | -| `cr` | composer require | Adds new packages to `composer.json` | -| `crm` | composer remove | Removes packages from `composer.json` | -| `ci` | composer install | Resolves and installs dependencies from `composer.json` | -| `ccp` | composer create-project | Create new project from an existing package | -| `cdu` | composer dump-autoload | Updates the autoloader | -| `cdo` | composer dump-autoload --optimize-autoloader | Converts PSR-0/4 autoloading to classmap for a faster autoloader (good for production) | -| `cgu` | composer global update | Allows update command to run on COMPOSER_HOME directory | -| `cgr` | composer global require | Allows require command to run on COMPOSER_HOME directory | -| `cgrm` | composer global remove | Allows remove command to run on COMPOSER_HOME directory | -| `cget` | `curl -s https://getcomposer.org/installer` | Installs composer in the current directory | +| Alias | Command | Description | +| ------ | ------------------------------------------- | --------------------------------------------------------------------------------------- | +| `c` | `composer` | Starts composer | +| `csu` | `composer self-update` | Updates composer to the latest version | +| `cu` | `composer update` | Updates composer dependencies and `composer.lock` file | +| `cr` | `composer require` | Adds new packages to `composer.json` | +| `crm` | `composer remove` | Removes packages from `composer.json` | +| `ci` | `composer install` | Resolves and installs dependencies from `composer.json` | +| `ccp` | `composer create-project` | Create new project from an existing package | +| `cdu` | `composer dump-autoload` | Updates the autoloader | +| `cdo` | `composer dump-autoload -o` | Converts PSR-0/4 autoloading to classmap for a faster autoloader (good for production) | +| `cgu` | `composer global update` | Allows update command to run on COMPOSER_HOME directory | +| `cgr` | `composer global require` | Allows require command to run on COMPOSER_HOME directory | +| `cgrm` | `composer global remove` | Allows remove command to run on COMPOSER_HOME directory | +| `cget` | `curl -s https://getcomposer.org/installer` | Installs composer in the current directory | +| `co` | `composer outdated` | Shows a list of installed packages with available updates | +| `cod` | `composer outdated --direct` | Shows a list of installed packages with available updates which are direct dependencies | diff --git a/zsh/plugins/composer/composer.plugin.zsh b/zsh/plugins/composer/composer.plugin.zsh index 6349610..75b03ff 100644 --- a/zsh/plugins/composer/composer.plugin.zsh +++ b/zsh/plugins/composer/composer.plugin.zsh @@ -15,20 +15,16 @@ _composer_get_required_list () { } _composer () { - local curcontext="$curcontext" state line - typeset -A opt_args - _arguments \ - '1: :->command'\ - '*: :->args' + local curcontext="$curcontext" state line + typeset -A opt_args + _arguments \ + '*:: :->subcmds' - case $state in - command) - compadd $(_composer_get_command_list) - ;; - *) - compadd $(_composer_get_required_list) - ;; - esac + if (( CURRENT == 1 )) || ( ((CURRENT == 2)) && [ "$words[1]" = "global" ] ) ; then + compadd $(_composer_get_command_list) + else + compadd $(_composer_get_required_list) + fi } compdef _composer composer @@ -43,17 +39,31 @@ alias crm='composer remove' alias ci='composer install' alias ccp='composer create-project' alias cdu='composer dump-autoload' -alias cdo='composer dump-autoload --optimize-autoloader' +alias cdo='composer dump-autoload -o' alias cgu='composer global update' alias cgr='composer global require' alias cgrm='composer global remove' +alias co='composer outdated' +alias cod='composer outdated --direct' # install composer in the current directory alias cget='curl -s https://getcomposer.org/installer | php' # Add Composer's global binaries to PATH, using Composer if available. if (( $+commands[composer] )); then - export PATH=$PATH:$(composer global config bin-dir --absolute 2>/dev/null) + autoload -Uz _store_cache _retrieve_cache + + _retrieve_cache composer + + if [[ -z $__composer_bin_dir ]]; then + __composer_bin_dir=$(composer global config bin-dir --absolute 2>/dev/null) + _store_cache composer __composer_bin_dir + fi + + # Add Composer's global binaries to PATH + export PATH="$PATH:$__composer_bin_dir" + + unset __composer_bin_dir else [ -d $HOME/.composer/vendor/bin ] && export PATH=$PATH:$HOME/.composer/vendor/bin [ -d $HOME/.config/composer/vendor/bin ] && export PATH=$PATH:$HOME/.config/composer/vendor/bin diff --git a/zsh/plugins/copybuffer/copybuffer.plugin.zsh b/zsh/plugins/copybuffer/copybuffer.plugin.zsh index cc205d4..483ed5a 100644 --- a/zsh/plugins/copybuffer/copybuffer.plugin.zsh +++ b/zsh/plugins/copybuffer/copybuffer.plugin.zsh @@ -1,9 +1,9 @@ # copy the active line from the command line buffer -# onto the system clipboard (requires clipcopy plugin) +# onto the system clipboard copybuffer () { if which clipcopy &>/dev/null; then - echo $BUFFER | clipcopy + printf "%s" "$BUFFER" | clipcopy else echo "clipcopy function not found. Please make sure you have Oh My Zsh installed correctly." fi diff --git a/zsh/plugins/copyfile/README.md b/zsh/plugins/copyfile/README.md index 53138ad..a110b83 100644 --- a/zsh/plugins/copyfile/README.md +++ b/zsh/plugins/copyfile/README.md @@ -3,7 +3,8 @@ Puts the contents of a file in your system clipboard so you can paste it anywhere. To use, add `copyfile` to your plugins array: -``` + +```zsh plugins=(... copyfile) ``` diff --git a/zsh/plugins/cpanm/README.md b/zsh/plugins/cpanm/README.md index 3803e3e..13e93d0 100644 --- a/zsh/plugins/cpanm/README.md +++ b/zsh/plugins/cpanm/README.md @@ -1,9 +1,9 @@ # Cpanm This plugin provides completion for [Cpanm](https://github.com/miyagawa/cpanminus) ([docs](https://metacpan.org/pod/App::cpanminus)). - + To use it add cpanm to the plugins array in your zshrc file. - - ```bash + +```zsh plugins=(... cpanm) ``` diff --git a/zsh/plugins/dash/README.md b/zsh/plugins/dash/README.md new file mode 100644 index 0000000..0ca3e4e --- /dev/null +++ b/zsh/plugins/dash/README.md @@ -0,0 +1,28 @@ +# Dash plugin + +This plugin adds command line functionality for [Dash](https://kapeli.com/dash), +an API Documentation Browser for macOS. This plugin requires Dash to be installed +to work. + +To use it, add `dash` to the plugins array in your zshrc file: + +```zsh +plugins=(... dash) +``` + +## Usage + +- Open and switch to the dash application. +``` +dash +``` + +- Query for something in dash app: `dash query` +``` +dash golang +``` + +- You can optionally provide a keyword: `dash [keyword:]query` +``` +dash python:tuple +``` diff --git a/zsh/plugins/dash/dash.plugin.zsh b/zsh/plugins/dash/dash.plugin.zsh index b00d487..ace2e33 100644 --- a/zsh/plugins/dash/dash.plugin.zsh +++ b/zsh/plugins/dash/dash.plugin.zsh @@ -35,36 +35,30 @@ _dash() { if [[ "$locator" == "platform" ]]; then # Since these are the only special cases right now, let's not do the # expensive processing unless we have to - if [[ "$keyword" == "python" || "$keyword" == "java" || \ - "$keyword" == "qt" || "$keyword" == "cocs2d" ]]; then + if [[ "$keyword" = (python|java|qt|cocos2d) ]]; then docsetName=`echo $doc | grep -Eo "docsetName = .*?;" | sed -e "s/docsetName = \(.*\);/\1/" -e "s/[\":]//g"` - if [[ "$keyword" == "python" ]]; then - if [[ "$docsetName" == "Python 2" ]]; then - keyword="python2" - elif [[ "$docsetName" == "Python 3" ]]; then - keyword="python3" - fi - elif [[ "$keyword" == "java" ]]; then - if [[ "$docsetName" == "Java SE7" ]]; then - keyword="java7" - elif [[ "$docsetName" == "Java SE6" ]]; then - keyword="java6" - elif [[ "$docsetName" == "Java SE8" ]]; then - keyword="java8" - fi - elif [[ "$keyword" == "qt" ]]; then - if [[ "$docsetName" == "Qt 5" ]]; then - keyword="qt5" - elif [[ "$docsetName" == "Qt 4" ]]; then - keyword="qt4" - elif [[ "$docsetName" == "Qt" ]]; then - keyword="qt4" - fi - elif [[ "$keyword" == "cocos2d" ]]; then - if [[ "$docsetName" == "Cocos3D" ]]; then - keyword="cocos3d" - fi - fi + case "$keyword" in + python) + case "$docsetName" in + "Python 2") keyword="python2" ;; + "Python 3") keyword="python3" ;; + esac ;; + java) + case "$docsetName" in + "Java SE7") keyword="java7" ;; + "Java SE6") keyword="java6" ;; + "Java SE8") keyword="java8" ;; + esac ;; + qt) + case "$docsetName" in + "Qt 5") keyword="qt5" ;; + "Qt 4"|Qt) keyword="qt4" ;; + esac ;; + cocos2d) + case "$docsetName" in + Cocos3D) keyword="cocos3d" ;; + esac ;; + esac fi fi diff --git a/zsh/plugins/dircycle/README.md b/zsh/plugins/dircycle/README.md index 3ac162f..3c9b3a9 100644 --- a/zsh/plugins/dircycle/README.md +++ b/zsh/plugins/dircycle/README.md @@ -15,10 +15,10 @@ This plugin enables directory navigation similar to using back and forward on br ) ``` -2. Reload the source file or restart your Terminal session: +2. Restart the shell or restart your Terminal session: ```console - $ source ~/.zshrc + $ exec zsh $ ``` diff --git a/zsh/plugins/direnv/README.md b/zsh/plugins/direnv/README.md new file mode 100644 index 0000000..8deaf38 --- /dev/null +++ b/zsh/plugins/direnv/README.md @@ -0,0 +1,15 @@ +# direnv plugin + +This plugin creates the [Direnv](https://direnv.net/) hook. + +To use it, add `direnv` to the plugins array in your zshrc file: + +```zsh +plugins=(... direnv) +``` + +## Requirements + +In order to make this work, you will need to have the direnv installed. + +More info on the usage and install: https://github.com/direnv/direnv diff --git a/zsh/plugins/direnv/direnv.plugin.zsh b/zsh/plugins/direnv/direnv.plugin.zsh new file mode 100644 index 0000000..5e32c4c --- /dev/null +++ b/zsh/plugins/direnv/direnv.plugin.zsh @@ -0,0 +1,16 @@ +# Don't continue if direnv is not found +command -v direnv &>/dev/null || return + +_direnv_hook() { + trap -- '' SIGINT; + eval "$(direnv export zsh)"; + trap - SIGINT; +} +typeset -ag precmd_functions; +if [[ -z ${precmd_functions[(r)_direnv_hook]} ]]; then + precmd_functions=( _direnv_hook ${precmd_functions[@]} ) +fi +typeset -ag chpwd_functions; +if [[ -z ${chpwd_functions[(r)_direnv_hook]} ]]; then + chpwd_functions=( _direnv_hook ${chpwd_functions[@]} ) +fi diff --git a/zsh/plugins/dirhistory/README.md b/zsh/plugins/dirhistory/README.md index 511f2be..2236507 100644 --- a/zsh/plugins/dirhistory/README.md +++ b/zsh/plugins/dirhistory/README.md @@ -7,6 +7,7 @@ To use it, add `dirhistory` to the plugins array in your zshrc file: ```zsh plugins=(... dirhistory) ``` + ## Keyboard Shortcuts | Shortcut | Description | @@ -15,3 +16,24 @@ plugins=(... dirhistory) | alt + right | Undo alt + left | | alt + up | Move into the parent directory | | alt + down | Move into the first child directory by alphabetical order | + +## Usage + +This plugin allows you to navigate the history of previous current-working-directories using ALT-LEFT and ALT-RIGHT. ALT-LEFT moves back to directories that the user has changed to in the past, and ALT-RIGHT undoes ALT-LEFT. MAC users may alternately use OPT-LEFT and OPT-RIGHT. + +Also, navigate directory **hierarchy** using ALT-UP and ALT-DOWN. (mac keybindings not yet implemented). ALT-UP moves to higher hierarchy (shortcut for 'cd ..'). ALT-DOWN moves into the first directory found in alphabetical order (useful to navigate long empty directories e.g. java packages) + +For example, if the shell was started, and the following commands were entered: + +```shell +cd ~ +cd /usr +cd share +cd doc +``` + +Then entering ALT-LEFT at the prompt would change directory from /usr/share/doc to /usr/share, then if pressed again to /usr/, then ~. If ALT-RIGHT were pressed the directory would be changed to /usr/ again. + +After that, ALT-DOWN will probably go to /usr/bin (depends on your /usr structure), ALT-UP will return to /usr, then ALT-UP will get you to / + +**Currently the max history size is 30**. The navigation should work for xterm, PuTTY xterm mode, GNU screen, and on MAC with alternate keys as mentioned above. diff --git a/zsh/plugins/dirhistory/dirhistory.plugin.zsh b/zsh/plugins/dirhistory/dirhistory.plugin.zsh index 239915e..35c43d7 100644 --- a/zsh/plugins/dirhistory/dirhistory.plugin.zsh +++ b/zsh/plugins/dirhistory/dirhistory.plugin.zsh @@ -53,7 +53,8 @@ function push_future() { } # Called by zsh when directory changes -chpwd_functions+=(chpwd_dirhistory) +autoload -U add-zsh-hook +add-zsh-hook chpwd chpwd_dirhistory function chpwd_dirhistory() { push_past $PWD # If DIRHISTORY_CD is not set... diff --git a/zsh/plugins/dirpersist/README.md b/zsh/plugins/dirpersist/README.md index 9880bc5..792fb4b 100644 --- a/zsh/plugins/dirpersist/README.md +++ b/zsh/plugins/dirpersist/README.md @@ -1,6 +1,7 @@ # Dirpersist plugin -This plugin keeps a running tally of the previous 20 unique directories in the $HOME/.zdirs file. When you cd to a new directory, it is prepended to the beginning of the file. +This plugin keeps a running tally of the previous 20 unique directories in the `$HOME/.zdirs` file. +When you cd to a new directory, it is prepended to the beginning of the file. To use it, add `dirpersist` to the plugins array in your zshrc file: diff --git a/zsh/plugins/dirpersist/dirpersist.plugin.zsh b/zsh/plugins/dirpersist/dirpersist.plugin.zsh index 616e2c3..daadc38 100644 --- a/zsh/plugins/dirpersist/dirpersist.plugin.zsh +++ b/zsh/plugins/dirpersist/dirpersist.plugin.zsh @@ -11,7 +11,8 @@ if [[ -f ${dirstack_file} ]] && [[ ${#dirstack[*]} -eq 0 ]] ; then [[ -d $dirstack[1] ]] && cd $dirstack[1] && cd $OLDPWD fi -chpwd_functions+=(chpwd_dirpersist) +autoload -U add-zsh-hook +add-zsh-hook chpwd chpwd_dirpersist chpwd_dirpersist() { if (( $DIRSTACKSIZE <= 0 )) || [[ -z $dirstack_file ]]; then return; fi local -ax my_stack diff --git a/zsh/plugins/django/README.md b/zsh/plugins/django/README.md index 415f6b7..1740e55 100644 --- a/zsh/plugins/django/README.md +++ b/zsh/plugins/django/README.md @@ -34,23 +34,3 @@ runfcgi -- run this project as a fastcgi runserver -- start a lightweight web server for development ... ``` - -If you want to see the options available for a specific command, try: - -```zsh -$> python manage.py makemessages (press here) -``` - -And that would result in: - -```zsh ---all -a -- re-examine all code and templates ---domain -d -- domain of the message files (default: "django") ---extensions -e -- file extension(s) to examine (default: ".html") ---help -- display help information ---locale -l -- locale to process (default: all) ---pythonpath -- directory to add to the Python path ---settings -- python path to settings module -... -``` - diff --git a/zsh/plugins/django/django.plugin.zsh b/zsh/plugins/django/django.plugin.zsh index 86558ff..c2d00c1 100644 --- a/zsh/plugins/django/django.plugin.zsh +++ b/zsh/plugins/django/django.plugin.zsh @@ -374,7 +374,8 @@ _managepy-commands() { _applist() { local line local -a apps - _call_program help-command "python -c \"import os.path as op, re, django.conf, sys;\\ + _call_program help-command "python -c \"import sys; del sys.path[0];\\ + import os.path as op, re, django.conf;\\ bn=op.basename(op.abspath(op.curdir));[sys\\ .stdout.write(str(re.sub(r'^%s\.(.*?)$' % bn, r'\1', i)) + '\n') for i in django.conf.settings.\\ diff --git a/zsh/plugins/dnf/README.md b/zsh/plugins/dnf/README.md index f9ef496..dc0d1e0 100644 --- a/zsh/plugins/dnf/README.md +++ b/zsh/plugins/dnf/README.md @@ -1,10 +1,14 @@ -## Description +# dnf plugin -This plugin makes `dnf` usage easier by adding aliases for the most -common commands. +This plugin makes `dnf` usage easier by adding aliases for the most common commands. -`dnf` is the new package manager for RPM-based distributions, which -replaces `yum`. +`dnf` is the new package manager for RPM-based distributions, which replaces `yum`. + +To use it, add `dnf` to the plugins array in your zshrc file: + +```zsh +plugins=(... dnf) +``` ## Aliases diff --git a/zsh/plugins/docker-compose/README.md b/zsh/plugins/docker-compose/README.md index 07a87bc..a81c2c7 100644 --- a/zsh/plugins/docker-compose/README.md +++ b/zsh/plugins/docker-compose/README.md @@ -4,7 +4,8 @@ This plugin provides completion for [docker-compose](https://docs.docker.com/com aliases for frequent docker-compose commands. To use it, add docker-compose to the plugins array of your zshrc file: -``` + +```zsh plugins=(... docker-compose) ``` @@ -27,3 +28,4 @@ plugins=(... docker-compose) | dclf | `docker-compose logs -f` | Show logs and follow output | | dcpull | `docker-compose pull` | Pull image of a service | | dcstart | `docker-compose start` | Start a container | +| dck | `docker-compose kill` | Kills containers | diff --git a/zsh/plugins/docker-compose/docker-compose.plugin.zsh b/zsh/plugins/docker-compose/docker-compose.plugin.zsh index 9ffe1ed..5b25b63 100644 --- a/zsh/plugins/docker-compose/docker-compose.plugin.zsh +++ b/zsh/plugins/docker-compose/docker-compose.plugin.zsh @@ -24,3 +24,4 @@ alias dcl='docker-compose logs' alias dclf='docker-compose logs -f' alias dcpull='docker-compose pull' alias dcstart='docker-compose start' +alias dck='docker-compose kill' diff --git a/zsh/plugins/docker/README.md b/zsh/plugins/docker/README.md index e917984..fab7aa8 100644 --- a/zsh/plugins/docker/README.md +++ b/zsh/plugins/docker/README.md @@ -1,5 +1,34 @@ -## Docker autocomplete plugin +# Docker plugin -A copy of the completion script from the -[docker/cli](https://github.com/docker/cli/blob/master/contrib/completion/zsh/_docker) -git repo. +This plugin adds auto-completion for [docker](https://www.docker.com/). + +To use it add `docker` to the plugins array in your zshrc file. + +```zsh +plugins=(... docker) +``` + +A copy of the completion script from the docker/cli git repo: +https://github.com/docker/cli/blob/master/contrib/completion/zsh/_docker + +## Settings + +By default, the completion doesn't allow option-stacking, meaning if you try to +complete `docker run -it ` it won't work, because you're _stacking_ the +`-i` and `-t` options. + +[You can enable it](https://github.com/docker/cli/commit/b10fb43048) by **adding +the lines below to your zshrc file**, but be aware of the side effects: + +> This enables Zsh to understand commands like `docker run -it +> ubuntu`. However, by enabling this, this also makes Zsh complete +> `docker run -u` with `docker run -uapprox` which is not valid. The +> users have to put the space or the equal sign themselves before trying +> to complete. +> +> Therefore, this behavior is disabled by default. To enable it: +> +> ``` +> zstyle ':completion:*:*:docker:*' option-stacking yes +> zstyle ':completion:*:*:docker-*:*' option-stacking yes +> ``` diff --git a/zsh/plugins/docker/_docker b/zsh/plugins/docker/_docker index 54b5e59..10c19e2 100644 --- a/zsh/plugins/docker/_docker +++ b/zsh/plugins/docker/_docker @@ -9,6 +9,7 @@ # - Felix Riedel # - Steve Durrheimer # - Vincent Bernat +# - Rohan Verma # # license: # @@ -604,6 +605,7 @@ __docker_container_subcommand() { "($help)*--blkio-weight-device=[Block IO (relative device weight)]:device:Block IO weight: " "($help)*--cap-add=[Add Linux capabilities]:capability: " "($help)*--cap-drop=[Drop Linux capabilities]:capability: " + "($help)--cgroupns=[Cgroup namespace mode to use]:cgroup namespace mode: " "($help)--cgroup-parent=[Parent cgroup for the container]:cgroup: " "($help)--cidfile=[Write the container ID to the file]:CID file:_files" "($help)--cpus=[Number of CPUs (default 0.000)]:cpus: " @@ -676,6 +678,7 @@ __docker_container_subcommand() { "($help -m --memory)"{-m=,--memory=}"[Memory limit]:Memory limit: " "($help)--memory-reservation=[Memory soft limit]:Memory limit: " "($help)--memory-swap=[Total memory limit with swap]:Memory limit: " + "($help)--pids-limit[Tune container pids limit (set -1 for unlimited)]" "($help)--restart=[Restart policy]:restart policy:(no on-failure always unless-stopped)" ) opts_help=("(: -)--help[Print usage]") @@ -801,7 +804,7 @@ __docker_container_subcommand() { "($help -l --latest)"{-l,--latest}"[Show only the latest created container]" \ "($help -n --last)"{-n=,--last=}"[Show n last created containers (includes all states)]:n:(1 5 10 25 50)" \ "($help)--no-trunc[Do not truncate output]" \ - "($help -q --quiet)"{-q,--quiet}"[Only show numeric IDs]" \ + "($help -q --quiet)"{-q,--quiet}"[Only show container IDs]" \ "($help -s --size)"{-s,--size}"[Display total file sizes]" \ "($help)--since=[Show only containers created since...]:containers:__docker_complete_containers" && ret=0 ;; @@ -832,7 +835,7 @@ __docker_container_subcommand() { _arguments $(__docker_arguments) \ $opts_help \ "($help -t --time)"{-t=,--time=}"[Number of seconds to try to stop for before killing the container]:seconds to before killing:(1 5 10 30 60)" \ - "($help -)*:containers:__docker_complete_containers_ids" && ret=0 + "($help -)*:containers:__docker_complete_containers" && ret=0 ;; (rm) local state @@ -1024,7 +1027,7 @@ __docker_image_subcommand() { $opts_help \ "($help -H --human)"{-H,--human}"[Print sizes and dates in human readable format]" \ "($help)--no-trunc[Do not truncate output]" \ - "($help -q --quiet)"{-q,--quiet}"[Only show numeric IDs]" \ + "($help -q --quiet)"{-q,--quiet}"[Only show image IDs]" \ "($help -)*: :__docker_complete_images" && ret=0 ;; (import) @@ -1056,7 +1059,7 @@ __docker_image_subcommand() { "($help)*"{-f=,--filter=}"[Filter values]:filter:__docker_complete_images_filters" \ "($help)--format=[Pretty-print images using a Go template]:template: " \ "($help)--no-trunc[Do not truncate output]" \ - "($help -q --quiet)"{-q,--quiet}"[Only show numeric IDs]" \ + "($help -q --quiet)"{-q,--quiet}"[Only show image IDs]" \ "($help -): :__docker_complete_repositories" && ret=0 ;; (prune) @@ -1076,6 +1079,7 @@ __docker_image_subcommand() { (push) _arguments $(__docker_arguments) \ $opts_help \ + "($help -a --all-tags)"{-a,--all-tags}"[Push all tagged images in the repository]" \ "($help)--disable-content-trust[Skip image signing]" \ "($help -): :__docker_complete_images" && ret=0 ;; @@ -1286,7 +1290,7 @@ __docker_network_subcommand() { "($help)--no-trunc[Do not truncate the output]" \ "($help)*"{-f=,--filter=}"[Provide filter values]:filter:__docker_network_complete_ls_filters" \ "($help)--format=[Pretty-print networks using a Go template]:template: " \ - "($help -q --quiet)"{-q,--quiet}"[Only display numeric IDs]" && ret=0 + "($help -q --quiet)"{-q,--quiet}"[Only display network IDs]" && ret=0 ;; (prune) _arguments $(__docker_arguments) \ @@ -2214,7 +2218,6 @@ __docker_stack_subcommand() { (deploy|up) _arguments $(__docker_arguments) \ $opts_help \ - "($help)--bundle-file=[Path to a Distributed Application Bundle file]:dab:_files -g \"*.dab\"" \ "($help -c --compose-file)"{-c=,--compose-file=}"[Path to a Compose file, or '-' to read from stdin]:compose file:_files -g \"*.(yml|yaml)\"" \ "($help)--with-registry-auth[Send registry authentication details to Swarm agents]" \ "($help -):stack:__docker_complete_stacks" && ret=0 @@ -2668,6 +2671,7 @@ __docker_subcommand() { "($help)*--log-opt=[Default log driver options for containers]:log driver options:__docker_complete_log_options" \ "($help)--max-concurrent-downloads[Set the max concurrent downloads for each pull]" \ "($help)--max-concurrent-uploads[Set the max concurrent uploads for each push]" \ + "($help)--max-download-attempts[Set the max download attempts for each pull]" \ "($help)--mtu=[Network MTU]:mtu:(0 576 1420 1500 9000)" \ "($help)--oom-score-adjust=[Set the oom_score_adj for the daemon]:oom-score:(-500)" \ "($help -p --pidfile)"{-p=,--pidfile=}"[Path to use for daemon PID file]:PID file:_files" \ @@ -2783,7 +2787,7 @@ __docker_subcommand() { $opts_help \ "($help -p --password)"{-p=,--password=}"[Password]:password: " \ "($help)--password-stdin[Read password from stdin]" \ - "($help -u --user)"{-u=,--user=}"[Username]:username: " \ + "($help -u --username)"{-u=,--username=}"[Username]:username: " \ "($help -)1:server: " && ret=0 ;; (logout) diff --git a/zsh/plugins/dotenv/README.md b/zsh/plugins/dotenv/README.md index cac5524..ab9d329 100644 --- a/zsh/plugins/dotenv/README.md +++ b/zsh/plugins/dotenv/README.md @@ -4,9 +4,7 @@ Automatically load your project ENV variables from `.env` file when you `cd` int Storing configuration in the environment is one of the tenets of a [twelve-factor app](https://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`: +To use it, add `dotenv` to the plugins array in your zshrc file: ```sh plugins=(... dotenv) @@ -17,32 +15,69 @@ plugins=(... dotenv) Create `.env` file inside your project root directory and put your ENV variables there. For example: + ```sh export AWS_S3_TOKEN=d84a83539134f28f412c652b09f9f98eff96c9a export SECRET_KEY=7c6c72d959416d5aa368a409362ec6e2ac90d7f export MONGO_URI=mongodb://127.0.0.1:27017 export PORT=3001 ``` + `export` is optional. This format works as well: + ```sh AWS_S3_TOKEN=d84a83539134f28f412c652b09f9f98eff96c9a 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. +## Settings + ### ZSH_DOTENV_FILE You can also modify the name of the file to be loaded with the variable `ZSH_DOTENV_FILE`. If the variable isn't set, the plugin will default to use `.env`. For example, this will make the plugin look for files named `.dotenv` and load them: -``` +```zsh # in ~/.zshrc, before Oh My Zsh is sourced: ZSH_DOTENV_FILE=.dotenv ``` +### ZSH_DOTENV_PROMPT + +Set `ZSH_DOTENV_PROMPT=false` in your zshrc file if you don't want the confirmation message. +You can also choose the `Always` option when prompted to always allow sourcing the .env file +in that directory. See the next section for more details. + +### ZSH_DOTENV_ALLOWED_LIST, ZSH_DOTENV_DISALLOWED_LIST + +The default behavior of the plugin is to always ask whether to source a dotenv file. There's +a **Y**es, **N**o, **A**lways and N**e**ver option. If you choose Always, the directory of the .env file +will be added to an allowed list; if you choose Never, it will be added to a disallowed list. +If a directory is found in either of those lists, the plugin won't ask for confirmation and will +instead either source the .env file or proceed without action respectively. + +The allowed and disallowed lists are saved by default in `$ZSH_CACHE_DIR/dotenv-allowed.list` and +`$ZSH_CACHE_DIR/dotenv-disallowed.list` respectively. If you want to change that location, +change the `$ZSH_DOTENV_ALLOWED_LIST` and `$ZSH_DOTENV_DISALLOWED_LIST` variables, like so: + +```zsh +# in ~/.zshrc, before Oh My Zsh is sourced: +ZSH_DOTENV_ALLOWED_LIST=/path/to/dotenv/allowed/list +ZSH_DOTENV_DISALLOWED_LIST=/path/to/dotenv/disallowed/list +``` + +The file is just a list of directories, separated by a newline character. If you want +to change your decision, just edit the file and remove the line for the directory you want to +change. + +NOTE: if a directory is found in both the allowed and disallowed lists, the disallowed list +takes preference, _i.e._ the .env file will never be sourced. + ## 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. @@ -52,5 +87,6 @@ ZSH_DOTENV_FILE=.dotenv 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/zsh/plugins/dotenv/dotenv.plugin.zsh b/zsh/plugins/dotenv/dotenv.plugin.zsh index 89763d0..24f285d 100644 --- a/zsh/plugins/dotenv/dotenv.plugin.zsh +++ b/zsh/plugins/dotenv/dotenv.plugin.zsh @@ -1,23 +1,54 @@ +## Settings + +# Filename of the dotenv file to look for +: ${ZSH_DOTENV_FILE:=.env} + +# Path to the file containing allowed paths +: ${ZSH_DOTENV_ALLOWED_LIST:="${ZSH_CACHE_DIR:-$ZSH/cache}/dotenv-allowed.list"} +: ${ZSH_DOTENV_DISALLOWED_LIST:="${ZSH_CACHE_DIR:-$ZSH/cache}/dotenv-disallowed.list"} + + +## Functions + source_env() { if [[ -f $ZSH_DOTENV_FILE ]]; then + if [[ "$ZSH_DOTENV_PROMPT" != false ]]; then + local confirmation dirpath="${PWD:A}" + + # make sure there is an (dis-)allowed file + touch "$ZSH_DOTENV_ALLOWED_LIST" + touch "$ZSH_DOTENV_DISALLOWED_LIST" + + # early return if disallowed + if grep -q "$dirpath" "$ZSH_DOTENV_DISALLOWED_LIST" &>/dev/null; then + return; + fi + + # check if current directory's .env file is allowed or ask for confirmation + if ! grep -q "$dirpath" "$ZSH_DOTENV_ALLOWED_LIST" &>/dev/null; then + # print same-line prompt and output newline character if necessary + echo -n "dotenv: found '$ZSH_DOTENV_FILE' file. Source it? ([Y]es/[n]o/[a]lways/n[e]ver) " + read -k 1 confirmation; [[ "$confirmation" != $'\n' ]] && echo + + # check input + case "$confirmation" in + [nN]) return ;; + [aA]) echo "$dirpath" >> "$ZSH_DOTENV_ALLOWED_LIST" ;; + [eE]) echo "$dirpath" >> "$ZSH_DOTENV_DISALLOWED_LIST"; return ;; + *) ;; # interpret anything else as a yes + esac + fi + fi + # test .env syntax zsh -fn $ZSH_DOTENV_FILE || echo "dotenv: error when sourcing '$ZSH_DOTENV_FILE' file" >&2 - if [[ -o a ]]; then - source $ZSH_DOTENV_FILE - else - set -a - source $ZSH_DOTENV_FILE - set +a - fi + setopt localoptions allexport + source $ZSH_DOTENV_FILE fi } autoload -U add-zsh-hook add-zsh-hook chpwd source_env -if [[ -z $ZSH_DOTENV_FILE ]]; then - ZSH_DOTENV_FILE=.env -fi - source_env diff --git a/zsh/plugins/dotnet/README.md b/zsh/plugins/dotnet/README.md new file mode 100644 index 0000000..7554b4e --- /dev/null +++ b/zsh/plugins/dotnet/README.md @@ -0,0 +1,23 @@ +# .NET Core CLI plugin + +This plugin provides completion and useful aliases for [.NET Core CLI](https://dotnet.microsoft.com/). + +To use it, add `dotnet` to the plugins array in your zshrc file. + +``` +plugins=(... dotnet) +``` + +## Aliases + +| Alias | Command | Description | +|-------|------------------|-------------------------------------------------------------------| +| dn | dotnet new | Create a new .NET project or file. | +| dr | dotnet run | Build and run a .NET project output. | +| dt | dotnet test | Run unit tests using the test runner specified in a .NET project. | +| dw | dotnet watch | Watch for source file changes and restart the dotnet command. | +| dwr | dotnet watch run | Watch for source file changes and restart the `run` command. | +| ds | dotnet sln | Modify Visual Studio solution files. | +| da | dotnet add | Add a package or reference to a .NET project. | +| dp | dotnet pack | Create a NuGet package. | +| dng | dotnet nuget | Provides additional NuGet commands. | diff --git a/zsh/plugins/dotnet/dotnet.plugin.zsh b/zsh/plugins/dotnet/dotnet.plugin.zsh new file mode 100644 index 0000000..6bd4b7a --- /dev/null +++ b/zsh/plugins/dotnet/dotnet.plugin.zsh @@ -0,0 +1,32 @@ +# This scripts is copied from (MIT License): +# https://github.com/dotnet/toolset/blob/master/scripts/register-completions.zsh + +_dotnet_zsh_complete() +{ + local completions=("$(dotnet complete "$words")") + + # If the completion list is empty, just continue with filename selection + if [ -z "$completions" ] + then + _arguments '*::arguments: _normal' + return + fi + + # This is not a variable assigment, don't remove spaces! + _values = "${(ps:\n:)completions}" +} + +compdef _dotnet_zsh_complete dotnet + +# Aliases bellow are here for backwards compatibility +# added by Shaun Tabone (https://github.com/xontab) + +alias dn='dotnet new' +alias dr='dotnet run' +alias dt='dotnet test' +alias dw='dotnet watch' +alias dwr='dotnet watch run' +alias ds='dotnet sln' +alias da='dotnet add' +alias dp='dotnet pack' +alias dng='dotnet nuget' diff --git a/zsh/plugins/eecms/README.md b/zsh/plugins/eecms/README.md new file mode 100644 index 0000000..c538355 --- /dev/null +++ b/zsh/plugins/eecms/README.md @@ -0,0 +1,11 @@ +# eecms plugin + +This plugin adds auto-completion of console commands for [`eecms`](https://github.com/ExpressionEngine/ExpressionEngine). + +To use it, add `eecms` to the plugins array of your `.zshrc` file: +``` +plugins=(... eecms) +``` + +It also adds the alias `eecms` which finds the eecms file in the current project +and runs it with php. diff --git a/zsh/plugins/emacs/emacs.plugin.zsh b/zsh/plugins/emacs/emacs.plugin.zsh index db0ab13..0b602d1 100644 --- a/zsh/plugins/emacs/emacs.plugin.zsh +++ b/zsh/plugins/emacs/emacs.plugin.zsh @@ -26,6 +26,16 @@ if "$ZSH/tools/require_tool.sh" emacsclient 24 2>/dev/null ; then # create a new X frame alias eframe='emacsclient --alternate-editor "" --create-frame' + # Emacs ANSI Term tracking + if [[ -n "$INSIDE_EMACS" ]]; then + chpwd_emacs() { print -P "\033AnSiTc %d"; } + print -P "\033AnSiTc %d" # Track current working directory + print -P "\033AnSiTu %n" # Track username + + # add chpwd hook + autoload -Uz add-zsh-hook + add-zsh-hook chpwd chpwd_emacs + fi # Write to standard output the path to the file # opened in the current buffer. diff --git a/zsh/plugins/emacs/emacsclient.sh b/zsh/plugins/emacs/emacsclient.sh index 26b28d4..0aa8d6f 100755 --- a/zsh/plugins/emacs/emacsclient.sh +++ b/zsh/plugins/emacs/emacsclient.sh @@ -20,7 +20,8 @@ _emacsfun() # tempfile. (first argument will be `--no-wait` passed in by the plugin.zsh) if [ "$#" -ge "2" -a "$2" = "-" ] then - tempfile="$(mktemp emacs-stdin-$USER.XXXXXXX --tmpdir)" + tempfile="$(mktemp --tmpdir emacs-stdin-$USER.XXXXXXX 2>/dev/null \ + || mktemp -t emacs-stdin-$USER)" # support BSD mktemp cat - > "$tempfile" _emacsfun --no-wait $tempfile else diff --git a/zsh/plugins/emoji-clock/emoji-clock.plugin.zsh b/zsh/plugins/emoji-clock/emoji-clock.plugin.zsh index 0a55528..bdd606f 100644 --- a/zsh/plugins/emoji-clock/emoji-clock.plugin.zsh +++ b/zsh/plugins/emoji-clock/emoji-clock.plugin.zsh @@ -2,7 +2,7 @@ # FILE: emoji-clock.plugin.zsh # DESCRIPTION: The current time with half hour accuracy as an emoji symbol. # Inspired by Andre Torrez' "Put A Burger In Your Shell" -# http://notes.torrez.org/2013/04/put-a-burger-in-your-shell.html +# https://notes.torrez.org/2013/04/put-a-burger-in-your-shell.html # AUTHOR: Alexis Hildebrandt (afh[at]surryhill.net) # VERSION: 1.0.0 # ----------------------------------------------------------------------------- diff --git a/zsh/plugins/emotty/README.md b/zsh/plugins/emotty/README.md new file mode 100644 index 0000000..ee57170 --- /dev/null +++ b/zsh/plugins/emotty/README.md @@ -0,0 +1,39 @@ +# emotty plugin + +This plugin returns an emoji for the current $TTY number so it can be used +in a prompt. + +To use it, add emotty to the plugins array in your zshrc file: +``` +plugins=(... emotty) +``` + +**NOTE:** it requires the [emoji plugin](https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/emoji). + +## Usage + +The function `emotty` displays an emoji from the current character set (default: `emoji`), based +on the number associated to the `$TTY`. + +There are different sets of emoji characters available, to choose a different +set, set `$emotty_set` to the name of the set you would like to use, e.g.: +``` +emotty_set=nature +``` + +### Character Sets + +- emoji +- loral +- love +- nature +- stellar +- zodiac + +Use the `display_emotty` function to list the emojis in the current character set, or +the character set passed as the first argument. For example: + +``` +$ display_emotty zodiac + +``` diff --git a/zsh/plugins/encode64/README.md b/zsh/plugins/encode64/README.md index 9850da8..86320cf 100644 --- a/zsh/plugins/encode64/README.md +++ b/zsh/plugins/encode64/README.md @@ -1,6 +1,12 @@ # encode64 -Alias plugin for encoding or decoding using `base64` command +Alias plugin for encoding or decoding using `base64` command. + +To use it, add `encode64` to the plugins array in your zshrc file: + +```zsh +plugins=(... encode64) +``` ## Functions and Aliases @@ -9,23 +15,6 @@ Alias plugin for encoding or decoding using `base64` command | `encode64` | `e64` | Encodes given data to base64 | | `decode64` | `d64` | Decodes given data from base64 | -## Enabling plugin - -1. Edit your `.zshrc` file and add `encode64` to the list of plugins: - - ```sh - plugins=( - # ...other enabled plugins - encode64 - ) - ``` - -2. Restart your terminal session or reload configuration by running: - - ```sh - source ~/.zshrc - ``` - ## Usage and examples ### Encoding @@ -64,6 +53,6 @@ Alias plugin for encoding or decoding using `base64` command ```console $ echo "b2gtbXktenNoCg==" | decode64 oh-my-zsh - $ echo "b2gtbXktenNoCg==" | decode64 + $ echo "b2gtbXktenNoCg==" | d64 oh-my-zsh ``` diff --git a/zsh/plugins/extract/README.md b/zsh/plugins/extract/README.md index 83b878c..b2b731e 100644 --- a/zsh/plugins/extract/README.md +++ b/zsh/plugins/extract/README.md @@ -23,25 +23,35 @@ plugins=(... extract) | `bz2` | Bzip2 file | | `deb` | Debian package | | `gz` | Gzip file | +| `ipa` | iOS app package | | `ipsw` | iOS firmware file | | `jar` | Java Archive | +| `lrz` | LRZ archive | +| `lz4` | LZ4 archive | | `lzma` | LZMA archive | | `rar` | WinRAR archive | +| `rpm` | RPM package | | `sublime-package` | Sublime Text package | | `tar` | Tarball | | `tar.bz2` | Tarball with bzip2 compression | | `tar.gz` | Tarball with gzip compression | +| `tar.lrz` | Tarball with lrzip compression | +| `tar.lz` | Tarball with lzip compression | +| `tar.lz4` | Tarball with lz4 compression | | `tar.xz` | Tarball with lzma2 compression | | `tar.zma` | Tarball with lzma compression | +| `tar.zst` | Tarball with zstd compression | | `tbz` | Tarball with bzip compression | | `tbz2` | Tarball with bzip2 compression | | `tgz` | Tarball with gzip compression | | `tlz` | Tarball with lzma compression | | `txz` | Tarball with lzma2 compression | +| `tzst` | Tarball with zstd compression | | `war` | Web Application archive (Java-based) | | `xpi` | Mozilla XPI module file | | `xz` | LZMA2 archive | | `zip` | Zip archive | +| `zst` | Zstandard file (zstd) | See [list of archive formats](https://en.wikipedia.org/wiki/List_of_archive_formats) for more information regarding archive formats. diff --git a/zsh/plugins/extract/_extract b/zsh/plugins/extract/_extract index 33d49fc..f96f0d4 100644 --- a/zsh/plugins/extract/_extract +++ b/zsh/plugins/extract/_extract @@ -3,5 +3,5 @@ _arguments \ '(-r --remove)'{-r,--remove}'[Remove archive.]' \ - "*::archive file:_files -g '(#i)*.(7z|Z|apk|aar|bz2|deb|gz|ipsw|jar|lzma|rar|sublime-package|tar|tar.bz2|tar.gz|tar.xz|tar.zma|tbz|tbz2|tgz|tlz|txz|war|whl|xpi|xz|zip)(-.)'" \ + "*::archive file:_files -g '(#i)*.(7z|Z|apk|aar|bz2|deb|gz|ipa|ipsw|jar|lrz|lz4|lzma|rar|rpm|sublime-package|tar|tar.bz2|tar.gz|tar.lrz|tar.lz|tar.lz4|tar.xz|tar.zma|tar.zst|tbz|tbz2|tgz|tlz|txz|tzst|war|whl|xpi|xz|zip|zst)(-.)'" \ && return 0 diff --git a/zsh/plugins/extract/extract.plugin.zsh b/zsh/plugins/extract/extract.plugin.zsh index 5e9b9ff..46e69f0 100644 --- a/zsh/plugins/extract/extract.plugin.zsh +++ b/zsh/plugins/extract/extract.plugin.zsh @@ -40,14 +40,24 @@ extract() { tar --lzma --help &> /dev/null \ && tar --lzma -xvf "$1" \ || lzcat "$1" | tar xvf - ;; + (*.tar.zst|*.tzst) + tar --zstd --help &> /dev/null \ + && tar --zstd -xvf "$1" \ + || zstdcat "$1" | tar xvf - ;; (*.tar) tar xvf "$1" ;; - (*.gz) (( $+commands[pigz] )) && pigz -d "$1" || gunzip "$1" ;; + (*.tar.lz) (( $+commands[lzip] )) && tar xvf "$1" ;; + (*.tar.lz4) lz4 -c -d "$1" | tar xvf - ;; + (*.tar.lrz) (( $+commands[lrzuntar] )) && lrzuntar "$1" ;; + (*.gz) (( $+commands[pigz] )) && pigz -dk "$1" || gunzip -k "$1" ;; (*.bz2) bunzip2 "$1" ;; (*.xz) unxz "$1" ;; + (*.lrz) (( $+commands[lrunzip] )) && lrunzip "$1" ;; + (*.lz4) lz4 -d "$1" ;; (*.lzma) unlzma "$1" ;; (*.z) uncompress "$1" ;; - (*.zip|*.war|*.jar|*.sublime-package|*.ipsw|*.xpi|*.apk|*.aar|*.whl) unzip "$1" -d $extract_dir ;; + (*.zip|*.war|*.jar|*.sublime-package|*.ipa|*.ipsw|*.xpi|*.apk|*.aar|*.whl) unzip "$1" -d $extract_dir ;; (*.rar) unrar x -ad "$1" ;; + (*.rpm) mkdir "$extract_dir" && cd "$extract_dir" && rpm2cpio "../$1" | cpio --quiet -id && cd .. ;; (*.7z) 7za x "$1" ;; (*.deb) mkdir -p "$extract_dir/control" @@ -58,6 +68,7 @@ extract() { cd ..; rm *.tar.* debian-binary cd .. ;; + (*.zst) unzstd "$1" ;; (*) echo "extract: '$1' cannot be extracted" >&2 success=1 diff --git a/zsh/plugins/fabric/README.md b/zsh/plugins/fabric/README.md index cf0fa81..f121d2e 100644 --- a/zsh/plugins/fabric/README.md +++ b/zsh/plugins/fabric/README.md @@ -4,6 +4,6 @@ This plugin provides completion for [Fabric](https://www.fabfile.org/). To use it add fabric to the plugins array in your zshrc file. -```bash +```zsh plugins=(... fabric) ``` diff --git a/zsh/plugins/fabric/_fab b/zsh/plugins/fabric/_fab index 4c2e613..9102dad 100644 --- a/zsh/plugins/fabric/_fab +++ b/zsh/plugins/fabric/_fab @@ -4,10 +4,19 @@ local curcontext=$curcontext state line declare -A opt_args -declare target_list -target_list=(`fab --shortlist 2>/dev/null || fab --complete 2>/dev/null`) +declare -a target_list +target_list=("${(@f)$(fab -l 2>/dev/null | awk '{ + if (NF == 0 || NR == 1) next + if (NF < 2) print $1 + else { + docstring=substr($0, index($0,$2)) + gsub(":", "\\:", docstring) + print $1":"docstring + } +}')}") -_targets() { +_fab_targets() { + [[ -n "$target_list" ]] || return _describe -t commands "fabric targets" target_list } @@ -28,7 +37,7 @@ _arguments -w -S -C \ '(-)--shortlist[print non-verbose list of possible commands and exit]: :->noargs' \ '(--reject-unknown-hosts)--reject-unknown-hosts[reject unknown hosts]' \ '(--no-pty)--no-pty[do not use pseudo-terminal in run/sudo]' \ - "(-d+ --display=-)"{-d+,--display=-}"[print detailed info about a given command]: :_targets" \ + "(-d+ --display=-)"{-d+,--display=-}"[print detailed info about a given command]: :_fab_targets" \ '(-D --disable-known-hosts)'{-D,--disable-known-hosts}'[do not load user known_hosts file]' \ '(-r --reject-unknown-hosts)'{-r,--reject-unknown-hosts}'[reject unknown hosts]' \ '(-u+ --user=-)'{-u+,--user=-}'[username to use when connecting to remote hosts]: :' \ @@ -53,7 +62,7 @@ if [[ CURRENT -ge 1 ]]; then levels) _describe -t commands "output levels" output_levels;; *) - _targets;; + _fab_targets;; esac return diff --git a/zsh/plugins/fancy-ctrl-z/fancy-ctrl-z.plugin.zsh b/zsh/plugins/fancy-ctrl-z/fancy-ctrl-z.plugin.zsh index 8ab2979..82b9688 100644 --- a/zsh/plugins/fancy-ctrl-z/fancy-ctrl-z.plugin.zsh +++ b/zsh/plugins/fancy-ctrl-z/fancy-ctrl-z.plugin.zsh @@ -1,10 +1,10 @@ fancy-ctrl-z () { if [[ $#BUFFER -eq 0 ]]; then BUFFER="fg" - zle accept-line + zle accept-line -w else - zle push-input - zle clear-screen + zle push-input -w + zle clear-screen -w fi } zle -N fancy-ctrl-z diff --git a/zsh/plugins/fasd/README.md b/zsh/plugins/fasd/README.md new file mode 100644 index 0000000..a5c74e5 --- /dev/null +++ b/zsh/plugins/fasd/README.md @@ -0,0 +1,21 @@ +# fasd + +[`Fasd`](https://github.com/clvv/fasd) (pronounced similar to "fast") is a command-line productivity booster. Fasd offers quick access to files and directories for POSIX shells. + +To use it, add `fasd` to the plugins array in your zshrc file: + +```zsh +plugins=(... fasd) +``` + +## Installation + +Please find detailed installation guide [`here`](https://github.com/clvv/fasd#install) + +## Aliases + +| Alias | Command | Description | +|-------|-------------------------------------------|-------------------------------------------------------------| +| v | `fasd -f -e "$EDITOR"` | List frequent/recent files matching the given filename. | +| o | `fasd -a -e xdg-open` | List frequent/recent files and directories matching. | +| j | `fasd_cd -d -i` | cd with interactive selection | diff --git a/zsh/plugins/fasd/fasd.plugin.zsh b/zsh/plugins/fasd/fasd.plugin.zsh index ec2e518..6538d09 100644 --- a/zsh/plugins/fasd/fasd.plugin.zsh +++ b/zsh/plugins/fasd/fasd.plugin.zsh @@ -1,12 +1,16 @@ -if [ $commands[fasd] ]; then # check if fasd is installed - fasd_cache="${ZSH_CACHE_DIR}/fasd-init-cache" - if [ "$(command -v fasd)" -nt "$fasd_cache" -o ! -s "$fasd_cache" ]; then - fasd --init auto >| "$fasd_cache" - fi - source "$fasd_cache" - unset fasd_cache - - alias v='f -e "$EDITOR"' - alias o='a -e xdg-open' - alias j='zz' +# check if fasd is installed +if (( ! ${+commands[fasd]} )); then + return fi + +fasd_cache="${ZSH_CACHE_DIR}/fasd-init-cache" +if [[ "$commands[fasd]" -nt "$fasd_cache" || ! -s "$fasd_cache" ]]; then + fasd --init posix-alias zsh-hook zsh-ccomp zsh-ccomp-install \ + zsh-wcomp zsh-wcomp-install >| "$fasd_cache" +fi +source "$fasd_cache" +unset fasd_cache + +alias v='f -e "$EDITOR"' +alias o='a -e xdg-open' +alias j='zz' diff --git a/zsh/plugins/fastfile/README.md b/zsh/plugins/fastfile/README.md new file mode 100644 index 0000000..37f5b2f --- /dev/null +++ b/zsh/plugins/fastfile/README.md @@ -0,0 +1,84 @@ +# Fastfile plugin + +This plugin adds a way to reference certain files or folders used frequently using +a global alias or shortcut. + +To use it, add `fastfile` to the plugins array in your zshrc file: +```zsh +plugins=(... fastfile) +``` + +## Usage + +Example: you access folder `/code/project/backend/database` very frequently. + +First, generate a shortcut with the name `pjdb`: +```zsh +$ fastfile pjdb /code/project/backend/database +``` + +Next time you want to access it, use `§pjdb`. For example: +```zsh +$ cd §pjdb +$ subl §pjdb +``` +where § is the fastfile prefix (see [below](#options) for how to change). + +**Note:** shortcuts with spaces in the name are assigned a global alias +where the spaces have been substituted with underscores (`_`). For example: +a shortcut named `"hello world"` corresponds with `§hello_world`. + + +## Functions + +- `fastfile `: generate a shortcut. + +- `fastfile_print `: prints a shortcut, with the format + ` -> `. + +- `fastfile_ls`: lists all shortcuts. + +- `fastfile_rm `: remove a shortcut. + +- `fastfile_sync`: generates the global aliases for the shortcuts. + + +### Internal functions + +- `fastfile_resolv `: resolves the location of the shortcut + file, i.e., the file in the fastfile directory where the shortcut path + is stored. + +- `fastfile_get `: get the real path of the shortcut. + + +## Aliases + +| Alias | Function | +|--------|------------------| +| ff | `fastfile` | +| ffp | `fastfile_print` | +| ffrm | `fastfile_rm` | +| ffls | `fastfile_ls` | +| ffsync | `fastfile_sync` | + + +## Options + +These are options you can set to change certain parts of the plugin. To change +them, add `=` to your zshrc file, before Oh My Zsh is sourced. +For example: `fastfile_var_prefix='@'`. + +- `fastfile_var_prefix`: prefix for the global aliases created. Controls the prefix of the + created global aliases. + **Default:** `§` (section sign), easy to type in a german keyboard via the combination + [`⇧ Shift`+`3`](https://en.wikipedia.org/wiki/German_keyboard_layout#/media/File:KB_Germany.svg), + or using `⌥ Option`+`6` in macOS. + +- `fastfile_dir`: directory where the fastfile shortcuts are stored. Needs to end + with a trailing slash. + **Default:** `$HOME/.fastfile/`. + +## Author + +- [Karolin Varner](https://github.com/koraa) diff --git a/zsh/plugins/fastfile/fastfile.plugin.zsh b/zsh/plugins/fastfile/fastfile.plugin.zsh index 775e948..ccbbce3 100644 --- a/zsh/plugins/fastfile/fastfile.plugin.zsh +++ b/zsh/plugins/fastfile/fastfile.plugin.zsh @@ -1,21 +1,11 @@ -################################################################################ -# FILE: fastfile.plugin.zsh -# DESCRIPTION: oh-my-zsh plugin file. -# AUTHOR: Michael Varner (musikmichael@web.de) -# VERSION: 1.0.0 -# -# This plugin adds the ability to on the fly generate and access file shortcuts. -# -################################################################################ - ########################### -# Settings +# Settings # These can be overwritten any time. # If they are not set yet, they will be # overwritten with their default values -default fastfile_dir "${HOME}/.fastfile/" +default fastfile_dir "${HOME}/.fastfile" default fastfile_var_prefix "§" ########################### @@ -33,7 +23,7 @@ default fastfile_var_prefix "§" function fastfile() { test "$2" || 2="." file=$(readlink -f "$2") - + test "$1" || 1="$(basename "$file")" name=$(echo "$1" | tr " " "_") @@ -51,7 +41,7 @@ function fastfile() { # Arguments: # 1. name - The name of the shortcut # STDOUT: -# The path +# The path to the shortcut file # function fastfile_resolv() { echo "${fastfile_dir}${1}" @@ -88,12 +78,12 @@ function fastfile_print() { # (=> fastfle_print) for each shortcut # function fastfile_ls() { - for f in "${fastfile_dir}"/*; do - file=`basename "$f"` # To enable simpler handeling of spaces in file names - varkey=`echo "$file" | tr " " "_"` + for f in "${fastfile_dir}"/*(NF); do + file=`basename "$f"` # To enable simpler handeling of spaces in file names + varkey=`echo "$file" | tr " " "_"` - # Special format for colums - echo "${fastfile_var_prefix}${varkey}|->|$(fastfile_get "$file")" + # Special format for colums + echo "${fastfile_var_prefix}${varkey}|->|$(fastfile_get "$file")" done | column -t -s "|" } @@ -102,7 +92,6 @@ function fastfile_ls() { # # Arguments: # 1. name - The name of the shortcut (default: name of the file) -# 2. file - The file or directory to make the shortcut for # STDOUT: # => fastfle_print # @@ -115,11 +104,11 @@ function fastfile_rm() { # Generate the aliases for the shortcuts # function fastfile_sync() { - for f in "${fastfile_dir}"/*; do - file=`basename "$f"` # To enable simpler handeling of spaces in file names - varkey=`echo "$file" | tr " " "_"` + for f in "${fastfile_dir}"/*(NF); do + file=`basename "$f"` # To enable simpler handeling of spaces in file names + varkey=`echo "$file" | tr " " "_"` - alias -g "${fastfile_var_prefix}${varkey}"="'$(fastfile_get "$file")'" + alias -g "${fastfile_var_prefix}${varkey}"="'$(fastfile_get "$file")'" done } @@ -133,6 +122,6 @@ alias ffls=fastfile_ls alias ffsync=fastfile_sync ################################## -# Init +# Init -fastfile_sync \ No newline at end of file +fastfile_sync diff --git a/zsh/plugins/fbterm/README.md b/zsh/plugins/fbterm/README.md new file mode 100644 index 0000000..70ce56d --- /dev/null +++ b/zsh/plugins/fbterm/README.md @@ -0,0 +1,10 @@ +# fbterm + +This plugin automatically starts [fbterm](https://github.com/zhangyuanwei/fbterm) +if on a real TTY (`/dev/tty*`). + +To use it, add `fbterm` to the plugins array of your zshrc file: + +```zsh +plugins=(... fbterm) +``` diff --git a/zsh/plugins/fedora/README.md b/zsh/plugins/fedora/README.md index 6594799..85d8d7d 100644 --- a/zsh/plugins/fedora/README.md +++ b/zsh/plugins/fedora/README.md @@ -1 +1 @@ -The fedora plugin is deprecated. Use the [dnf plugin](https://github.com/robbyrussell/oh-my-zsh/tree/master/plugins/dnf) instead. +The fedora plugin is deprecated. Use the [dnf plugin](https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/dnf) instead. diff --git a/zsh/plugins/fedora/fedora.plugin.zsh b/zsh/plugins/fedora/fedora.plugin.zsh deleted file mode 120000 index 16a2143..0000000 --- a/zsh/plugins/fedora/fedora.plugin.zsh +++ /dev/null @@ -1 +0,0 @@ -../dnf/dnf.plugin.zsh \ No newline at end of file diff --git a/zsh/plugins/fedora/fedora.plugin.zsh b/zsh/plugins/fedora/fedora.plugin.zsh new file mode 100644 index 0000000..226506c --- /dev/null +++ b/zsh/plugins/fedora/fedora.plugin.zsh @@ -0,0 +1,3 @@ +print -P "%F{yellow}The 'fedora' plugin is deprecated. Use the '%Udnf%u' plugin instead.%f" + +source "$ZSH/plugins/dnf/dnf.plugin.zsh" diff --git a/zsh/plugins/firewalld/readme.md b/zsh/plugins/firewalld/README.md similarity index 100% rename from zsh/plugins/firewalld/readme.md rename to zsh/plugins/firewalld/README.md diff --git a/zsh/plugins/flutter/README.md b/zsh/plugins/flutter/README.md new file mode 100644 index 0000000..be41914 --- /dev/null +++ b/zsh/plugins/flutter/README.md @@ -0,0 +1,21 @@ +## Flutter plugin + +The Flutter plugin provides completion and useful aliases + +To use it, add flutter to the plugins array of your zshrc file: + +``` +plugins=(... flutter) +``` + +## Aliases + +| Alias | Command | Description | +| :--------- | :--------------------- | :------------------------------------------------------------------------- | +| `fl` | `flutter` | Shorthand for flutter command | +| `flr` | `flutter run` | Runs flutter app | +| `fldoc` | `flutter doctor` | Runs flutter doctor | +| `flb` | `flutter build` | Build flutter application | +| `flattach` | `flutter attach` | Attaches flutter to a running flutter application with enabled observatory | +| `flget` | `flutter packages get` | Installs dependencies | +| `flc` | `flutter clean` | Cleans flutter porject | diff --git a/zsh/plugins/flutter/_flutter b/zsh/plugins/flutter/_flutter new file mode 100644 index 0000000..ab6ce42 --- /dev/null +++ b/zsh/plugins/flutter/_flutter @@ -0,0 +1,37 @@ +#compdef flutter +#autoload + +local -a _1st_arguments +_1st_arguments=( + "analyze":"Analyze the project's Dart code." + "assemble":"Assemble and build flutter resources." + "attach":"Attach to a running application." + "build":"Flutter build commands." + "channel":"List or switch flutter channels." + "clean":"Delete the build/ and .dart_tool/ directories." + "config":"Configure Flutter settings." + "create":"Create a new Flutter project." + "devices":"List all connected devices." + "doctor":"Show information about the installed tooling." + "drive":"Runs Flutter Driver tests for the current project." + "emulators":"List, launch and create emulators." + "format":" Format one or more dart files." + "help":"Display help information for flutter." + "install":"Install a Flutter app on an attached device." + "logs":"Show log output for running Flutter apps." + "make-host-app-editable":"Moves host apps from generated directories to non-generated directories so that they can be edited by developers." + "precache":"Populates the Flutter tool's cache of binary artifacts." + "pub":"Commands for managing Flutter packages." + "run":"Run your Flutter app on an attached device." + "screenshot":"Take a screenshot from a connected device." + "test":"Run Flutter unit tests for the current project." + "upgrade":"Upgrade your copy of Flutter." + "version":"List or switch flutter versions." +) + +_arguments -C '*:: :->subcmds' + +if (( CURRENT == 1 )); then + _describe -t commands "flutter command" _1st_arguments + return +fi diff --git a/zsh/plugins/flutter/flutter.plugin.zsh b/zsh/plugins/flutter/flutter.plugin.zsh new file mode 100644 index 0000000..01c4c9f --- /dev/null +++ b/zsh/plugins/flutter/flutter.plugin.zsh @@ -0,0 +1,7 @@ +alias fl="flutter" +alias flr="flutter run" +alias fldoc="flutter doctor" +alias flb="flutter build" +alias flattach="flutter attach" +alias flget="flutter packages get" +alias flc="flutter clean" diff --git a/zsh/plugins/forklift/README.md b/zsh/plugins/forklift/README.md index 6c4ce1e..7dfd8bf 100644 --- a/zsh/plugins/forklift/README.md +++ b/zsh/plugins/forklift/README.md @@ -1,15 +1,23 @@ -## forklift +# forklift Plugin for ForkLift, an FTP application for OS X. -### Requirements +To use it, add `forklift` to the plugins array in your zshrc file: + +```zsh +plugins=(... forklift) +``` + +## Requirements * [ForkLift](https://binarynights.com/) -### Usage +## Usage -fl [*file_or_folder*] +`fl []` * If `fl` is called without arguments then the current folder is opened in ForkLift. This is equivalent to `fl .`. -* If `fl` is called with a directory as the argument, then that directory is opened in ForkLift. If called with a non-directory file as the argument, then the file's parent directory is opened. +* If `fl` is called with a directory as the argument, then that directory is opened in ForkLift + +* If `fl` is called with a non-directory file as the argument, then the file's parent directory is opened. diff --git a/zsh/plugins/forklift/forklift.plugin.zsh b/zsh/plugins/forklift/forklift.plugin.zsh index 274c4a8..8588948 100644 --- a/zsh/plugins/forklift/forklift.plugin.zsh +++ b/zsh/plugins/forklift/forklift.plugin.zsh @@ -1,6 +1,7 @@ # Open folder in ForkLift.app or ForkLift2.app from console # Author: Adam Strzelecki nanoant.com, modified by Bodo Tasche bitboxer.de # Updated to support ForkLift 2 and ForkLift 3 by Johan Kaving +# Updated to support ForkLift from Setapp by Paul Rudkin # # Usage: # fl [] @@ -24,6 +25,13 @@ function fl { fi osascript 2>&1 1>/dev/null < /dev/null + fi + + # Key bindings + if [[ ! "$DISABLE_FZF_KEY_BINDINGS" == "true" ]]; then + source "${fzf_shell}/key-bindings.zsh" + fi + else + return 1 + fi +} + + +function setup_using_debian_package() { + (( $+commands[dpkg] )) && dpkg -s fzf &> /dev/null + if (( $? )); then + # Either not a debian based distro, or no fzf installed. In any case skip ahead + return 1 + fi + + # NOTE: There is no need to configure PATH for debian package, all binaries + # are installed to /usr/bin by default + + # Determine completion file path: first bullseye/sid, then buster/stretch + local completions="/usr/share/doc/fzf/examples/completion.zsh" + [[ -f "$completions" ]] || completions="/usr/share/zsh/vendor-completions/_fzf" + + local key_bindings="/usr/share/doc/fzf/examples/key-bindings.zsh" + + # Auto-completion + if [[ $- == *i* ]] && [[ ! "$DISABLE_FZF_AUTO_COMPLETION" == "true" ]]; then + source $completions 2> /dev/null + fi + + # Key bindings + if [[ ! "$DISABLE_FZF_KEY_BINDINGS" == "true" ]]; then + source $key_bindings + fi + + return 0 +} + +function indicate_error() { + print "[oh-my-zsh] fzf plugin: Cannot find fzf installation directory.\n"\ + "Please add \`export FZF_BASE=/path/to/fzf/install/dir\` to your .zshrc" >&2 +} + +# Check for debian package first, because it easy to short cut +# Indicate to user that fzf installation not found if nothing worked +setup_using_debian_package || setup_using_base_dir || indicate_error + +unset -f setup_using_debian_package setup_using_base_dir indicate_error + +if [[ -z "$FZF_DEFAULT_COMMAND" ]]; then + if (( $+commands[rg] )); then + export FZF_DEFAULT_COMMAND='rg --files --hidden' + elif (( $+commands[fd] )); then + export FZF_DEFAULT_COMMAND='fd --type f --hidden --exclude .git' + elif (( $+commands[ag] )); then + export FZF_DEFAULT_COMMAND='ag -l --hidden -g ""' + fi fi - -if [[ -n "${fzf_base}" ]]; then - - # Fix fzf shell directory for Archlinux package - if [[ ! -d "${fzf_base}/shell" ]] && [[ -f /etc/arch-release ]]; then - fzf_shell="${fzf_base}" - else - fzf_shell="${fzf_base}/shell" - fi - - # Setup fzf - # --------- - if ! (( ${+commands[fzf]} )) && [[ ! "$PATH" == *$fzf_base/bin* ]]; then - export PATH="$PATH:$fzf_base/bin" - fi - - # Auto-completion - # --------------- - if [[ ! "$DISABLE_FZF_AUTO_COMPLETION" == "true" ]]; then - [[ $- == *i* ]] && source "${fzf_shell}/completion.zsh" 2> /dev/null - fi - - # Key bindings - # ------------ - if [[ ! "$DISABLE_FZF_KEY_BINDINGS" == "true" ]]; then - source "${fzf_shell}/key-bindings.zsh" - fi - -else - print "[oh-my-zsh] fzf plugin: Cannot find fzf installation directory.\n"\ - "Please add \`export FZF_BASE=/path/to/fzf/install/dir\` to your .zshrc" >&2 -fi - -unset fzf_base fzf_shell dir fzfdirs diff --git a/zsh/plugins/gas/README.md b/zsh/plugins/gas/README.md new file mode 100644 index 0000000..47b3fb9 --- /dev/null +++ b/zsh/plugins/gas/README.md @@ -0,0 +1,10 @@ +# Gas plugin + +This plugin adds autocompletion for the [gas](http://walle.github.com/gas) command, +a utility to manage Git authors. + +To use it, add `gas` to the plugins array of your zshrc file: + +```zsh +plugins=(... gas) +``` diff --git a/zsh/plugins/gcloud/README.md b/zsh/plugins/gcloud/README.md new file mode 100644 index 0000000..e7ce0e0 --- /dev/null +++ b/zsh/plugins/gcloud/README.md @@ -0,0 +1,24 @@ +# gcloud + +This plugin provides completion support for the +[Google Cloud SDK CLI](https://cloud.google.com/sdk/gcloud/). + +To use it, add `gcloud` to the plugins array in your zshrc file. + +```zsh +plugins=(... gcloud) +``` + +It relies on you having installed the SDK using one of the supported options +listed [here](https://cloud.google.com/sdk/install). + +## Plugin Options + +* Set `CLOUDSDK_HOME` in your `zshrc` file before you load oh-my-zsh if you have +your GCloud SDK installed in a non-standard location. The plugin will use this +as the base for your SDK if it finds it set already. + +* If you do not have a `python2` in your `PATH` you'll also need to set the +`CLOUDSDK_PYTHON` environment variable at the end of your `.zshrc`. This is +used by the SDK to call a compatible interpreter when you run one of the +SDK commands. diff --git a/zsh/plugins/gcloud/gcloud.plugin.zsh b/zsh/plugins/gcloud/gcloud.plugin.zsh new file mode 100644 index 0000000..c7aebe6 --- /dev/null +++ b/zsh/plugins/gcloud/gcloud.plugin.zsh @@ -0,0 +1,33 @@ +##################################################### +# gcloud plugin for oh-my-zsh # +# Author: Ian Chesal (github.com/ianchesal) # +##################################################### + +if [[ -z "${CLOUDSDK_HOME}" ]]; then + search_locations=( + "$HOME/google-cloud-sdk" + "/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk" + "/usr/share/google-cloud-sdk" + "/snap/google-cloud-sdk/current" + "/usr/lib64/google-cloud-sdk/" + "/opt/google-cloud-sdk" + ) + + for gcloud_sdk_location in $search_locations; do + if [[ -d "${gcloud_sdk_location}" ]]; then + CLOUDSDK_HOME="${gcloud_sdk_location}" + break + fi + done +fi + +if (( ${+CLOUDSDK_HOME} )); then + if (( ! $+commands[gcloud] )); then + # Only source this if GCloud isn't already on the path + if [[ -f "${CLOUDSDK_HOME}/path.zsh.inc" ]]; then + source "${CLOUDSDK_HOME}/path.zsh.inc" + fi + fi + source "${CLOUDSDK_HOME}/completion.zsh.inc" + export CLOUDSDK_HOME +fi diff --git a/zsh/plugins/geeknote/README.md b/zsh/plugins/geeknote/README.md index 3f23531..95b3aa7 100644 --- a/zsh/plugins/geeknote/README.md +++ b/zsh/plugins/geeknote/README.md @@ -1,12 +1,10 @@ -## ZSH-Geeknote +# Geeknote plugin -[Geeknote](https://github.com/VitaliyRodnenko/geeknote) plugin for oh-my-zsh. +This plugin provides autocompletion for [Geeknote](https://github.com/VitaliyRodnenko/geeknote) +and an alias for `geeknote` called `gn`. -Plugins provides: +To use it, add `geeknote` to the plugins array in your zshrc file: -- auto completion of commands and their options -- alias `gn` - -You can find information how to install Geeknote and it's available commands on the [project website](http://www.geeknote.me/). - -Maintainer : Ján Koščo ([@s7anley](https://twitter.com/s7anley)) +```zsh +plugins=( ... geeknote ...) +``` diff --git a/zsh/plugins/geeknote/_geeknote b/zsh/plugins/geeknote/_geeknote index cf1a187..a34be59 100644 --- a/zsh/plugins/geeknote/_geeknote +++ b/zsh/plugins/geeknote/_geeknote @@ -1,136 +1,157 @@ #compdef geeknote -# --------------- ------------------------------------------------------------ -# Name : _geeknote -# Synopsis : zsh completion for geeknote -# Author : Ján Koščo <3k.stanley@gmail.com> -# HomePage : http://www.geeknote.me -# Version : 0.1 -# Tag : [ shell, zsh, completion, evernote ] -# Copyright : © 2014 by Ján Koščo, -# Released under current GPL license. -# --------------- ------------------------------------------------------------ + +# Geeknote Autocomplete plugin for Zsh +# Requires: Geeknote installed +# Author : Ján Koščo (@s7anley) + +__login() { + # no arguments +} + +__logout() { + _arguments \ + '--force[Do not ask about logging out.]' +} + +__settings() { + _arguments \ + "--editor+[Set the editor, which use to edit and create notes.]::" +} + +__create() { + _arguments \ + '--title+[The note title.]::' \ + '--content+[The note content.]::' \ + '--tags+[One tag or the list of tags which will be added to the note.]::' \ + '--notebook+[Set the notebook where to save note.]::' \ + '--resource+[Add a resource to the note.]::' +} + +__edit() { + _arguments \ + '--note+[The name or ID from the previous search of a note to edit.]::' \ + '--title+[Set new title of the note.]::' \ + '--content+[Set new content of the note.]::' \ + '--tags+[Set new list o tags for the note.]::' \ + '--notebook+[Assign new notebook for the note.]::' \ + '--resource+[Add a resource to the note.]::' +} + +__find() { + _arguments \ + '--search+[Text to search.]::' \ + '--tags+[Notes with which tag/tags to search.]::' \ + '--notebook+[In which notebook search the note.]::' \ + '--date+[Set date in format dd.mm.yyyy or date range dd.mm.yyyy-dd.mm.yyyy.]::' \ + '--count+[How many notes show in the result list.]::' \ + '--with-url[Add direct url of each note in results to Evernote web-version.]' \ + '--content-search[Search by content, not by title.]' \ + '--exact-entry[Search for exact entry of the request.]' +} + +__show() { + _arguments \ + '--note+[The name or ID from the previous search of a note to show.]::' \ + '--raw[Show the raw note body.]' +} + +__remove() { + _arguments \ + '--note+[The name or ID from the previous search of a note to remove.]::' \ + '--force[Do not ask about removing.]' +} + +__notebook-list() { + # no arguments +} + +__notebook-create() { + _arguments \ + '--title+[Set the title of new notebook.]::' +} + +__notebook-edit() { + _arguments \ + '--title+[Set the title of new notebook.]::' \ + '--notebook+[The name of a notebook to rename.]::' +} + +__tag-list() { + # no arguments +} + +__tag-create() { + _arguments \ + '--title+[Set the title of new tag.]::' +} + +__tag-edit() { + _arguments \ + '--tagname+[The name of a tag to rename.]::' \ + '--title+[Set the new name of tag.]::' +} + +__user() { + _arguments \ + '--full[Show full information.]' +} local -a _1st_arguments _1st_arguments=( - 'login' - 'logout' - 'settings' - 'create' - 'edit' - 'find' - 'show' - 'remove' - 'notebook-list' - 'notebook-create' - 'notebook-edit' - 'tag-list' - 'tag-create' - 'tag-edit' - 'tag-remove' - 'gnsync' - 'user' + 'login':'Authorize in Evernote.' + 'logout':'Logout from Evernote.' + 'settings':'Show and edit current settings.' + 'create':'Create note in Evernote.' + 'edit':'Edit note in Evernote.' + 'find':'Search notes in Evernote.' + 'show':'Output note in the terminal.' + 'remove':'Remove note from Evernote.' + 'notebook-list':'Show the list of existing notebooks in your Evernote.' + 'notebook-create':'Create new notebook.' + 'notebook-edit':'Edit/rename notebook.' + 'tag-list':'Show the list of existing tags in your Evernote.' + 'tag-create':'Create new tag.' + 'tag-edit':'Edit/rename tag.' + 'user':'Show information about active user.' ) _arguments '*:: :->command' if (( CURRENT == 1 )); then - _describe -t commands "geeknote command" _1st_arguments - return + _describe -t commands "geeknote command" _1st_arguments + return fi local -a _command_args case "$words[1]" in - user) - _command_args=( - '(--full)--full' \ - ) - ;; - logout) - _command_args=( - '(--force)--force' \ - ) - ;; - settings) - _command_args=( - '(--editor)--editor' \ - ) - ;; - create) - _command_args=( - '(-t|--title)'{-t,--title}'[note title]' \ - '(-c|--content)'{-c,--content}'[note content]' \ - '(-tg|--tags)'{-tg,--tags}'[one tag or the list of tags which will be added to the note]' \ - '(-nb|--notebook)'{-nb,--notebook}'[name of notebook where to save note]' \ - ) - ;; - edit) - _command_args=( - '(-n|--note)'{-n,--note}'[name or ID from the previous search of a note to edit]' \ - '(-t|--title)'{-t,--title}'[note title]' \ - '(-c|--content)'{-c,--content}'[note content]' \ - '(-tg|--tags)'{-tg,--tags}'[one tag or the list of tags which will be added to the note]' \ - '(-nb|--notebook)'{-nb,--notebook}'[name of notebook where to save note]' \ - ) - ;; - remove) - _command_args=( - '(-n|--note)'{-n,--note}'[name or ID from the previous search of a note to edit]' \ - '(--force)--force' \ - ) - ;; - show) - _command_args=( - '(-n|--note)'{-n,--note}'[name or ID from the previous search of a note to edit]' \ - ) - ;; - find) - _command_args=( - '(-s|--search)'{-s,--search}'[text to search]' \ - '(-tg|--tags)'{-tg,--tags}'[notes with which tag/tags to search]' \ - '(-nb|--notebook)'{-nb,--notebook}'[in which notebook search the note]' \ - '(-d|--date)'{-d,--date}'[date in format dd.mm.yyyy or date range dd.mm.yyyy-dd.mm.yyyy]' \ - '(-cn|--count)'{-cn,--count}'[how many notes show in the result list]' \ - '(-uo|--url-only)'{-uo,--url-only}'[add direct url of each note in results to Evernote web-version]' \ - '(-ee|--exact-entry)'{-ee,--exact-entry}'[search for exact entry of the request]' \ - '(-cs|--content-search)'{-cs,--content-search}'[search by content, not by title]' \ - ) - ;; - notebook-create) - _command_args=( - '(-t|--title)'{-t,--title}'[notebook title]' \ - ) - ;; - notebook-edit) - _command_args=( - '(-nb|--notebook)'{-nb,--notebook}'[name of notebook to rename]' \ - '(-t|--title)'{-t,--title}'[new notebook title]' \ - ) - ;; - notebook-remove) - _command_args=( - '(-nb|--notebook)'{-nb,--notebook}'[name of notebook to remove]' \ - '(--force)--force' \ - ) - ;; - tag-create) - _command_args=( - '(-t|--title)'{-t,--title}'[title of tag]' \ - ) - ;; - tag-edit) - _command_args=( - '(-tgn|--tagname)'{-tgn,--tagname}'[tag to edit]' \ - '(-t|--title)'{-t,--title}'[new tag name]' \ - ) - ;; - tag-remove) - _command_args=( - '(-tgn|--tagname)'{-tgn,--tagname}'[tag to remove]' \ - '(--force)--force' \ - ) - ;; - esac - -_arguments \ - $_command_args \ - && return 0 + login) + __login ;; + logout) + __logout ;; + settings) + __settings ;; + create) + __create ;; + edit) + __edit ;; + find) + __find ;; + show) + __show ;; + remove) + __remove ;; + notebook-list) + __notebook-list ;; + notebook-create) + __notebook-create ;; + notebook-edit) + __notebook-edit ;; + tag-list) + __tag-list ;; + tag-create) + __tag-create ;; + tag-edit) + __tag-edit ;; + user) + __user ;; +esac diff --git a/zsh/plugins/git-auto-fetch/git-auto-fetch.plugin.zsh b/zsh/plugins/git-auto-fetch/git-auto-fetch.plugin.zsh index 56ab86d..5c42c21 100644 --- a/zsh/plugins/git-auto-fetch/git-auto-fetch.plugin.zsh +++ b/zsh/plugins/git-auto-fetch/git-auto-fetch.plugin.zsh @@ -1,16 +1,17 @@ GIT_AUTO_FETCH_INTERVAL=${GIT_AUTO_FETCH_INTERVAL:=60} function git-fetch-all { - (`git rev-parse --is-inside-work-tree 2>/dev/null` && - dir=`git rev-parse --git-dir` && + (`command git rev-parse --is-inside-work-tree 2>/dev/null` && + dir=`command git rev-parse --git-dir` && [[ ! -f $dir/NO_AUTO_FETCH ]] && (( `date +%s` - `date -r $dir/FETCH_LOG +%s 2>/dev/null || echo 0` > $GIT_AUTO_FETCH_INTERVAL )) && - git fetch --all 2>/dev/null &>! $dir/FETCH_LOG &) + GIT_SSH_COMMAND="command ssh -o BatchMode=yes" \ + command git fetch --all 2>/dev/null &>! $dir/FETCH_LOG &) } function git-auto-fetch { - `git rev-parse --is-inside-work-tree 2>/dev/null` || return - guard="`git rev-parse --git-dir`/NO_AUTO_FETCH" + `command git rev-parse --is-inside-work-tree 2>/dev/null` || return + guard="`command git rev-parse --git-dir`/NO_AUTO_FETCH" (rm $guard 2>/dev/null && echo "${fg_bold[green]}enabled${reset_color}") || diff --git a/zsh/plugins/git-escape-magic/README.md b/zsh/plugins/git-escape-magic/README.md index c3e3898..7fefed3 100644 --- a/zsh/plugins/git-escape-magic/README.md +++ b/zsh/plugins/git-escape-magic/README.md @@ -4,13 +4,13 @@ This plugin is copied from the original at https://github.com/knu/zsh-git-escape-magic. All credit for the functionality enabled by this plugin should go to @knu. -An excerpt from that project's readme explains it's purpose. +An excerpt from that project's readme explains its purpose. > It eliminates the need for manually escaping those meta-characters. The zle function it provides is context aware and recognizes the characteristics of each subcommand of git. Every time you type one of these meta-characters on a git command line, it automatically escapes the meta-character with a backslash as necessary and as appropriate. ## Usage -To use this plugin add it to your list of plugins in your `.zshrc` file. +To use this plugin, add it to your list of plugins in your `.zshrc` file. -**NOTE**: If you use url-quote-magic it must be included before this +**NOTE**: If you use url-quote-magic, it must be included before this plugin runs to prevent any conflicts. diff --git a/zsh/plugins/git-extras/README.md b/zsh/plugins/git-extras/README.md index 987f0d8..2adc9d4 100644 --- a/zsh/plugins/git-extras/README.md +++ b/zsh/plugins/git-extras/README.md @@ -2,10 +2,16 @@ This plugin provides completion definitions for some of the commands defined by [git-extras](https://github.com/tj/git-extras). -## Setup notes +To use it, add `git-extras` to the plugins array in your zshrc file: + +```zsh +plugins=(... git-extras) +``` + +## Setup notes The completions work by augmenting the `_git` completion provided by `zsh`. This only works with the `zsh`-provided `_git`, not the `_git` provided by `git` itself. If you have both `zsh` and `git` installed, you need to make sure that the `zsh`-provided `_git` takes precedence. ### OS X Homebrew Setup -On OS X with Homebrew, you need to install `git` with `brew install git --without-completions`. Otherwise, `git`'s `_git` will take precedence, and you won't see the completions for `git-extras` commands. +**NOTE:** this no longer works on current Homebrew distributions of git. ~~On OS X with Homebrew, you need to install `git` with `brew install git --without-completions`. Otherwise, `git`'s `_git` will take precedence, and you won't see the completions for `git-extras` commands.~~ diff --git a/zsh/plugins/git-flow/README.md b/zsh/plugins/git-flow/README.md index 5d8049e..9c25dec 100644 --- a/zsh/plugins/git-flow/README.md +++ b/zsh/plugins/git-flow/README.md @@ -1,18 +1,15 @@ # Git-Flow plugin -This plugin adds completion and aliases for the `git-flow` command. More information -at https://github.com/nvie/gitflow. +This plugin adds completion and aliases for the [`git-flow` command](https://github.com/nvie/gitflow). -Enable git-flow plugin in your zshrc file: -``` +To use it, add `git-flow` to the plugins array in your zshrc file: + +```zsh plugins=(... git-flow) ``` ## Aliases -More information about `git-flow` commands: -https://github.com/nvie/gitflow/wiki/Command-Line-Arguments - | Alias | Command | Description | |---------|----------------------------|----------------------------------------| | `gfl` | `git flow` | Git-Flow command | @@ -30,3 +27,5 @@ https://github.com/nvie/gitflow/wiki/Command-Line-Arguments | `gflfp` | `git flow feature publish` | Publish feature: `gflfp ` | | `gflhf` | `git flow hotfix finish` | Finish hotfix: `gflhf ` | | `gflrf` | `git flow release finish` | Finish release: `gflrf ` | + +[More information about `git-flow` commands](https://github.com/nvie/gitflow/wiki/Command-Line-Arguments). diff --git a/zsh/plugins/git-lfs/README.md b/zsh/plugins/git-lfs/README.md new file mode 100644 index 0000000..1222b27 --- /dev/null +++ b/zsh/plugins/git-lfs/README.md @@ -0,0 +1,24 @@ +# git lfs plugin + +The git lfs plugin provides [aliases](#aliases) and [functions](#functions) for [git-lfs](https://github.com/git-lfs/git-lfs). + +To use it, add `git-lfs` to the plugins array in your zshrc file: + +```zsh +plugins=(... git-lfs) +``` + +## Aliases + +| Alias | Command | +| :------- | :---------------------------------- | +| `glfsi` | `git lfs install` | +| `glfst` | `git lfs track` | +| `glfsls` | `git lfs ls-files` | +| `glfsmi` | `git lfs migrate import --include=` | + +## Functions + +| Function | Command | +| :------- | :---------------------------------------------- | +| `gplfs` | `git lfs push origin "$(current_branch)" --all` | diff --git a/zsh/plugins/git-lfs/git-lfs.plugin.zsh b/zsh/plugins/git-lfs/git-lfs.plugin.zsh new file mode 100644 index 0000000..e7bb676 --- /dev/null +++ b/zsh/plugins/git-lfs/git-lfs.plugin.zsh @@ -0,0 +1,17 @@ +# +# Aliases +# + +alias glfsi='git lfs install' +alias glfst='git lfs track' +alias glfsls='git lfs ls-files' +alias glfsmi='git lfs migrate import --include=' + +# +# Functions +# + +function gplfs() { + local b="$(git_current_branch)" + git lfs push origin "$b" --all +} diff --git a/zsh/plugins/git-prompt/README.md b/zsh/plugins/git-prompt/README.md index e3b2d62..83948f5 100644 --- a/zsh/plugins/git-prompt/README.md +++ b/zsh/plugins/git-prompt/README.md @@ -11,6 +11,9 @@ plugins=(... git-prompt) See the [original repository](https://github.com/olivierverdier/zsh-git-prompt). +## Prerequisites +This plugin uses `python`, so your host needs to have it installed + ## Examples The prompt may look like the following: diff --git a/zsh/plugins/git-prompt/git-prompt.plugin.zsh b/zsh/plugins/git-prompt/git-prompt.plugin.zsh index 1742429..da674af 100644 --- a/zsh/plugins/git-prompt/git-prompt.plugin.zsh +++ b/zsh/plugins/git-prompt/git-prompt.plugin.zsh @@ -1,6 +1,3 @@ -# ZSH Git Prompt Plugin from: -# http://github.com/olivierverdier/zsh-git-prompt - __GIT_PROMPT_DIR="${0:A:h}" ## Hook function definitions @@ -23,9 +20,10 @@ function precmd_update_git_vars() { fi } -chpwd_functions+=(chpwd_update_git_vars) -precmd_functions+=(precmd_update_git_vars) -preexec_functions+=(preexec_update_git_vars) +autoload -U add-zsh-hook +add-zsh-hook chpwd chpwd_update_git_vars +add-zsh-hook precmd precmd_update_git_vars +add-zsh-hook preexec preexec_update_git_vars ## Function definitions @@ -42,19 +40,16 @@ function update_current_git_vars() { GIT_CONFLICTS=$__CURRENT_GIT_STATUS[5] GIT_CHANGED=$__CURRENT_GIT_STATUS[6] GIT_UNTRACKED=$__CURRENT_GIT_STATUS[7] - GIT_DELETED=$__CURRENT_GIT_STATUS[8] } git_super_status() { precmd_update_git_vars if [ -n "$__CURRENT_GIT_STATUS" ]; then STATUS="$ZSH_THEME_GIT_PROMPT_PREFIX$ZSH_THEME_GIT_PROMPT_BRANCH$GIT_BRANCH%{${reset_color}%}" - if [ "$GIT_BEHIND" -ne "0" ]; then - STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_SEPARATOR" + if [ "$GIT_BEHIND" -ne "0" ]; then STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_BEHIND$GIT_BEHIND%{${reset_color}%}" fi if [ "$GIT_AHEAD" -ne "0" ]; then - STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_SEPARATOR" STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_AHEAD$GIT_AHEAD%{${reset_color}%}" fi STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_SEPARATOR" @@ -67,11 +62,8 @@ git_super_status() { if [ "$GIT_CHANGED" -ne "0" ]; then STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_CHANGED$GIT_CHANGED%{${reset_color}%}" fi - if [ "$GIT_DELETED" -ne "0" ]; then - STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_DELETED$GIT_DELETED%{${reset_color}%}" - fi if [ "$GIT_UNTRACKED" -ne "0" ]; then - STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_UNTRACKED$GIT_UNTRACKED%{${reset_color}%}" + STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_UNTRACKED%{${reset_color}%}" fi if [ "$GIT_CHANGED" -eq "0" ] && [ "$GIT_CONFLICTS" -eq "0" ] && [ "$GIT_STAGED" -eq "0" ] && [ "$GIT_UNTRACKED" -eq "0" ]; then STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_CLEAN" @@ -93,7 +85,6 @@ ZSH_THEME_GIT_PROMPT_BEHIND="%{↓%G%}" ZSH_THEME_GIT_PROMPT_AHEAD="%{↑%G%}" ZSH_THEME_GIT_PROMPT_UNTRACKED="%{…%G%}" ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg_bold[green]%}%{✔%G%}" -ZSH_THEME_GIT_PROMPT_DELETED="%{$fg[red]%}-" # Set the prompt. RPROMPT='$(git_super_status)' diff --git a/zsh/plugins/git-prompt/gitstatus.py b/zsh/plugins/git-prompt/gitstatus.py index 709de9e..300365d 100644 --- a/zsh/plugins/git-prompt/gitstatus.py +++ b/zsh/plugins/git-prompt/gitstatus.py @@ -1,28 +1,24 @@ #!/usr/bin/env python from __future__ import print_function +import os import sys import re -import shlex from subprocess import Popen, PIPE, check_output def get_tagname_or_hash(): """return tagname if exists else hash""" - cmd = 'git log -1 --format="%h%d"' - output = check_output(shlex.split(cmd)).decode('utf-8').strip() - hash_, tagname = None, None # get hash - m = re.search('\(.*\)$', output) - if m: - hash_ = output[:m.start()-1] - # get tagname - m = re.search('tag: .*[,\)]', output) - if m: - tagname = 'tags/' + output[m.start()+len('tag: '): m.end()-1] + hash_cmd = ['git', 'rev-parse', '--short', 'HEAD'] + hash_ = check_output(hash_cmd).strip() - if tagname: - return tagname + # get tagname + tags_cmd = ['git', 'for-each-ref', '--points-at=HEAD', '--count=2', '--sort=-version:refname', '--format=%(refname:short)', 'refs/tags'] + tags = check_output(tags_cmd).split() + + if tags: + return tags[0] + ('+' if len(tags) > 1 else '') elif hash_: return hash_ return None @@ -30,18 +26,18 @@ def get_tagname_or_hash(): # `git status --porcelain --branch` can collect all information # branch, remote_branch, untracked, staged, changed, conflicts, ahead, behind -po = Popen(['git', 'status', '--porcelain', '--branch'], stdout=PIPE, stderr=PIPE) +po = Popen(['git', 'status', '--porcelain', '--branch'], env=dict(os.environ, LANG="C"), stdout=PIPE, stderr=PIPE) stdout, sterr = po.communicate() if po.returncode != 0: sys.exit(0) # Not a git repository # collect git status information -untracked, staged, changed, conflicts, deleted = [], [], [], [], [] +untracked, staged, changed, conflicts = [], [], [], [] ahead, behind = 0, 0 status = [(line[0], line[1], line[2:]) for line in stdout.decode('utf-8').splitlines()] for st in status: if st[0] == '#' and st[1] == '#': - if re.search('Initial commit on', st[2]): + if re.search('Initial commit on', st[2]) or re.search('No commits yet on', st[2]): branch = st[2].split(' ')[-1] elif re.search('no branch', st[2]): # detached status branch = get_tagname_or_hash() @@ -67,8 +63,6 @@ for st in status: else: if st[1] == 'M': changed.append(st) - if st[1] == 'D': - deleted.append(st) if st[0] == 'U': conflicts.append(st) elif st[0] != ' ': @@ -82,6 +76,5 @@ out = ' '.join([ str(len(conflicts)), str(len(changed)), str(len(untracked)), - str(len(deleted)), ]) print(out, end='') diff --git a/zsh/plugins/git-remote-branch/git-remote-branch.plugin.zsh b/zsh/plugins/git-remote-branch/git-remote-branch.plugin.zsh deleted file mode 100644 index 6c5ab8f..0000000 --- a/zsh/plugins/git-remote-branch/git-remote-branch.plugin.zsh +++ /dev/null @@ -1,19 +0,0 @@ -_git_remote_branch() { - ref=$(git symbolic-ref HEAD 2> /dev/null) - if [[ -n $ref ]]; then - if (( CURRENT == 2 )); then - # first arg: operation - compadd create publish rename delete track - elif (( CURRENT == 3 )); then - # second arg: remote branch name - remotes=`git remote | tr '\n' '|' | sed "s/\|$//g"` - compadd `git branch -r | grep -v HEAD | sed "s/$remotes\///" | sed "s/ //g"` - elif (( CURRENT == 4 )); then - # third arg: remote name - compadd `git remote` - fi - else; - _files - fi -} -compdef _git_remote_branch grb diff --git a/zsh/plugins/git/README.md b/zsh/plugins/git/README.md index 7878f74..b7f2168 100644 --- a/zsh/plugins/git/README.md +++ b/zsh/plugins/git/README.md @@ -10,194 +10,211 @@ plugins=(... git) ## Aliases -| Alias | Command | -|:---------------------|:------------------------------------------------------------------------------------------------------------------------------| -| g | git | -| ga | git add | -| gaa | git add --all | -| gapa | git add --patch | -| gau | git add --update | -| gav | git add --verbose | -| gap | git apply | -| gb | git branch | -| gba | git branch -a | -| gbd | git branch -d | -| gbda | git branch --no-color --merged \| command grep -vE "^(\+|\*\|\s*(master\|develop\|dev)\s*$)" \| command xargs -n 1 git branch -d | -| gbD | git branch -D | -| gbl | git blame -b -w | -| gbnm | git branch --no-merged | -| gbr | git branch --remote | -| gbs | git bisect | -| gbsb | git bisect bad | -| gbsg | git bisect good | -| gbsr | git bisect reset | -| gbss | git bisect start | -| gc | git commit -v | -| gc! | git commit -v --amend | -| gcn! | git commit -v --no-edit --amend | -| gca | git commit -v -a | -| gca! | git commit -v -a --amend | -| gcan! | git commit -v -a --no-edit --amend | -| gcans! | git commit -v -a -s --no-edit --amend | -| gcam | git commit -a -m | -| gcsm | git commit -s -m | -| gcb | git checkout -b | -| gcf | git config --list | -| gcl | git clone --recurse-submodules | -| gclean | git clean -id | -| gpristine | git reset --hard && git clean -dfx | -| gcm | git checkout master | -| gcd | git checkout develop | -| gcmsg | git commit -m | -| gco | git checkout | -| gcount | git shortlog -sn | -| gcp | git cherry-pick | -| gcpa | git cherry-pick --abort | -| gcpc | git cherry-pick --continue | -| gcs | git commit -S | -| gd | git diff | -| gdca | git diff --cached | -| gdcw | git diff --cached --word-diff | -| gdct | git describe --tags $(git rev-list --tags --max-count=1) | -| gds | git diff --staged | -| gdt | git diff-tree --no-commit-id --name-only -r | -| gdv | git diff -w $@ \| view - | -| gdw | git diff --word-diff | -| gf | git fetch | -| gfa | git fetch --all --prune | -| gfg | git ls-files \| grep | -| gfo | git fetch origin | -| gg | git gui citool | -| gga | git gui citool --amend | -| ggf | git push --force origin $(current_branch) | -| ggfl | git push --force-with-lease origin $(current_branch) | -| ggl | git pull origin $(current_branch) | -| ggp | git push origin $(current_branch) | -| ggpnp | ggl && ggp | -| ggpull | git pull origin "$(git_current_branch)" | -| ggpur | ggu | -| ggpush | git push origin "$(git_current_branch)" | -| ggsup | git branch --set-upstream-to=origin/$(git_current_branch) | -| ggu | git pull --rebase origin $(current_branch) | -| gpsup | git push --set-upstream origin $(git_current_branch) | -| ghh | git help | -| gignore | git update-index --assume-unchanged | -| gignored | git ls-files -v \| grep "^[[:lower:]]" | -| git-svn-dcommit-push | git svn dcommit && git push github master:svntrunk | -| gk | gitk --all --branches | -| gke | gitk --all $(git log -g --pretty=%h) | -| gl | git pull | -| glg | git log --stat | -| glgp | git log --stat -p | -| glgg | git log --graph | -| glgga | git log --graph --decorate --all | -| glgm | git log --graph --max-count=10 | -| glo | git log --oneline --decorate | -| glol | git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' | -| glols | git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --stat | -| glod | git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ad) %C(bold blue)<%an>%Creset' | -| glods | git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ad) %C(bold blue)<%an>%Creset' --date=short | -| glola | git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --all | -| glog | git log --oneline --decorate --graph | -| gloga | git log --oneline --decorate --graph --all | -| glp | `_git_log_prettily` | -| gm | git merge | -| gmom | git merge origin/master | -| gmt | git mergetool --no-prompt | -| gmtvim | git mergetool --no-prompt --tool=vimdiff | -| gmum | git merge upstream/master | -| gma | git merge --abort | -| gp | git push | -| gpd | git push --dry-run | -| gpf | git push --force-with-lease | -| gpf! | git push --force | -| gpoat | git push origin --all && git push origin --tags | -| gpu | git push upstream | -| gpv | git push -v | -| gr | git remote | -| gra | git remote add | -| grb | git rebase | -| grba | git rebase --abort | -| grbc | git rebase --continue | -| grbd | git rebase develop | -| grbi | git rebase -i | -| grbm | git rebase master | -| grbs | git rebase --skip | -| grev | git revert | -| grh | git reset | -| grhh | git reset --hard | -| groh | git reset origin/$(git_current_branch) --hard | -| grm | git rm | -| grmc | git rm --cached | -| grmv | git remote rename | -| grrm | git remote remove | -| grs | git restore | -| grset | git remote set-url | -| grss | git restore --source | -| grt | cd "$(git rev-parse --show-toplevel \|\| echo .)" | -| gru | git reset -- | -| grup | git remote update | -| grv | git remote -v | -| gsb | git status -sb | -| gsd | git svn dcommit | -| gsh | git show | -| gsi | git submodule init | -| gsps | git show --pretty=short --show-signature | -| gsr | git svn rebase | -| gss | git status -s | -| gst | git status | -| gsta | git stash push | -| gsta | git stash save | -| gstaa | git stash apply | -| gstc | git stash clear | -| gstd | git stash drop | -| gstl | git stash list | -| gstp | git stash pop | -| gsts | git stash show --text | -| gstall | git stash --all | -| gsu | git submodule update | -| gsw | git switch | -| gswc | git switch -c | -| gts | git tag -s | -| gtv | git tag \| sort -V | -| gtl | gtl(){ git tag --sort=-v:refname -n -l ${1}* }; noglob gtl | -| gunignore | git update-index --no-assume-unchanged | -| gunwip | git log -n 1 \| grep -q -c "\-\-wip\-\-" && git reset HEAD~1 | -| gup | git pull --rebase | -| gupv | git pull --rebase -v | -| gupa | git pull --rebase --autostash | -| gupav | git pull --rebase --autostash -v | -| glum | git pull upstream master | -| gwch | git whatchanged -p --abbrev-commit --pretty=medium | -| gwip | git add -A; git rm $(git ls-files --deleted) 2> /dev/null; git commit --no-verify --no-gpg-sign -m "--wip-- [skip ci]" | +| Alias | Command | +|:---------------------|:---------------------------------------------------------------------------------------------------------------------------------| +| g | git | +| ga | git add | +| gaa | git add --all | +| gapa | git add --patch | +| gau | git add --update | +| gav | git add --verbose | +| gap | git apply | +| gapt | git apply --3way | +| gb | git branch | +| gba | git branch -a | +| gbd | git branch -d | +| gbda | git branch --no-color --merged \| command grep -vE "^(\+\|\*\|\s*($(git_main_branch)\|development\|develop\|devel\|dev)\s*$)" \| command xargs -n 1 git branch -d | +| gbD | git branch -D | +| gbl | git blame -b -w | +| gbnm | git branch --no-merged | +| gbr | git branch --remote | +| gbs | git bisect | +| gbsb | git bisect bad | +| gbsg | git bisect good | +| gbsr | git bisect reset | +| gbss | git bisect start | +| gc | git commit -v | +| gc! | git commit -v --amend | +| gcn! | git commit -v --no-edit --amend | +| gca | git commit -v -a | +| gca! | git commit -v -a --amend | +| gcan! | git commit -v -a --no-edit --amend | +| gcans! | git commit -v -a -s --no-edit --amend | +| gcam | git commit -a -m | +| gcsm | git commit -s -m | +| gcb | git checkout -b | +| gcf | git config --list | +| gcl | git clone --recurse-submodules | +| gclean | git clean -id | +| gpristine | git reset --hard && git clean -dffx | +| gcm | git checkout $(git_main_branch) | +| gcd | git checkout develop | +| gcmsg | git commit -m | +| gco | git checkout | +| gcount | git shortlog -sn | +| gcp | git cherry-pick | +| gcpa | git cherry-pick --abort | +| gcpc | git cherry-pick --continue | +| gcs | git commit -S | +| gd | git diff | +| gdca | git diff --cached | +| gdcw | git diff --cached --word-diff | +| gdct | git describe --tags $(git rev-list --tags --max-count=1) | +| gds | git diff --staged | +| gdt | git diff-tree --no-commit-id --name-only -r | +| gdnolock | git diff $@ ":(exclude)package-lock.json" ":(exclude)*.lock" | +| gdv | git diff -w $@ \| view - | +| gdw | git diff --word-diff | +| gf | git fetch | +| gfa | git fetch --all --prune | +| gfg | git ls-files \| grep | +| gfo | git fetch origin | +| gg | git gui citool | +| gga | git gui citool --amend | +| ggf | git push --force origin $(current_branch) | +| ggfl | git push --force-with-lease origin $(current_branch) | +| ggl | git pull origin $(current_branch) | +| ggp | git push origin $(current_branch) | +| ggpnp | ggl && ggp | +| ggpull | git pull origin "$(git_current_branch)" | +| ggpur | ggu | +| ggpush | git push origin "$(git_current_branch)" | +| ggsup | git branch --set-upstream-to=origin/$(git_current_branch) | +| ggu | git pull --rebase origin $(current_branch) | +| gpsup | git push --set-upstream origin $(git_current_branch) | +| ghh | git help | +| gignore | git update-index --assume-unchanged | +| gignored | git ls-files -v \| grep "^[[:lower:]]" | +| git-svn-dcommit-push | git svn dcommit && git push github $(git_main_branch):svntrunk | +| gk | gitk --all --branches | +| gke | gitk --all $(git log -g --pretty=%h) | +| gl | git pull | +| glg | git log --stat | +| glgp | git log --stat -p | +| glgg | git log --graph | +| glgga | git log --graph --decorate --all | +| glgm | git log --graph --max-count=10 | +| glo | git log --oneline --decorate | +| glol | git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' | +| glols | git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --stat | +| glod | git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ad) %C(bold blue)<%an>%Creset' | +| glods | git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ad) %C(bold blue)<%an>%Creset' --date=short | +| glola | git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --all | +| glog | git log --oneline --decorate --graph | +| gloga | git log --oneline --decorate --graph --all | +| glp | git log --pretty=\ | +| gm | git merge | +| gmom | git merge origin/$(git_main_branch) | +| gmt | git mergetool --no-prompt | +| gmtvim | git mergetool --no-prompt --tool=vimdiff | +| gmum | git merge upstream/$(git_main_branch) | +| gma | git merge --abort | +| gp | git push | +| gpd | git push --dry-run | +| gpf | git push --force-with-lease | +| gpf! | git push --force | +| gpoat | git push origin --all && git push origin --tags | +| gpu | git push upstream | +| gpv | git push -v | +| gr | git remote | +| gra | git remote add | +| grb | git rebase | +| grba | git rebase --abort | +| grbc | git rebase --continue | +| grbd | git rebase develop | +| grbi | git rebase -i | +| grbm | git rebase $(git_main_branch) | +| grbs | git rebase --skip | +| grev | git revert | +| grh | git reset | +| grhh | git reset --hard | +| groh | git reset origin/$(git_current_branch) --hard | +| grm | git rm | +| grmc | git rm --cached | +| grmv | git remote rename | +| grrm | git remote remove | +| grs | git restore | +| grset | git remote set-url | +| grss | git restore --source | +| grt | cd "$(git rev-parse --show-toplevel \|\| echo .)" | +| gru | git reset -- | +| grup | git remote update | +| grv | git remote -v | +| gsb | git status -sb | +| gsd | git svn dcommit | +| gsh | git show | +| gsi | git submodule init | +| gsps | git show --pretty=short --show-signature | +| gsr | git svn rebase | +| gss | git status -s | +| gst | git status | +| gsta | git stash push | +| gsta | git stash save | +| gstaa | git stash apply | +| gstc | git stash clear | +| gstd | git stash drop | +| gstl | git stash list | +| gstp | git stash pop | +| gsts | git stash show --text | +| gstu | git stash --include-untracked | +| gstall | git stash --all | +| gsu | git submodule update | +| gsw | git switch | +| gswc | git switch -c | +| gts | git tag -s | +| gtv | git tag \| sort -V | +| gtl | gtl(){ git tag --sort=-v:refname -n -l ${1}* }; noglob gtl | +| gunignore | git update-index --no-assume-unchanged | +| gunwip | git log -n 1 \| grep -q -c "\-\-wip\-\-" && git reset HEAD~1 | +| gup | git pull --rebase | +| gupv | git pull --rebase -v | +| gupa | git pull --rebase --autostash | +| gupav | git pull --rebase --autostash -v | +| glum | git pull upstream $(git_main_branch) | +| gwch | git whatchanged -p --abbrev-commit --pretty=medium | +| gwip | git add -A; git rm $(git ls-files --deleted) 2> /dev/null; git commit --no-verify --no-gpg-sign -m "--wip-- [skip ci]" | +| gam | git am | +| gamc | git am --continue | +| gams | git am --skip | +| gama | git am --abort | +| gamscp | git am --show-current-patch | -### Deprecated +### Main branch preference + +Following the recent push for removing racially-charged words from our technical vocabulary, the git plugin favors using +a branch name other than `master`. In this case, we favor the shorter, neutral and descriptive term `main`. This means +that any aliases and functions that previously used `master`, will use `main` if that branch exists. We do this via the +function `git_main_branch`. + +### Deprecated aliases These are aliases that have been removed, renamed, or otherwise modified in a way that may, or may not, receive further support. -| Alias | Command | Modification | -| :----- | :----------------------------------------------------------------------------------| --------------------------------------------------------------------------------------------------- | -| gap | git add --patch | new alias `gapa` | -| gcl | git config --list | new alias `gcf` | -| gdc | git diff --cached | new alias `gdca` | -| gdt | git difftool | no replacement | -| ggpull | git pull origin $(current_branch) | new alias `ggl` (`ggpull` still exists for now though) | -| ggpur | git pull --rebase origin $(current_branch) | new alias `ggu` (`ggpur` still exists for now though) | -| ggpush | git push origin $(current_branch) | new alias `ggp` (`ggpush` still exists for now though) | -| gk | gitk --all --branches | now aliased to `gitk --all --branches` | -| glg | git log --stat --max-count = 10 | now aliased to `git log --stat --color` | -| glgg | git log --graph --max-count = 10 | now aliased to `git log --graph --color` | -| gwc | git whatchanged -p --abbrev-commit --pretty = medium | new alias `gwch` | +| Alias | Command | Modification | +| :----- | :----------------------------------------------------- | :----------------------------------------------------- | +| gap | `git add --patch` | new alias `gapa` | +| gcl | `git config --list` | new alias `gcf` | +| gdc | `git diff --cached` | new alias `gdca` | +| gdt | `git difftool` | no replacement | +| ggpull | `git pull origin $(current_branch)` | new alias `ggl` (`ggpull` still exists for now though) | +| ggpur | `git pull --rebase origin $(current_branch)` | new alias `ggu` (`ggpur` still exists for now though) | +| ggpush | `git push origin $(current_branch)` | new alias `ggp` (`ggpush` still exists for now though) | +| gk | `gitk --all --branches` | now aliased to `gitk --all --branches` | +| glg | `git log --stat --max-count = 10` | now aliased to `git log --stat --color` | +| glgg | `git log --graph --max-count = 10` | now aliased to `git log --graph --color` | +| gwc | `git whatchanged -p --abbrev-commit --pretty = medium` | new alias `gwch` | ## Functions ### Current -| Command | Description | -|:-----------------------|:----------------------------------------| -| current_branch | Return the name of the current branch | -| git_current_user_name | Returns the `user.name` config value | -| git_current_user_email | Returns the `user.email` config value | +| Command | Description | +|:-----------------------|:-----------------------------------------------------------------------------| +| `grename ` | Rename `old` branch to `new`, including in origin remote | +| current_branch | Return the name of the current branch | +| git_current_user_name | Returns the `user.name` config value | +| git_current_user_email | Returns the `user.email` config value | +| git_main_branch | Returns the name of the main branch: `main` if it exists, `master` otherwise | ### Work in Progress (WIP) @@ -209,7 +226,7 @@ These features allow to pause a branch development and switch to another one (_" | gwip | Commit wip branch | | gunwip | Uncommit wip branch | -### Deprecated +### Deprecated functions | Command | Description | Reason | |:-----------------------|:----------------------------------------|:----------------------------------------------------------------| diff --git a/zsh/plugins/git/git.plugin.zsh b/zsh/plugins/git/git.plugin.zsh index d8c4cff..ccb9d84 100644 --- a/zsh/plugins/git/git.plugin.zsh +++ b/zsh/plugins/git/git.plugin.zsh @@ -1,3 +1,7 @@ +# Git version checking +autoload -Uz is-at-least +git_version="${${(As: :)$(git version 2>/dev/null)}[3]}" + # # Functions # @@ -25,6 +29,15 @@ function work_in_progress() { fi } +# Check if main exists and use instead of master +function git_main_branch() { + if [[ -n "$(git branch --list main)" ]]; then + echo main + else + echo master + fi +} + # # Aliases # (sorted alphabetically) @@ -38,11 +51,12 @@ alias gapa='git add --patch' alias gau='git add --update' alias gav='git add --verbose' alias gap='git apply' +alias gapt='git apply --3way' alias gb='git branch' alias gba='git branch -a' alias gbd='git branch -d' -alias gbda='git branch --no-color --merged | command grep -vE "^(\+|\*|\s*(master|develop|dev)\s*$)" | command xargs -n 1 git branch -d' +alias gbda='git branch --no-color --merged | command grep -vE "^(\+|\*|\s*($(git_main_branch)|development|develop|devel|dev)\s*$)" | command xargs -n 1 git branch -d' alias gbD='git branch -D' alias gbl='git blame -b -w' alias gbnm='git branch --no-merged' @@ -66,8 +80,8 @@ alias gcb='git checkout -b' alias gcf='git config --list' alias gcl='git clone --recurse-submodules' alias gclean='git clean -id' -alias gpristine='git reset --hard && git clean -dfx' -alias gcm='git checkout master' +alias gpristine='git reset --hard && git clean -dffx' +alias gcm='git checkout $(git_main_branch)' alias gcd='git checkout develop' alias gcmsg='git commit -m' alias gco='git checkout' @@ -85,11 +99,19 @@ alias gds='git diff --staged' alias gdt='git diff-tree --no-commit-id --name-only -r' alias gdw='git diff --word-diff' +function gdnolock() { + git diff "$@" ":(exclude)package-lock.json" ":(exclude)*.lock" +} +compdef _git gdnolock=git-diff + function gdv() { git diff -w "$@" | view - } compdef _git gdv=git-diff alias gf='git fetch' -alias gfa='git fetch --all --prune' +# --jobs= was added in git 2.8 +is-at-least 2.8 "$git_version" \ + && alias gfa='git fetch --all --prune --jobs=10' \ + || alias gfa='git fetch --all --prune' alias gfo='git fetch origin' alias gfg='git ls-files | grep' @@ -154,7 +176,7 @@ alias ghh='git help' alias gignore='git update-index --assume-unchanged' alias gignored='git ls-files -v | grep "^[[:lower:]]"' -alias git-svn-dcommit-push='git svn dcommit && git push github master:svntrunk' +alias git-svn-dcommit-push='git svn dcommit && git push github $(git_main_branch):svntrunk' alias gk='\gitk --all --branches' alias gke='\gitk --all $(git log -g --pretty=%h)' @@ -176,10 +198,10 @@ alias gloga='git log --oneline --decorate --graph --all' alias glp="_git_log_prettily" alias gm='git merge' -alias gmom='git merge origin/master' +alias gmom='git merge origin/$(git_main_branch)' alias gmt='git mergetool --no-prompt' alias gmtvim='git mergetool --no-prompt --tool=vimdiff' -alias gmum='git merge upstream/master' +alias gmum='git merge upstream/$(git_main_branch)' alias gma='git merge --abort' alias gp='git push' @@ -197,7 +219,7 @@ 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 grbm='git rebase $(git_main_branch)' alias grbs='git rebase --skip' alias grev='git revert' alias grh='git reset' @@ -225,8 +247,7 @@ alias gss='git status -s' alias gst='git status' # use the default stash push on git 2.13 and newer -autoload -Uz is-at-least -is-at-least 2.13 "$(git --version 2>/dev/null | awk '{print $3}')" \ +is-at-least 2.13 "$git_version" \ && alias gsta='git stash push' \ || alias gsta='git stash save' @@ -236,6 +257,7 @@ alias gstd='git stash drop' alias gstl='git stash list' alias gstp='git stash pop' alias gsts='git stash show --text' +alias gstu='git stash --include-untracked' alias gstall='git stash --all' alias gsu='git submodule update' alias gsw='git switch' @@ -251,7 +273,29 @@ alias gup='git pull --rebase' alias gupv='git pull --rebase -v' alias gupa='git pull --rebase --autostash' alias gupav='git pull --rebase --autostash -v' -alias glum='git pull upstream master' +alias glum='git pull upstream $(git_main_branch)' alias gwch='git whatchanged -p --abbrev-commit --pretty=medium' alias gwip='git add -A; git rm $(git ls-files --deleted) 2> /dev/null; git commit --no-verify --no-gpg-sign -m "--wip-- [skip ci]"' + +alias gam='git am' +alias gamc='git am --continue' +alias gams='git am --skip' +alias gama='git am --abort' +alias gamscp='git am --show-current-patch' + +function grename() { + if [[ -z "$1" || -z "$2" ]]; then + echo "Usage: $0 old_branch new_branch" + return 1 + fi + + # Rename branch locally + git branch -m "$1" "$2" + # Rename branch in origin remote + if git push origin :"$1"; then + git push --set-upstream origin "$2" + fi +} + +unset git_version diff --git a/zsh/plugins/gitfast/README.md b/zsh/plugins/gitfast/README.md index 84e35d7..fed4b12 100644 --- a/zsh/plugins/gitfast/README.md +++ b/zsh/plugins/gitfast/README.md @@ -1,6 +1,6 @@ # Gitfast plugin -This plugin adds completion for Git, using the zsh completion from git.git folks, which is much faster than the official one from zsh. A lot of zsh-specific features are not supported, like descriptions for every argument, but everything the bash completion has, this one does too (as it is using it behind the scenes). Not only is it faster, it should be more robust, and updated regularly to the latest git upstream version.. +This plugin adds completion for Git, using the zsh completion from git.git folks, which is much faster than the official one from zsh. A lot of zsh-specific features are not supported, like descriptions for every argument, but everything the bash completion has, this one does too (as it is using it behind the scenes). Not only is it faster, it should be more robust, and updated regularly to the latest git upstream version. To use it, add `gitfast` to the plugins array in your zshrc file: @@ -11,5 +11,5 @@ plugins=(... gitfast) ## Aliases An earlier version of the plugin also loaded the git plugin. If you want to keep those -aliases enable the [git plugin](https://github.com/robbyrussell/oh-my-zsh/tree/master/plugins/git) +aliases enable the [git plugin](https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/git) as well. diff --git a/zsh/plugins/gitfast/_git b/zsh/plugins/gitfast/_git index 886bf95..78a6dbb 100644 --- a/zsh/plugins/gitfast/_git +++ b/zsh/plugins/gitfast/_git @@ -30,7 +30,7 @@ if [ -z "$script" ]; then local -a locations local e locations=( - $(dirname ${funcsourcetrace[1]%:*})/git-completion.bash + "$(dirname ${funcsourcetrace[1]%:*})/git-completion.bash" '/etc/bash_completion.d/git' # fedora, old debian '/usr/share/bash-completion/completions/git' # arch, ubuntu, new debian '/usr/share/bash-completion/git' # gentoo @@ -39,7 +39,7 @@ if [ -z "$script" ]; then test -f $e && script="$e" && break done fi -GIT_SOURCING_ZSH_COMPLETION=y . "$script" +ZSH_VERSION='' . "$script" __gitcomp () { @@ -93,22 +93,13 @@ __gitcomp_nl_append () compadd -Q -S "${4- }" -p "${2-}" -- ${=1} && _ret=0 } -__gitcomp_file_direct () -{ - emulate -L zsh - - local IFS=$'\n' - compset -P '*[=:]' - compadd -f -- ${=1} && _ret=0 -} - __gitcomp_file () { emulate -L zsh local IFS=$'\n' compset -P '*[=:]' - compadd -p "${2-}" -f -- ${=1} && _ret=0 + compadd -Q -p "${2-}" -f -- ${=1} && _ret=0 } __git_zsh_bash_func () @@ -232,8 +223,10 @@ _git () if (( $+functions[__${service}_zsh_main] )); then __${service}_zsh_main - else + elif (( $+functions[__${service}_main] )); then emulate ksh -c __${service}_main + elif (( $+functions[_${service}] )); then + emulate ksh -c _${service} fi let _ret && _default && _ret=0 diff --git a/zsh/plugins/gitfast/git-completion.bash b/zsh/plugins/gitfast/git-completion.bash index e087c4b..b6ff5dc 100644 --- a/zsh/plugins/gitfast/git-completion.bash +++ b/zsh/plugins/gitfast/git-completion.bash @@ -29,16 +29,13 @@ # tell the completion to use commit completion. This also works with aliases # of form "!sh -c '...'". For example, "!sh -c ': git commit ; ... '". # -# Compatible with bash 3.2.57. -# # You can set the following environment variables to influence the behavior of # the completion routines: # # GIT_COMPLETION_CHECKOUT_NO_GUESS # # When set to "1", do not include "DWIM" suggestions in git-checkout -# and git-switch completion (e.g., completing "foo" when "origin/foo" -# exists). +# completion (e.g., completing "foo" when "origin/foo" exists). case "$COMP_WORDBREAKS" in *:*) : great ;; @@ -95,70 +92,6 @@ __git () ${__git_dir:+--git-dir="$__git_dir"} "$@" 2>/dev/null } -# Removes backslash escaping, single quotes and double quotes from a word, -# stores the result in the variable $dequoted_word. -# 1: The word to dequote. -__git_dequote () -{ - local rest="$1" len ch - - dequoted_word="" - - while test -n "$rest"; do - len=${#dequoted_word} - dequoted_word="$dequoted_word${rest%%[\\\'\"]*}" - rest="${rest:$((${#dequoted_word}-$len))}" - - case "${rest:0:1}" in - \\) - ch="${rest:1:1}" - case "$ch" in - $'\n') - ;; - *) - dequoted_word="$dequoted_word$ch" - ;; - esac - rest="${rest:2}" - ;; - \') - rest="${rest:1}" - len=${#dequoted_word} - dequoted_word="$dequoted_word${rest%%\'*}" - rest="${rest:$((${#dequoted_word}-$len+1))}" - ;; - \") - rest="${rest:1}" - while test -n "$rest" ; do - len=${#dequoted_word} - dequoted_word="$dequoted_word${rest%%[\\\"]*}" - rest="${rest:$((${#dequoted_word}-$len))}" - case "${rest:0:1}" in - \\) - ch="${rest:1:1}" - case "$ch" in - \"|\\|\$|\`) - dequoted_word="$dequoted_word$ch" - ;; - $'\n') - ;; - *) - dequoted_word="$dequoted_word\\$ch" - ;; - esac - rest="${rest:2}" - ;; - \") - rest="${rest:1}" - break - ;; - esac - done - ;; - esac - done -} - # The following function is based on code from: # # bash_completion - programmable completion functions for bash 3.2+ @@ -331,32 +264,9 @@ __gitcomp () case "$cur_" in --*=) ;; - --no-*) - local c i=0 IFS=$' \t\n' - for c in $1; do - if [[ $c == "--" ]]; then - continue - fi - c="$c${4-}" - if [[ $c == "$cur_"* ]]; then - case $c in - --*=*|*.) ;; - *) c="$c " ;; - esac - COMPREPLY[i++]="${2-}$c" - fi - done - ;; *) local c i=0 IFS=$' \t\n' for c in $1; do - if [[ $c == "--" ]]; then - c="--no-...${4-}" - if [[ $c == "$cur_"* ]]; then - COMPREPLY[i++]="${2-}$c " - fi - break - fi c="$c${4-}" if [[ $c == "$cur_"* ]]; then case $c in @@ -370,48 +280,6 @@ __gitcomp () esac } -# Clear the variables caching builtins' options when (re-)sourcing -# the completion script. -if [[ -n ${ZSH_VERSION-} ]]; then - unset $(set |sed -ne 's/^\(__gitcomp_builtin_[a-zA-Z0-9_][a-zA-Z0-9_]*\)=.*/\1/p') 2>/dev/null -else - unset $(compgen -v __gitcomp_builtin_) -fi - -# This function is equivalent to -# -# __gitcomp "$(git xxx --git-completion-helper) ..." -# -# except that the output is cached. Accept 1-3 arguments: -# 1: the git command to execute, this is also the cache key -# 2: extra options to be added on top (e.g. negative forms) -# 3: options to be excluded -__gitcomp_builtin () -{ - # spaces must be replaced with underscore for multi-word - # commands, e.g. "git remote add" becomes remote_add. - local cmd="$1" - local incl="$2" - local excl="$3" - - local var=__gitcomp_builtin_"${cmd/-/_}" - local options - eval "options=\$$var" - - if [ -z "$options" ]; then - # leading and trailing spaces are significant to make - # option removal work correctly. - options=" $incl $(__git ${cmd/_/ } --git-completion-helper) " || return - - for i in $excl; do - options="${options/ $i / }" - done - eval "$var=\"$options\"" - fi - - __gitcomp "$options" -} - # Variation of __gitcomp_nl () that appends to the existing list of # completion candidates, COMPREPLY. __gitcomp_nl_append () @@ -435,24 +303,6 @@ __gitcomp_nl () __gitcomp_nl_append "$@" } -# Fills the COMPREPLY array with prefiltered paths without any additional -# processing. -# Callers must take care of providing only paths that match the current path -# to be completed and adding any prefix path components, if necessary. -# 1: List of newline-separated matching paths, complete with all prefix -# path components. -__gitcomp_file_direct () -{ - local IFS=$'\n' - - COMPREPLY=($1) - - # use a hack to enable file mode in bash < 4 - compopt -o filenames +o nospace 2>/dev/null || - compgen -f /non-existing-dir/ >/dev/null || - true -} - # Generates completion reply with compgen from newline-separated possible # completion filenames. # It accepts 1 to 3 arguments: @@ -472,8 +322,7 @@ __gitcomp_file () # use a hack to enable file mode in bash < 4 compopt -o filenames +o nospace 2>/dev/null || - compgen -f /non-existing-dir/ >/dev/null || - true + compgen -f /non-existing-dir/ > /dev/null } # Execute 'git ls-files', unless the --committable option is specified, in @@ -483,12 +332,10 @@ __gitcomp_file () __git_ls_files_helper () { if [ "$2" == "--committable" ]; then - __git -C "$1" -c core.quotePath=false diff-index \ - --name-only --relative HEAD -- "${3//\\/\\\\}*" + __git -C "$1" diff-index --name-only --relative HEAD else # NOTE: $2 is not quoted in order to support multiple options - __git -C "$1" -c core.quotePath=false ls-files \ - --exclude-standard $2 -- "${3//\\/\\\\}*" + __git -C "$1" ls-files --exclude-standard $2 fi } @@ -499,103 +346,17 @@ __git_ls_files_helper () # If provided, only files within the specified directory are listed. # Sub directories are never recursed. Path must have a trailing # slash. -# 3: List only paths matching this path component (optional). __git_index_files () { - local root="$2" match="$3" + local root="${2-.}" file - __git_ls_files_helper "$root" "$1" "$match" | - awk -F / -v pfx="${2//\\/\\\\}" '{ - paths[$1] = 1 - } - END { - for (p in paths) { - if (substr(p, 1, 1) != "\"") { - # No special characters, easy! - print pfx p - continue - } - - # The path is quoted. - p = dequote(p) - if (p == "") - continue - - # Even when a directory name itself does not contain - # any special characters, it will still be quoted if - # any of its (stripped) trailing path components do. - # Because of this we may have seen the same direcory - # both quoted and unquoted. - if (p in paths) - # We have seen the same directory unquoted, - # skip it. - continue - else - print pfx p - } - } - function dequote(p, bs_idx, out, esc, esc_idx, dec) { - # Skip opening double quote. - p = substr(p, 2) - - # Interpret backslash escape sequences. - while ((bs_idx = index(p, "\\")) != 0) { - out = out substr(p, 1, bs_idx - 1) - esc = substr(p, bs_idx + 1, 1) - p = substr(p, bs_idx + 2) - - if ((esc_idx = index("abtvfr\"\\", esc)) != 0) { - # C-style one-character escape sequence. - out = out substr("\a\b\t\v\f\r\"\\", - esc_idx, 1) - } else if (esc == "n") { - # Uh-oh, a newline character. - # We cant reliably put a pathname - # containing a newline into COMPREPLY, - # and the newline would create a mess. - # Skip this path. - return "" - } else { - # Must be a \nnn octal value, then. - dec = esc * 64 + \ - substr(p, 1, 1) * 8 + \ - substr(p, 2, 1) - out = out sprintf("%c", dec) - p = substr(p, 3) - } - } - # Drop closing double quote, if there is one. - # (There isnt any if this is a directory, as it was - # already stripped with the trailing path components.) - if (substr(p, length(p), 1) == "\"") - out = out substr(p, 1, length(p) - 1) - else - out = out p - - return out - }' -} - -# __git_complete_index_file requires 1 argument: -# 1: the options to pass to ls-file -# -# The exception is --committable, which finds the files appropriate commit. -__git_complete_index_file () -{ - local dequoted_word pfx="" cur_ - - __git_dequote "$cur" - - case "$dequoted_word" in - ?*/*) - pfx="${dequoted_word%/*}/" - cur_="${dequoted_word##*/}" - ;; - *) - cur_="$dequoted_word" - esac - - __gitcomp_file_direct "$(__git_index_files "$1" "$pfx" "$cur_")" + __git_ls_files_helper "$root" "$1" | + while read -r file; do + case "$file" in + ?*/*) echo "${file%%/*}" ;; + *) echo "$file" ;; + esac + done | sort | uniq } # Lists branches from the local repository. @@ -678,7 +439,7 @@ __git_refs () track="" ;; *) - for i in HEAD FETCH_HEAD ORIG_HEAD MERGE_HEAD REBASE_HEAD; do + for i in HEAD FETCH_HEAD ORIG_HEAD MERGE_HEAD; do case "$i" in $match*) if [ -e "$dir/$i" ]; then @@ -833,7 +594,7 @@ __git_is_configured_remote () __git_list_merge_strategies () { - LANG=C LC_ALL=C git merge -s help 2>&1 | + git merge -s help 2>&1 | sed -n -e '/[Aa]vailable strategies are: /,/^$/{ s/\.$// s/.*:// @@ -855,14 +616,9 @@ __git_compute_merge_strategies () __git_merge_strategies=$(__git_list_merge_strategies) } -__git_merge_strategy_options="ours theirs subtree subtree= patience - histogram diff-algorithm= ignore-space-change ignore-all-space - ignore-space-at-eol renormalize no-renormalize no-renames - find-renames find-renames= rename-threshold=" - __git_complete_revlist_file () { - local dequoted_word pfx ls ref cur_="$cur" + local pfx ls ref cur_="$cur" case "$cur_" in *..?*:*) return @@ -870,18 +626,14 @@ __git_complete_revlist_file () ?*:*) ref="${cur_%%:*}" cur_="${cur_#*:}" - - __git_dequote "$cur_" - - case "$dequoted_word" in + case "$cur_" in ?*/*) - pfx="${dequoted_word%/*}" - cur_="${dequoted_word##*/}" + pfx="${cur_%/*}" + cur_="${cur_##*/}" ls="$ref:$pfx" pfx="$pfx/" ;; *) - cur_="$dequoted_word" ls="$ref" ;; esac @@ -891,10 +643,21 @@ __git_complete_revlist_file () *) pfx="$ref:$pfx" ;; esac - __gitcomp_file "$(__git ls-tree "$ls" \ - | sed 's/^.* // - s/$//')" \ - "$pfx" "$cur_" + __gitcomp_nl "$(__git ls-tree "$ls" \ + | sed '/^100... blob /{ + s,^.* ,, + s,$, , + } + /^120000 blob /{ + s,^.* ,, + s,$, , + } + /^040000 tree /{ + s,^.* ,, + s,$,/, + } + s/^.* //')" \ + "$pfx" "$cur_" "" ;; *...*) pfx="${cur_%...*}..." @@ -912,6 +675,26 @@ __git_complete_revlist_file () esac } + +# __git_complete_index_file requires 1 argument: +# 1: the options to pass to ls-file +# +# The exception is --committable, which finds the files appropriate commit. +__git_complete_index_file () +{ + local pfx="" cur_="$cur" + + case "$cur_" in + ?*/*) + pfx="${cur_%/*}" + cur_="${cur_##*/}" + pfx="${pfx}/" + ;; + esac + + __gitcomp_file "$(__git_index_files "$1" ${pfx:+"$pfx"})" "$pfx" "$cur_" +} + __git_complete_file () { __git_complete_revlist_file @@ -943,7 +726,6 @@ __git_complete_remote_or_refspec () *) ;; esac ;; - --multiple) no_complete_refspec=1; break ;; -*) ;; *) remote="$i"; break ;; esac @@ -1003,30 +785,136 @@ __git_complete_strategy () -s|--strategy) __gitcomp "$__git_merge_strategies" return 0 - ;; - -X) - __gitcomp "$__git_merge_strategy_options" - return 0 - ;; esac case "$cur" in --strategy=*) __gitcomp "$__git_merge_strategies" "" "${cur##--strategy=}" return 0 ;; - --strategy-option=*) - __gitcomp "$__git_merge_strategy_options" "" "${cur##--strategy-option=}" - return 0 - ;; esac return 1 } +__git_commands () { + if test -n "${GIT_TESTING_COMMAND_COMPLETION:-}" + then + printf "%s" "${GIT_TESTING_COMMAND_COMPLETION}" + else + git help -a|egrep '^ [a-zA-Z0-9]' + fi +} + +__git_list_all_commands () +{ + local i IFS=" "$'\n' + for i in $(__git_commands) + do + case $i in + *--*) : helper pattern;; + *) echo $i;; + esac + done +} + __git_all_commands= __git_compute_all_commands () { test -n "$__git_all_commands" || - __git_all_commands=$(__git --list-cmds=main,others,alias,nohelpers) + __git_all_commands=$(__git_list_all_commands) +} + +__git_list_porcelain_commands () +{ + local i IFS=" "$'\n' + __git_compute_all_commands + for i in $__git_all_commands + do + case $i in + *--*) : helper pattern;; + applymbox) : ask gittus;; + applypatch) : ask gittus;; + archimport) : import;; + cat-file) : plumbing;; + check-attr) : plumbing;; + check-ignore) : plumbing;; + check-mailmap) : plumbing;; + check-ref-format) : plumbing;; + checkout-index) : plumbing;; + column) : internal helper;; + commit-tree) : plumbing;; + count-objects) : infrequent;; + credential) : credentials;; + credential-*) : credentials helper;; + cvsexportcommit) : export;; + cvsimport) : import;; + cvsserver) : daemon;; + daemon) : daemon;; + diff-files) : plumbing;; + diff-index) : plumbing;; + diff-tree) : plumbing;; + fast-import) : import;; + fast-export) : export;; + fsck-objects) : plumbing;; + fetch-pack) : plumbing;; + fmt-merge-msg) : plumbing;; + for-each-ref) : plumbing;; + hash-object) : plumbing;; + http-*) : transport;; + index-pack) : plumbing;; + init-db) : deprecated;; + local-fetch) : plumbing;; + ls-files) : plumbing;; + ls-remote) : plumbing;; + ls-tree) : plumbing;; + mailinfo) : plumbing;; + mailsplit) : plumbing;; + merge-*) : plumbing;; + mktree) : plumbing;; + mktag) : plumbing;; + pack-objects) : plumbing;; + pack-redundant) : plumbing;; + pack-refs) : plumbing;; + parse-remote) : plumbing;; + patch-id) : plumbing;; + prune) : plumbing;; + prune-packed) : plumbing;; + quiltimport) : import;; + read-tree) : plumbing;; + receive-pack) : plumbing;; + remote-*) : transport;; + rerere) : plumbing;; + rev-list) : plumbing;; + rev-parse) : plumbing;; + runstatus) : plumbing;; + sh-setup) : internal;; + shell) : daemon;; + show-ref) : plumbing;; + send-pack) : plumbing;; + show-index) : plumbing;; + ssh-*) : transport;; + stripspace) : plumbing;; + symbolic-ref) : plumbing;; + unpack-file) : plumbing;; + unpack-objects) : plumbing;; + update-index) : plumbing;; + update-ref) : plumbing;; + update-server-info) : daemon;; + upload-archive) : plumbing;; + upload-pack) : plumbing;; + write-tree) : plumbing;; + var) : infrequent;; + verify-pack) : infrequent;; + verify-tag) : plumbing;; + *) echo $i;; + esac + done +} + +__git_porcelain_commands= +__git_compute_porcelain_commands () +{ + test -n "$__git_porcelain_commands" || + __git_porcelain_commands=$(__git_list_porcelain_commands) } # Lists all set config variables starting with the given section prefix, @@ -1044,6 +932,11 @@ __git_pretty_aliases () __git_get_config_variables "pretty" } +__git_aliases () +{ + __git_get_config_variables "alias" +} + # __git_aliased_command requires 1 argument __git_aliased_command () { @@ -1179,14 +1072,12 @@ __git_count_arguments () } __git_whitespacelist="nowarn warn error error-all fix" -__git_patchformat="mbox stgit stgit-series hg mboxrd" -__git_am_inprogress_options="--skip --continue --resolved --abort --quit --show-current-patch" _git_am () { __git_find_repo_path if [ -d "$__git_repo_path"/rebase-apply ]; then - __gitcomp "$__git_am_inprogress_options" + __gitcomp "--skip --continue --resolved --abort" return fi case "$cur" in @@ -1194,13 +1085,13 @@ _git_am () __gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}" return ;; - --patch-format=*) - __gitcomp "$__git_patchformat" "" "${cur##--patch-format=}" - return - ;; --*) - __gitcomp_builtin am "" \ - "$__git_am_inprogress_options" + __gitcomp " + --3way --committer-date-is-author-date --ignore-date + --ignore-whitespace --ignore-space-change + --interactive --keep --no-utf8 --signoff --utf8 + --whitespace= --scissors + " return esac } @@ -1213,7 +1104,14 @@ _git_apply () return ;; --*) - __gitcomp_builtin apply + __gitcomp " + --stat --numstat --summary --check --index + --cached --index-info --reverse --reject --unidiff-zero + --apply --no-add --exclude= + --ignore-whitespace --ignore-space-change + --whitespace= --inaccurate-eof --verbose + --recount --directory= + " return esac } @@ -1221,12 +1119,11 @@ _git_apply () _git_add () { case "$cur" in - --chmod=*) - __gitcomp "+x -x" "" "${cur##--chmod=}" - return - ;; --*) - __gitcomp_builtin add + __gitcomp " + --interactive --refresh --patch --update --dry-run + --ignore-errors --intent-to-add --force --edit --chmod= + " return esac @@ -1285,8 +1182,6 @@ _git_bisect () esac } -__git_ref_fieldlist="refname objecttype objectsize objectname upstream push HEAD symref" - _git_branch () { local i c=1 only_local_ref="n" has_r="n" @@ -1305,7 +1200,13 @@ _git_branch () __git_complete_refs --cur="${cur##--set-upstream-to=}" ;; --*) - __gitcomp_builtin branch + __gitcomp " + --color --no-color --verbose --abbrev= --no-abbrev + --track --no-track --contains --no-contains --merged --no-merged + --set-upstream-to= --edit-description --list + --unset-upstream --delete --move --copy --remotes + --column --no-column --sort= --points-at + " ;; *) if [ $only_local_ref = "y" -a $has_r = "n" ]; then @@ -1346,7 +1247,11 @@ _git_checkout () __gitcomp "diff3 merge" "" "${cur##--conflict=}" ;; --*) - __gitcomp_builtin checkout + __gitcomp " + --quiet --ours --theirs --track --no-track --merge + --conflict= --orphan --patch --detach --ignore-skip-worktree-bits + --recurse-submodules --no-recurse-submodules + " ;; *) # check if --track, --no-track, or --no-guess was specified @@ -1361,22 +1266,21 @@ _git_checkout () esac } -__git_cherry_pick_inprogress_options="--continue --quit --abort" +_git_cherry () +{ + __git_complete_refs +} _git_cherry_pick () { __git_find_repo_path if [ -f "$__git_repo_path"/CHERRY_PICK_HEAD ]; then - __gitcomp "$__git_cherry_pick_inprogress_options" + __gitcomp "--continue --quit --abort" return fi - - __git_complete_strategy && return - case "$cur" in --*) - __gitcomp_builtin cherry-pick "" \ - "$__git_cherry_pick_inprogress_options" + __gitcomp "--edit --no-commit --signoff --strategy= --mainline" ;; *) __git_complete_refs @@ -1388,7 +1292,7 @@ _git_clean () { case "$cur" in --*) - __gitcomp_builtin clean + __gitcomp "--dry-run --quiet" return ;; esac @@ -1401,7 +1305,26 @@ _git_clone () { case "$cur" in --*) - __gitcomp_builtin clone + __gitcomp " + --local + --no-hardlinks + --shared + --reference + --quiet + --no-checkout + --bare + --mirror + --origin + --upload-pack + --template= + --depth + --single-branch + --no-tags + --branch + --recurse-submodules + --no-single-branch + --shallow-submodules + " return ;; esac @@ -1434,7 +1357,16 @@ _git_commit () return ;; --*) - __gitcomp_builtin commit + __gitcomp " + --all --author= --signoff --verify --no-verify + --edit --no-edit + --amend --include --only --interactive + --dry-run --reuse-message= --reedit-message= + --reset-author --file= --message= --template= + --cleanup= --untracked-files --untracked-files= + --verbose --quiet --fixup= --squash= + --patch --short --date --allow-empty + " return esac @@ -1450,7 +1382,11 @@ _git_describe () { case "$cur" in --*) - __gitcomp_builtin describe + __gitcomp " + --all --tags --contains --abbrev= --candidates= + --exact-match --debug --long --match --always --first-parent + --exclude --dirty --broken + " return esac __git_complete_refs @@ -1475,7 +1411,7 @@ __git_diff_common_options="--stat --numstat --shortstat --summary --dirstat --dirstat= --dirstat-by-file --dirstat-by-file= --cumulative --diff-algorithm= - --submodule --submodule= --ignore-submodules + --submodule --submodule= " _git_diff () @@ -1503,8 +1439,7 @@ _git_diff () } __git_mergetools_common="diffuse diffmerge ecmerge emerge kdiff3 meld opendiff - tkdiff vimdiff gvimdiff xxdiff araxis p4merge bc - codecompare smerge + tkdiff vimdiff gvimdiff xxdiff araxis p4merge bc codecompare " _git_difftool () @@ -1517,11 +1452,11 @@ _git_difftool () return ;; --*) - __gitcomp_builtin difftool "$__git_diff_common_options - --base --cached --ours --theirs - --pickaxe-all --pickaxe-regex - --relative --staged - " + __gitcomp "--cached --staged --pickaxe-all --pickaxe-regex + --base --ours --theirs + --no-renames --diff-filter= --find-copies-harder + --relative --ignore-submodules + --tool=" return ;; esac @@ -1530,6 +1465,12 @@ _git_difftool () __git_fetch_recurse_submodules="yes on-demand no" +__git_fetch_options=" + --quiet --verbose --append --upload-pack --force --keep --depth= + --tags --no-tags --all --prune --dry-run --recurse-submodules= + --unshallow --update-shallow +" + _git_fetch () { case "$cur" in @@ -1537,21 +1478,21 @@ _git_fetch () __gitcomp "$__git_fetch_recurse_submodules" "" "${cur##--recurse-submodules=}" return ;; - --filter=*) - __gitcomp "blob:none blob:limit= sparse:oid=" "" "${cur##--filter=}" - return - ;; --*) - __gitcomp_builtin fetch + __gitcomp "$__git_fetch_options" return ;; esac __git_complete_remote_or_refspec } -__git_format_patch_extra_options=" - --full-index --not --all --no-prefix --src-prefix= - --dst-prefix= --notes +__git_format_patch_options=" + --stdout --attach --no-attach --thread --thread= --no-thread + --numbered --start-number --numbered-files --keep-subject --signoff + --signature --no-signature --in-reply-to= --cc= --full-index --binary + --not --all --cover-letter --no-prefix --src-prefix= --dst-prefix= + --inline --suffix= --ignore-if-in-upstream --subject-prefix= + --output-directory --reroll-count --to= --quiet --notes " _git_format_patch () @@ -1564,7 +1505,7 @@ _git_format_patch () return ;; --*) - __gitcomp_builtin format-patch "$__git_format_patch_extra_options" + __gitcomp "$__git_format_patch_options" return ;; esac @@ -1575,7 +1516,20 @@ _git_fsck () { case "$cur" in --*) - __gitcomp_builtin fsck + __gitcomp " + --tags --root --unreachable --cache --no-reflogs --full + --strict --verbose --lost-found --name-objects + " + return + ;; + esac +} + +_git_gc () +{ + case "$cur" in + --*) + __gitcomp "--prune --aggressive" return ;; esac @@ -1631,7 +1585,21 @@ _git_grep () case "$cur" in --*) - __gitcomp_builtin grep + __gitcomp " + --cached + --text --ignore-case --word-regexp --invert-match + --full-name --line-number + --extended-regexp --basic-regexp --fixed-strings + --perl-regexp + --threads + --files-with-matches --name-only + --files-without-match + --max-depth + --count + --and --or --not --all-match + --break --heading --show-function --function-context + --untracked --no-index + " return ;; esac @@ -1649,16 +1617,17 @@ _git_help () { case "$cur" in --*) - __gitcomp_builtin help + __gitcomp "--all --guides --info --man --web" return ;; esac - if test -n "$GIT_TESTING_ALL_COMMAND_LIST" - then - __gitcomp "$GIT_TESTING_ALL_COMMAND_LIST $(__git --list-cmds=alias,list-guide) gitk" - else - __gitcomp "$(__git --list-cmds=main,nohelpers,alias,list-guide) gitk" - fi + __git_compute_all_commands + __gitcomp "$__git_all_commands $(__git_aliases) + attributes cli core-tutorial cvs-migration + diffcore everyday gitk glossary hooks ignore modules + namespaces repository-layout revisions tutorial tutorial-2 + workflows + " } _git_init () @@ -1671,7 +1640,7 @@ _git_init () return ;; --*) - __gitcomp_builtin init + __gitcomp "--quiet --bare --template= --shared --shared=" return ;; esac @@ -1681,7 +1650,13 @@ _git_ls_files () { case "$cur" in --*) - __gitcomp_builtin ls-files + __gitcomp "--cached --deleted --modified --others --ignored + --stage --directory --no-empty-directory --unmerged + --killed --exclude= --exclude-from= + --exclude-per-directory= --exclude-standard + --error-unmatch --with-tree= --full-name + --abbrev --ignored --exclude-per-directory + " return ;; esac @@ -1695,7 +1670,7 @@ _git_ls_remote () { case "$cur" in --*) - __gitcomp_builtin ls-remote + __gitcomp "--heads --tags --refs --get-url --symref" return ;; esac @@ -1704,13 +1679,6 @@ _git_ls_remote () _git_ls_tree () { - case "$cur" in - --*) - __gitcomp_builtin ls-tree - return - ;; - esac - __git_complete_file } @@ -1737,8 +1705,8 @@ __git_log_shortlog_options=" --all-match --invert-grep " -__git_log_pretty_formats="oneline short medium full fuller email raw format: mboxrd" -__git_log_date_formats="relative iso8601 iso8601-strict rfc2822 short local default raw unix format:" +__git_log_pretty_formats="oneline short medium full fuller email raw format:" +__git_log_date_formats="relative iso8601 rfc2822 short local default raw" _git_log () { @@ -1826,13 +1794,22 @@ _git_log () __git_complete_revlist } +# Common merge options shared by git-merge(1) and git-pull(1). +__git_merge_options=" + --no-commit --no-stat --log --no-log --squash --strategy + --commit --stat --no-squash --ff --no-ff --ff-only --edit --no-edit + --verify-signatures --no-verify-signatures --gpg-sign + --quiet --verbose --progress --no-progress +" + _git_merge () { __git_complete_strategy && return case "$cur" in --*) - __gitcomp_builtin merge + __gitcomp "$__git_merge_options + --rerere-autoupdate --no-rerere-autoupdate --abort --continue" return esac __git_complete_refs @@ -1846,7 +1823,7 @@ _git_mergetool () return ;; --*) - __gitcomp "--tool= --prompt --no-prompt --gui --no-gui" + __gitcomp "--tool= --prompt --no-prompt" return ;; esac @@ -1856,7 +1833,7 @@ _git_merge_base () { case "$cur" in --*) - __gitcomp_builtin merge-base + __gitcomp "--octopus --independent --is-ancestor --fork-point" return ;; esac @@ -1867,7 +1844,7 @@ _git_mv () { case "$cur" in --*) - __gitcomp_builtin mv + __gitcomp "--dry-run" return ;; esac @@ -1881,14 +1858,19 @@ _git_mv () fi } +_git_name_rev () +{ + __gitcomp "--tags --all --stdin" +} + _git_notes () { - local subcommands='add append copy edit get-ref list merge prune remove show' + local subcommands='add append copy edit list prune remove show' local subcommand="$(__git_find_on_cmdline "$subcommands")" case "$subcommand,$cur" in ,--*) - __gitcomp_builtin notes + __gitcomp '--ref' ;; ,*) case "$prev" in @@ -1900,14 +1882,21 @@ _git_notes () ;; esac ;; - *,--reuse-message=*|*,--reedit-message=*) + add,--reuse-message=*|append,--reuse-message=*|\ + add,--reedit-message=*|append,--reedit-message=*) __git_complete_refs --cur="${cur#*=}" ;; - *,--*) - __gitcomp_builtin notes_$subcommand + add,--*|append,--*) + __gitcomp '--file= --message= --reedit-message= + --reuse-message=' ;; - prune,*|get-ref,*) - # this command does not take a ref, do not complete it + copy,--*) + __gitcomp '--stdin' + ;; + prune,--*) + __gitcomp '--dry-run --verbose' + ;; + prune,*) ;; *) case "$prev" in @@ -1931,8 +1920,12 @@ _git_pull () return ;; --*) - __gitcomp_builtin pull - + __gitcomp " + --rebase --no-rebase + --autostash --no-autostash + $__git_merge_options + $__git_fetch_options + " return ;; esac @@ -1983,36 +1976,27 @@ _git_push () return ;; --*) - __gitcomp_builtin push + __gitcomp " + --all --mirror --tags --dry-run --force --verbose + --quiet --prune --delete --follow-tags + --receive-pack= --repo= --set-upstream + --force-with-lease --force-with-lease= --recurse-submodules= + " return ;; esac __git_complete_remote_or_refspec } -_git_range_diff () -{ - case "$cur" in - --*) - __gitcomp " - --creation-factor= --no-dual-color - $__git_diff_common_options - " - return - ;; - esac - __git_complete_revlist -} - _git_rebase () { __git_find_repo_path if [ -f "$__git_repo_path"/rebase-merge/interactive ]; then - __gitcomp "--continue --skip --abort --quit --edit-todo --show-current-patch" + __gitcomp "--continue --skip --abort --quit --edit-todo" return elif [ -d "$__git_repo_path"/rebase-apply ] || \ [ -d "$__git_repo_path"/rebase-merge ]; then - __gitcomp "--continue --skip --abort --quit --show-current-patch" + __gitcomp "--continue --skip --abort --quit" return fi __git_complete_strategy && return @@ -2024,7 +2008,7 @@ _git_rebase () --*) __gitcomp " --onto --merge --strategy --interactive - --rebase-merges --preserve-merges --stat --no-stat + --preserve-merges --stat --no-stat --committer-date-is-author-date --ignore-date --ignore-whitespace --whitespace= --autosquash --no-autosquash @@ -2032,7 +2016,6 @@ _git_rebase () --autostash --no-autostash --verify --no-verify --keep-empty --root --force-rebase --no-ff - --rerere-autoupdate --exec " @@ -2094,16 +2077,16 @@ _git_send_email () return ;; --*) - __gitcomp_builtin send-email "--annotate --bcc --cc --cc-cmd --chain-reply-to + __gitcomp "--annotate --bcc --cc --cc-cmd --chain-reply-to --compose --confirm= --dry-run --envelope-sender --from --identity --in-reply-to --no-chain-reply-to --no-signed-off-by-cc - --no-suppress-from --no-thread --quiet --reply-to + --no-suppress-from --no-thread --quiet --signed-off-by-cc --smtp-pass --smtp-server --smtp-server-port --smtp-encryption= --smtp-user --subject --suppress-cc= --suppress-from --thread --to --validate --no-validate - $__git_format_patch_extra_options" + $__git_format_patch_options" return ;; esac @@ -2136,7 +2119,11 @@ _git_status () return ;; --*) - __gitcomp_builtin status + __gitcomp " + --short --branch --porcelain --long --verbose + --untracked-files= --ignore-submodules= --ignored + --column= --no-column + " return ;; esac @@ -2161,44 +2148,6 @@ _git_status () __git_complete_index_file "$complete_opt" } -_git_switch () -{ - case "$cur" in - --conflict=*) - __gitcomp "diff3 merge" "" "${cur##--conflict=}" - ;; - --*) - __gitcomp_builtin switch - ;; - *) - # check if --track, --no-track, or --no-guess was specified - # if so, disable DWIM mode - local track_opt="--track" only_local_ref=n - if [ "$GIT_COMPLETION_CHECKOUT_NO_GUESS" = "1" ] || - [ -n "$(__git_find_on_cmdline "--track --no-track --no-guess")" ]; then - track_opt='' - fi - # explicit --guess enables DWIM mode regardless of - # $GIT_COMPLETION_CHECKOUT_NO_GUESS - if [ -n "$(__git_find_on_cmdline "--guess")" ]; then - track_opt='--track' - fi - if [ -z "$(__git_find_on_cmdline "-d --detach")" ]; then - only_local_ref=y - else - # --guess --detach is invalid combination, no - # dwim will be done when --detach is specified - track_opt= - fi - if [ $only_local_ref = y -a -z "$track_opt" ]; then - __gitcomp_direct "$(__git_heads "" "$cur" " ")" - else - __git_complete_refs $track_opt - fi - ;; - esac -} - __git_config_get_set_variables () { local prevword word config_file= c=$cword @@ -2221,24 +2170,9 @@ __git_config_get_set_variables () __git config $config_file --name-only --list } -__git_config_vars= -__git_compute_config_vars () -{ - test -n "$__git_config_vars" || - __git_config_vars="$(git help --config-for-completion | sort | uniq)" -} - _git_config () { - local varname - - if [ "${BASH_VERSINFO[0]:-0}" -ge 4 ]; then - varname="${prev,,}" - else - varname="$(echo "$prev" |tr A-Z a-z)" - fi - - case "$varname" in + case "$prev" in branch.*.remote|branch.*.pushremote) __gitcomp_nl "$(__git_remotes)" return @@ -2248,7 +2182,7 @@ _git_config () return ;; branch.*.rebase) - __gitcomp "false true merges preserve interactive" + __gitcomp "false true preserve interactive" return ;; remote.pushdefault) @@ -2294,7 +2228,7 @@ _git_config () return ;; diff.submodule) - __gitcomp "$__git_diff_submodule_formats" + __gitcomp "log short" return ;; help.format) @@ -2305,7 +2239,7 @@ _git_config () __gitcomp "$__git_log_date_formats" return ;; - sendemail.aliasfiletype) + sendemail.aliasesfiletype) __gitcomp "mutt mailrc pine elm gnus" return ;; @@ -2331,25 +2265,32 @@ _git_config () esac case "$cur" in --*) - __gitcomp_builtin config + __gitcomp " + --system --global --local --file= + --list --replace-all + --get --get-all --get-regexp + --add --unset --unset-all + --remove-section --rename-section + --name-only + " return ;; branch.*.*) local pfx="${cur%.*}." cur_="${cur##*.}" - __gitcomp "remote pushRemote merge mergeOptions rebase" "$pfx" "$cur_" + __gitcomp "remote pushremote merge mergeoptions rebase" "$pfx" "$cur_" return ;; branch.*) local pfx="${cur%.*}." cur_="${cur#*.}" __gitcomp_direct "$(__git_heads "$pfx" "$cur_" ".")" - __gitcomp_nl_append $'autoSetupMerge\nautoSetupRebase\n' "$pfx" "$cur_" + __gitcomp_nl_append $'autosetupmerge\nautosetuprebase\n' "$pfx" "$cur_" return ;; guitool.*.*) local pfx="${cur%.*}." cur_="${cur##*.}" __gitcomp " - argPrompt cmd confirm needsFile noConsole noRescan - prompt revPrompt revUnmerged title + argprompt cmd confirm needsfile noconsole norescan + prompt revprompt revunmerged title " "$pfx" "$cur_" return ;; @@ -2378,14 +2319,14 @@ _git_config () local pfx="${cur%.*}." cur_="${cur##*.}" __gitcomp " url proxy fetch push mirror skipDefaultUpdate - receivepack uploadpack tagOpt pushurl + receivepack uploadpack tagopt pushurl " "$pfx" "$cur_" return ;; remote.*) local pfx="${cur%.*}." cur_="${cur#*.}" __gitcomp_nl "$(__git_remotes)" "$pfx" "$cur_" "." - __gitcomp_nl_append "pushDefault" "$pfx" "$cur_" + __gitcomp_nl_append "pushdefault" "$pfx" "$cur_" return ;; url.*.*) @@ -2393,14 +2334,332 @@ _git_config () __gitcomp "insteadOf pushInsteadOf" "$pfx" "$cur_" return ;; - *.*) - __git_compute_config_vars - __gitcomp "$__git_config_vars" - ;; - *) - __git_compute_config_vars - __gitcomp "$(echo "$__git_config_vars" | sed 's/\.[^ ]*/./g')" esac + __gitcomp " + add.ignoreErrors + advice.amWorkDir + advice.commitBeforeMerge + advice.detachedHead + advice.implicitIdentity + advice.pushAlreadyExists + advice.pushFetchFirst + advice.pushNeedsForce + advice.pushNonFFCurrent + advice.pushNonFFMatching + advice.pushUpdateRejected + advice.resolveConflict + advice.rmHints + advice.statusHints + advice.statusUoption + advice.ignoredHook + alias. + am.keepcr + am.threeWay + apply.ignorewhitespace + apply.whitespace + branch.autosetupmerge + branch.autosetuprebase + browser. + clean.requireForce + color.branch + color.branch.current + color.branch.local + color.branch.plain + color.branch.remote + color.decorate.HEAD + color.decorate.branch + color.decorate.remoteBranch + color.decorate.stash + color.decorate.tag + color.diff + color.diff.commit + color.diff.frag + color.diff.func + color.diff.meta + color.diff.new + color.diff.old + color.diff.plain + color.diff.whitespace + color.grep + color.grep.context + color.grep.filename + color.grep.function + color.grep.linenumber + color.grep.match + color.grep.selected + color.grep.separator + color.interactive + color.interactive.error + color.interactive.header + color.interactive.help + color.interactive.prompt + color.pager + color.showbranch + color.status + color.status.added + color.status.changed + color.status.header + color.status.localBranch + color.status.nobranch + color.status.remoteBranch + color.status.unmerged + color.status.untracked + color.status.updated + color.ui + commit.cleanup + commit.gpgSign + commit.status + commit.template + commit.verbose + core.abbrev + core.askpass + core.attributesfile + core.autocrlf + core.bare + core.bigFileThreshold + core.checkStat + core.commentChar + core.compression + core.createObject + core.deltaBaseCacheLimit + core.editor + core.eol + core.excludesfile + core.fileMode + core.fsyncobjectfiles + core.gitProxy + core.hideDotFiles + core.hooksPath + core.ignoreStat + core.ignorecase + core.logAllRefUpdates + core.loosecompression + core.notesRef + core.packedGitLimit + core.packedGitWindowSize + core.packedRefsTimeout + core.pager + core.precomposeUnicode + core.preferSymlinkRefs + core.preloadindex + core.protectHFS + core.protectNTFS + core.quotepath + core.repositoryFormatVersion + core.safecrlf + core.sharedRepository + core.sparseCheckout + core.splitIndex + core.sshCommand + core.symlinks + core.trustctime + core.untrackedCache + core.warnAmbiguousRefs + core.whitespace + core.worktree + credential.helper + credential.useHttpPath + credential.username + credentialCache.ignoreSIGHUP + diff.autorefreshindex + diff.external + diff.ignoreSubmodules + diff.mnemonicprefix + diff.noprefix + diff.renameLimit + diff.renames + diff.statGraphWidth + diff.submodule + diff.suppressBlankEmpty + diff.tool + diff.wordRegex + diff.algorithm + difftool. + difftool.prompt + fetch.recurseSubmodules + fetch.unpackLimit + format.attach + format.cc + format.coverLetter + format.from + format.headers + format.numbered + format.pretty + format.signature + format.signoff + format.subjectprefix + format.suffix + format.thread + format.to + gc. + gc.aggressiveDepth + gc.aggressiveWindow + gc.auto + gc.autoDetach + gc.autopacklimit + gc.logExpiry + gc.packrefs + gc.pruneexpire + gc.reflogexpire + gc.reflogexpireunreachable + gc.rerereresolved + gc.rerereunresolved + gc.worktreePruneExpire + gitcvs.allbinary + gitcvs.commitmsgannotation + gitcvs.dbTableNamePrefix + gitcvs.dbdriver + gitcvs.dbname + gitcvs.dbpass + gitcvs.dbuser + gitcvs.enabled + gitcvs.logfile + gitcvs.usecrlfattr + guitool. + gui.blamehistoryctx + gui.commitmsgwidth + gui.copyblamethreshold + gui.diffcontext + gui.encoding + gui.fastcopyblame + gui.matchtrackingbranch + gui.newbranchtemplate + gui.pruneduringfetch + gui.spellingdictionary + gui.trustmtime + help.autocorrect + help.browser + help.format + http.lowSpeedLimit + http.lowSpeedTime + http.maxRequests + http.minSessions + http.noEPSV + http.postBuffer + http.proxy + http.sslCipherList + http.sslVersion + http.sslCAInfo + http.sslCAPath + http.sslCert + http.sslCertPasswordProtected + http.sslKey + http.sslVerify + http.useragent + i18n.commitEncoding + i18n.logOutputEncoding + imap.authMethod + imap.folder + imap.host + imap.pass + imap.port + imap.preformattedHTML + imap.sslverify + imap.tunnel + imap.user + init.templatedir + instaweb.browser + instaweb.httpd + instaweb.local + instaweb.modulepath + instaweb.port + interactive.singlekey + log.date + log.decorate + log.showroot + mailmap.file + man. + man.viewer + merge. + merge.conflictstyle + merge.log + merge.renameLimit + merge.renormalize + merge.stat + merge.tool + merge.verbosity + mergetool. + mergetool.keepBackup + mergetool.keepTemporaries + mergetool.prompt + notes.displayRef + notes.rewrite. + notes.rewrite.amend + notes.rewrite.rebase + notes.rewriteMode + notes.rewriteRef + pack.compression + pack.deltaCacheLimit + pack.deltaCacheSize + pack.depth + pack.indexVersion + pack.packSizeLimit + pack.threads + pack.window + pack.windowMemory + pager. + pretty. + pull.octopus + pull.twohead + push.default + push.followTags + rebase.autosquash + rebase.stat + receive.autogc + receive.denyCurrentBranch + receive.denyDeleteCurrent + receive.denyDeletes + receive.denyNonFastForwards + receive.fsckObjects + receive.unpackLimit + receive.updateserverinfo + remote.pushdefault + remotes. + repack.usedeltabaseoffset + rerere.autoupdate + rerere.enabled + sendemail. + sendemail.aliasesfile + sendemail.aliasfiletype + sendemail.bcc + sendemail.cc + sendemail.cccmd + sendemail.chainreplyto + sendemail.confirm + sendemail.envelopesender + sendemail.from + sendemail.identity + sendemail.multiedit + sendemail.signedoffbycc + sendemail.smtpdomain + sendemail.smtpencryption + sendemail.smtppass + sendemail.smtpserver + sendemail.smtpserveroption + sendemail.smtpserverport + sendemail.smtpuser + sendemail.suppresscc + sendemail.suppressfrom + sendemail.thread + sendemail.to + sendemail.tocmd + sendemail.validate + sendemail.smtpbatchsize + sendemail.smtprelogindelay + showbranch.default + status.relativePaths + status.showUntrackedFiles + status.submodulesummary + submodule. + tar.umask + transfer.unpackLimit + url. + user.email + user.name + user.signingkey + web.browser + branch. remote. + " } _git_remote () @@ -2413,7 +2672,7 @@ _git_remote () if [ -z "$subcommand" ]; then case "$cur" in --*) - __gitcomp_builtin remote + __gitcomp "--verbose" ;; *) __gitcomp "$subcommands" @@ -2424,33 +2683,33 @@ _git_remote () case "$subcommand,$cur" in add,--*) - __gitcomp_builtin remote_add + __gitcomp "--track --master --fetch --tags --no-tags --mirror=" ;; add,*) ;; set-head,--*) - __gitcomp_builtin remote_set-head + __gitcomp "--auto --delete" ;; set-branches,--*) - __gitcomp_builtin remote_set-branches + __gitcomp "--add" ;; set-head,*|set-branches,*) __git_complete_remote_or_refspec ;; update,--*) - __gitcomp_builtin remote_update + __gitcomp "--prune" ;; update,*) - __gitcomp "$(__git_remotes) $(__git_get_config_variables "remotes")" + __gitcomp "$(__git_get_config_variables "remotes")" ;; set-url,--*) - __gitcomp_builtin remote_set-url + __gitcomp "--push --add --delete" ;; get-url,--*) - __gitcomp_builtin remote_get-url + __gitcomp "--push --all" ;; prune,--*) - __gitcomp_builtin remote_prune + __gitcomp "--dry-run" ;; *) __gitcomp_nl "$(__git_remotes)" @@ -2461,12 +2720,8 @@ _git_remote () _git_replace () { case "$cur" in - --format=*) - __gitcomp "short medium long" "" "${cur##--format=}" - return - ;; --*) - __gitcomp_builtin replace + __gitcomp "--edit --graft --format= --list --delete" return ;; esac @@ -2490,42 +2745,26 @@ _git_reset () case "$cur" in --*) - __gitcomp_builtin reset + __gitcomp "--merge --mixed --hard --soft --patch --keep" return ;; esac __git_complete_refs } -_git_restore () -{ - case "$cur" in - --conflict=*) - __gitcomp "diff3 merge" "" "${cur##--conflict=}" - ;; - --source=*) - __git_complete_refs --cur="${cur##--source=}" - ;; - --*) - __gitcomp_builtin restore - ;; - esac -} - -__git_revert_inprogress_options="--continue --quit --abort" - _git_revert () { __git_find_repo_path if [ -f "$__git_repo_path"/REVERT_HEAD ]; then - __gitcomp "$__git_revert_inprogress_options" + __gitcomp "--continue --quit --abort" return fi - __git_complete_strategy && return case "$cur" in --*) - __gitcomp_builtin revert "" \ - "$__git_revert_inprogress_options" + __gitcomp " + --edit --mainline --no-edit --no-commit --signoff + --strategy= --strategy-option= + " return ;; esac @@ -2536,7 +2775,7 @@ _git_rm () { case "$cur" in --*) - __gitcomp_builtin rm + __gitcomp "--cached --dry-run --ignore-unmatch --quiet" return ;; esac @@ -2594,7 +2833,12 @@ _git_show_branch () { case "$cur" in --*) - __gitcomp_builtin show-branch + __gitcomp " + --all --remotes --topo-order --date-order --current --more= + --list --independent --merge-base --no-name + --color --no-color + --sha1-name --sparse --topics --reflog + " return ;; esac @@ -2604,21 +2848,13 @@ _git_show_branch () _git_stash () { local save_opts='--all --keep-index --no-keep-index --quiet --patch --include-untracked' - local subcommands='push list show apply clear drop pop create branch' - local subcommand="$(__git_find_on_cmdline "$subcommands save")" - if [ -n "$(__git_find_on_cmdline "-p")" ]; then - subcommand="push" - fi + local subcommands='push save list show apply clear drop pop create branch' + local subcommand="$(__git_find_on_cmdline "$subcommands")" if [ -z "$subcommand" ]; then case "$cur" in --*) __gitcomp "$save_opts" ;; - sa*) - if [ -z "$(__git_find_on_cmdline "$save_opts")" ]; then - __gitcomp "save" - fi - ;; *) if [ -z "$(__git_find_on_cmdline "$save_opts")" ]; then __gitcomp "$subcommands" @@ -2639,9 +2875,6 @@ _git_stash () drop,--*) __gitcomp "--quiet" ;; - list,--*) - __gitcomp "--name-status --oneline --patch-with-stat" - ;; show,--*|branch,--*) ;; branch,*) @@ -2666,7 +2899,7 @@ _git_submodule () { __git_has_doubledash && return - local subcommands="add status init deinit update set-branch summary foreach sync absorbgitdirs" + local subcommands="add status init deinit update summary foreach sync" local subcommand="$(__git_find_on_cmdline "$subcommands")" if [ -z "$subcommand" ]; then case "$cur" in @@ -2697,9 +2930,6 @@ _git_submodule () --force --rebase --merge --reference --depth --recursive --jobs " ;; - set-branch,--*) - __gitcomp "--default --branch" - ;; summary,--*) __gitcomp "--cached --files --summary-limit" ;; @@ -2815,7 +3045,7 @@ _git_tag () while [ $c -lt $cword ]; do i="${words[c]}" case "$i" in - -d|--delete|-v|--verify) + -d|-v) __gitcomp_direct "$(__git_tags "" "$cur" " ")" return ;; @@ -2841,7 +3071,11 @@ _git_tag () case "$cur" in --*) - __gitcomp_builtin tag + __gitcomp " + --list --delete --verify --annotate --message --file + --sign --cleanup --local-user --force --column --sort= + --contains --no-contains --points-at --merged --no-merged --create-reflog + " ;; esac } @@ -2853,26 +3087,23 @@ _git_whatchanged () _git_worktree () { - local subcommands="add list lock move prune remove unlock" + local subcommands="add list lock prune unlock" local subcommand="$(__git_find_on_cmdline "$subcommands")" if [ -z "$subcommand" ]; then __gitcomp "$subcommands" else case "$subcommand,$cur" in add,--*) - __gitcomp_builtin worktree_add + __gitcomp "--detach" ;; list,--*) - __gitcomp_builtin worktree_list + __gitcomp "--porcelain" ;; lock,--*) - __gitcomp_builtin worktree_lock + __gitcomp "--reason" ;; prune,--*) - __gitcomp_builtin worktree_prune - ;; - remove,--*) - __gitcomp "--force" + __gitcomp "--dry-run --expire --verbose" ;; *) ;; @@ -2880,52 +3111,6 @@ _git_worktree () fi } -__git_complete_common () { - local command="$1" - - case "$cur" in - --*) - __gitcomp_builtin "$command" - ;; - esac -} - -__git_cmds_with_parseopt_helper= -__git_support_parseopt_helper () { - test -n "$__git_cmds_with_parseopt_helper" || - __git_cmds_with_parseopt_helper="$(__git --list-cmds=parseopt)" - - case " $__git_cmds_with_parseopt_helper " in - *" $1 "*) - return 0 - ;; - *) - return 1 - ;; - esac -} - -__git_complete_command () { - local command="$1" - local completion_func="_git_${command//-/_}" - if ! declare -f $completion_func >/dev/null 2>/dev/null && - declare -f _completion_loader >/dev/null 2>/dev/null - then - _completion_loader "git-$command" - fi - if declare -f $completion_func >/dev/null 2>/dev/null - then - $completion_func - return 0 - elif __git_support_parseopt_helper "$command" - then - __git_complete_common "$command" - return 0 - else - return 1 - fi -} - __git_main () { local i c=1 command __git_dir __git_repo_path @@ -2979,24 +3164,20 @@ __git_main () --help " ;; - *) - if test -n "$GIT_TESTING_PORCELAIN_COMMAND_LIST" - then - __gitcomp "$GIT_TESTING_PORCELAIN_COMMAND_LIST" - else - __gitcomp "$(__git --list-cmds=list-mainporcelain,others,nohelpers,alias,list-complete,config)" - fi - ;; + *) __git_compute_porcelain_commands + __gitcomp "$__git_porcelain_commands $(__git_aliases)" ;; esac return fi - __git_complete_command "$command" && return + local completion_func="_git_${command//-/_}" + declare -f $completion_func >/dev/null 2>/dev/null && $completion_func && return local expansion=$(__git_aliased_command "$command") if [ -n "$expansion" ]; then words[1]=$expansion - __git_complete_command "$expansion" + completion_func="_git_${expansion//-/_}" + declare -f $completion_func >/dev/null 2>/dev/null && $completion_func fi } @@ -3024,10 +3205,7 @@ __gitk_main () __git_complete_revlist } -if [[ -n ${ZSH_VERSION-} ]] && - # Don't define these functions when sourced from 'git-completion.zsh', - # it has its own implementations. - [[ -z ${GIT_SOURCING_ZSH_COMPLETION-} ]]; then +if [[ -n ${ZSH_VERSION-} ]]; then echo "WARNING: this script is deprecated, please see git-completion.zsh" 1>&2 autoload -U +X compinit && compinit @@ -3076,22 +3254,13 @@ if [[ -n ${ZSH_VERSION-} ]] && compadd -Q -S "${4- }" -p "${2-}" -- ${=1} && _ret=0 } - __gitcomp_file_direct () - { - emulate -L zsh - - local IFS=$'\n' - compset -P '*[=:]' - compadd -f -- ${=1} && _ret=0 - } - __gitcomp_file () { emulate -L zsh local IFS=$'\n' compset -P '*[=:]' - compadd -p "${2-}" -f -- ${=1} && _ret=0 + compadd -Q -p "${2-}" -f -- ${=1} && _ret=0 } _git () @@ -3146,6 +3315,6 @@ __git_complete gitk __gitk_main # when the user has tab-completed the executable name and consequently # included the '.exe' suffix. # -if [ Cygwin = "$(uname -o 2>/dev/null)" ]; then +if [[ "$OSTYPE" = cygwin* ]]; then __git_complete git.exe __git_main fi diff --git a/zsh/plugins/gitfast/git-prompt.sh b/zsh/plugins/gitfast/git-prompt.sh index f7009b0..fd2b049 100644 --- a/zsh/plugins/gitfast/git-prompt.sh +++ b/zsh/plugins/gitfast/git-prompt.sh @@ -219,7 +219,7 @@ __git_ps1_show_upstream () if [[ -n "$count" && -n "$name" ]]; then __git_ps1_upstream_name=$(git rev-parse \ --abbrev-ref "$upstream" 2>/dev/null) - if [ "$pcmode" = yes ] && [ "$ps1_expanded" = yes ]; then + if [ $pcmode = yes ] && [ $ps1_expanded = yes ]; then p="$p \${__git_ps1_upstream_name}" else p="$p ${__git_ps1_upstream_name}" @@ -237,7 +237,7 @@ __git_ps1_show_upstream () # to build a gitstring. __git_ps1_colorize_gitstring () { - if [[ -n "${ZSH_VERSION-}" ]]; then + if [[ -n ${ZSH_VERSION-} ]]; then local c_red='%F{red}' local c_green='%F{green}' local c_lblue='%F{blue}' @@ -255,7 +255,7 @@ __git_ps1_colorize_gitstring () local flags_color="$c_lblue" local branch_color="" - if [ "$detached" = no ]; then + if [ $detached = no ]; then branch_color="$ok_color" else branch_color="$bad_color" @@ -508,13 +508,13 @@ __git_ps1 () # NO color option unless in PROMPT_COMMAND mode or it's Zsh if [ -n "${GIT_PS1_SHOWCOLORHINTS-}" ]; then - if [ "$pcmode" = yes ] || [ -n "${ZSH_VERSION-}" ]; then + if [ $pcmode = yes ] || [ -n "${ZSH_VERSION-}" ]; then __git_ps1_colorize_gitstring fi fi b=${b##refs/heads/} - if [ "$pcmode" = yes ] && [ "$ps1_expanded" = yes ]; then + if [ $pcmode = yes ] && [ $ps1_expanded = yes ]; then __git_ps1_branch_name=$b b="\${__git_ps1_branch_name}" fi @@ -522,7 +522,7 @@ __git_ps1 () local f="$w$i$s$u" local gitstring="$c$b${f:+$z$f}$r$p" - if [ "$pcmode" = yes ]; then + if [ $pcmode = yes ]; then if [ "${__git_printf_supports_v-}" != yes ]; then gitstring=$(printf -- "$printf_format" "$gitstring") else diff --git a/zsh/plugins/github/README.md b/zsh/plugins/github/README.md index 2b66e39..70b863f 100644 --- a/zsh/plugins/github/README.md +++ b/zsh/plugins/github/README.md @@ -1,4 +1,4 @@ -# github +# github plugin This plugin supports working with GitHub from the command line. It provides a few things: @@ -6,7 +6,7 @@ This plugin supports working with GitHub from the command line. It provides a fe * Completion for the `github` Ruby gem. * Convenience functions for working with repos and URLs. -### Functions +### Functions * `empty_gh` - Creates a new empty repo (with a `README.md`) and pushes it to GitHub * `new_gh` - Initializes an existing directory as a repo and pushes it to GitHub @@ -14,13 +14,13 @@ This plugin supports working with GitHub from the command line. It provides a fe * `git.io` - Shortens a URL using [git.io](https://git.io) -## Installation +## Installation [Hub](https://github.com/github/hub) needs to be installed if you want to use it. On OS X with Homebrew, this can be done with `brew install hub`. The `hub` completion definition needs to be added to your `$FPATH` before initializing OMZ. The [`github` Ruby gem](https://github.com/defunkt/github-gem) needs to be installed if you want to use it. -### Configuration +### Configuration These settings affect `github`'s behavior. @@ -35,7 +35,7 @@ These settings affect `github`'s behavior. See `man hub` for more details. -### Homebrew installation note +### Homebrew installation note If you have installed `hub` using Homebrew, its completions may not be on your `$FPATH` if you are using the system `zsh`. Homebrew installs `zsh` completion definitions to `/usr/local/share/zsh/site-functions`, which will be on `$FPATH` for the Homebrew-installed `zsh`, but not for the system `zsh`. If you want it to work with the system `zsh`, add this to your `~/.zshrc` before it sources `oh-my-zsh.sh`. diff --git a/zsh/plugins/gitignore/gitignore.plugin.zsh b/zsh/plugins/gitignore/gitignore.plugin.zsh index 15e38d3..a687f5c 100644 --- a/zsh/plugins/gitignore/gitignore.plugin.zsh +++ b/zsh/plugins/gitignore/gitignore.plugin.zsh @@ -1,4 +1,4 @@ -function gi() { curl -fL https://www.gitignore.io/api/${(j:,:)@} } +function gi() { curl -fLw '\n' https://www.gitignore.io/api/"${(j:,:)@}" } _gitignoreio_get_command_list() { curl -sfL https://www.gitignore.io/api/list | tr "," "\n" diff --git a/zsh/plugins/glassfish/README.md b/zsh/plugins/glassfish/README.md new file mode 100644 index 0000000..1f4a8be --- /dev/null +++ b/zsh/plugins/glassfish/README.md @@ -0,0 +1,9 @@ +# glassfish + +The glassfish plugin adds completion for the `asadmin` utility, a command to manage +[Oracle GlassFish](https://docs.oracle.com/cd/E18930_01/html/821-2416/giobi.html) servers. + +To use it, add `glassfish` to the plugins array in your zshrc file: +```zsh +plugins=(... glassfish) +``` diff --git a/zsh/plugins/glassfish/glassfish.plugin.zsh b/zsh/plugins/glassfish/glassfish.plugin.zsh index fde2edb..e69de29 100644 --- a/zsh/plugins/glassfish/glassfish.plugin.zsh +++ b/zsh/plugins/glassfish/glassfish.plugin.zsh @@ -1,3 +0,0 @@ -# if there is a user named 'glassfish' on the system, we'll assume -# that is the user asadmin should be run as -# grep -e '^glassfish' /etc/passwd > /dev/null && alias asadmin='sudo -u glassfish asadmin' \ No newline at end of file diff --git a/zsh/plugins/globalias/README.md b/zsh/plugins/globalias/README.md index 0b06410..cd7fc3c 100644 --- a/zsh/plugins/globalias/README.md +++ b/zsh/plugins/globalias/README.md @@ -17,6 +17,9 @@ Then just press `SPACE` to trigger the expansion of a command you've written. If you only want to insert a space without expanding the command line, press `CTRL`+`SPACE`. +if you would like to filter out any values from expanding set `GLOBALIAS_FILTER_VALUES` to +an array of said values. See [Filtered values](#filtered-values). + ## Examples #### Glob expressions @@ -37,7 +40,6 @@ $ ls folder/file.json anotherfolder/another.json $ mkdir "`date -R`" # expands to $ mkdir Tue,\ 04\ Oct\ 2016\ 13:54:03\ +0300 - ``` #### Aliases @@ -60,3 +62,18 @@ $ S # expands to: $ sudo systemctl ``` + +#### Filtered values + +``` +# .zshrc +alias l='ls -lh' +alias la='ls --color=auto -lah' +GLOBALIAS_FILTER_VALUES=(l) + +$ l +# does not expand +$ la +# expands to: +$ ls --color=auto -lah +``` diff --git a/zsh/plugins/globalias/globalias.plugin.zsh b/zsh/plugins/globalias/globalias.plugin.zsh index 9602a96..bd27d58 100644 --- a/zsh/plugins/globalias/globalias.plugin.zsh +++ b/zsh/plugins/globalias/globalias.plugin.zsh @@ -1,6 +1,12 @@ globalias() { - zle _expand_alias - zle expand-word + # Get last word to the left of the cursor: + # (z) splits into words using shell parsing + # (A) makes it an array even if there's only one element + local word=${${(Az)LBUFFER}[-1]} + if [[ $GLOBALIAS_FILTER_VALUES[(Ie)$word] -eq 0 ]]; then + zle _expand_alias + zle expand-word + fi zle self-insert } zle -N globalias diff --git a/zsh/plugins/gnu-utils/README.md b/zsh/plugins/gnu-utils/README.md new file mode 100644 index 0000000..f5fa81e --- /dev/null +++ b/zsh/plugins/gnu-utils/README.md @@ -0,0 +1,38 @@ +# gnu-utils plugin + +This plugin binds GNU coreutils to their default names, so that you don't have +to call them using their prefixed name, which starts with `g`. This is useful +in systems which don't have GNU coreutils installed by default, mainly macOS +or FreeBSD, which use BSD coreutils. + +To use it, add `gnu-utils` to the plugins array in your zshrc file: +```zsh +plugins=(... gnu-utils) +``` + +The plugin works by changing the path that the command hash points to, so +instead of `ls` pointing to `/bin/ls`, it points to wherever `gls` is +installed. + +Since `hash -rf` or `rehash` refreshes the command hashes, it also wraps +`hash` and `rehash` so that the coreutils binding is always done again +after calling these two commands. + +Look at the source code of the plugin to see which GNU coreutils are tried +to rebind. Open an issue if there are some missing. + +## Other methods + +The plugin also documents two other ways to do this: + +1. Using a function wrapper, such that, for example, there exists a function +named `ls` which calls `gls` instead. Since functions have a higher preference +than commands, this ends up calling the GNU coreutil. It has also a higher +preference over shell builtins (`gecho` is called instead of the builtin `echo`). + +2. Using an alias. This has an even higher preference than functions, but they +could be overridden because of a user setting. + +## Author + +- [Sorin Ionescu](https://github.com/sorin-ionescu). diff --git a/zsh/plugins/gnu-utils/gnu-utils.plugin.zsh b/zsh/plugins/gnu-utils/gnu-utils.plugin.zsh index b66e25d..23e00c2 100644 --- a/zsh/plugins/gnu-utils/gnu-utils.plugin.zsh +++ b/zsh/plugins/gnu-utils/gnu-utils.plugin.zsh @@ -5,79 +5,79 @@ # VERSION: 1.0.0 # ------------------------------------------------------------------------------ - -if [[ -x "${commands[gwhoami]}" ]]; then - __gnu_utils() { - emulate -L zsh - local gcmds - local gcmd - local cmd - local prefix - - # coreutils - gcmds=('g[' 'gbase64' 'gbasename' 'gcat' 'gchcon' 'gchgrp' 'gchmod' - 'gchown' 'gchroot' 'gcksum' 'gcomm' 'gcp' 'gcsplit' 'gcut' 'gdate' - 'gdd' 'gdf' 'gdir' 'gdircolors' 'gdirname' 'gdu' 'gecho' 'genv' 'gexpand' - 'gexpr' 'gfactor' 'gfalse' 'gfmt' 'gfold' 'ggroups' 'ghead' 'ghostid' - 'gid' 'ginstall' 'gjoin' 'gkill' 'glink' 'gln' 'glogname' 'gls' 'gmd5sum' - 'gmkdir' 'gmkfifo' 'gmknod' 'gmktemp' 'gmv' 'gnice' 'gnl' 'gnohup' 'gnproc' - 'god' 'gpaste' 'gpathchk' 'gpinky' 'gpr' 'gprintenv' 'gprintf' 'gptx' 'gpwd' - 'greadlink' 'grm' 'grmdir' 'gruncon' 'gseq' 'gsha1sum' 'gsha224sum' - 'gsha256sum' 'gsha384sum' 'gsha512sum' 'gshred' 'gshuf' 'gsleep' 'gsort' - 'gsplit' 'gstat' 'gstty' 'gsum' 'gsync' 'gtac' 'gtail' 'gtee' 'gtest' - 'gtimeout' 'gtouch' 'gtr' 'gtrue' 'gtruncate' 'gtsort' 'gtty' 'guname' - 'gunexpand' 'guniq' 'gunlink' 'guptime' 'gusers' 'gvdir' 'gwc' 'gwho' - 'gwhoami' 'gyes') - - # findutils - gcmds+=('gfind' 'gxargs' 'glocate') - - # Not part of either coreutils or findutils, installed separately. - gcmds+=('gsed' 'gtar' 'gtime') - - for gcmd in "${gcmds[@]}"; do - # - # This method allows for builtin commands to be primary but it's - # lost if hash -r or rehash -f is executed. Thus, those two - # functions have to be wrapped. - # - (( ${+commands[$gcmd]} )) && hash ${gcmd[2,-1]}=${commands[$gcmd]} - - # - # This method generates wrapper functions. - # It will override shell builtins. - # - # (( ${+commands[$gcmd]} )) && \ - # eval "function $gcmd[2,-1]() { \"${prefix}/${gcmd//"["/"\\["}\" \"\$@\"; }" - - # - # This method is inflexible since the aliases are at risk of being - # overridden resulting in the BSD coreutils being called. - # - # (( ${+commands[$gcmd]} )) && \ - # alias "$gcmd[2,-1]"="${prefix}/${gcmd//"["/"\\["}" - done - - return 0 - } - __gnu_utils; - - function hash() { - if [[ "$*" =~ "-(r|f)" ]]; then - builtin hash "$@" - __gnu_utils - else - builtin hash "$@" - fi - } - - function rehash() { - if [[ "$*" =~ "-f" ]]; then - builtin rehash "$@" - __gnu_utils - else - builtin rehash "$@" - fi - } +# Detect if GNU coreutils are installed by looking for gwhoami +if [[ ! -x "${commands[gwhoami]}" ]]; then + return fi +__gnu_utils() { + emulate -L zsh + local gcmds + local gcmd + local cmd + local prefix + + # coreutils + gcmds=('g[' 'gbase64' 'gbasename' 'gcat' 'gchcon' 'gchgrp' 'gchmod' + 'gchown' 'gchroot' 'gcksum' 'gcomm' 'gcp' 'gcsplit' 'gcut' 'gdate' + 'gdd' 'gdf' 'gdir' 'gdircolors' 'gdirname' 'gdu' 'gecho' 'genv' 'gexpand' + 'gexpr' 'gfactor' 'gfalse' 'gfmt' 'gfold' 'ggroups' 'ghead' 'ghostid' + 'gid' 'ginstall' 'gjoin' 'gkill' 'glink' 'gln' 'glogname' 'gls' 'gmd5sum' + 'gmkdir' 'gmkfifo' 'gmknod' 'gmktemp' 'gmv' 'gnice' 'gnl' 'gnohup' 'gnproc' + 'god' 'gpaste' 'gpathchk' 'gpinky' 'gpr' 'gprintenv' 'gprintf' 'gptx' 'gpwd' + 'greadlink' 'grm' 'grmdir' 'gruncon' 'gseq' 'gsha1sum' 'gsha224sum' + 'gsha256sum' 'gsha384sum' 'gsha512sum' 'gshred' 'gshuf' 'gsleep' 'gsort' + 'gsplit' 'gstat' 'gstty' 'gsum' 'gsync' 'gtac' 'gtail' 'gtee' 'gtest' + 'gtimeout' 'gtouch' 'gtr' 'gtrue' 'gtruncate' 'gtsort' 'gtty' 'guname' + 'gunexpand' 'guniq' 'gunlink' 'guptime' 'gusers' 'gvdir' 'gwc' 'gwho' + 'gwhoami' 'gyes') + + # findutils + gcmds+=('gfind' 'gxargs' 'glocate') + + # Not part of either coreutils or findutils, installed separately. + gcmds+=('gsed' 'gtar' 'gtime' 'gmake') + + for gcmd in "${gcmds[@]}"; do + # Do nothing if the command isn't found + (( ${+commands[$gcmd]} )) || continue + + # This method allows for builtin commands to be primary but it's + # lost if hash -r or rehash -f is executed. Thus, those two + # functions have to be wrapped. + # + hash ${gcmd[2,-1]}=${commands[$gcmd]} + + # This method generates wrapper functions. + # It will override shell builtins. + # + # eval "function $gcmd[2,-1]() { \"${prefix}/${gcmd//"["/"\\["}\" \"\$@\"; }" + + # This method is inflexible since the aliases are at risk of being + # overridden resulting in the BSD coreutils being called. + # + # alias "$gcmd[2,-1]"="${prefix}/${gcmd//"["/"\\["}" + done + + return 0 +} +__gnu_utils + +function hash() { + if [[ "$*" =~ "-(r|f)" ]]; then + builtin hash "$@" + __gnu_utils + else + builtin hash "$@" + fi +} + +function rehash() { + if [[ "$*" =~ "-f" ]]; then + builtin rehash "$@" + __gnu_utils + else + builtin rehash "$@" + fi +} + diff --git a/zsh/plugins/go/README.md b/zsh/plugins/go/README.md index 6ce6f4e..bf43b9f 100644 --- a/zsh/plugins/go/README.md +++ b/zsh/plugins/go/README.md @@ -1 +1 @@ -The go plugin is deprecated. Use the [golang plugin](https://github.com/robbyrussell/oh-my-zsh/tree/master/plugins/golang) instead. +The go plugin is deprecated. Use the [golang plugin](https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/golang) instead. diff --git a/zsh/plugins/go/go.plugin.zsh b/zsh/plugins/go/go.plugin.zsh deleted file mode 120000 index cf943e2..0000000 --- a/zsh/plugins/go/go.plugin.zsh +++ /dev/null @@ -1 +0,0 @@ -../golang/golang.plugin.zsh \ No newline at end of file diff --git a/zsh/plugins/go/go.plugin.zsh b/zsh/plugins/go/go.plugin.zsh new file mode 100644 index 0000000..da7c87c --- /dev/null +++ b/zsh/plugins/go/go.plugin.zsh @@ -0,0 +1,3 @@ +print -P "%F{yellow}The 'go' plugin is deprecated. Use the '%Ugolang%u' plugin instead.%f" + +source "$ZSH/plugins/golang/golang.plugin.zsh" diff --git a/zsh/plugins/gpg-agent/README.md b/zsh/plugins/gpg-agent/README.md index a9711f9..9c1e6d2 100644 --- a/zsh/plugins/gpg-agent/README.md +++ b/zsh/plugins/gpg-agent/README.md @@ -3,6 +3,7 @@ Enables [GPG's gpg-agent](https://www.gnupg.org/documentation/manuals/gnupg/) if it is not running. To use it, add gpg-agent to the plugins array of your zshrc file: -``` + +```zsh plugins=(... gpg-agent) ``` diff --git a/zsh/plugins/gradle/README.md b/zsh/plugins/gradle/README.md index 215503c..3756db0 100644 --- a/zsh/plugins/gradle/README.md +++ b/zsh/plugins/gradle/README.md @@ -1,4 +1,4 @@ -## Gradle Plugin +# Gradle plugin This plugin adds completions and aliases for [Gradle](https://gradle.org/). @@ -10,9 +10,15 @@ plugins=(... gradle) ## Usage -This plugin creates an alias `gradle` which is used to determine whether the current working directory has a gradlew file. If gradlew is present it will be used otherwise `gradle` is used directly. Gradle tasks can be executed directly without regard for whether it is `gradle` or `gradlew` +This plugin creates a function called `gradle-or-gradlew`, which is aliased +to `gradle`, which is used to determine whether the current project directory +has a gradlew file. If `gradlew` is present it will be used, otherwise `gradle` +is used instead. Gradle tasks can be executed directly without regard for +whether it is `gradle` or `gradlew`. It also supports being called from +any directory inside the root project directory. Examples: + ```zsh gradle test gradle build @@ -20,4 +26,5 @@ gradle build ## Completion -The completion provided for this plugin caches the parsed tasks into a file named `.gradletasknamecache` in the current working directory, so you might want to add that to your `.gitignore` file so that it's not accidentally committed. +This plugin uses [the completion from the Gradle project](https://github.com/gradle/gradle-completion), +which is distributed under the MIT license. diff --git a/zsh/plugins/gradle/_gradle b/zsh/plugins/gradle/_gradle deleted file mode 120000 index 80723f2..0000000 --- a/zsh/plugins/gradle/_gradle +++ /dev/null @@ -1 +0,0 @@ -gradle.plugin.zsh \ No newline at end of file diff --git a/zsh/plugins/gradle/_gradle b/zsh/plugins/gradle/_gradle new file mode 100644 index 0000000..e77b23c --- /dev/null +++ b/zsh/plugins/gradle/_gradle @@ -0,0 +1,420 @@ +#compdef gradle gradlew gw +# +# Taken from https://github.com/gradle/gradle-completion +# Copyright (c) 2017 Eric Wendelin +# +# 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. +# Terms + +__gradle-set-project-root-dir() { + local dir=`pwd` + project_root_dir=`pwd` + while [[ $dir != '/' ]]; do + if [[ -f "$dir/settings.gradle" || -f "$dir/settings.gradle.kts" || -f "$dir/gradlew" ]]; then + project_root_dir=$dir + return 0 + fi + dir="$(dirname "$dir")" + done + return 1 +} + +__gradle-init-cache-dir() { + cache_dir="$HOME/.gradle/completion" + mkdir -p $cache_dir +} + +__gradle-set-settings-file() { + # In order of precedence: --settings-file=filename, settings.gradle, settings.gradle.kts + + local default_gradle_settings_file="$project_root_dir/settings.gradle" + if [[ ! -f $default_gradle_settings_file ]]; then + default_gradle_settings_file="$project_root_dir/settings.gradle.kts" + fi + gradle_settings_file=${${(v)opt_args[(i)-c|--settings-file]}:-$default_gradle_settings_file} +} + +__gradle-set-build-file() { + __gradle-set-settings-file + # In order of precedence: --build-file=filename, rootProject.buildFileName, build.gradle, build.gradle.kts + + local default_gradle_build_file_name="build.gradle" + if [[ -r $gradle_settings_file ]]; then + default_gradle_build_file_name=${$(grep "^rootProject\.buildFileName" $gradle_settings_file | \ + sed -n -e "s/rootProject\.buildFileName = [\'\"]\(.*\)[\'\"]/\1/p")} + + default_gradle_build_file_name="${default_gradle_build_file:-build.gradle}" + fi + + local default_gradle_build_file="$project_root_dir/$default_gradle_build_file_name" + if [[ ! -f $default_gradle_build_file ]]; then + default_gradle_build_file="$project_root_dir/build.gradle.kts" + fi + + # If a build file is specified after '-b' or '--build-file', use this file. + gradle_build_file=${${(v)opt_args[(i)-b|--build-file]}:-$default_gradle_build_file} +} + +__gradle-set-cache-name() { + # Cache name is constructed from the absolute path of the build file. + cache_name=${${gradle_build_file:a}//[^[:alnum:]]/_} +} + +__gradle-set-files-checksum() { + # Cache MD5 sum of all Gradle scripts and modified timestamps + if builtin command -v md5 > /dev/null; then + gradle_files_checksum=( $(md5 -q -s "$(cat "$cache_dir/$cache_name" | xargs ls -o 2>/dev/null)") ) + elif builtin command -v md5sum > /dev/null; then + gradle_files_checksum=( $(cat "$cache_dir/$cache_name" | xargs ls -o 2>/dev/null | md5sum | awk '{print $1}') ) + else + _message 'Cannot generate completions as neither md5 nor md5sum exist on \$PATH' + return 1 + fi +} + +__gradle-generate-script-cache() { + # Invalidate cache after 3 weeks by default + local cache_ttl_mins=${$(echo $GRADLE_CACHE_TTL_MINUTES):-30240} + local script_exclude_pattern=${$(echo $GRADLE_COMPLETION_EXCLUDE_PATTERN):-"/(.git|build|integTest|samples|templates|smokeTest|testFixtures|out)/"} + if [[ ! $(find $cache_dir/$cache_name -mmin -$cache_ttl_mins 2>/dev/null) ]]; then + zle -R "Generating Gradle build script cache" + # Cache all Gradle scripts + local -a gradle_build_scripts + gradle_build_scripts=( $(find $project_root_dir -type f -name "*.gradle" -o -name "*.gradle.kts" 2>/dev/null | egrep -v "$script_exclude_pattern") ) + printf "%s\n" "${gradle_build_scripts[@]}" >| $cache_dir/$cache_name + fi +} + +__gradle-generate-tasks-cache() { + __gradle-set-files-checksum + + # Use Gradle wrapper when it exists. + local gradle_cmd="gradle" + if [[ -x "$project_root_dir/gradlew" ]]; then + gradle_cmd="$project_root_dir/gradlew" + fi + + zle -R "Generating Gradle task cache from $gradle_build_file" + + # Run gradle to retrieve possible tasks and cache. + # Reuse Gradle Daemon if IDLE but don't start a new one. + local gradle_tasks_output + if [[ ! -z "$($gradle_cmd --status 2>/dev/null | grep IDLE)" ]]; then + gradle_tasks_output="$($gradle_cmd --daemon --build-file $gradle_build_file --console plain -q tasks --all 2>/dev/null)" + else + gradle_tasks_output="$($gradle_cmd --no-daemon --build-file $gradle_build_file --console plain -q tasks --all 2>/dev/null)" + fi + local gradle_all_tasks="" root_tasks="" subproject_tasks="" output_line + local -a match + for output_line in ${(f)"$(printf "%s\n" "${gradle_tasks_output[@]}")"}; do + if [[ $output_line =~ ^([[:lower:]][[:alnum:][:punct:]]*)([[:space:]]-[[:space:]]([[:print:]]*))? ]]; then + local task_name="${match[1]}" + local task_description="${match[3]}" + # Completion for subproject tasks with ':' prefix + if [[ $task_name =~ ^([[:alnum:][:punct:]]+):([[:alnum:]]+) ]]; then + gradle_all_tasks+="${task_name//:/\\:}:$task_description\n\\:${task_name//:/\\:}:$task_description\n" + subproject_tasks+="${match[2]}\n" + else + gradle_all_tasks+="${task_name//:/\\:}:$task_description\n" + root_tasks+="$task_name\n" + fi + fi + done + + # subproject tasks can be referenced implicitly from root project + if [[ $GRADLE_COMPLETION_UNQUALIFIED_TASKS == "true" ]]; then + local -a implicit_tasks + implicit_tasks=( $(comm -23 <(echo $subproject_tasks | sort) <(echo $root_tasks | sort)) ) + for task in $(printf "%s\n" "${implicit_tasks[@]}"); do + gradle_all_tasks+="$task\n" + done + fi + + echo $gradle_all_tasks >| $cache_dir/$gradle_files_checksum + echo $gradle_files_checksum >| $cache_dir/$cache_name.md5 +} + +__gradle-completion-init() { + local cache_dir cache_name gradle_build_file gradle_files_checksum project_root_dir + __gradle-init-cache-dir + __gradle-set-project-root-dir + __gradle-set-build-file + if [[ -f $gradle_build_file ]]; then + __gradle-set-cache-name + __gradle-generate-script-cache + __gradle-set-files-checksum + __gradle-generate-tasks-cache + fi + return 0 +} + +__gradle_tasks() { + local cache_dir cache_name gradle_build_file gradle_files_checksum project_root_dir + + __gradle-init-cache-dir + __gradle-set-project-root-dir + __gradle-set-build-file + if [[ -f $gradle_build_file ]]; then + __gradle-set-cache-name + __gradle-generate-script-cache + __gradle-set-files-checksum + + # The cache key is md5 sum of all gradle scripts, so it's valid if it exists. + if [[ -f $cache_dir/$cache_name.md5 ]]; then + local cached_checksum="$(cat $cache_dir/$cache_name.md5)" + local -a cached_tasks + if [[ -z $cur ]]; then + cached_tasks=(${(f)"$(cat $cache_dir/$cached_checksum)"}) + else + cached_tasks=(${(f)"$(grep "^${cur//:/\\\\:}" $cache_dir/$cached_checksum)"}) + fi + _describe 'all tasks' cached_tasks && ret=0 + else + __gradle-generate-tasks-cache + fi + + # Regenerate tasks cache in the background + if [[ $gradle_files_checksum != "$(cat $cache_dir/$cache_name.md5)" || ! -f $cache_dir/$gradle_files_checksum || $(wc -c < $cache_dir/$gradle_files_checksum) -le 1 ]]; then + $(__gradle-generate-tasks-cache 1>&2 2>/dev/null &) + fi + else + _describe 'built-in tasks' '( + "buildEnvironment:Displays all buildscript dependencies declared in root project." + "components:Displays the components produced by root project." + "dependencies:Displays all dependencies declared in root project." + "dependencyInsight:Displays the insight into a specific dependency in root project." + "dependentComponents:Displays the dependent components of components in root project." + "help:Displays a help message." + "init:Initializes a new Gradle build." + "model:Displays the configuration model of root project." + "projects:Displays the sub-projects of root project." + "properties:Displays the properties of root project." + "tasks:Displays the tasks runnable from root project." + "wrapper:Generates Gradle wrapper files." + )' && ret=0 + fi +} + +__gradle_subcommand() { + integer ret=1 + + case "$words[1]" in + (dependencies) + _arguments \ + '--configuration=[The configuration to generate the report for.]:dependency configuration:_gradle_dependency_configurations' && ret=0 + ;; + (dependencyInsight) + _arguments \ + '--dependency=[Shows the details of given dependency.]' \ + '--configuration=[Looks for the dependency in given configuration.]:dependency configuration:_gradle_dependency_configurations' && ret=0 + ;; + (help) + _arguments \ + '--task[The task to show help for.]' && ret=0 + ;; + (init) + _arguments \ + '--dsl=[DSL to be used in generated scripts.]:dsl:(groovy kotlin)' \ + '--package=[Package for the generated source.]' \ + '--project-name=[Name of the generated project.]' \ + '--test-framework=[Test framework to be used.]:test framework:(junit kotlintest scalatest spock testng)' \ + '--type=[Project type to generate.]:project type:(basic cpp-application cpp-library groovy-application groovy-library java-application java-library kotlin-application kotlin-library pom scala-library)' && ret=0 + ;; + (tasks) + _arguments \ + '--all[List all tasks, including subproject tasks.]' \ + '--group=[Show tasks only from given task group.]' && ret=0 + ;; + (test) + _arguments -C \ + '--debug-jvm[Enable debugging for the test process. The process is started suspended and listening on port 5005. Requires the "java" plugin.]' \ + '--fail-fast[Stops test execution after the first failed test. Requires the "java" plugin.]' \ + '--tests=[Sets test class or method name to be included, * is supported. Requires the "java" plugin.]' \ + '(-)*:: :->task-or-option' && ret=0 + ;; + (wrapper) + _arguments \ + '--distribution-type=[Binary-only or all with docs and sources]:*:distribution type:(bin all)' \ + '--gradle-version=[Set Gradle version for wrapper]' \ + '--gradle-distribution-sha256-sum=[SHA-256 checksum]' \ + '--gradle-distribution-url=[Set Gradle distribution URL]' && ret=0 + ;; + (*) + _arguments -C \ + {-a,--no-rebuild}'[Do not rebuild project dependencies.]' \ + '(--no-build-cache)--build-cache[Enable the Gradle build cache.]' \ + {-b,--build-file}'[Specifies the build file.]:build script:_files -g \*.gradle' \ + {-C,--cache}'[Specifies how compiled build scripts should be cached.]:cache policy:(on rebuild)' \ + {-c,--settings-file}'[Specifies the settings file.]:settings file:_files -g \*.gradle' \ + '(--no-configure-on-demand)--configure-on-demand[Only relevant projects are configured in this build run.]' \ + '--console=[Specifies which type of console output to generate.]:console output type:(plain auto rich verbose)' \ + '--continue[Continues task execution after a task failure.]' \ + '-Dorg.gradle.cache.reserved.mb=[Reserve Gradle Daemon memory for operations.]' \ + '-Dorg.gradle.caching=[Set true to enable Gradle build cache.]:enable build cache:(true false)' \ + '-Dorg.gradle.console=[Set type of console output to generate.]:console output type:(plain auto rich verbose)' \ + '-Dorg.gradle.daemon.debug=[Set true to debug Gradle Daemon.]:enable daemon debug:(true false)' \ + '-Dorg.gradle.daemon.idletimeout=[Kill Gradle Daemon after # idle millis.]' \ + '-Dorg.gradle.debug=[Set true to debug Gradle Client.]' \ + '-Dorg.gradle.jvmargs=[Set JVM arguments.]' \ + '-Dorg.gradle.java.home=[Set JDK home dir.]' \ + '-Dorg.gradle.logging.level=[Set default Gradle log level.]:log level:(quiet warn lifecycle info debug)' \ + '-Dorg.gradle.parallel=[Set true to enable parallel project builds.]:enable parallel build:(true false)' \ + '-Dorg.gradle.priority=[Set priority for Gradle worker processes.]:priority:(low normal)' \ + '-Dorg.gradle.warning.mode=[Set types of warnings to log.]:warning level:(all summary none)' \ + '-Dorg.gradle.workers.max=[Set the number of workers Gradle is allowed to use.]' \ + '(-i --info -w --warn -q --quiet)'{-d,--debug}'[Log in debug mode (includes normal stacktrace).]' \ + '(--no-daemon)--daemon[Uses the Gradle daemon to run the build. Starts the daemon if not running.]' \ + '--foreground[Starts the Gradle daemon in the foreground.]' \ + {-g,--gradle-user-home}'[Specifies the gradle user home directory.]:file:_directories' \ + \*--include-build'[Includes the specified build in the composite.]:file:_directories' \ + \*{-I,--init-script}'[Specifies an initialization script.]:init script:_files -g \*.gradle' \ + '(-d --debug -w --warn -q --quiet)'{-i,--info}'[Set log level to info.]' \ + '--max-workers[Set the maximum number of concurrent workers that Gradle may use.]:number workers' \ + {-m,--dry-run}'[Runs the builds with all task actions disabled.]' \ + '--no-color[Do not use color in the console output. (Removed in Gradle 3.0)]' \ + '(--build-cache)--no-build-cache[Do not use the Gradle build cache.]' \ + '(--configure-on-demand)--no-configure-on-demand[Disables configuration on demand.]' \ + '(--daemon)--no-daemon[Do not use the Gradle daemon to run the build.]' \ + '(--parallel)--no-parallel[Disables parallel execution to build projects.]' \ + '(--scan)--no-scan[Do not create a build scan.]' \ + '--offline[The build should operate without accessing network resources.]' \ + \*{-P+,--project-prop}'[Set project property for the build script (e.g. -Pmyprop=myvalue).]:project property (prop=val):' \ + {-p,--project-dir}'[Specifies the start directory for Gradle.]:start directory:_directories' \ + '(--no-parallel)--parallel[Build projects in parallel. Gradle will attempt to determine the optimal number of executor threads to use.]' \ + '--profile[Profiles build execution time and generates a report in the /reports/profile directory.]' \ + '--priority[Set priority for Gradle worker processes.]:priority:(low normal)' \ + '--project-cache-dir[Specifies the project-specific cache directory.]:cache directory:_directories' \ + '(-d --debug -w --warn -i --info)'{-q,--quiet}'[Log errors only.]' \ + '--recompile-scripts[Force build script recompiling.]' \ + '--refresh[Refresh the state of resources of the type(s) specified.]:refresh policy:(dependencies)' \ + '--refresh-dependencies[Refresh the state of dependencies.]' \ + '--rerun-tasks[Ignore previously cached task results.]' \ + '(--no-scan)--scan[Create a build scan.]' \ + '(-S --full-stacktrace)'{-s,--stacktrace}'[Print out the stacktrace for all exceptions.]' \ + '(-s --stacktrace)'{-S,--full-stacktrace}'[Print out the full (very verbose) stacktrace for all exceptions.]' \ + '--system-prop[system property (prop=val)]' \ + {-t,--continuous}'[Enables continuous build. Gradle does not exit and will re-execute tasks when task file inputs change.]' \ + {-u,--no-search-upward}"[Don't search in parent folders for a settings.gradle file.]" \ + '(--write-locks)--update-locks[Perform a partial update of the dependency lock.]' \ + '(-d --debug -q --quiet -i --info)'{-w,--warn}'[Log warnings and errors only.]' \ + '--warning-mode=[Set types of warnings to log.]:warning mode:(all summary none)' \ + '(--update-locks)--write-locks[Persists dependency resolution for locked configurations.]' \ + {-x,--exclude-task}'[Specify a task to be excluded from execution.]' && ret=0 + ;; + esac + + return ret +} + +(( $+functions[_gradle_dependency_configurations] )) || +_gradle_dependency_configurations() { + local configurations + configurations=( + 'compileClasspath' + 'runtimeClasspath' + 'testCompileClasspath' + 'testRuntimeClasspath' + ) + _describe -t 'dependency configurations' "dependency configuration" configurations +} + +_gradle() { + local cur=${words[CURRENT]} + local curcontext="$curcontext" state + integer ret=1 + typeset -A opt_args + + _arguments -C \ + '(-)'{-\?,-h,--help}'[Shows a help message.]' \ + {-a,--no-rebuild}'[Do not rebuild project dependencies.]' \ + '(--no-build-cache)--build-cache[Enable the Gradle build cache.]' \ + {-b,--build-file}'[Specifies the build file.]:build script:_files -g \*.gradle' \ + {-C,--cache}'[Specifies how compiled build scripts should be cached.]:cache policy:(on rebuild)' \ + {-c,--settings-file}'[Specifies the settings file.]:settings file:_files -g \*.gradle:->argument-expected' \ + '(--no-configure-on-demand)--configure-on-demand[Only relevant projects are configured in this build run.]' \ + '--console=[Specifies which type of console output to generate.]:console output type:(plain auto rich verbose)' \ + '--continue[Continues task execution after a task failure.]' \ + '-Dorg.gradle.cache.reserved.mb=[Reserve Gradle Daemon memory for operations.]' \ + '-Dorg.gradle.caching=[Set true to enable Gradle build cache.]' \ + '-Dorg.gradle.console=[Set type of console output to generate.]:console output type:(plain auto rich verbose)' \ + '-Dorg.gradle.daemon.debug=[Set true to debug Gradle Daemon.]' \ + '-Dorg.gradle.daemon.idletimeout=[Kill Gradle Daemon after # idle millis.]' \ + '-Dorg.gradle.debug=[Set true to debug Gradle Client.]' \ + '-Dorg.gradle.jvmargs=[Set JVM arguments.]' \ + '-Dorg.gradle.java.home=[Set JDK home dir.]' \ + '-Dorg.gradle.logging.level=[Set default Gradle log level.]:log level:(quiet warn lifecycle info debug)' \ + '-Dorg.gradle.parallel=[Set true to enable parallel project builds.]:(true false)' \ + '-Dorg.gradle.priority=[Set priority for Gradle worker processes.]:priority:(low normal)' \ + '-Dorg.gradle.warning.mode=[Set types of warnings to log.]:warning level:(all summary none)' \ + '-Dorg.gradle.workers.max=[Set the number of workers Gradle is allowed to use.]' \ + '(-i --info -w --warn -q --quiet)'{-d,--debug}'[Log in debug mode (includes normal stacktrace).]' \ + '(--no-daemon)--daemon[Uses the Gradle daemon to run the build. Starts the daemon if not running.]' \ + '--foreground[Starts the Gradle daemon in the foreground.]' \ + {-g,--gradle-user-home}'[Specifies the gradle user home directory.]:home directory:_directories:->argument-expected' \ + '(-)--gui[Launches the Gradle GUI. (Removed in Gradle 4.0)]' \ + \*--include-build'[Includes the specified build in the composite.]:file:_directories:->argument-expected' \ + \*{-I,--init-script}'[Specifies an initialization script.]:init script:_files -g \*.gradle:->argument-expected' \ + '(-d --debug -w --warn -q --quiet)'{-i,--info}'[Set log level to info.]' \ + '--max-workers[Set the maximum number of concurrent workers that Gradle may use.]:number workers:->argument-expected' \ + {-m,--dry-run}'[Runs the builds with all task actions disabled.]' \ + '--no-color[Do not use color in the console output. (Removed in Gradle 3.0)]' \ + '(--build-cache)--no-build-cache[Do not use the Gradle build cache.]' \ + '(--configure-on-demand)--no-configure-on-demand[Disables configuration on demand.]' \ + '(--daemon)--no-daemon[Do not use the Gradle daemon to run the build.]' \ + '(--parallel)--no-parallel[Disables parallel execution to build projects.]' \ + '(--scan)--no-scan[Do not create a build scan.]' \ + '--offline[The build should operate without accessing network resources.]' \ + \*{-P+,--project-prop}'[Set project property for the build script (e.g. -Pmyprop=myvalue).]:project property (prop=val):->argument-expected' \ + {-p,--project-dir}'[Specifies the start directory for Gradle.]:start directory:_directories:->argument-expected' \ + '(--no-parallel)--parallel[Build projects in parallel. Gradle will attempt to determine the optimal number of executor threads to use.]' \ + '--priority=[Set priority for Gradle worker processes.]:priority:(low normal)' \ + '--profile[Profiles build execution time and generates a report in the /reports/profile directory.]' \ + '--project-cache-dir=[Specifies the project-specific cache directory.]:cache directory:_directories:->argument-expected' \ + '(-d --debug -w --warn -i --info)'{-q,--quiet}'[Log errors only.]' \ + '--recompile-scripts[Force build script recompiling.]' \ + '--refresh[Refresh the state of resources of the type(s) specified.]:refresh policy:(dependencies)' \ + '--refresh-dependencies[Refresh the state of dependencies.]' \ + '--rerun-tasks[Ignore previously cached task results.]' \ + '(--no-scan)--scan[Create a build scan.]' \ + '(-S --full-stacktrace)'{-s,--stacktrace}'[Print out the stacktrace for all exceptions.]' \ + '(-s --stacktrace)'{-S,--full-stacktrace}'[Print out the full (very verbose) stacktrace for all exceptions.]' \ + '(-)--status[Shows status of running and recently stopped Gradle Daemons.]' \ + '(-)--stop[Stops all Gradle daemons.]' \ + '--system-prop[system property (prop=val)]' \ + {-t,--continuous}'[Enables continuous build. Gradle does not exit and will re-execute tasks when task file inputs change.]' \ + {-u,--no-search-upward}"[Don't search in parent folders for a settings.gradle file.]" \ + '(--write-locks)--update-locks[Perform a partial update of the dependency lock.]' \ + '(-)'{-v,--version}'[Print version info.]' \ + '(-d --debug -q --quiet -i --info)'{-w,--warn}'[Log warnings and errors only.]' \ + '--warning-mode=[Set types of warnings to log.]:warning mode:(all summary none)' \ + '(--update-locks)--write-locks[Persists dependency resolution for locked configurations.]' \ + {-x,--exclude-task}'[Specify a task to be excluded from execution.]' \ + '(-)*:: :->task-or-option' && ret=0 + + if [[ $words[CURRENT] != -* && $state != "argument-expected" ]]; then + __gradle_tasks && ret=0 + else + curcontext=${curcontext%:*:*}:gradle-$words[1]: + __gradle_subcommand && ret=0 + fi + + return ret +} + +_gradle "$@" diff --git a/zsh/plugins/gradle/_gradlew b/zsh/plugins/gradle/_gradlew deleted file mode 120000 index 80723f2..0000000 --- a/zsh/plugins/gradle/_gradlew +++ /dev/null @@ -1 +0,0 @@ -gradle.plugin.zsh \ No newline at end of file diff --git a/zsh/plugins/gradle/gradle.plugin.zsh b/zsh/plugins/gradle/gradle.plugin.zsh index 8d578e2..5bca364 100644 --- a/zsh/plugins/gradle/gradle.plugin.zsh +++ b/zsh/plugins/gradle/gradle.plugin.zsh @@ -1,183 +1,26 @@ -############################################################################## -# A descriptive listing of core Gradle commands -############################################################################ - -gradle-or-gradlew() { - if [ -f ./gradlew ] ; then - echo "executing gradlew instead of gradle"; - ./gradlew "$@"; - else - gradle "$@"; - fi -} - -alias gradle=gradle-or-gradlew; - -function _gradle_core_commands() { - local ret=1 state - _arguments ':subcommand:->subcommand' && ret=0 - - case $state in - subcommand) - subcommands=( - "properties:Display all project properties" - "tasks:Calculate and display all tasks" - "dependencies:Calculate and display all dependencies" - "projects:Discover and display all sub-projects" - "build:Build the project" - "help:Display help" - ) - _describe -t subcommands 'gradle subcommands' subcommands && ret=0 - esac - - return ret -} - -function _gradle_arguments() { - _arguments -C \ - '-a[Do not rebuild project dependencies]' \ - '-b[Specifies the build file]' \ - '-c[Specifies the settings file]' \ - '-d[Log at the debug level]' \ - '-g[Specifies the Gradle user home directory]' \ - '-h[Shows a help message]' \ - '-i[Set log level to INFO]' \ - '-m[Runs the build with all task actions disabled]' \ - '-p[Specifies the start directory for Gradle]' \ - '-q[Log errors only]' \ - '-s[Print out the stacktrace also for user exceptions]' \ - '-t[Continuous mode. Automatically re-run build after changes]' \ - '-u[Don''t search in parent directories for a settings.gradle file]' \ - '-v[Prints Gradle version info]' \ - '-x[Specify a task to be excluded]' \ - '-D[Set a system property]' \ - '-I[Specifies an initialization script]' \ - '-P[Sets a project property of the root project]' \ - '-S[Print out the full (very verbose) stacktrace]' \ - '--build-file[Specifies the build file]' \ - '--configure-on-demand[Only relevant projects are configured]' \ - '--console[Type of console output to generate (plain, auto, or rich)]' \ - '--continue[Continues task execution after a task failure]' \ - '--continuous[Continuous mode. Automatically re-run build after changes]' \ - '--daemon[Use the Gradle Daemon]' \ - '--debug[Log at the debug level]' \ - '--dry-run[Runs the build with all task actions disabled]' \ - '--exclude-task[Specify a task to be excluded]' \ - '--full-stacktrace[Print out the full (very verbose) stacktrace]' \ - '--gradle-user-home[Specifies the Gradle user home directory]' \ - '--gui[Launches the Gradle GUI app (Deprecated)]' \ - '--help[Shows a help message]' \ - '--include-build[Run the build as a composite, including the specified build]' \ - '--info[Set log level to INFO]' \ - '--init-script[Specifies an initialization script]' \ - '--max-workers[Set the maximum number of workers that Gradle may use]' \ - '--no-daemon[Do not use the Gradle Daemon]' \ - '--no-rebuild[Do not rebuild project dependencies]' \ - '--no-search-upwards[Don''t search in parent directories for a settings.gradle file]' \ - '--offline[Build without accessing network resources]' \ - '--parallel[Build projects in parallel]' \ - '--profile[Profile build time and create report]' \ - '--project-cache-dir[Specifies the project-specific cache directory]' \ - '--project-dir[Specifies the start directory for Gradle]' \ - '--project-prop[Sets a project property of the root project]' \ - '--quiet[Log errors only]' \ - '--recompile-scripts[Forces scripts to be recompiled, bypassing caching]' \ - '--refresh-dependencies[Refresh the state of dependencies]' \ - '--rerun-task[Specifies that any task optimization is ignored]' \ - '--settings-file[Specifies the settings file]' \ - '--stacktrace[Print out the stacktrace also for user exceptions]' \ - '--status[Print Gradle Daemon status]' \ - '--stop[Stop all Gradle Daemons]' \ - '--system-prop[Set a system property]' \ - '--version[Prints Gradle version info]' \ - '*::command:->command' \ - && return 0 -} - - -############################################################################## -# Examine the build.gradle file to see if its timestamp has changed; -# and if so, regenerate the .gradle_tasks cache file -############################################################################ -_gradle_does_task_list_need_generating () { - [[ ! -f .gradletasknamecache ]] || [[ build.gradle -nt .gradletasknamecache || build.gradle.kts -nt .gradletasknamecache ]] -} - -############## -# Parse the tasks from `gradle(w) tasks --all` and return them to the calling function. -# All lines in the output from gradle(w) that are between /^-+$/ and /^\s*$/ -# are considered to be tasks. If and when gradle adds support for listing tasks -# for programmatic parsing, this method can be deprecated. -############## -_gradle_parse_tasks () { - lines_might_be_tasks=false - task_name_buffer="" - while read -r line; do - if [[ $line =~ ^-+$ ]]; then - lines_might_be_tasks=true - # Empty buffer, because it contains items that are not tasks - task_name_buffer="" - elif [[ $line =~ ^\s*$ ]]; then - if [[ "$lines_might_be_tasks" = true ]]; then - # If a newline is found, echo the buffer to the calling function - while read -r task; do - echo $task | awk '/[a-zA-Z0-9:-]+/ {print $1}' - done <<< "$task_name_buffer" - # Empty buffer, because we are done with the tasks - task_name_buffer="" - fi - lines_might_be_tasks=false - elif [[ "$lines_might_be_tasks" = true ]]; then - task_name_buffer="${task_name_buffer}\n${line}" +# Looks for a gradlew file in the current working directory +# or any of its parent directories, and executes it if found. +# Otherwise it will call gradle directly. +function gradle-or-gradlew() { + # find project root + # taken from https://github.com/gradle/gradle-completion + local dir="$PWD" project_root="$PWD" + while [[ "$dir" != / ]]; do + if [[ -f "$dir/settings.gradle" || -f "$dir/settings.gradle.kts" || -f "$dir/gradlew" ]]; then + project_root="$dir" + break fi - done <<< "$1" -} + dir="${dir:h}" + done - -############## -# Gradle tasks from subprojects are allowed to be executed without specifying -# the subproject; that task will then be called on all subprojects. -# gradle(w) tasks --all only lists tasks per subproject, but when autocompleting -# we often want to be able to run a specific task on all subprojects, e.g. -# "gradle clean". -# This function uses the list of tasks from "gradle tasks --all", and for each -# line grabs everything after the last ":" and combines that output with the original -# output. The combined list is returned as the result of this function. -############## -_gradle_parse_and_extract_tasks () { - # All tasks - tasks=$(_gradle_parse_tasks "$1") - # Task name without sub project(s) prefix - simple_tasks=$(echo $tasks | awk 'BEGIN { FS = ":" } { print $NF }') - echo "$tasks\n$simple_tasks" -} - -############################################################################## -# Discover the gradle tasks by running "gradle tasks --all" -############################################################################ -_gradle_tasks () { - if [[ -f build.gradle || -f build.gradle.kts || -f settings.gradle || -f settings.gradle.kts ]]; then - _gradle_arguments - if _gradle_does_task_list_need_generating; then - _gradle_parse_and_extract_tasks "$(gradle tasks --all)" > .gradletasknamecache - fi - compadd -X "==== Gradle Tasks ====" $(cat .gradletasknamecache) + # if gradlew found, run it instead of gradle + if [[ -f "$project_root/gradlew" ]]; then + echo "executing gradlew instead of gradle" + "$project_root/gradlew" "$@" + else + command gradle "$@" fi } -_gradlew_tasks () { - if [[ -f build.gradle || -f build.gradle.kts || -f settings.gradle || -f settings.gradle.kts ]]; then - _gradle_arguments - if _gradle_does_task_list_need_generating; then - _gradle_parse_and_extract_tasks "$(./gradlew tasks --all)" > .gradletasknamecache - fi - compadd -X "==== Gradlew Tasks ====" $(cat .gradletasknamecache) - fi -} - - -############################################################################## -# Register the completions against the gradle and gradlew commands -############################################################################ -compdef _gradle_tasks gradle -compdef _gradlew_tasks gradlew +alias gradle=gradle-or-gradlew +compdef _gradle gradle-or-gradlew diff --git a/zsh/plugins/grails/README.md b/zsh/plugins/grails/README.md index 64b4a9f..5d9ebd7 100644 --- a/zsh/plugins/grails/README.md +++ b/zsh/plugins/grails/README.md @@ -14,58 +14,3 @@ It looks for scripts in the following paths: - `~/.grails/scripts` - `./scripts` - `./plugins/*/scripts` - -## Grails Commands -- `add-proxy` -- `alias` -- `bootstrap` -- `bug-report` -- `clean` -- `clean-all` -- `clear-proxy` -- `compile` -- `console` -- `create-app` -- `create-controller` -- `create-domain-class` -- `create-filters` -- `create-integration-test` -- `create-multi-project-build` -- `create-plugin` -- `create-pom` -- `create-script` -- `create-service` -- `create-tag-lib` -- `create-unit-test` -- `dependency-report` -- `doc` -- `help` -- `init` -- `install-app-templates` -- `install-dependency` -- `install-plugin` -- `install-templates` -- `integrate-with` -- `interactive` -- `list-plugin-updates` -- `list-plugins` -- `migrate-docs` -- `package` -- `package-plugin` -- `plugin-info` -- `refresh-dependencies` -- `remove-proxy` -- `run-app` -- `run-script` -- `run-war` -- `set-grails-version` -- `set-proxy` -- `set-version` -- `shell` -- `stats` -- `stop-app` -- `test-app` -- `uninstall-plugin` -- `url-mappings-report` -- `war` -- `wrapper` diff --git a/zsh/plugins/history-substring-search/README.md b/zsh/plugins/history-substring-search/README.md index 7fb0fa0..6d8b564 100644 --- a/zsh/plugins/history-substring-search/README.md +++ b/zsh/plugins/history-substring-search/README.md @@ -1,25 +1,44 @@ -zsh-history-substring-search -============================================================================== +# zsh-history-substring-search This is a clean-room implementation of the [Fish shell][1]'s history search -feature, where you can type in any part of any previously entered command -and press the UP and DOWN arrow keys to cycle through the matching commands. -You can also use K and J in VI mode or ^P and ^N in EMACS mode for the same. +feature, where you can type in any part of any command from history and then +press chosen keys, such as the UP and DOWN arrows, to cycle through matches. -[1]: https://fishshell.com -[2]: https://www.zsh.org/mla/users/2009/msg00818.html -[3]: https://sourceforge.net/projects/fizsh/ +[1]: http://fishshell.com +[2]: http://www.zsh.org/mla/users/2009/msg00818.html +[3]: http://sourceforge.net/projects/fizsh/ [4]: https://github.com/robbyrussell/oh-my-zsh/pull/215 [5]: https://github.com/zsh-users/zsh-history-substring-search [6]: https://github.com/zsh-users/zsh-syntax-highlighting ------------------------------------------------------------------------------- + Requirements ------------------------------------------------------------------------------ * [ZSH](http://zsh.sourceforge.net) 4.3 or newer +Install ------------------------------------------------------------------------------ + +Using the [Homebrew]( https://brew.sh ) package manager: + + brew install zsh-history-substring-search + echo 'source /usr/local/share/zsh-history-substring-search/zsh-history-substring-search.zsh' >> ~/.zshrc + +Using [Oh-my-zsh](https://github.com/robbyrussell/oh-my-zsh): + +1. Clone this repository in oh-my-zsh's plugins directory: + + git clone https://github.com/zsh-users/zsh-history-substring-search ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-history-substring-search + +2. Activate the plugin in `~/.zshrc`: + + plugins=( [plugins...] history-substring-search) + +3. Source `~/.zshrc` to take changes into account: + + source ~/.zshrc + Usage ------------------------------------------------------------------------------ @@ -33,117 +52,147 @@ Usage % source zsh-syntax-highlighting.zsh % source zsh-history-substring-search.zsh -2. Bind keyboard shortcuts to this script's functions: +2. Bind keyboard shortcuts to this script's functions. - # bind UP and DOWN arrow keys - zmodload zsh/terminfo - bindkey "$terminfo[kcuu1]" history-substring-search-up - bindkey "$terminfo[kcud1]" history-substring-search-down + Users typically bind their UP and DOWN arrow keys to this script, thus: + * Run `cat -v` in your favorite terminal emulator to observe key codes. +      (**NOTE:** In some cases, `cat -v` shows the wrong key codes. If the + key codes shown by `cat -v` don't work for you, press `` and + `` at your ZSH command line prompt for correct key codes.) + * Press the UP arrow key and observe what is printed in your terminal. + * Press the DOWN arrow key and observe what is printed in your terminal. + * Press the Control and C keys simultaneously to terminate the `cat -v`. + * Use your observations from the previous steps to create key bindings. + For example, if you observed `^[[A` for UP and `^[[B` for DOWN, then: - # bind UP and DOWN arrow keys (compatibility fallback - # for Ubuntu 12.04, Fedora 21, and MacOSX 10.9 users) - bindkey '^[[A' history-substring-search-up - bindkey '^[[B' history-substring-search-down + bindkey '^[[A' history-substring-search-up + bindkey '^[[B' history-substring-search-down - # bind P and N for EMACS mode - bindkey -M emacs '^P' history-substring-search-up - bindkey -M emacs '^N' history-substring-search-down + However, if the observed values don't work, you can try using terminfo: - # bind k and j for VI mode - bindkey -M vicmd 'k' history-substring-search-up - bindkey -M vicmd 'j' history-substring-search-down + bindkey "$terminfo[kcuu1]" history-substring-search-up + bindkey "$terminfo[kcud1]" history-substring-search-down + + You might also want to bind the Control-P/N keys for use in EMACS mode: + + bindkey -M emacs '^P' history-substring-search-up + bindkey -M emacs '^N' history-substring-search-down + + You might also want to bind the `k` and `j` keys for use in VI mode: + + bindkey -M vicmd 'k' history-substring-search-up + bindkey -M vicmd 'j' history-substring-search-down 3. Type any part of any previous command and then: - * Press the UP arrow key to select the nearest command that (1) contains - your query and (2) is older than the current command in the command - history. + * Press the `history-substring-search-up` key, which was configured in + step 2 above, to select the nearest command that (1) contains your query + and (2) is also older than the current command in your command history. - * Press the DOWN arrow key to select the nearest command that (1) - contains your query and (2) is newer than the current command in the - command history. + * Press the `history-substring-search-down` key, which was configured in + step 2 above, to select the nearest command that (1) contains your query + and (2) is also newer than the current command in your command history. - * Press ^U (the Control and U keys simultaneously) to abort the search. + * Press `^U` the Control and U keys simultaneously to abort the search. 4. If a matching command spans more than one line of text, press the LEFT arrow key to move the cursor away from the end of the command, and then: - * Press the UP arrow key to move the cursor to the line above. When the - cursor reaches the first line of the command, pressing the UP arrow - key again will cause this script to perform another search. + * Press the `history-substring-search-up` key, which was configured in + step 2 above, to move the cursor to the line above the cursored line. + When the cursor reaches the first line of the command, pressing the + `history-substring-search-up` key again will cause this script to + perform another search. + + * Press the `history-substring-search-down` key, which was configured in + step 2 above, to move the cursor to the line below the cursored line. + When the cursor reaches the last line of the command, pressing the + `history-substring-search-down` key, which was configured in step 2 + above, again will cause this script to perform another search. - * Press the DOWN arrow key to move the cursor to the line below. When - the cursor reaches the last line of the command, pressing the DOWN - arrow key again will cause this script to perform another search. ------------------------------------------------------------------------------- Configuration ------------------------------------------------------------------------------ This script defines the following global variables. You may override their default values only after having loaded this script into your ZSH session. -* HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_FOUND is a global variable that defines +* `HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_FOUND` is a global variable that defines how the query should be highlighted inside a matching command. Its default value causes this script to highlight using bold, white text on a magenta background. See the "Character Highlighting" section in the zshzle(1) man page to learn about the kinds of values you may assign to this variable. -* HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_NOT_FOUND is a global variable that +* `HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_NOT_FOUND` is a global variable that defines how the query should be highlighted when no commands in the history match it. Its default value causes this script to highlight using bold, white text on a red background. See the "Character Highlighting" section in the zshzle(1) man page to learn about the kinds of values you may assign to this variable. -* HISTORY_SUBSTRING_SEARCH_GLOBBING_FLAGS is a global variable that defines +* `HISTORY_SUBSTRING_SEARCH_GLOBBING_FLAGS` is a global variable that defines how the command history will be searched for your query. Its default value causes this script to perform a case-insensitive search. See the "Globbing Flags" section in the zshexpn(1) man page to learn about the kinds of values you may assign to this variable. -To always receive _unique_ search results, use `setopt HIST_IGNORE_ALL_DUPS`. -Alternatively, use `setopt HIST_FIND_NO_DUPS` which makes this plugin skip -duplicate _adjacent_ search results as you cycle through them---however, this -does not guarantee that search results are unique: if your search results were -"Dog", "Dog", "HotDog", "Dog", then cycling them gives "Dog", "HotDog", "Dog". -Notice that the "Dog" search result appeared twice as you cycled through them! -If you wish to avoid this limitation, then use `setopt HIST_IGNORE_ALL_DUPS`. +* `HISTORY_SUBSTRING_SEARCH_FUZZY` is a global variable that defines + how the command history will be searched for your query. If set to a non-empty + value, causes this script to perform a fuzzy search by words, matching in + given order e.g. `ab c` will match `*ab*c*` + +* `HISTORY_SUBSTRING_SEARCH_ENSURE_UNIQUE` is a global variable that defines + whether all search results returned are _unique_. If set to a non-empty + value, then only unique search results are presented. This behaviour is off + by default. An alternative way to ensure that search results are unique is + to use `setopt HIST_IGNORE_ALL_DUPS`. If this configuration variable is off + and `setopt HIST_IGNORE_ALL_DUPS` is unset, then `setopt HIST_FIND_NO_DUPS` + is still respected and it makes this script skip duplicate _adjacent_ search + results as you cycle through them, but this does not guarantee that search + results are unique: if your search results were "Dog", "Dog", "HotDog", + "Dog", then cycling them gives "Dog", "HotDog", "Dog". Notice that the "Dog" + search result appeared twice as you cycled through them. If you wish to + receive globally unique search results only once, then use this + configuration variable, or use `setopt HIST_IGNORE_ALL_DUPS`. + ------------------------------------------------------------------------------- History ------------------------------------------------------------------------------ -This script was originally written by [Peter Stephenson][2], who published it -to the ZSH users mailing list (thereby making it public domain) in September -2009. It was later revised by Guido van Steen and released under the BSD -license (see below) as part of [the fizsh project][3] in January 2011. +* September 2009: [Peter Stephenson][2] originally wrote this script and it + published to the zsh-users mailing list. -It was later extracted from fizsh release 1.0.1, refactored heavily, and -repackaged as both an [oh-my-zsh plugin][4] and as an independently loadable -[ZSH script][5] by Suraj N. Kurapati in 2011. +* January 2011: Guido van Steen (@guidovansteen) revised this script and + released it under the 3-clause BSD license as part of [fizsh][3], the + Friendly Interactive ZSHell. -It was [further developed][4] by Guido van Steen, Suraj N. Kurapati, Sorin -Ionescu, and Vincent Guerci in 2011. +* January 2011: Suraj N. Kurapati (@sunaku) extracted this script from + [fizsh][3] 1.0.1, refactored it heavily, and finally repackaged it as an + [oh-my-zsh plugin][4] and as an independently loadable [ZSH script][5]. + +* July 2011: Guido van Steen, Suraj N. Kurapati, and Sorin Ionescu + (@sorin-ionescu) [further developed it][4] with Vincent Guerci (@vguerci). + +* March 2016: Geza Lore (@gezalore) greatly refactored it in pull request #55. ------------------------------------------------------------------------------ Oh My Zsh Distribution Notes ------------------------------------------------------------------------------ -What you are looking at now is Oh My Zsh's repackaging of zsh-history-substring-search +What you are looking at now is Oh My Zsh's repackaging of zsh-history-substring-search as an OMZ module inside the Oh My Zsh distribution. -The upstream repo, zsh-users/zsh-history-substring-search, can be found on GitHub at +The upstream repo, zsh-users/zsh-history-substring-search, can be found on GitHub at https://github.com/zsh-users/zsh-history-substring-search. This downstream copy was last updated from the following upstream commit: - SHA: 2c295432175990c1bb4e90bc13f609daa67a25d6 - Commit date: 2015-09-28 10:47:34 -0700 + SHA: 0f80b8eb3368b46e5e573c1d91ae69eb095db3fb + Commit date: 2019-05-12 17:35:54 -0700 Everything above this section is a copy of the original upstream's README, so things may differ slightly when you're using this inside OMZ. In particular, you do not -need to set up key bindings for the up and down arrows yourself in `~/.zshrc`; the OMZ +need to set up key bindings for the up and down arrows yourself in `~/.zshrc`; the OMZ plugin does that for you. You may still want to set up additional emacs- or vi-specific bindings as mentioned above. diff --git a/zsh/plugins/history-substring-search/history-substring-search.plugin.zsh b/zsh/plugins/history-substring-search/history-substring-search.plugin.zsh index 7883a65..d2c749b 100644 --- a/zsh/plugins/history-substring-search/history-substring-search.plugin.zsh +++ b/zsh/plugins/history-substring-search/history-substring-search.plugin.zsh @@ -1,20 +1,9 @@ -# This file integrates the zsh-history-substring-search script into oh-my-zsh. - -source "${0:r:r}.zsh" - -if test "$CASE_SENSITIVE" = true; then - unset HISTORY_SUBSTRING_SEARCH_GLOBBING_FLAGS -fi - -if test "$DISABLE_COLOR" = true; then - unset HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_FOUND - unset HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_NOT_FOUND -fi +0=${(%):-%N} +source ${0:A:h}/history-substring-search.zsh # Bind terminal-specific up and down keys -# Bind in both emacs and vi modes so it works in both, and is not -# sensitive to whether this is loaded before or after the vi-mode plugin + if [[ -n "$terminfo[kcuu1]" ]]; then bindkey -M emacs "$terminfo[kcuu1]" history-substring-search-up bindkey -M viins "$terminfo[kcuu1]" history-substring-search-up diff --git a/zsh/plugins/history-substring-search/history-substring-search.zsh b/zsh/plugins/history-substring-search/history-substring-search.zsh index 3b8afd3..a791cc4 100644 --- a/zsh/plugins/history-substring-search/history-substring-search.zsh +++ b/zsh/plugins/history-substring-search/history-substring-search.zsh @@ -6,6 +6,8 @@ # Copyright (c) 2011 Suraj N. Kurapati # Copyright (c) 2011 Sorin Ionescu # Copyright (c) 2011 Vincent Guerci +# Copyright (c) 2016 Geza Lore +# Copyright (c) 2017 Bengt Brodersen # All rights reserved. # # Redistribution and use in source and binary forms, with or without @@ -38,12 +40,30 @@ ############################################################################## #----------------------------------------------------------------------------- -# configuration variables +# declare global configuration variables #----------------------------------------------------------------------------- -HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_FOUND='bg=magenta,fg=white,bold' -HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_NOT_FOUND='bg=red,fg=white,bold' -HISTORY_SUBSTRING_SEARCH_GLOBBING_FLAGS='i' +typeset -g HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_FOUND='bg=magenta,fg=white,bold' +typeset -g HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_NOT_FOUND='bg=red,fg=white,bold' +typeset -g HISTORY_SUBSTRING_SEARCH_GLOBBING_FLAGS='i' +typeset -g HISTORY_SUBSTRING_SEARCH_ENSURE_UNIQUE='' +typeset -g HISTORY_SUBSTRING_SEARCH_FUZZY='' + +#----------------------------------------------------------------------------- +# declare internal global variables +#----------------------------------------------------------------------------- + +typeset -g BUFFER MATCH MBEGIN MEND CURSOR +typeset -g _history_substring_search_refresh_display +typeset -g _history_substring_search_query_highlight +typeset -g _history_substring_search_result +typeset -g _history_substring_search_query +typeset -g -a _history_substring_search_query_parts +typeset -g -a _history_substring_search_raw_matches +typeset -g -i _history_substring_search_raw_match_index +typeset -g -a _history_substring_search_matches +typeset -g -i _history_substring_search_match_index +typeset -g -A _history_substring_search_unique_filter #----------------------------------------------------------------------------- # the main ZLE widgets @@ -180,62 +200,104 @@ _history-substring-search-begin() { _history_substring_search_query_highlight= # - # Continue using the previous $_history_substring_search_result by default, - # unless the current query was cleared or a new/different query was entered. + # If the buffer is the same as the previously displayed history substring + # search result, then just keep stepping through the match list. Otherwise + # start a new search. # - if [[ -z $BUFFER || $BUFFER != $_history_substring_search_result ]]; then + if [[ -n $BUFFER && $BUFFER == ${_history_substring_search_result:-} ]]; then + return; + fi + + # + # Clear the previous result. + # + _history_substring_search_result='' + + if [[ -z $BUFFER ]]; then # - # For the purpose of highlighting we will also keep - # a version without doubly-escaped meta characters. + # If the buffer is empty, we will just act like up-history/down-history + # in ZSH, so we do not need to actually search the history. This should + # speed things up a little. + # + _history_substring_search_query= + _history_substring_search_query_parts=() + _history_substring_search_raw_matches=() + + else + # + # For the purpose of highlighting we keep a copy of the original + # query string. # _history_substring_search_query=$BUFFER # - # $BUFFER contains the text that is in the command-line currently. - # we put an extra "\\" before meta characters such as "\(" and "\)", - # so that they become "\\\(" and "\\\)". + # compose search pattern # - _history_substring_search_query_escaped=${BUFFER//(#m)[\][()|\\*?#<>~^]/\\$MATCH} + if [[ -n $HISTORY_SUBSTRING_SEARCH_FUZZY ]]; then + # + # `=` split string in arguments + # + _history_substring_search_query_parts=(${=_history_substring_search_query}) + else + _history_substring_search_query_parts=(${==_history_substring_search_query}) + fi # - # Find all occurrences of the search query in the history file. + # Escape and join query parts with wildcard character '*' as seperator + # `(j:CHAR:)` join array to string with CHAR as seperator + # + local search_pattern="*${(j:*:)_history_substring_search_query_parts[@]//(#m)[\][()|\\*?#<>~^]/\\$MATCH}*" + + # + # Find all occurrences of the search pattern in the history file. # # (k) returns the "keys" (history index numbers) instead of the values - # (Oa) reverses the order, because (R) returns results reversed. + # (R) returns values in reverse older, so the index of the youngest + # matching history entry is at the head of the list. # - _history_substring_search_matches=(${(kOa)history[(R)(#$HISTORY_SUBSTRING_SEARCH_GLOBBING_FLAGS)*${_history_substring_search_query_escaped}*]}) + _history_substring_search_raw_matches=(${(k)history[(R)(#$HISTORY_SUBSTRING_SEARCH_GLOBBING_FLAGS)${search_pattern}]}) + fi - # - # Define the range of values that $_history_substring_search_match_index - # can take: [0, $_history_substring_search_matches_count_plus]. - # - _history_substring_search_matches_count=$#_history_substring_search_matches - _history_substring_search_matches_count_plus=$(( _history_substring_search_matches_count + 1 )) - _history_substring_search_matches_count_sans=$(( _history_substring_search_matches_count - 1 )) + # + # In order to stay as responsive as possible, we will process the raw + # matches lazily (when the user requests the next match) to choose items + # that need to be displayed to the user. + # _history_substring_search_raw_match_index holds the index of the last + # unprocessed entry in _history_substring_search_raw_matches. Any items + # that need to be displayed will be added to + # _history_substring_search_matches. + # + # We use an associative array (_history_substring_search_unique_filter) as + # a 'set' data structure to ensure uniqueness of the results if desired. + # If an entry (key) is in the set (non-empty value), then we have already + # added that entry to _history_substring_search_matches. + # + _history_substring_search_raw_match_index=0 + _history_substring_search_matches=() + _history_substring_search_unique_filter=() - # - # If $_history_substring_search_match_index is equal to - # $_history_substring_search_matches_count_plus, this indicates that we - # are beyond the beginning of $_history_substring_search_matches. - # - # If $_history_substring_search_match_index is equal to 0, this indicates - # that we are beyond the end of $_history_substring_search_matches. - # - # If we have initially pressed "up" we have to initialize - # $_history_substring_search_match_index to - # $_history_substring_search_matches_count_plus so that it will be - # decreased to $_history_substring_search_matches_count. - # - # If we have initially pressed "down" we have to initialize - # $_history_substring_search_match_index to - # $_history_substring_search_matches_count so that it will be increased to - # $_history_substring_search_matches_count_plus. - # - if [[ $WIDGET == history-substring-search-down ]]; then - _history_substring_search_match_index=$_history_substring_search_matches_count - else - _history_substring_search_match_index=$_history_substring_search_matches_count_plus - fi + # + # If $_history_substring_search_match_index is equal to + # $#_history_substring_search_matches + 1, this indicates that we + # are beyond the end of $_history_substring_search_matches and that we + # have also processed all entries in + # _history_substring_search_raw_matches. + # + # If $#_history_substring_search_match_index is equal to 0, this indicates + # that we are beyond the beginning of $_history_substring_search_matches. + # + # If we have initially pressed "up" we have to initialize + # $_history_substring_search_match_index to 0 so that it will be + # incremented to 1. + # + # If we have initially pressed "down" we have to initialize + # $_history_substring_search_match_index to 1 so that it will be + # decremented to 0. + # + if [[ $WIDGET == history-substring-search-down ]]; then + _history_substring_search_match_index=1 + else + _history_substring_search_match_index=0 fi } @@ -255,16 +317,21 @@ _history-substring-search-end() { _zsh_highlight # highlight the search query inside the command line - if [[ -n $_history_substring_search_query_highlight && -n $_history_substring_search_query ]]; then - # - # The following expression yields a variable $MBEGIN, which - # indicates the begin position + 1 of the first occurrence - # of _history_substring_search_query_escaped in $BUFFER. - # - : ${(S)BUFFER##(#m$HISTORY_SUBSTRING_SEARCH_GLOBBING_FLAGS)($_history_substring_search_query##)} - local begin=$(( MBEGIN - 1 )) - local end=$(( begin + $#_history_substring_search_query )) - region_highlight+=("$begin $end $_history_substring_search_query_highlight") + if [[ -n $_history_substring_search_query_highlight ]]; then + # highlight first matching query parts + local highlight_start_index=0 + local highlight_end_index=0 + local query_part + for query_part in $_history_substring_search_query_parts; do + local escaped_query_part=${query_part//(#m)[\][()|\\*?#<>~^]/\\$MATCH} + # (i) get index of pattern + local query_part_match_index="${${BUFFER:$highlight_start_index}[(i)(#$HISTORY_SUBSTRING_SEARCH_GLOBBING_FLAGS)${escaped_query_part}]}" + if [[ $query_part_match_index -le ${#BUFFER:$highlight_start_index} ]]; then + highlight_start_index=$(( $highlight_start_index + $query_part_match_index )) + highlight_end_index=$(( $highlight_start_index + ${#query_part} )) + region_highlight+=("$(($highlight_start_index - 1)) $(($highlight_end_index - 1)) $_history_substring_search_query_highlight") + fi + done fi # For debugging purposes: @@ -378,12 +445,143 @@ _history-substring-search-down-history() { return 1 } +_history_substring_search_process_raw_matches() { + # + # Process more outstanding raw matches and append any matches that need to + # be displayed to the user to _history_substring_search_matches. + # Return whether there were any more results appended. + # + + # + # While we have more raw matches. Process them to see if there are any more + # matches that need to be displayed to the user. + # + while [[ $_history_substring_search_raw_match_index -lt $#_history_substring_search_raw_matches ]]; do + # + # Move on to the next raw entry and get its history index. + # + _history_substring_search_raw_match_index+=1 + local index=${_history_substring_search_raw_matches[$_history_substring_search_raw_match_index]} + + # + # If HISTORY_SUBSTRING_SEARCH_ENSURE_UNIQUE is set to a non-empty value, + # then ensure that only unique matches are presented to the user. + # When HIST_IGNORE_ALL_DUPS is set, ZSH already ensures a unique history, + # so in this case we do not need to do anything. + # + if [[ ! -o HIST_IGNORE_ALL_DUPS && -n $HISTORY_SUBSTRING_SEARCH_ENSURE_UNIQUE ]]; then + # + # Get the actual history entry at the new index, and check if we have + # already added it to _history_substring_search_matches. + # + local entry=${history[$index]} + + if [[ -z ${_history_substring_search_unique_filter[$entry]} ]]; then + # + # This is a new unique entry. Add it to the filter and append the + # index to _history_substring_search_matches. + # + _history_substring_search_unique_filter[$entry]=1 + _history_substring_search_matches+=($index) + + # + # Indicate that we did find a match. + # + return 0 + fi + + else + # + # Just append the new history index to the processed matches. + # + _history_substring_search_matches+=($index) + + # + # Indicate that we did find a match. + # + return 0 + fi + + done + + # + # We are beyond the end of the list of raw matches. Indicate that no + # more matches are available. + # + return 1 +} + +_history-substring-search-has-next() { + # + # Predicate function that returns whether any more older matches are + # available. + # + + if [[ $_history_substring_search_match_index -lt $#_history_substring_search_matches ]]; then + # + # We did not reach the end of the processed list, so we do have further + # matches. + # + return 0 + + else + # + # We are at the end of the processed list. Try to process further + # unprocessed matches. _history_substring_search_process_raw_matches + # returns whether any more matches were available, so just return + # that result. + # + _history_substring_search_process_raw_matches + return $? + fi +} + +_history-substring-search-has-prev() { + # + # Predicate function that returns whether any more younger matches are + # available. + # + + if [[ $_history_substring_search_match_index -gt 1 ]]; then + # + # We did not reach the beginning of the processed list, so we do have + # further matches. + # + return 0 + + else + # + # We are at the beginning of the processed list. We do not have any more + # matches. + # + return 1 + fi +} + +_history-substring-search-found() { + # + # A match is available. The index of the match is held in + # $_history_substring_search_match_index + # + # 1. Make $BUFFER equal to the matching history entry. + # + # 2. Use $HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_FOUND + # to highlight the current buffer. + # + BUFFER=$history[$_history_substring_search_matches[$_history_substring_search_match_index]] + _history_substring_search_query_highlight=$HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_FOUND +} + _history-substring-search-not-found() { # - # Nothing matched the search query, so put it back into the $BUFFER while - # highlighting it accordingly so the user can revise it and search again. + # No more matches are available. + # + # 1. Make $BUFFER equal to $_history_substring_search_query so the user can + # revise it and search again. + # + # 2. Use $HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_NOT_FOUND + # to highlight the current buffer. # - _history_substring_search_old_buffer=$BUFFER BUFFER=$_history_substring_search_query _history_substring_search_query_highlight=$HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_NOT_FOUND } @@ -392,91 +590,84 @@ _history-substring-search-up-search() { _history_substring_search_refresh_display=1 # - # Highlight matches during history-substring-up-search: + # Select history entry during history-substring-down-search: # - # The following constants have been initialized in + # The following variables have been initialized in # _history-substring-search-up/down-search(): # - # $_history_substring_search_matches is the current list of matches - # $_history_substring_search_matches_count is the current number of matches - # $_history_substring_search_matches_count_plus is the current number of matches + 1 - # $_history_substring_search_matches_count_sans is the current number of matches - 1 + # $_history_substring_search_matches is the current list of matches that + # need to be displayed to the user. # $_history_substring_search_match_index is the index of the current match + # that is being displayed to the user. # # The range of values that $_history_substring_search_match_index can take - # is: [0, $_history_substring_search_matches_count_plus]. A value of 0 - # indicates that we are beyond the end of + # is: [0, $#_history_substring_search_matches + 1]. A value of 0 + # indicates that we are beyond the beginning of # $_history_substring_search_matches. A value of - # $_history_substring_search_matches_count_plus indicates that we are beyond - # the beginning of $_history_substring_search_matches. + # $#_history_substring_search_matches + 1 indicates that we are beyond + # the end of $_history_substring_search_matches and that we have also + # processed all entries in _history_substring_search_raw_matches. + # + # If $_history_substring_search_match_index equals + # $#_history_substring_search_matches and + # $_history_substring_search_raw_match_index is not greater than + # $#_history_substring_search_raw_matches, then we need to further process + # $_history_substring_search_raw_matches to see if there are any more + # entries that need to be displayed to the user. # # In _history-substring-search-up-search() the initial value of - # $_history_substring_search_match_index is - # $_history_substring_search_matches_count_plus. This value is set in - # _history-substring-search-begin(). _history-substring-search-up-search() - # will initially decrease it to $_history_substring_search_matches_count. + # $_history_substring_search_match_index is 0. This value is set in + # _history-substring-search-begin(). _history-substring-search-up-search() + # will initially increment it to 1. # - if [[ $_history_substring_search_match_index -ge 2 ]]; then - # - # Highlight the next match: - # - # 1. Decrease the value of $_history_substring_search_match_index. - # - # 2. Use $HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_FOUND - # to highlight the current buffer. - # - (( _history_substring_search_match_index-- )) - BUFFER=$history[$_history_substring_search_matches[$_history_substring_search_match_index]] - _history_substring_search_query_highlight=$HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_FOUND - elif [[ $_history_substring_search_match_index -eq 1 ]]; then + if [[ $_history_substring_search_match_index -gt $#_history_substring_search_matches ]]; then # - # We will move beyond the end of $_history_substring_search_matches: + # We are beyond the end of $_history_substring_search_matches. This + # can only happen if we have also exhausted the unprocessed matches in + # _history_substring_search_raw_matches. # - # 1. Decrease the value of $_history_substring_search_match_index. - # - # 2. Save the current buffer in $_history_substring_search_old_buffer, - # so that it can be retrieved by - # _history-substring-search-down-search() later. - # - # 3. Make $BUFFER equal to $_history_substring_search_query. - # - # 4. Use $HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_NOT_FOUND - # to highlight the current buffer. - # - (( _history_substring_search_match_index-- )) - _history-substring-search-not-found - - elif [[ $_history_substring_search_match_index -eq $_history_substring_search_matches_count_plus ]]; then - # - # We were beyond the beginning of $_history_substring_search_matches but - # UP makes us move back to $_history_substring_search_matches: - # - # 1. Decrease the value of $_history_substring_search_match_index. - # - # 2. Restore $BUFFER from $_history_substring_search_old_buffer. - # - # 3. Use $HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_FOUND - # to highlight the current buffer. - # - (( _history_substring_search_match_index-- )) - BUFFER=$_history_substring_search_old_buffer - _history_substring_search_query_highlight=$HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_FOUND - - else - # - # We are at the beginning of history and there are no further matches. + # 1. Update display to indicate search not found. # _history-substring-search-not-found return fi + if _history-substring-search-has-next; then + # + # We do have older matches. + # + # 1. Move index to point to the next match. + # 2. Update display to indicate search found. + # + _history_substring_search_match_index+=1 + _history-substring-search-found + + else + # + # We do not have older matches. + # + # 1. Move the index beyond the end of + # _history_substring_search_matches. + # 2. Update display to indicate search not found. + # + _history_substring_search_match_index+=1 + _history-substring-search-not-found + fi + # # When HIST_FIND_NO_DUPS is set, meaning that only unique command lines from # history should be matched, make sure the new and old results are different. - # But when HIST_IGNORE_ALL_DUPS is set, ZSH already ensures a unique history. # - if [[ ! -o HIST_IGNORE_ALL_DUPS && -o HIST_FIND_NO_DUPS && $BUFFER == $_history_substring_search_result ]]; then + # However, if the HIST_IGNORE_ALL_DUPS shell option, or + # HISTORY_SUBSTRING_SEARCH_ENSURE_UNIQUE is set, then we already have a + # unique history, so in this case we do not need to do anything. + # + if [[ -o HIST_IGNORE_ALL_DUPS || -n $HISTORY_SUBSTRING_SEARCH_ENSURE_UNIQUE ]]; then + return + fi + + if [[ -o HIST_FIND_NO_DUPS && $BUFFER == $_history_substring_search_result ]]; then # # Repeat the current search so that a different (unique) match is found. # @@ -488,92 +679,75 @@ _history-substring-search-down-search() { _history_substring_search_refresh_display=1 # - # Highlight matches during history-substring-up-search: + # Select history entry during history-substring-down-search: # - # The following constants have been initialized in + # The following variables have been initialized in # _history-substring-search-up/down-search(): # - # $_history_substring_search_matches is the current list of matches - # $_history_substring_search_matches_count is the current number of matches - # $_history_substring_search_matches_count_plus is the current number of matches + 1 - # $_history_substring_search_matches_count_sans is the current number of matches - 1 + # $_history_substring_search_matches is the current list of matches that + # need to be displayed to the user. # $_history_substring_search_match_index is the index of the current match + # that is being displayed to the user. # # The range of values that $_history_substring_search_match_index can take - # is: [0, $_history_substring_search_matches_count_plus]. A value of 0 - # indicates that we are beyond the end of + # is: [0, $#_history_substring_search_matches + 1]. A value of 0 + # indicates that we are beyond the beginning of # $_history_substring_search_matches. A value of - # $_history_substring_search_matches_count_plus indicates that we are beyond - # the beginning of $_history_substring_search_matches. + # $#_history_substring_search_matches + 1 indicates that we are beyond + # the end of $_history_substring_search_matches and that we have also + # processed all entries in _history_substring_search_raw_matches. # # In _history-substring-search-down-search() the initial value of - # $_history_substring_search_match_index is - # $_history_substring_search_matches_count. This value is set in - # _history-substring-search-begin(). - # _history-substring-search-down-search() will initially increase it to - # $_history_substring_search_matches_count_plus. + # $_history_substring_search_match_index is 1. This value is set in + # _history-substring-search-begin(). _history-substring-search-down-search() + # will initially decrement it to 0. # - if [[ $_history_substring_search_match_index -le $_history_substring_search_matches_count_sans ]]; then - # - # Highlight the next match: - # - # 1. Increase $_history_substring_search_match_index by 1. - # - # 2. Use $HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_FOUND - # to highlight the current buffer. - # - (( _history_substring_search_match_index++ )) - BUFFER=$history[$_history_substring_search_matches[$_history_substring_search_match_index]] - _history_substring_search_query_highlight=$HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_FOUND - elif [[ $_history_substring_search_match_index -eq $_history_substring_search_matches_count ]]; then + if [[ $_history_substring_search_match_index -lt 1 ]]; then # - # We will move beyond the beginning of $_history_substring_search_matches: + # We are beyond the beginning of $_history_substring_search_matches. # - # 1. Increase $_history_substring_search_match_index by 1. - # - # 2. Save the current buffer in $_history_substring_search_old_buffer, so - # that it can be retrieved by _history-substring-search-up-search() - # later. - # - # 3. Make $BUFFER equal to $_history_substring_search_query. - # - # 4. Use $HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_NOT_FOUND - # to highlight the current buffer. - # - (( _history_substring_search_match_index++ )) - _history-substring-search-not-found - - elif [[ $_history_substring_search_match_index -eq 0 ]]; then - # - # We were beyond the end of $_history_substring_search_matches but DOWN - # makes us move back to the $_history_substring_search_matches: - # - # 1. Increase $_history_substring_search_match_index by 1. - # - # 2. Restore $BUFFER from $_history_substring_search_old_buffer. - # - # 3. Use $HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_FOUND - # to highlight the current buffer. - # - (( _history_substring_search_match_index++ )) - BUFFER=$_history_substring_search_old_buffer - _history_substring_search_query_highlight=$HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_FOUND - - else - # - # We are at the end of history and there are no further matches. + # 1. Update display to indicate search not found. # _history-substring-search-not-found return fi + if _history-substring-search-has-prev; then + # + # We do have younger matches. + # + # 1. Move index to point to the previous match. + # 2. Update display to indicate search found. + # + _history_substring_search_match_index+=-1 + _history-substring-search-found + + else + # + # We do not have younger matches. + # + # 1. Move the index beyond the beginning of + # _history_substring_search_matches. + # 2. Update display to indicate search not found. + # + _history_substring_search_match_index+=-1 + _history-substring-search-not-found + fi + # # When HIST_FIND_NO_DUPS is set, meaning that only unique command lines from # history should be matched, make sure the new and old results are different. - # But when HIST_IGNORE_ALL_DUPS is set, ZSH already ensures a unique history. # - if [[ ! -o HIST_IGNORE_ALL_DUPS && -o HIST_FIND_NO_DUPS && $BUFFER == $_history_substring_search_result ]]; then + # However, if the HIST_IGNORE_ALL_DUPS shell option, or + # HISTORY_SUBSTRING_SEARCH_ENSURE_UNIQUE is set, then we already have a + # unique history, so in this case we do not need to do anything. + # + if [[ -o HIST_IGNORE_ALL_DUPS || -n $HISTORY_SUBSTRING_SEARCH_ENSURE_UNIQUE ]]; then + return + fi + + if [[ -o HIST_FIND_NO_DUPS && $BUFFER == $_history_substring_search_result ]]; then # # Repeat the current search so that a different (unique) match is found. # diff --git a/zsh/plugins/history/README.md b/zsh/plugins/history/README.md index dd92868..a9d480f 100644 --- a/zsh/plugins/history/README.md +++ b/zsh/plugins/history/README.md @@ -1,15 +1,17 @@ -## history +# history plugin Provides a couple of convenient aliases for using the `history` command to examine your command line history. -### Requirements +To use it, add `history` to the plugins array in your zshrc file: -* None. +```zsh +plugins=(... history) +``` -### Usage +## Aliases -* If `h` is called, your command history is listed. Equivalent to using `history` - -* If `hsi` is called with an argument, a **case insensitive** `grep` search is performed on your command history, looking for commands that match the argument provided - -* If `hsi` is called without an argument you will help on `grep` arguments \ No newline at end of file +| Alias | Command | Description | +|-------|----------------------|------------------------------------------------------------------| +| `h` | `history` | Prints your command history | +| `hs` | `history \| grep` | Use grep to search your command history | +| `hsi` | `history \| grep -i` | Use grep to do a case-insensitive search of your command history | diff --git a/zsh/plugins/history/history.plugin.zsh b/zsh/plugins/history/history.plugin.zsh index 0f4aa4b..9cee48f 100644 --- a/zsh/plugins/history/history.plugin.zsh +++ b/zsh/plugins/history/history.plugin.zsh @@ -1,8 +1,3 @@ alias h='history' - -function hs -{ - history | grep $* -} - -alias hsi='hs -i' +alias hs='history | grep' +alias hsi='history | grep -i' diff --git a/zsh/plugins/hitokoto/README.md b/zsh/plugins/hitokoto/README.md new file mode 100644 index 0000000..3a8758f --- /dev/null +++ b/zsh/plugins/hitokoto/README.md @@ -0,0 +1,15 @@ +# hitokoto plugin + +Displays a random quote taken from [hitokoto.cn](https://v1.hitokoto.cn/) + +Created by [Sinrimin](https://github.com/sinrimin) + +## Usage + +Add the plugin to the plugins array in your zshrc file and restart zsh: + +```zsh +plugins=(... hitokoto) +``` + +Then, run `hitokoto` to get a new random quote. diff --git a/zsh/plugins/hitokoto/hitokoto.plugin.zsh b/zsh/plugins/hitokoto/hitokoto.plugin.zsh new file mode 100644 index 0000000..8646ebf --- /dev/null +++ b/zsh/plugins/hitokoto/hitokoto.plugin.zsh @@ -0,0 +1,14 @@ +if ! (( $+commands[curl] )); then + echo "hitokoto plugin needs curl to work" >&2 + return +fi + +function hitokoto { + emulate -L zsh + Q=$(curl -s --connect-timeout 2 "https://v1.hitokoto.cn" | jq -j '.hitokoto+"\t"+.from') + + TXT=$(echo "$Q" | awk -F '\t' '{print $1}') + WHO=$(echo "$Q" | awk -F '\t' '{print $2}') + + [[ -n "$WHO" && -n "$TXT" ]] && print -P "%F{3}${WHO}%f: “%F{5}${TXT}%f”" +} diff --git a/zsh/plugins/httpie/README.md b/zsh/plugins/httpie/README.md index f22d3a6..40d60c4 100644 --- a/zsh/plugins/httpie/README.md +++ b/zsh/plugins/httpie/README.md @@ -11,5 +11,10 @@ plugins=(... httpie) It uses completion from [zsh-completions](https://github.com/zsh-users/zsh-completions). +## Aliases + +| Alias | Command | +| ------------ | ---------------------------------------------------------------- | +| `https` | `http --default-scheme=https` | **Maintainer:** [lululau](https://github.com/lululau) diff --git a/zsh/plugins/httpie/httpie.plugin.zsh b/zsh/plugins/httpie/httpie.plugin.zsh new file mode 100644 index 0000000..088a1f1 --- /dev/null +++ b/zsh/plugins/httpie/httpie.plugin.zsh @@ -0,0 +1,7 @@ +# +# Aliases +# (sorted alphabetically) +# + +alias https='http --default-scheme=https' + diff --git a/zsh/plugins/ionic/README.md b/zsh/plugins/ionic/README.md new file mode 100644 index 0000000..3ec4fc8 --- /dev/null +++ b/zsh/plugins/ionic/README.md @@ -0,0 +1,30 @@ +# Ionic plugin + +This plugin adds completion for the [Ionic CLI](https://ionicframework.com/docs/cli), +as well as some aliases for common Ionic commands. + +To use it, add `ionic` to the plugins array in your zshrc file: + +```zsh +plugins=(... ionic) +``` + +## Aliases + +| Alias | Command | Description | +|-------|--------------------------------------|------------------------------------------------------------------| +| iv | `ionic --version` | Check Ionic version | +| ih | `ionic --help` | Ionic help command | +| ist | `ionic start` | Create a new project | +| ii | `ionic info` | Print system/environment info | +| is | `ionic serve` | Start a local dev server for app dev/testing | +| icba | `ionic cordova build android` | Build web assets and prepare app for android platform targets | +| icbi | `ionic cordova build ios` | Build web assets and prepare app for ios platform targets | +| icra | `ionic cordova run android` | Run an Ionic project on a connected android device | +| icri | `ionic cordova run ios` | Run an Ionic project on a connected ios device | +| icrsa | `ionic cordova resources android` | Automatically create icon and splash screen resources for android| +| icrsi | `ionic cordova resources ios` | Automatically create icon and splash screen resources for ios | +| icpaa | `ionic cordova platform add android` | Add Cordova android platform targets | +| icpai | `ionic cordova platform add ios` | Add Cordova ios platform targets | +| icpra | `ionic cordova platform rm android` | Remove Cordova platform targets | +| icpri | `ionic cordova platform rm ios` | Remove Cordova platform targets | diff --git a/zsh/plugins/ionic/ionic.plugin.zsh b/zsh/plugins/ionic/ionic.plugin.zsh new file mode 100644 index 0000000..cf388af --- /dev/null +++ b/zsh/plugins/ionic/ionic.plugin.zsh @@ -0,0 +1,15 @@ +alias iv="ionic --version" +alias ih="ionic --help" +alias ist="ionic start" +alias ii="ionic info" +alias is="ionic serve" +alias icba="ionic cordova build android" +alias icbi="ionic cordova build ios" +alias icra="ionic cordova run android" +alias icri="ionic cordova run ios" +alias icrsa="ionic cordova resources android" +alias icrsi="ionic cordova resources ios" +alias icpaa="ionic cordova platform add android" +alias icpai="ionic cordova platform add ios" +alias icpra="ionic cordova platform rm android" +alias icpri="ionic cordova platform rm ios" diff --git a/zsh/plugins/ipfs/LICENSE b/zsh/plugins/ipfs/LICENSE new file mode 100644 index 0000000..cf84491 --- /dev/null +++ b/zsh/plugins/ipfs/LICENSE @@ -0,0 +1,22 @@ +The MIT License (MIT) + +Copyright (c) 2015 Angel Ramboi + +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. + diff --git a/zsh/plugins/ipfs/README.md b/zsh/plugins/ipfs/README.md new file mode 100644 index 0000000..0808a26 --- /dev/null +++ b/zsh/plugins/ipfs/README.md @@ -0,0 +1,17 @@ +# zsh-ipfs + +zsh completion plugin for [The InterPlanetary File System (IPFS)][1] + +Please submit issues and pull requests to the [main zsh-ipfs repo][2]. + +### About + +[IPFS (InterPlanetary File System)][1] is a peer-to-peer hypermedia protocol +designed to make the web faster, safer, and more open. + +### License + +See: https://github.com/hellounicorn/zsh-ipfs/blob/master/LICENSE + +[1]: http://ipfs.io/ +[2]: https://github.com/hellounicorn/zsh-ipfs diff --git a/zsh/plugins/ipfs/_ipfs b/zsh/plugins/ipfs/_ipfs new file mode 100644 index 0000000..9ee8bd7 --- /dev/null +++ b/zsh/plugins/ipfs/_ipfs @@ -0,0 +1,717 @@ +#compdef ipfs +#autoload + +local -a _1st_arguments +_1st_arguments=( + 'add:Add a file or directory to ipfs.' + 'bitswap:Interact with the bitswap agent.' + 'block:Interact with raw IPFS blocks.' + 'bootstrap:Show or edit the list of bootstrap peers.' + 'cat:Show IPFS object data.' + 'cid:Convert and discover properties of CIDs' + 'commands:List all available commands.' + 'config:Get and set ipfs config values.' + 'daemon:Run a network-connected IPFS node.' + 'dag:Interact with ipld dag objects. (experimental)' + 'dht:Issue commands directly through the DHT.' + 'diag:Generate diagnostic reports.' + 'dns:Resolve DNS links.' + 'files:Interact with unixfs files.' + 'filestore:Interact with filestore objects. (experimental)' + 'get:Download IPFS objects.' + 'id:Show ipfs node id info.' + 'init:Initializes ipfs config file.' + 'key:Create and list IPNS name keypairs.' + 'log:Interact with the daemon log output.' + 'ls:List directory contents for Unix filesystem objects.' + 'mount:Mounts IPFS to the filesystem (read-only).' + 'name:Publish and resolve IPNS names.' + 'object:Interact with IPFS objects.' + 'p2p:Libp2p stream mounting.' + 'pin:Pin (and unpin) objects to local storage.' + 'ping:Send echo request packets to IPFS hosts.' + 'refs:List links (references) from an object.' + 'repo:Manipulate the IPFS repo.' + 'resolve:Resolve the value of names to IPFS.' + 'stats:Query IPFS statistics.' + 'swarm:Interact with the swarm.' + 'tar:Utility functions for tar files in ipfs.' + 'update:Download and apply go-ipfs updates' + 'version:Show ipfs version information.' +) + +_ipfs_subcommand(){ + local curcontext="$curcontext" state line + typeset -A opt_args + _arguments -C ':command:->command' '*::options:->options' + case $state in + (command) + _describe -t commands "ipfs subcommand" $1 + return + ;; + (options) + case $line[1] in + (wantlist) + case $MAIN_SUBCOMMAND in + (bitswap) + _arguments '(-p --peer)'{-p,--peer}'[Specify which peer to show wantlist for. Default: self.]' + ;; + esac + ;; + (add) + case $MAIN_SUBCOMMAND in + (pin) + _arguments \ + '(-r --recursive)'{-r,--recursive}'[Recursively pin the object linked to by the specified object(s). Default: true.]' \ + '--progress[Show progress.]' + ;; + (bootstrap) + local -a _bootstrap_rm_arguments + _bootstrap_rm_arguments=( + 'default:Add default peers to the bootstrap list.' + ) + _ipfs_subcommand _bootstrap_rm_arguments + ;; + esac + ;; + (rm) + case $MAIN_SUBCOMMAND in + (pin) + _arguments '(-r --recursive)'{-r,--recursive}'[Recursively unpin the object linked to by the specified object(s). Default: true.]' + ;; + (bootstrap) + local -a _bootstrap_rm_arguments + _bootstrap_rm_arguments=( + 'all:Remove all peers from the bootstrap list.' + ) + _ipfs_subcommand _bootstrap_rm_arguments + ;; + esac + ;; + (ls) + case $MAIN_SUBCOMMAND in + (pin) + _arguments \ + '(-t --type)'{-t,--type}'[The type of pinned keys to list. Can be "direct", "indirect", "recursive", or "all". Default: all.]' \ + '(-q --quiet)'{-q,--quiet}'[Write just hashes of objects.]' + ;; + (p2p) + _arguments '(-v --headers)'{-v,--headers}'[Print table headers (Protocol, Listen, Target).]' + ;; + esac + ;; + (update) + case $MAIN_SUBCOMMAND in + (pin) + _arguments '--unpin[Remove the old pin. Default: true.]' + ;; + esac + ;; + (verify) + case $MAIN_SUBCOMMAND in + (pin) + _arguments \ + '--verbose[Also write the hashes of non-broken pins.]' \ + '(-q --quiet)'{-q,--quiet}'[Write just hashes of broken pins.]' + ;; + esac + ;; + (get|query|findpeer) + case $MAIN_SUBCOMMAND in + (dht) + _arguments '(-v --verbose)'{-v,--verbose}'[Print extra information.]' + ;; + (object) + _arguments '--data-encoding[Encoding type of the data field, either "text" or "base64". Default: text.]' + ;; + esac + ;; + (put) + case $MAIN_SUBCOMMAND in + (dht) + _arguments '(-v --verbose)'{-v,--verbose}'[Print extra information.]' + ;; + (object) + _arguments \ + '--inputenc[Encoding type of input data. One of: {"protobuf", "json"}. Default: json.]' \ + '--datafieldenc[Encoding type of the data field, either "text" or "base64". Default: text.]' \ + '--pin[Pin this object when adding.]' \ + '(-q --quiet)'{-q,--quiet}'[Write minimal output]' + ;; + esac + ;; + (findprovs) + case $MAIN_SUBCOMMAND in + (dht) + _arguments \ + '(-v --verbose)'{-v,--verbose}'[Print extra information.]' \ + '(-n --num-providers)'{-n,--num-providers}'[The number of providers to find. Default: 20.]' + ;; + esac + ;; + (provide) + case $MAIN_SUBCOMMAND in + (dht) + _arguments \ + '(-v --verbose)'{-v,--verbose}'[Print extra information.]' \ + '(-r --recursive)'{-r,--recursive}'[Recursively provide entire graph.]' + ;; + esac + ;; + (cmds|diff) + case $MAIN_SUBCOMMAND in + (diag|object) + _arguments '(-v --verbose)'{-v,--verbose}'[Print extra information.]' + ;; + esac + ;; + (stat) + case $MAIN_SUBCOMMAND in + (object) + _arguments '--human[Print sizes in human readable format (e.g., 1K 234M 2G).]' + ;; + (repo) + _arguments \ + '--size-only[Only report RepoSize and StorageMax.]' \ + '--human[Print sizes in human readable format (e.g., 1K 234M 2G).]' + ;; + esac + ;; + (publish) + case $MAIN_SUBCOMMAND in + (name) + _arguments \ + '--resolve[Check if the given path can be resolved before publishing. Default: true.]' \ + '(-t --lifetime)'{-t,--lifetime}'[Time duration that the record will be valid for. Default: 24h.]' \ + '--allow-offline[When offline, save the IPNS record to the the local datastore without broadcasting to the network instead of simply failing.]' \ + '--ttl[Time duration this record should be cached for. Uses the same syntax as the lifetime option. (caution: experimental).]' \ + '(-k --key)'{-k,--key}"[Name of the key to be used or a valid PeerID, as listed by 'ipfs key list -l'. Default: self.]" \ + '(-Q --quieter)'{-Q,--quieter}'[Write only final hash.]' + ;; + esac + ;; + (pubsub) + case $MAIN_SUBCOMMAND in + (name) + local -a _name_pubsub_arguments + _name_pubsub_arguments=( + 'cancel:Cancel a name subscription' + 'state:Query the state of IPNS pubsub' + 'subs:Show current name subscriptions' + ) + _ipfs_subcommand _name_pubsub_arguments + ;; + esac + ;; + (resolve) + case $MAIN_SUBCOMMAND in + (name) + _arguments \ + '(-r --recursive)'{-r,--recursive}'[Resolve until the result is not an IPNS name. Default: true.]' \ + '(-n --nocache)'{-n,--nocache}'[Do not use cached entries.]' \ + '(--dhtrc --dht-record-count)'{--dhtrc,--dht-record-count}'[Number of records to request for DHT resolution.]' \ + '(--dhtt --dht-timeout)'{--dhtt,--dht-timeout}'[Max time to collect values during DHT resolution eg "30s". Pass 0 for no timeout.]' \ + '(-s --stream)'{-s,--stream}'[Stream entries as they are found.]' + ;; + esac + ;; + (patch) + case $MAIN_SUBCOMMAND in + (object) + local -a _object_patch_arguments + _object_patch_arguments=( + 'add-link:Add a link to a given object.' + 'append-data:Append data to the data segment of a dag node.' + 'rm-link:Remove a link from a given object.' + 'set-data:Set the data field of an IPFS object.' + ) + _ipfs_subcommand _object_patch_arguments + ;; + esac + ;; + (gc) + case $MAIN_SUBCOMMAND in + (repo) + _arguments \ + '--stream-errors[Stream errors.]' \ + '(-q --quiet)'{-q,--quiet}'[Write minimal output.]' + ;; + esac + ;; + (bitswap) + case $MAIN_SUBCOMMAND in + (stats) + _arguments \ + '(-v --verbose)'{-v,--verbose}'[Print extra information.]' \ + '--human[Print sizes in human readable format (e.g., 1K 234M 2G).]' + ;; + esac + ;; + (bw) + case $MAIN_SUBCOMMAND in + (stats) + _arguments \ + '(-p --peer)'{-p,--peer}'[Specify a peer to print bandwidth for.]' \ + '(-t --proto)'{-t,--proto}'[Specify a protocol to print bandwidth for.]' \ + '--poll[Print bandwidth at an interval.]' \ + '(-i --interval)'{-i,--interval}'[Time interval to wait between updating output, if 'poll' is true.]' + ;; + esac + ;; + (repo) + case $MAIN_SUBCOMMAND in + (stats) + _arguments \ + '--size-only[Only report RepoSize and StorageMax.]' \ + '--human[Print sizes in human readable format (e.g., 1K 234M 2G).]' + ;; + esac + ;; + (bases) + case $MAIN_SUBCOMMAND in + (cid) + _arguments \ + '--prefix[also include the single leter prefixes in addition to the code.]' \ + '--numeric[also include numeric codes.]' + ;; + esac + ;; + (codecs|hashes) + case $MAIN_SUBCOMMAND in + (cid) + _arguments '--numeric[also include numeric codes.]' + ;; + esac + ;; + (format) + case $MAIN_SUBCOMMAND in + (cid) + _arguments \ + '-f[Printf style format string. Default: %s.]' \ + '-v[CID version to convert to.]' \ + '-b[Multibase to display CID in.]' + ;; + esac + ;; + (close) + case $MAIN_SUBCOMMAND in + (p2p) + _arguments \ + '(-a --all)'{-a,--all}'[Close all listeners.]' \ + '(-p --protocol)'{-p,--protocol}'[Match protocol name.]' \ + '(-l --listen-address)'{-l,--listen-address}'[Match listen address.]' \ + '(-t --target-address)'{-t,--target-address}'[Match target address.]' + ;; + esac + ;; + (forward) + case $MAIN_SUBCOMMAND in + (p2p) + _arguments "--allow-custom-protocol[Don't require /x/ prefix.]" + ;; + esac + ;; + (listen) + case $MAIN_SUBCOMMAND in + (p2p) + _arguments \ + "--allow-custom-protocol[Don't require /x/ prefix.]" \ + '(-r --report-peer-id)'{-r,--report-peer-id}'[Send remote base58 peerid to target when a new connection is established.]' + ;; + esac + ;; + (stream) + case $MAIN_SUBCOMMAND in + (p2p) + local -a _p2p_stream_arguments + _p2p_stream_arguments=( + 'close:Close active p2p stream.' + 'ls:List active p2p streams.' + ) + _ipfs_subcommand _p2p_stream_arguments + ;; + esac + ;; + (addrs) + case $MAIN_SUBCOMMAND in + (swarm) + local -a _swarm_addrs_arguments + _swarm_addrs_arguments=( + 'listen:List interface listening addresses.' + 'local:List local addresses.' + ) + _ipfs_subcommand _swarm_addrs_arguments + ;; + esac + ;; + (filters) + case $MAIN_SUBCOMMAND in + (swarm) + local -a _swarm_filters_arguments + _swarm_filters_arguments=( + 'add:Add an address filter.' + 'rm:Remove an address filter.' + ) + _ipfs_subcommand _swarm_filters_arguments + ;; + esac + ;; + (peers) + case $MAIN_SUBCOMMAND in + (swarm) + _arguments \ + '(-v --verbose)'{-v,--verbose}'[display all extra information.]' \ + '--streams[Also list information about open streams for each peer.]' \ + '--latency[Also list information about latency to each peer.]' \ + '--direction[Also list information about the direction of connection.]' + ;; + esac + ;; + esac + ;; + esac +} + +local expl + +_arguments \ + '(-c --config)'{-c,--config}'[Path to the configuration file to use.]' \ + '(-D --debug)'{-D,--debug}'[Operate in debug mode.]' \ + '(--help)--help[Show the full command help text.]' \ + '(--h)-h[Show a short version of the command help text.]' \ + '(-L --local)'{-L,--local}'[Run the command locally, instead of using the daemon. DEPRECATED: use --offline.]' \ + '(--offline)--offline[Run the command offline.]' \ + '(--api)--api[Use a specific API instance (defaults to /ip4/127.0.0.1/tcp/5001).]' \ + '(--cid-base)--cid-base[Multibase encoding used for version 1 CIDs in output.]' \ + '(--upgrade-cidv0-in-output)--upgrade-cidv0-in-output[Upgrade version 0 to version 1 CIDs in output.]' \ + '(--enc --encoding)'{--enc,--encoding}'[The encoding type the output should be encoded with (json, xml, or text). Default: text.]' \ + '(--stream-channels)--stream-channels[Stream channel output.]' \ + '(--timeout)--timeout[Set a global timeout on the command.]' \ + '*:: :->subcmds' && return 0 + +if (( CURRENT == 1 )); then + _describe -t commands "ipfs subcommand" _1st_arguments + return +fi + +MAIN_SUBCOMMAND="$words[1]" +case $MAIN_SUBCOMMAND in + (add) + _arguments \ + '(-r --recursive)'{-r,--recursive}'[Add directory paths recursively.]' \ + '(--dereference-args)--dereference-args[Symlinks supplied in arguments are dereferenced.]' \ + '(--stdin-name)--stdin-name[Assign a name if the file source is stdin.]' \ + '(-H --hidden)'{-H,--hidden}'[Include files that are hidden. Only takes effect on recursive add.]' \ + '(-q --quiet)'{-q,--quiet}'[Write minimal output.]' \ + '(-Q --quieter)'{-Q,--quieter}'[Write only final hash.]' \ + '(--silent)--silent[Write no output.]' \ + '(-p --progress)'{-p,--progress}'[Stream progress data.]' \ + '(-t --trickle)'{-t,--trickle}'[Use trickle-dag format for dag generation.]' \ + '(-n --only-hash)'{-n,--only-hash}'[Only chunk and hash - do not write to disk.]' \ + '(-w --wrap-with-directory)'{-w,--wrap-with-directory}'[Wrap files with a directory object.]' \ + '(-s --chunker)'{-s,--chunker}'[Chunking algorithm, size-(bytes) or rabin-(min)-(avg)-(max). Default: size-262144.]' \ + '(--pin)--pin[Pin this object when adding. Default: true.]' \ + '(--raw-leaves)--raw-leaves[Use raw blocks for leaf nodes. (experimental).]' \ + '(--nocopy)--nocopy[Add the file using filestore. Implies raw-leaves. (experimental).]' \ + '(--fscache)--fscache[Check the filestore for pre-existing blocks. (experimental).]' \ + '(--cid-version)--cid-version[CID version. Defaults to 0 unless an option that depends on CIDv1 is passed. (experimental).]' \ + '(--hash)--hash[Hash function to use. Implies CIDv1 if not sha2-256. (experimental). Default: sha2-256.]' \ + '(--inline)--inline[Inline small blocks into CIDs. (experimental).]' \ + '(--inline-limit)--inline-limit[Maximum block size to inline. (experimental). Default: 32.]' + ;; + (bitswap) + local -a _bitswap_arguments + _bitswap_arguments=( + 'ledger:Show the current ledger for a peer.' + 'reprovide:Trigger reprovider.' + 'stat:Show some diagnostic information on the bitswap agent.' + 'wantlist:Show blocks currently on the wantlist.' + ) + _ipfs_subcommand _bitswap_arguments + ;; + (block) + local -a _block_arguments + _block_arguments=( + 'get:Get a raw IPFS block.' + 'put:Store input as an IPFS block.' + 'rm:Remove IPFS block(s).' + 'stat:Print information of a raw IPFS block.' + ) + _ipfs_subcommand _block_arguments + ;; + (bootstrap) + local -a _bootstrap_arguments + _bootstrap_arguments=( + 'add:Add peers to the bootstrap list.' + 'list:Show peers in the bootstrap list.' + 'rm:Remove peers from the bootstrap list.' + ) + _ipfs_subcommand _bootstrap_arguments + ;; + (cat) + _arguments \ + '(-o --offset)'{-o,--offset}'[Byte offset to begin reading from.]' \ + '(-l --length)'{-l,--length}'[Maximum number of bytes to read.]' + ;; + (cid) + local -a _cid_arguments + _cid_arguments=( + 'base32:Convert CIDs to Base32 CID version 1.' + 'bases:List available multibase encodings.' + 'codecs:List available CID codecs.' + 'format:Format and convert a CID in various useful ways.' + 'hashes:List available multihashes.' + ) + _ipfs_subcommand _cid_arguments + ;; + (commands) + _arguments '(-f --flags)'{-f,--flags}'[Show command flags.]' + ;; + (config) + _arguments \ + '--bool[Set a boolean value.]' \ + '--json[Parse stringified JSON.]' + local -a _config_arguments + _config_arguments=( + 'edit:Open the config file for editing in $EDITOR.' + 'profile:Apply profiles to config.' + 'replace:Replace the config with .' + 'show:Output config file contents.' + ) + _ipfs_subcommand _config_arguments + ;; + (daemon) + _arguments \ + '--init[Initialize ipfs with default settings if not already initialized.]' \ + '--init-profile[Configuration profiles to apply for --init. See ipfs init --help for more.]' \ + '--routing[Overrides the routing option. Default: default.]' \ + '--mount[Mounts IPFS to the filesystem.]' \ + '--writable[Enable writing objects (with POST, PUT and DELETE).]' \ + '--mount-ipfs[Path to the mountpoint for IPFS (if using --mount). Defaults to config setting.]' \ + '--mount-ipns[Path to the mountpoint for IPNS (if using --mount). Defaults to config setting.]' \ + '--unrestricted-api[Allow API access to unlisted hashes.]' \ + '--disable-transport-encryption[Disable transport encryption (for debugging protocols).]' \ + '--enable-gc[Enable automatic periodic repo garbage collection.]' \ + '--manage-fdlimit[Check and raise file descriptor limits if needed. Default: true.]' \ + '--migrate[If true, assume yes at the migrate prompt. If false, assume no.]' \ + '--enable-pubsub-experiment[Instantiate the ipfs daemon with the experimental pubsub feature enabled.]' \ + '--enable-namesys-pubsub[Enable IPNS record distribution through pubsub; enables pubsub.]' \ + '--enable-mplex-experiment[Add the experimental 'go-multiplex' stream muxer to libp2p on construction. Default: true.]' + ;; + (dag) + local -a _dag_arguments + _dag_arguments=( + 'get:Get a dag node from ipfs.' + 'put:Add a dag node to ipfs.' + 'resolve:Resolve ipld block.' + ) + _ipfs_subcommand _dag_arguments + ;; + (dht) + local -a _dht_arguments + _dht_arguments=( + 'findpeer:Find the multiaddresses associated with a Peer ID.' + 'findprovs:Find peers that can provide a specific value, given a key.' + 'get:Given a key, query the routing system for its best value.' + 'provide:Announce to the network that you are providing given values.' + 'put:Write a key/value pair to the routing system.' + 'query:Find the closest Peer IDs to a given Peer ID by querying the DHT.' + ) + _ipfs_subcommand _dht_arguments + ;; + (diag) + local -a _diag_arguments + _diag_arguments=( + 'cmds:List commands run on this IPFS node.' + 'sys:Print system diagnostic information.' + ) + _ipfs_subcommand _diag_arguments + ;; + (dns) + _arguments '(-r --recursive)'{-r,--recursive}'[Resolve until the result is not a DNS link. Default: true.]' + ;; + (files) + _arguments '(-f --flush)'{-f,--flush}'[Flush target and ancestors after write. Default: true.]' + local -a _files_arguments + _files_arguments=( + 'chcid:Change the cid version or hash function of the root node of a given path.' + 'cp:Copy files into mfs.' + "flush:Flush a given path's data to disk." + 'ls:List directories in the local mutable namespace.' + 'mkdir:Make directories.' + 'mv:Move files.' + 'read:Read a file in a given mfs.' + 'rm:Remove a file.' + 'stat:Display file status.' + 'write:Write to a mutable file in a given filesystem.' + ) + _ipfs_subcommand _files_arguments + ;; + (filestore) + local -a _filestore_arguments + _filestore_arguments=( + 'dups:List blocks that are both in the filestore and standard block storage.' + 'ls:List objects in filestore.' + 'verify:Verify objects in filestore.' + ) + _ipfs_subcommand _filestore_arguments + ;; + (get) + _arguments \ + '(-o --output)'{-o,--output}'[The path where the output should be stored.]'\ + '(-a --archive)'{-a,--archive}'[Output a TAR archive.]' \ + '(-C --compress)'{-C,--compress}'[Compress the output with GZIP compression.]' \ + '(-l --compression-level)'{-l,--compression-level}'[The level of compression (1-9).]' + ;; + (id) + _arguments '(-f --format)'{-f,--format}'[Optional output format.]' + ;; + (init) + _arguments \ + '(-b --bits)'{-b,--bits}'[Number of bits to use in the generated RSA private key. Default: 2048.]' \ + '(-e --empty-repo)'{-e,--empty-repo}"[Don't add and pin help files to the local storage.]" \ + '(-p --profile)'{-p,--profile}"[Apply profile settings to config. Multiple profiles can be separated by ','.]" + ;; + (key) + local -a _key_arguments + _key_arguments=( + 'gen:Create a new keypair' + 'list:List all local keypairs' + 'rename:Rename a keypair' + 'rm:Remove a keypair' + ) + _ipfs_subcommand _key_arguments + ;; + (log) + local -a _log_arguments + _log_arguments=( + 'level:Change the logging level.' + 'ls:List the logging subsystems.' + 'tail:Read the event log.' + ) + _ipfs_subcommand _log_arguments + ;; + (ls) + _arguments \ + '(-v --headers)'{-v,--headers}'[Print table headers (Hash, Size, Name).]' \ + '--resolve-type[Resolve linked objects to find out their types. Default: true.]' \ + '--size[Resolve linked objects to find out their file size. Default: true.]' \ + '(-s --stream)'{-s,--stream}'[Enable exprimental streaming of directory entries as they are traversed.]' \ + ;; + (mount) + _arguments \ + '(-f --ipfs-path)'{-f,--ipfs-path}'[The path where IPFS should be mounted.]' \ + '(-n --ipns-path)'{-n,--ipns-path}'[The path where IPNS should be mounted.]' + ;; + (name) + local -a _name_arguments + _name_arguments=( + 'publish:Publish IPNS names.' + 'pubsub:IPNS pubsub management.' + 'resolve:Resolve IPNS names.' + ) + _ipfs_subcommand _name_arguments + ;; + (object) + local -a _object_arguments + _object_arguments=( + 'data:Output the raw bytes of an IPFS object.' + 'diff:Display the diff between two ipfs objects.' + 'get:Get and serialize the DAG node named by .' + 'links:Output the links pointed to by the specified object.' + 'new:Create a new object from an ipfs template.' + 'patch:Create a new merkledag object based on an existing one.' + 'put:Store input as a DAG object, print its key.' + 'stat:Get stats for the DAG node named by .' + ) + _ipfs_subcommand _object_arguments + ;; + (p2p) + local -a _p2p_arguments + _p2p_arguments=( + 'close:Stop listening for new connections to forward.' + 'forward:Forward connections to libp2p service' + 'listen:Create libp2p service' + 'ls:List active p2p listeners.' + 'stream:P2P stream management.' + ) + _ipfs_subcommand _p2p_arguments + ;; + (pin) + local -a _pin_arguments + _pin_arguments=( + 'add:Pin objects to local storage.' + 'ls:List objects pinned to local storage.' + 'rm:Remove pinned objects from local storage.' + 'update:Update a recursive pin' + 'verify:Verify that recursive pins are complete.' + ) + _ipfs_subcommand _pin_arguments + ;; + (ping) + _arguments '(-n --count)'{-n,--count}'[Number of ping messages to send. Default: 10.]' + ;; + (refs) + _arguments \ + '--format[Emit edges with given format. Available tokens: . Default: .]' \ + '(-e --edges)'{-e,--edges}'[Emit edge format: ` -> `.]' \ + '(-u --unique)'{-u,--unique}'[Omit duplicate refs from output.]' \ + '(-r --recursive)'{-r,--recursive}'[Recursively list links of child nodes.]' \ + '--max-depth[Only for recursive refs, limits fetch and listing to the given depth. Default: -1.]' + local -a _refs_arguments + _refs_arguments='local:List all local references.' + _ipfs_subcommand _refs_arguments + ;; + (repo) + local -a _repo_arguments + _repo_arguments=( + 'fsck:Remove repo lockfiles.' + 'gc:Perform a garbage collection sweep on the repo.' + 'stat:Get stats for the currently used repo.' + 'verify:Verify all blocks in repo are not corrupted.' + 'version:Show the repo version.' + ) + _ipfs_subcommand _repo_arguments + ;; + (resolve) + _arguments \ + '(-r --recursive)'{-r,--recursive}'[Resolve until the result is an IPFS name. Default: true.]' \ + '(--dhtrc --dht-record-count)'{--dhtrc,--dht-record-count}'[Number of records to request for DHT resolution.]' \ + '(--dhtt --dht-timeout)'{--dhtt,--dht-timeout}'[Max time to collect values during DHT resolution eg "30s". Pass 0 for no timeout.]' + ;; + (stats) + local -a _stats_arguments + _stats_arguments=( + 'bitswap:Show some diagnostic information on the bitswap agent.' + 'bw:Print ipfs bandwidth information.' + 'repo:Get stats for the currently used repo.' + ) + _ipfs_subcommand _stats_arguments + ;; + (swarm) + local -a _swarm_arguments + _swarm_arguments=( + 'addrs:List known addresses. Useful for debugging.' + 'connect:Open connection to a given address.' + 'disconnect:Close connection to a given address.' + 'filters:Manipulate address filters.' + 'peers:List peers with open connections.' + ) + _ipfs_subcommand _swarm_arguments + ;; + (tar) + local -a _tar_arguments + _tar_arguments=( + 'add:Import a tar file into ipfs.' + 'cat:Export a tar file from IPFS.' + ) + _ipfs_subcommand _tar_arguments + ;; + (version) + _arguments \ + '(-n --number)'{-n,--number}'[Only show the version number.]' \ + '--commit[Show the commit hash.]' \ + '--repo[Show repo version.]' \ + '--all[Show all version information.]' + ;; +esac diff --git a/zsh/plugins/jenv/jenv.plugin.zsh b/zsh/plugins/jenv/jenv.plugin.zsh index 2eda803..946ce18 100644 --- a/zsh/plugins/jenv/jenv.plugin.zsh +++ b/zsh/plugins/jenv/jenv.plugin.zsh @@ -1,4 +1,4 @@ -jenvdirs=("$HOME/.jenv" "/usr/local" "/usr/local/jenv" "/opt/jenv") +jenvdirs=("$HOME/.jenv" "/usr/local/bin/jenv" "/usr/local/jenv" "/opt/jenv") FOUND_JENV=0 for jenvdir in $jenvdirs; do @@ -15,7 +15,7 @@ if [[ $FOUND_JENV -eq 0 ]]; then fi if [[ $FOUND_JENV -eq 1 ]]; then - export PATH="${jenvdir}/bin:$PATH" + (( $+commands[jenv] )) || export PATH="${jenvdir}/bin:$PATH" eval "$(jenv init - zsh)" function jenv_prompt_info() { jenv version-name 2>/dev/null } diff --git a/zsh/plugins/jfrog/README.md b/zsh/plugins/jfrog/README.md new file mode 100644 index 0000000..1d85862 --- /dev/null +++ b/zsh/plugins/jfrog/README.md @@ -0,0 +1,11 @@ +# JFrog CLI + +This plugin provides completion for [JFrog CLI](https://github.com/jfrog/jfrog-cli). + +JFrog CLI provides a simple interface that automates access to [Artifactory](https://jfrog.com/artifactory), [Xray](https://jfrog.com/xray), [Bintray](https://jfrog.com/bintray) and [Mission Control](https://jfrog.com/mission-control) through their respective REST APIs. + +To use it, add `jfrog` to the plugins array in your zshrc file: + +```zsh +plugins=(... jfrog) +``` diff --git a/zsh/plugins/jfrog/jfrog.plugin.zsh b/zsh/plugins/jfrog/jfrog.plugin.zsh new file mode 100644 index 0000000..064ffa2 --- /dev/null +++ b/zsh/plugins/jfrog/jfrog.plugin.zsh @@ -0,0 +1,10 @@ +_jfrog() { + local -a opts + opts=("${(@f)$(_CLI_ZSH_AUTOCOMPLETE_HACK=1 ${words[@]:0:#words[@]-1} --generate-bash-completion)}") + _describe 'values' opts + if [[ $compstate[nmatches] -eq 0 && $words[$CURRENT] != -* ]]; then + _files + fi +} + +compdef _jfrog jfrog \ No newline at end of file diff --git a/zsh/plugins/jhbuild/README.md b/zsh/plugins/jhbuild/README.md index 9105269..3220e0d 100644 --- a/zsh/plugins/jhbuild/README.md +++ b/zsh/plugins/jhbuild/README.md @@ -1,4 +1,34 @@ -## JHBuild +# JHBuild + +This plugin adds some [JHBuild](https://developer.gnome.org/jhbuild/) aliases. + +To use it, add `jhbuild` to the plugins array of your zshrc file: + +```zsh +plugins=(... jhbuild) +``` + **Maintainer:** [Miguel Vaello](https://github.com/miguxbe) -This plugin adds some jhbuild aliases and increase the completion function provided by zsh. +## Aliases + +| Alias | Command | +|---------|---------------------------| +| `jh` | `jhbuild` | +| `jhb` | `jhbuild build` | +| `jhbo` | `jhbuild buildone` | +| `jhckb` | `jhbuild checkbranches` | +| `jhckm` | `jhbuild checkmodulesets` | +| `jhi` | `jhbuild info` | +| `jhl` | `jhbuild list` | +| `jhc` | `jhbuild clean` | +| `jhco` | `jhbuild cleanone` | +| `jhm` | `jhbuild make` | +| `jhr` | `jhbuild run` | +| `jhrd` | `jhbuild rdepends` | +| `jhsd` | `jhbuild sysdeps` | +| `jhu` | `jhbuild update` | +| `jhuo` | `jhbuild updateone` | +| `jhun` | `jhbuild uninstall` | +| `jhsh` | `jhbuild shell` | +| `jht` | `jhbuild tinderbox` | diff --git a/zsh/plugins/jhbuild/jhbuild.plugin.zsh b/zsh/plugins/jhbuild/jhbuild.plugin.zsh index fed1bc9..416745d 100644 --- a/zsh/plugins/jhbuild/jhbuild.plugin.zsh +++ b/zsh/plugins/jhbuild/jhbuild.plugin.zsh @@ -1,5 +1,6 @@ -# Aliases -# +# JHBuild Aliases + +# Base alias jh='jhbuild' # Build alias jhb='jhbuild build' @@ -7,12 +8,14 @@ alias jhbo='jhbuild buildone' # Checks alias jhckb='jhbuild checkbranches' alias jhckm='jhbuild checkmodulesets' -# Info & list +# Info & List alias jhi='jhbuild info' alias jhl='jhbuild list' # Clean alias jhc='jhbuild clean' alias jhco='jhbuild cleanone' +# Make +alias jhm='jhbuild make' # Run alias jhr='jhbuild run' # Depends @@ -23,6 +26,7 @@ alias jhu='jhbuild update' alias jhuo='jhbuild updateone' # Uninstall alias jhun='jhbuild uninstall' - - - +# Shell +alias jhsh='jhbuild shell' +# Tinderbox +alias jht='jhbuild tinderbox' diff --git a/zsh/plugins/jira/README.md b/zsh/plugins/jira/README.md index 091dccb..a5633af 100644 --- a/zsh/plugins/jira/README.md +++ b/zsh/plugins/jira/README.md @@ -19,10 +19,14 @@ jira # performs the default action jira new # opens a new issue jira dashboard # opens your JIRA dashboard +jira tempo # opens your JIRA Tempo jira reported [username] # queries for issues reported by a user jira assigned [username] # queries for issues assigned to a user jira myissues # queries for you own issues jira branch # opens an existing issue matching the current branch name + # The branch name may have prefixes ending in "/": "feature/MP-1234", + # and also suffixes starting with "_": "MP-1234_fix_dashboard" + # In both these cases, the issue opened will be "MP-1234" jira ABC-123 # opens an existing issue jira ABC-123 m # opens an existing issue for adding a comment ``` diff --git a/zsh/plugins/jira/_jira b/zsh/plugins/jira/_jira index d646142..1ac3eed 100644 --- a/zsh/plugins/jira/_jira +++ b/zsh/plugins/jira/_jira @@ -5,6 +5,7 @@ local -a _1st_arguments _1st_arguments=( 'new:create a new issue' 'dashboard:open the dashboard' + 'tempo:open the tempo' 'reported:search for issues reported by a user' 'assigned:search for issues assigned to a user' 'branch:open the issue named after the git branch of the current directory' diff --git a/zsh/plugins/jira/jira.plugin.zsh b/zsh/plugins/jira/jira.plugin.zsh index e706948..22807e0 100644 --- a/zsh/plugins/jira/jira.plugin.zsh +++ b/zsh/plugins/jira/jira.plugin.zsh @@ -54,6 +54,9 @@ function jira() { else open_command "${jira_url}/secure/Dashboard.jspa" fi + elif [[ "$action" == "tempo" ]]; then + echo "Opening tempo" + open_command "${jira_url}/secure/Tempo.jspa" elif [[ "$action" == "dumpconfig" ]]; then echo "JIRA_URL=$jira_url" echo "JIRA_PREFIX=$jira_prefix" @@ -63,25 +66,33 @@ function jira() { else # Anything that doesn't match a special action is considered an issue name # but `branch` is a special case that will parse the current git branch + local issue_arg issue if [[ "$action" == "branch" ]]; then - local issue_arg=$(git rev-parse --abbrev-ref HEAD) - local issue="${jira_prefix}${issue_arg}" + # Get name of the branch + issue_arg=$(git rev-parse --abbrev-ref HEAD) + # Strip prefixes like feature/ or bugfix/ + issue_arg=${issue_arg##*/} + # Strip suffixes starting with _ + issue_arg=(${(s:_:)issue_arg}) + issue_arg=${issue_arg[1]} + if [[ "$issue_arg" = ${jira_prefix}* ]]; then + issue="${issue_arg}" + else + issue="${jira_prefix}${issue_arg}" + fi else - local issue_arg=$action - local issue="${jira_prefix}${issue_arg}" + issue_arg=${(U)action} + issue="${jira_prefix}${issue_arg}" fi - local url_fragment='' + + local url_fragment if [[ "$2" == "m" ]]; then url_fragment="#add-comment" echo "Add comment to issue #$issue" else echo "Opening issue #$issue" fi - if [[ "$JIRA_RAPID_BOARD" == "true" ]]; then - open_command "${jira_url}/issues/${issue}${url_fragment}" - else - open_command "${jira_url}/browse/${issue}${url_fragment}" - fi + open_command "${jira_url}/browse/${issue}${url_fragment}" fi } diff --git a/zsh/plugins/jruby/README.md b/zsh/plugins/jruby/README.md new file mode 100644 index 0000000..821a46d --- /dev/null +++ b/zsh/plugins/jruby/README.md @@ -0,0 +1,21 @@ +# JRuby plugin + +This plugin adds aliases for [JRuby](https://www.jruby.org/). + +To use it, add `jruby` to the plugins array in your zshrc file: + +```zsh +plugins=(... jruby) +``` + +## Requirements + +This plugin assumes you already have jruby installed and available in your [path](https://www.jruby.org/getting-started). + +## Aliases + +| Alias | Command | +| ------------ | ---------------------------------------------------------------- | +| `jrspec` | `jruby --debug -S rspec --debug` | +| `jprofile` | `jruby --profile.api -S rspec` | +| `jexec` | `jruby -S` | diff --git a/zsh/plugins/jsontools/README.md b/zsh/plugins/jsontools/README.md index 4faf58b..1fa2b8e 100644 --- a/zsh/plugins/jsontools/README.md +++ b/zsh/plugins/jsontools/README.md @@ -2,41 +2,47 @@ Handy command line tools for dealing with json data. -## Tools +To use it, add `jsontools` to the plugins array in your zshrc file: -- **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 +```zsh +plugins=(... jsontools) +``` ## Usage -Usage is simple...just take your json data and pipe it into the appropriate jsontool. -```sh - | -``` -## Examples -##### pp_json +Usage is simple... just take your json data and pipe it into the appropriate jsontool: + +- `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. + +### Examples + +- **pp_json**: ```sh # curl json data and pretty print the results curl https://coderwall.com/bobwilliams.json | pp_json ``` -##### is_json +- **is_json**: + ```sh -# pretty print the contents of an existing json file +# Validate if file's content conforms to a valid JSON schema less data.json | is_json ``` -##### urlencode_json +- **urlencode_json**: + ```sh # json data directly from the command line echo '{"b":2, "a":1}' | urlencode_json ``` -##### urldecode_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/zsh/plugins/jsontools/jsontools.plugin.zsh b/zsh/plugins/jsontools/jsontools.plugin.zsh index 20d5eb1..912c835 100644 --- a/zsh/plugins/jsontools/jsontools.plugin.zsh +++ b/zsh/plugins/jsontools/jsontools.plugin.zsh @@ -11,9 +11,10 @@ if [[ $(whence node) != "" && ( "x$JSONTOOLS_METHOD" = "x" || "x$JSONTOOLS_METH 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 pp_json='python -c "import sys; del sys.path[0]; import runpy; runpy._run_module_as_main(\"json.tool\")"' alias is_json='python -c " -import json, sys; +import sys; del sys.path[0]; +import json; try: json.loads(sys.stdin.read()) except ValueError, e: @@ -22,11 +23,13 @@ else: print True sys.exit(0)"' alias urlencode_json='python -c " -import urllib, json, sys; +import sys; del sys.path[0]; +import urllib, json; print urllib.quote_plus(sys.stdin.read()) sys.exit(0)"' alias urldecode_json='python -c " -import urllib, json, sys; +import sys; del sys.path[0]; +import urllib, json; print urllib.unquote_plus(sys.stdin.read()) sys.exit(0)"' elif [[ $(whence ruby) != "" && ( "x$JSONTOOLS_METHOD" = "x" || "x$JSONTOOLS_METHOD" = "xruby" ) ]]; then @@ -36,4 +39,4 @@ elif [[ $(whence ruby) != "" && ( "x$JSONTOOLS_METHOD" = "x" || "x$JSONTOOLS_MET alias urldecode_json='ruby -e "require \"uri\"; puts URI.unescape(STDIN.read)"' fi -unset JSONTOOLS_METHOD \ No newline at end of file +unset JSONTOOLS_METHOD diff --git a/zsh/plugins/jump/README.md b/zsh/plugins/jump/README.md index ed64152..1b0ce68 100644 --- a/zsh/plugins/jump/README.md +++ b/zsh/plugins/jump/README.md @@ -17,3 +17,15 @@ plugins=(... jump) | `mark [mark-name]` | Create a mark with the given name or with the name of the current directory if none is provided | | `unmark ` | Remove the given mark | | `marks` | List the existing marks and the directories they point to | + +## Key bindings + +Pressing `CTRL`+`G` substitutes the written mark name for the full path of the mark. +For example, with a mark named `mymark` pointing to `/path/to/my/mark`: +```zsh +$ cp /tmp/file mymark +``` +will become: +```zsh +$ cp /tmp/file /path/to/my/mark +``` diff --git a/zsh/plugins/jump/jump.plugin.zsh b/zsh/plugins/jump/jump.plugin.zsh index d161a6d..c2da114 100644 --- a/zsh/plugins/jump/jump.plugin.zsh +++ b/zsh/plugins/jump/jump.plugin.zsh @@ -9,33 +9,34 @@ export MARKPATH=$HOME/.marks jump() { - cd -P "$MARKPATH/$1" 2>/dev/null || {echo "No such mark: $1"; return 1} + builtin cd -P "$MARKPATH/$1" 2>/dev/null || {echo "No such mark: $1"; return 1} } mark() { - if [[ ( $# == 0 ) || ( "$1" == "." ) ]]; then - MARK=$(basename "$PWD") + if [[ $# -eq 0 || "$1" = "." ]]; then + MARK=${PWD:t} else MARK="$1" fi - if read -q \?"Mark $PWD as ${MARK}? (y/n) "; then - mkdir -p "$MARKPATH"; ln -sfn "$PWD" "$MARKPATH/$MARK" + if read -q "?Mark $PWD as ${MARK}? (y/n) "; then + command mkdir -p "$MARKPATH" + command ln -sfn "$PWD" "$MARKPATH/$MARK" fi } unmark() { - rm -i "$MARKPATH/$1" + LANG= command rm -i "$MARKPATH/$1" } marks() { - local max=0 - for link in $MARKPATH/*(@); do + local link max=0 + for link in $MARKPATH/{,.}*(@N); do if [[ ${#link:t} -gt $max ]]; then max=${#link:t} fi done local printf_markname_template="$(printf -- "%%%us " "$max")" - for link in $MARKPATH/*(@); do + for link in $MARKPATH/{,.}*(@N); do local markname="$fg[cyan]${link:t}$reset_color" local markpath="$fg[blue]$(readlink $link)$reset_color" printf -- "$printf_markname_template" "$markname" @@ -44,21 +45,15 @@ marks() { } _completemarks() { - if [[ $(ls "${MARKPATH}" | wc -l) -gt 1 ]]; then - reply=($(ls $MARKPATH/**/*(-) | grep : | sed -E 's/(.*)\/([_a-zA-Z0-9\.\-]*):$/\2/g')) - else - if readlink -e "${MARKPATH}"/* &>/dev/null; then - reply=($(ls "${MARKPATH}")) - fi - fi + reply=("${MARKPATH}"/{,.}*(@N:t)) } compctl -K _completemarks jump compctl -K _completemarks unmark _mark_expansion() { - setopt extendedglob + setopt localoptions extendedglob autoload -U modify-current-argument - modify-current-argument '$(readlink "$MARKPATH/$ARG")' + modify-current-argument '$(readlink "$MARKPATH/$ARG" || echo "$ARG")' } zle -N _mark_expansion bindkey "^g" _mark_expansion diff --git a/zsh/plugins/keychain/keychain.plugin.zsh b/zsh/plugins/keychain/keychain.plugin.zsh index af34793..f122f79 100644 --- a/zsh/plugins/keychain/keychain.plugin.zsh +++ b/zsh/plugins/keychain/keychain.plugin.zsh @@ -1,4 +1,9 @@ -function _start_agent() { +(( $+commands[keychain] )) || return + +# Define SHORT_HOST if not defined (%m = host name up to first .) +SHORT_HOST=${SHORT_HOST:-${(%):-%m}} + +function { local agents local -a identities local -a options @@ -15,7 +20,7 @@ function _start_agent() { zstyle -a :omz:plugins:keychain options options # start keychain... - keychain ${^options:-} --agents ${agents:-gpg} ${^identities} + keychain ${^options:-} --agents ${agents:-gpg} ${^identities} --host $SHORT_HOST # Get the filenames to store/lookup the environment from _keychain_env_sh="$HOME/.keychain/$SHORT_HOST-sh" @@ -25,8 +30,3 @@ function _start_agent() { [ -f "$_keychain_env_sh" ] && . "$_keychain_env_sh" [ -f "$_keychain_env_sh_gpg" ] && . "$_keychain_env_sh_gpg" } - -_start_agent - -# tidy up after ourselves -unfunction _start_agent diff --git a/zsh/plugins/kitchen/_kitchen b/zsh/plugins/kitchen/_kitchen index 29a3125..d93d93d 100644 --- a/zsh/plugins/kitchen/_kitchen +++ b/zsh/plugins/kitchen/_kitchen @@ -67,7 +67,7 @@ _kitchen() { _kitchen_commands() { local commands - commands=("${(@f)$(_call_program commands $service help | sed -n 's/^ kitchen \([[:alpha:]]*\) [ [].*# \(.*\)$/\1:\2/p')}") + commands=("${(@f)$(_call_program commands $service help | sed -n 's/^ kitchen \([[:alpha:]]*\) [ A-Z[].*# \(.*\)$/\1:\2/p')}") _describe -t commands 'kitchen commands' commands } diff --git a/zsh/plugins/knife/README.md b/zsh/plugins/knife/README.md new file mode 100644 index 0000000..b167f16 --- /dev/null +++ b/zsh/plugins/knife/README.md @@ -0,0 +1,25 @@ +# knife plugin + +This plugin adds completion for [knife](https://docs.chef.io/knife.html), a command-line tool +to interact with [Chef](https://chef.io), a platform to automate and manage infrastructure via +code. + +To use it, add `knife` to the plugins array in your zshrc file: +```zsh +plugins=(... knife) +``` + +## Options + +- `KNIFE_RELATIVE_PATH`: if set to `true`, the completion script will look for local cookbooks + under the `cookbooks` folder in the chef root directory. It has preference over the other two + options below. **Default:** empty. + +- `KNIFE_COOKBOOK_PATH`: if set, it points to the folder that contains local cookbooks, for + example: `/path/to/my/chef/cookbooks`. **Default:** `cookbook_path` field in `knife.rb` + (see below). + +- `KNIFE_CONF_PATH`: variable pointing to the `knife.rb` configuration file, for example + `/path/to/my/.chef/knife.rb`. Only used if `$KNIFE_COOKBOOK_PATH` isn't set. If it exists, + `$PWD/.chef/knife.rb` is used instead. Otherwise, if it's set, its value is used. + **Default**: `$HOME/.chef/knife.rb`. diff --git a/zsh/plugins/knife/_knife b/zsh/plugins/knife/_knife index 0d61ff1..09757eb 100644 --- a/zsh/plugins/knife/_knife +++ b/zsh/plugins/knife/_knife @@ -3,13 +3,13 @@ # You can override the path to knife.rb and your cookbooks by setting # KNIFE_CONF_PATH=/path/to/my/.chef/knife.rb # KNIFE_COOKBOOK_PATH=/path/to/my/chef/cookbooks -# If you want your local cookbooks path to be calculated relative to where you are then +# If you want your local cookbooks path to be calculated relative to where you are then # set the below option -# KNIFE_RELATIVE_PATH=true +# KNIFE_RELATIVE_PATH=true # Read around where these are used for more detail. # These flags should be available everywhere according to man knife -knife_general_flags=( --help --server-url --key --config --editor --format --log_level --logfile --no-editor --user --print-after --version --yes ) +knife_general_flags=(--help --server-url --key --config --editor --format --log_level --logfile --no-editor --user --print-after --version --yes) # knife has a very special syntax, some example calls are: # knife status @@ -25,183 +25,200 @@ _knife() { typeset -A opt_args cloudproviders=(bluebox ec2 rackspace slicehost terremark) _arguments \ - '1: :->knifecmd'\ - '2: :->knifesubcmd'\ + '1: :->knifecmd' \ + '2: :->knifesubcmd' \ '3: :->knifesubcmd2' \ '4: :->knifesubcmd3' \ '5: :->knifesubcmd4' \ '6: :->knifesubcmd5' - + case $state in knifecmd) - compadd -Q "$@" bootstrap client configure cookbook "cookbook site" "data bag" diff exec environment index node recipe role search ssh status upload vault windows $cloudproviders - ;; + compadd -Q "$@" bootstrap client configure cookbook "cookbook site" "data bag" diff exec environment index node recipe role search solo ssh status upload vault windows $cloudproviders + ;; knifesubcmd) case $words[2] in - (bluebox|ec2|rackspace|slicehost|terremark) + bluebox|ec2|rackspace|slicehost|terremark) compadd "$@" server images - ;; + ;; client) compadd -Q "$@" "bulk delete" list create show delete edit reregister - ;; + ;; configure) compadd "$@" client - ;; + ;; cookbook) compadd -Q "$@" test list create download delete "metadata from" show "bulk delete" metadata upload - ;; + ;; diff) _arguments '*:file or directory:_files -g "*"' - ;; + ;; environment) compadd -Q "$@" list create delete edit show "from file" - ;; + ;; node) - compadd -Q "$@" "from file" create show edit delete list run_list "bulk delete" - ;; + compadd -Q "$@" "from file" create show edit delete list run_list "bulk delete" + ;; recipe) - compadd "$@" list - ;; + compadd "$@" list + ;; role) compadd -Q "$@" "bulk delete" create delete edit "from file" list show - ;; + ;; + solo) + compadd "$@" bootstrap clean cook init prepare + ;; upload) - _arguments '*:file or directory:_files -g "*"' - ;; + _arguments '*:file or directory:_files -g "*"' + ;; vault) compadd -Q "$@" create decrypt delete edit remove "rotate all keys" "rotate keys" show update - ;; + ;; windows) compadd "$@" bootstrap - ;; + ;; *) - _arguments '2:Subsubcommands:($(_knife_options1))' + _arguments '2:Subsubcommands:($(_knife_options1))' + ;; esac - ;; - knifesubcmd2) + ;; + knifesubcmd2) case $words[3] in - server) + server) compadd "$@" list create delete - ;; - images) + ;; + images) compadd "$@" list - ;; - site) + ;; + site) compadd "$@" vendor show share search download list unshare - ;; - (show|delete|edit) - _arguments '3:Subsubcommands:($(_chef_$words[2]s_remote))' - ;; - (upload|test) - _arguments '3:Subsubcommands:($(_chef_$words[2]s_local) --all)' - ;; + ;; + show|delete|edit) + _arguments '3:Subsubcommands:($(_chef_$words[2]s_remote))' + ;; + upload|test) + _arguments '3:Subsubcommands:($(_chef_$words[2]s_local) --all)' + ;; list) - compadd -a "$@" knife_general_flags - ;; + compadd -a "$@" knife_general_flags + ;; bag) compadd -Q "$@" show edit list "from file" create delete - ;; + ;; + bootstrap|clean|cook|prepare) + compadd "$@" nodes/*.json(N:t:r) + ;; + init) + compadd "$@" ./*(/N:t) + ;; *) _arguments '3:Subsubcommands:($(_knife_options2))' + ;; esac - ;; - knifesubcmd3) - case $words[3] in - show) - case $words[2] in - cookbook) - versioncomp=1 - _arguments '4:Cookbookversions:($(_cookbook_versions) latest)' - ;; - (node|client|role) - compadd "$@" --attribute - esac - esac - case $words[4] in - (show|edit) - _arguments '4:Subsubsubcommands:($(_chef_$words[2]_$words[3]s_remote))' ;; - file) + knifesubcmd3) + case $words[3] in + show) + case $words[2] in + cookbook) + versioncomp=1 + _arguments '4:Cookbookversions:($(_cookbook_versions) latest)' + ;; + node|client|role) + compadd "$@" --attribute + ;; + esac + ;; + esac + case $words[4] in + show|edit) + _arguments '4:Subsubsubcommands:($(_chef_$words[2]_$words[3]s_remote))' + ;; + file) case $words[2] in environment) _arguments '*:files:_path_files -g "*.(rb|json)" -W "$(_chef_root)/environments"' - ;; + ;; node) _arguments '*:files:_path_files -g "*.(rb|json)" -W "$(_chef_root)/nodes"' - ;; + ;; role) _arguments '*:files:_path_files -g "*.(rb|json)" -W "$(_chef_root)/roles"' - ;; + ;; *) _arguments '*:Subsubcommands:($(_knife_options3))' - esac - ;; - list) - compadd -a "$@" knife_general_flags - ;; - *) - _arguments '*:Subsubcommands:($(_knife_options3))' + ;; + esac + ;; + list) + compadd -a "$@" knife_general_flags + ;; + *) + _arguments '*:Subsubcommands:($(_knife_options3))' + ;; esac ;; - knifesubcmd4) - if (( versioncomp > 0 )); then - compadd "$@" attributes definitions files libraries providers recipes resources templates - else - case $words[5] in - file) - _arguments '*:directory:_path_files -/ -W "$(_chef_root)/data_bags" -qS \ ' + knifesubcmd4) + if ((versioncomp > 0)); then + compadd "$@" attributes definitions files libraries providers recipes resources templates + else + case $words[5] in + file) + _arguments '*:directory:_path_files -/ -W "$(_chef_root)/data_bags" -qS \ ' ;; - *) _arguments '*:Subsubcommands:($(_knife_options2))' + *) _arguments '*:Subsubcommands:($(_knife_options2))' ;; esac - fi - ;; - knifesubcmd5) - case $words[5] in - file) - _arguments '*:files:_path_files -g "*.json" -W "$(_chef_root)/data_bags/$words[6]"' - ;; - *) - _arguments '*:Subsubcommands:($(_knife_options3))' - esac - esac + fi + ;; + knifesubcmd5) + case $words[5] in + file) + _arguments '*:files:_path_files -g "*.json" -W "$(_chef_root)/data_bags/$words[6]"' + ;; + *) + _arguments '*:Subsubcommands:($(_knife_options3))' + ;; + esac + ;; + esac } # Helper functions to provide the argument completion for several depths of commands _knife_options1() { - ( for line in $( knife $words[2] --help | grep -v "^knife" ); do echo $line | grep "\-\-"; done ) + (for line in $(knife $words[2] --help | grep -v "^knife"); do echo $line | grep "\-\-"; done) } _knife_options2() { - ( for line in $( knife $words[2] $words[3] --help | grep -v "^knife" ); do echo $line | grep "\-\-"; done ) + (for line in $(knife $words[2] $words[3] --help | grep -v "^knife"); do echo $line | grep "\-\-"; done) } _knife_options3() { - ( for line in $( knife $words[2] $words[3] $words[4] --help | grep -v "^knife" ); do echo $line | grep "\-\-"; done ) + (for line in $(knife $words[2] $words[3] $words[4] --help | grep -v "^knife"); do echo $line | grep "\-\-"; done) } # The chef_x_remote functions use knife to get a list of objects of type x on the server _chef_roles_remote() { - (knife role list --format json | grep \" | awk '{print $1}' | awk -F"," '{print $1}' | awk -F"\"" '{print $2}') + (knife role list --format json | grep \" | awk '{print $1}' | awk -F"," '{print $1}' | awk -F"\"" '{print $2}') } _chef_clients_remote() { - (knife client list --format json | grep \" | awk '{print $1}' | awk -F"," '{print $1}' | awk -F"\"" '{print $2}') + (knife client list --format json | grep \" | awk '{print $1}' | awk -F"," '{print $1}' | awk -F"\"" '{print $2}') } _chef_nodes_remote() { - (knife node list --format json | grep \" | awk '{print $1}' | awk -F"," '{print $1}' | awk -F"\"" '{print $2}') + (knife node list --format json | grep \" | awk '{print $1}' | awk -F"," '{print $1}' | awk -F"\"" '{print $2}') } _chef_cookbooks_remote() { - (knife cookbook list --format json | grep \" | awk '{print $1}' | awk -F"," '{print $1}' | awk -F"\"" '{print $2}') + (knife cookbook list --format json | grep \" | awk '{print $1}' | awk -F"," '{print $1}' | awk -F"\"" '{print $2}') } _chef_sitecookbooks_remote() { - (knife cookbook site list --format json | grep \" | awk '{print $1}' | awk -F"," '{print $1}' | awk -F"\"" '{print $2}') + (knife cookbook site list --format json | grep \" | awk '{print $1}' | awk -F"," '{print $1}' | awk -F"\"" '{print $2}') } _chef_data_bags_remote() { - (knife data bag list --format json | grep \" | awk '{print $1}' | awk -F"," '{print $1}' | awk -F"\"" '{print $2}') + (knife data bag list --format json | grep \" | awk '{print $1}' | awk -F"," '{print $1}' | awk -F"\"" '{print $2}') } _chef_environments_remote() { @@ -210,14 +227,14 @@ _chef_environments_remote() { # The chef_x_local functions use the knife config to find the paths of relevant objects x to be uploaded to the server _chef_cookbooks_local() { - if [ $KNIFE_RELATIVE_PATH ]; then + if [ $KNIFE_RELATIVE_PATH ]; then local cookbook_path="$(_chef_root)/cookbooks" - else + else local knife_rb=${KNIFE_CONF_PATH:-${HOME}/.chef/knife.rb} if [ -f ./.chef/knife.rb ]; then knife_rb="./.chef/knife.rb" fi - local cookbook_path=${KNIFE_COOKBOOK_PATH:-$(grep cookbook_path $knife_rb | awk 'BEGIN {FS = "[" }; {print $2}' | sed 's/\,//g' | sed "s/'//g" | sed 's/\(.*\)]/\1/' )} + local cookbook_path=${KNIFE_COOKBOOK_PATH:-$(grep cookbook_path $knife_rb | awk 'BEGIN {FS = "[" }; {print $2}' | sed 's/\,//g' | sed "s/'//g" | sed 's/\(.*\)]/\1/')} fi (for i in $cookbook_path; do ls $i; done) } @@ -227,12 +244,11 @@ _cookbook_versions() { (knife cookbook show $words[4] | grep -v $words[4] | grep -v -E '\]|\[|\{|\}' | sed 's/ //g' | sed 's/"//g') } -# Searches up from current directory to find the closest folder that has a .chef folder -# Useful for the knife upload/from file commands -_chef_root () { +# Searches up from current directory to find the closest folder that has a .chef folder +# Useful for the knife upload/from file commands +_chef_root() { directory="$PWD" - while [ $directory != '/' ] - do + while [ $directory != '/' ]; do test -e "$directory/.chef" && echo "$directory" && return directory="${directory:h}" done diff --git a/zsh/plugins/knife_ssh/README.md b/zsh/plugins/knife_ssh/README.md new file mode 100644 index 0000000..cb836b7 --- /dev/null +++ b/zsh/plugins/knife_ssh/README.md @@ -0,0 +1,14 @@ +# knife_ssh plugin + +This plugin adds a `knife_ssh` function as well as completion for it, to allow +connecting via ssh to servers managed with [Chef](https://www.chef.io/). + +To use it, add `knife_ssh` to the plugins array in your zshrc file: +```zsh +plugins=(... knife_ssh) +``` + +The plugin creates a cache of the Chef node list via `knife`, and stores it +in `$HOME/.knife_comp~`, when first triggering knife_ssh completion. + +**Requirements:** `knife` has to be installed. diff --git a/zsh/plugins/knife_ssh/knife_ssh.plugin.zsh b/zsh/plugins/knife_ssh/knife_ssh.plugin.zsh index 7fdd42a..dc425a3 100644 --- a/zsh/plugins/knife_ssh/knife_ssh.plugin.zsh +++ b/zsh/plugins/knife_ssh/knife_ssh.plugin.zsh @@ -1,17 +1,17 @@ function knife_ssh() { - grep -q $1 ~/.knife_comp~ 2> /dev/null || rm -f ~/.knife_comp~; + grep -q $1 ~/.knife_comp~ 2> /dev/null || rm -f ~/.knife_comp~ ssh $(knife node show $1 | awk '/IP:/{print $2}') } _knife_ssh() { if hash knife 2>/dev/null; then if [[ ! -f ~/.knife_comp~ ]]; then - echo "\nGenerating ~/.knife_comp~..." >/dev/stderr + echo "\nGenerating ~/.knife_comp~..." >&2 knife node list > ~/.knife_comp~ fi - compadd $(<~/.knife_comp~) + compadd $(< ~/.knife_comp~) else - echo "Could not find knife" > /dev/stderr; + echo "Could not find knife" >&2 fi } diff --git a/zsh/plugins/kube-ps1/README.md b/zsh/plugins/kube-ps1/README.md index 82c0a77..b08997b 100644 --- a/zsh/plugins/kube-ps1/README.md +++ b/zsh/plugins/kube-ps1/README.md @@ -1,104 +1,238 @@ -# Kubernetes prompt for zsh +kube-ps1: Kubernetes prompt for bash and zsh +============================================ -A Kubernetes zsh prompt that displays the current cluster cluster -and the namespace. +A script that lets you add the current Kubernetes context and namespace +configured on `kubectl` to your Bash/Zsh prompt strings (i.e. the `$PS1`). -Inspired by several tools used to simplify usage of kubectl +Inspired by several tools used to simplify usage of `kubectl`. -NOTE: If you are not using zsh, check out [kube-ps1](https://github.com/jonmosco/kube-ps1) -designed for bash as well as zsh. +## Installing + +### MacOS + +Homebrew package manager: + +``` +$ brew update +$ brew install kube-ps1 +``` +### From Source + +1. Clone this repository +2. Source the kube-ps1.sh in your `~/.zshrc` or your `~/.bashrc` + +### Arch Linux +AUR Package available at [https://aur.archlinux.org/packages/kube-ps1/](https://aur.archlinux.org/packages/kube-ps1/). + +#### Zsh +```sh +source /path/to/kube-ps1.sh +PROMPT='$(kube_ps1)'$PROMPT +``` +#### Bash +```sh +source /path/to/kube-ps1.sh +PS1='[\u@\h \W $(kube_ps1)]\$ ' +``` + +### Zsh Plugin Managers + +#### Using [zplugin](https://github.com/zdharma/zplugin) + +Update `.zshrc` with: +```sh +zplugin light jonmosco/kube-ps1 +PROMPT='$(kube_ps1)'$PROMPT +``` ## Requirements -The default prompt assumes you have the kubectl command line utility installed. It -can be obtained here: +The default prompt assumes you have the `kubectl` command line utility installed. +Official installation instructions and binaries are available: [Install and Set up kubectl](https://kubernetes.io/docs/tasks/tools/install-kubectl/) -If using this with OpenShift, the oc tool needs installed. It can be obtained from here: +If using this with OpenShift, the `oc` tool needs installed. It can be obtained +from brew ports: + +``` +brew install openshift-cli +``` +or the source can be downloaded: [OC Client Tools](https://www.openshift.org/download.html) +Set the binary to `oc` with the following environment variable: + +``` +KUBE_PS1_BINARY=oc +``` + +If neither binary is available, the prompt will print the following: + +``` +(|BINARY-N/A:N/A) +``` + ## Helper utilities -There are several great tools that make using kubectl very enjoyable. +There are several great tools that make using kubectl very enjoyable: -[kubectx and kubenx](https://github.com/ahmetb/kubectx) are great for +- [`kubectx` and `kubens`](https://github.com/ahmetb/kubectx) are great for fast switching between clusters and namespaces. +## Tmux port + +I have begun porting kube-ps1 to tmux as a status line plugin. If you prefer +tmux, and like the functionality provided by kube-ps1, checkout the +[kube-tmux](https://github.com/jonmosco/kube-tmux) project + ## Prompt Structure -The prompt layout is: +The default prompt layout is: ``` -(|:) +(|:) ``` -## Enabling +If the current-context is not set, kube-ps1 will return the following: -In order to use kube-ps1 with Oh My Zsh, you'll need to enable them in the -.zshrc file. You'll find the zshrc file in your $HOME directory. Open it with -your favorite text editor and you'll see a spot to list all the plugins you -want to load. - -```shell -vim $HOME/.zshrc +``` +(|N/A:N/A) ``` -Add kube-ps1 to the list of enabled plugins and enable it on the prompt: +## Enabling/Disabling -```shell -plugins=( - git - kube-ps1 -) +If you want to stop showing Kubernetes status on your prompt string temporarily +run `kubeoff`. To disable the prompt for all shell sessions, run `kubeoff -g`. +You can enable it again in the current shell by running `kubeon`, and globally +with `kubeon -g`. -# After the "source Oh My Zsh" line -PROMPT=$PROMPT'$(kube_ps1) ' ``` - -Note: The `PROMPT` example above was tested with the theme `robbyrussell`. - -## Enabling / Disabling on the current shell - -Sometimes the kubernetes information can be anoying, you can easily -switch it on and off with the following commands: - -```shell -kubeon +kubeon : turn on kube-ps1 status for this shell. Takes precedence over + global setting for current session +kubeon -g : turn on kube-ps1 status globally +kubeoff : turn off kube-ps1 status for this shell. Takes precedence over + global setting for current session +kubeoff -g : turn off kube-ps1 status globally ``` -```shell -kubeoff -``` - -## Colors - -Blue was used as the prefix to match the Kubernetes color as closely as -possible. Red was chosen as the cluster name to stand out, and cyan -for the namespace. Check the customization section for changing them. - ## Customization -The default settings can be overridden in ~/.zshrc +The default settings can be overridden in `~/.bashrc` or `~/.zshrc` by setting +the following environment variables: | Variable | Default | Meaning | | :------- | :-----: | ------- | | `KUBE_PS1_BINARY` | `kubectl` | Default Kubernetes binary | +| `KUBE_PS1_NS_ENABLE` | `true` | Display the namespace. If set to `false`, this will also disable `KUBE_PS1_DIVIDER` | | `KUBE_PS1_PREFIX` | `(` | Prompt opening character | | `KUBE_PS1_SYMBOL_ENABLE` | `true ` | Display the prompt Symbol. If set to `false`, this will also disable `KUBE_PS1_SEPARATOR` | | `KUBE_PS1_SYMBOL_DEFAULT` | `⎈ ` | Default prompt symbol. Unicode `\u2388` | | `KUBE_PS1_SYMBOL_USE_IMG` | `false` | ☸️ , Unicode `\u2638` as the prompt symbol | -| `KUBE_PS1_NS_ENABLE` | `true` | Display the namespace. If set to `false`, this will also disable `KUBE_PS1_DIVIDER` | -| `KUBE_PS1_SEPERATOR` | `\|` | Separator between symbol and cluster name | -| `KUBE_PS1_DIVIDER` | `:` | Separator between cluster and namespace | +| `KUBE_PS1_SEPARATOR` | | | Separator between symbol and context name | +| `KUBE_PS1_DIVIDER` | `:` | Separator between context and namespace | | `KUBE_PS1_SUFFIX` | `)` | Prompt closing character | -| `KUBE_PS1_COLOR_SYMBOL` | `"%F{blue}"` | Custom color for the symbol | -| `KUBE_PS1_COLOR_CONTEXT` | `"%F{red}"` | Custom color for the context | -| `KUBE_PS1_COLOR_NS` | `"%F{cyan}"` | Custom color for the namespace | -| `KUBE_PS1_ENABLED` | `true` | Set to false to start disabled on any new shell, `kubeon`/`kubeoff` will flip this value on the current shell | +| `KUBE_PS1_CLUSTER_FUNCTION` | No default, must be user supplied | Function to customize how cluster is displayed | +| `KUBE_PS1_NAMESPACE_FUNCTION` | No default, must be user supplied | Function to customize how namespace is displayed | + +For terminals that do not support UTF-8, the symbol will be replaced with the +string `k8s`. + +To disable a feature, set it to an empty string: + +``` +KUBE_PS1_SEPARATOR='' +``` + +## Colors + +The default colors are set with the following environment variables: + +| Variable | Default | Meaning | +| :------- | :-----: | ------- | +| `KUBE_PS1_SYMBOL_COLOR` | `blue` | Set default color of the Kubernetes symbol | +| `KUBE_PS1_CTX_COLOR` | `red` | Set default color of the context | +| `KUBE_PS1_NS_COLOR` | `cyan` | Set default color of the namespace | +| `KUBE_PS1_BG_COLOR` | `null` | Set default color of the prompt background | + +Blue was used for the default symbol to match the Kubernetes color as closely +as possible. Red was chosen as the context name to stand out, and cyan for the +namespace. + +Set the variable to an empty string if you do not want color for each +prompt section: + +``` +KUBE_PS1_CTX_COLOR='' +``` + +Names are usable for the following colors: + +``` +black, red, green, yellow, blue, magenta, cyan +``` + +256 colors are available by specifying the numerical value as the variable +argument. + +## Customize display of cluster name and namespace + +You can change how the cluster name and namespace are displayed using the +`KUBE_PS1_CLUSTER_FUNCTION` and `KUBE_PS1_NAMESPACE_FUNCTION` variables +respectively. + +For the following examples let's assume the following: + +cluster name: `sandbox.k8s.example.com` +namespace: `alpha` + +If you're using domain style cluster names, your prompt will get quite long +very quickly. Let's say you only want to display the first portion of the +cluster name (`sandbox`), you could do that by adding the following: + +```sh +function get_cluster_short() { + echo "$1" | cut -d . -f1 +} + +KUBE_PS1_CLUSTER_FUNCTION=get_cluster_short +``` + +The same pattern can be followed to customize the display of the namespace. +Let's say you would prefer the namespace to be displayed in all uppercase +(`ALPHA`), here's one way you could do that: + +```sh +function get_namespace_upper() { + echo "$1" | tr '[:lower:]' '[:upper:]' +} + +export KUBE_PS1_NAMESPACE_FUNCTION=get_namespace_upper +``` + +In both cases, the variable is set to the name of the function, and you must have defined the function in your shell configuration before kube_ps1 is called. The function must accept a single parameter and echo out the final value. + +### Bug Reports and shell configuration + +Due to the vast ways of customizing the shell, please try the prompt with a +minimal configuration before submitting a bug report. + +This can be done as follows for each shell before loading kube-ps1: + +Bash: +```bash +bash --norc +``` + +Zsh: +```bash +zsh -f +or +zsh --no-rcs +``` ## Contributors -- Jared Yanovich -- Pedro Moranga +* [Ahmet Alp Balkan](https://github.com/ahmetb) +* Jared Yanovich diff --git a/zsh/plugins/kube-ps1/kube-ps1.plugin.zsh b/zsh/plugins/kube-ps1/kube-ps1.plugin.zsh index 3cb2128..9e77cbc 100644 --- a/zsh/plugins/kube-ps1/kube-ps1.plugin.zsh +++ b/zsh/plugins/kube-ps1/kube-ps1.plugin.zsh @@ -1,16 +1,15 @@ -#!/bin/zsh +#!/bin/bash # Kubernetes prompt helper for bash/zsh -# ported to oh-my-zsh # Displays current context and namespace -# Copyright 2018 Jon Mosco +# Copyright 2019 Jon Mosco # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # -# https://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, @@ -21,39 +20,150 @@ # Debug [[ -n $DEBUG ]] && set -x -setopt PROMPT_SUBST -autoload -U add-zsh-hook -add-zsh-hook precmd _kube_ps1_update_cache -zmodload zsh/stat -zmodload zsh/datetime - # Default values for the prompt -# Override these values in ~/.zshrc +# Override these values in ~/.zshrc or ~/.bashrc KUBE_PS1_BINARY="${KUBE_PS1_BINARY:-kubectl}" KUBE_PS1_SYMBOL_ENABLE="${KUBE_PS1_SYMBOL_ENABLE:-true}" -KUBE_PS1_SYMBOL_DEFAULT="${KUBE_PS1_SYMBOL_DEFAULT:-\u2388 }" +KUBE_PS1_SYMBOL_DEFAULT=${KUBE_PS1_SYMBOL_DEFAULT:-$'\u2388 '} KUBE_PS1_SYMBOL_USE_IMG="${KUBE_PS1_SYMBOL_USE_IMG:-false}" KUBE_PS1_NS_ENABLE="${KUBE_PS1_NS_ENABLE:-true}" +KUBE_PS1_CONTEXT_ENABLE="${KUBE_PS1_CONTEXT_ENABLE:-true}" +KUBE_PS1_PREFIX="${KUBE_PS1_PREFIX-(}" KUBE_PS1_SEPARATOR="${KUBE_PS1_SEPARATOR-|}" KUBE_PS1_DIVIDER="${KUBE_PS1_DIVIDER-:}" -KUBE_PS1_PREFIX="${KUBE_PS1_PREFIX-(}" KUBE_PS1_SUFFIX="${KUBE_PS1_SUFFIX-)}" +KUBE_PS1_SYMBOL_COLOR="${KUBE_PS1_SYMBOL_COLOR-blue}" +KUBE_PS1_CTX_COLOR="${KUBE_PS1_CTX_COLOR-red}" +KUBE_PS1_NS_COLOR="${KUBE_PS1_NS_COLOR-cyan}" +KUBE_PS1_BG_COLOR="${KUBE_PS1_BG_COLOR}" +KUBE_PS1_KUBECONFIG_CACHE="${KUBECONFIG}" +KUBE_PS1_DISABLE_PATH="${HOME}/.kube/kube-ps1/disabled" KUBE_PS1_LAST_TIME=0 -KUBE_PS1_ENABLED=true +KUBE_PS1_CLUSTER_FUNCTION="${KUBE_PS1_CLUSTER_FUNCTION}" +KUBE_PS1_NAMESPACE_FUNCTION="${KUBE_PS1_NAMESPACE_FUNCTION}" -KUBE_PS1_COLOR_SYMBOL="%{$fg[blue]%}" -KUBE_PS1_COLOR_CONTEXT="%{$fg[red]%}" -KUBE_PS1_COLOR_NS="%{$fg[cyan]%}" +# Determine our shell +if [ "${ZSH_VERSION-}" ]; then + KUBE_PS1_SHELL="zsh" +elif [ "${BASH_VERSION-}" ]; then + KUBE_PS1_SHELL="bash" +fi + +_kube_ps1_init() { + [[ -f "${KUBE_PS1_DISABLE_PATH}" ]] && KUBE_PS1_ENABLED=off + + case "${KUBE_PS1_SHELL}" in + "zsh") + _KUBE_PS1_OPEN_ESC="%{" + _KUBE_PS1_CLOSE_ESC="%}" + _KUBE_PS1_DEFAULT_BG="%k" + _KUBE_PS1_DEFAULT_FG="%f" + setopt PROMPT_SUBST + autoload -U add-zsh-hook + add-zsh-hook precmd _kube_ps1_update_cache + zmodload -F zsh/stat b:zstat + zmodload zsh/datetime + ;; + "bash") + _KUBE_PS1_OPEN_ESC=$'\001' + _KUBE_PS1_CLOSE_ESC=$'\002' + _KUBE_PS1_DEFAULT_BG=$'\033[49m' + _KUBE_PS1_DEFAULT_FG=$'\033[39m' + [[ $PROMPT_COMMAND =~ _kube_ps1_update_cache ]] || PROMPT_COMMAND="_kube_ps1_update_cache;${PROMPT_COMMAND:-:}" + ;; + esac +} + +_kube_ps1_color_fg() { + local KUBE_PS1_FG_CODE + case "${1}" in + black) KUBE_PS1_FG_CODE=0;; + red) KUBE_PS1_FG_CODE=1;; + green) KUBE_PS1_FG_CODE=2;; + yellow) KUBE_PS1_FG_CODE=3;; + blue) KUBE_PS1_FG_CODE=4;; + magenta) KUBE_PS1_FG_CODE=5;; + cyan) KUBE_PS1_FG_CODE=6;; + white) KUBE_PS1_FG_CODE=7;; + # 256 + [0-9]|[1-9][0-9]|[1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-6]) KUBE_PS1_FG_CODE="${1}";; + *) KUBE_PS1_FG_CODE=default + esac + + if [[ "${KUBE_PS1_FG_CODE}" == "default" ]]; then + KUBE_PS1_FG_CODE="${_KUBE_PS1_DEFAULT_FG}" + return + elif [[ "${KUBE_PS1_SHELL}" == "zsh" ]]; then + KUBE_PS1_FG_CODE="%F{$KUBE_PS1_FG_CODE}" + elif [[ "${KUBE_PS1_SHELL}" == "bash" ]]; then + if tput setaf 1 &> /dev/null; then + KUBE_PS1_FG_CODE="$(tput setaf ${KUBE_PS1_FG_CODE})" + elif [[ $KUBE_PS1_FG_CODE -ge 0 ]] && [[ $KUBE_PS1_FG_CODE -le 256 ]]; then + KUBE_PS1_FG_CODE="\033[38;5;${KUBE_PS1_FG_CODE}m" + else + KUBE_PS1_FG_CODE="${_KUBE_PS1_DEFAULT_FG}" + fi + fi + echo ${_KUBE_PS1_OPEN_ESC}${KUBE_PS1_FG_CODE}${_KUBE_PS1_CLOSE_ESC} +} + +_kube_ps1_color_bg() { + local KUBE_PS1_BG_CODE + case "${1}" in + black) KUBE_PS1_BG_CODE=0;; + red) KUBE_PS1_BG_CODE=1;; + green) KUBE_PS1_BG_CODE=2;; + yellow) KUBE_PS1_BG_CODE=3;; + blue) KUBE_PS1_BG_CODE=4;; + magenta) KUBE_PS1_BG_CODE=5;; + cyan) KUBE_PS1_BG_CODE=6;; + white) KUBE_PS1_BG_CODE=7;; + # 256 + [0-9]|[1-9][0-9]|[1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-6]) KUBE_PS1_BG_CODE="${1}";; + *) KUBE_PS1_BG_CODE=$'\033[0m';; + esac + + if [[ "${KUBE_PS1_BG_CODE}" == "default" ]]; then + KUBE_PS1_FG_CODE="${_KUBE_PS1_DEFAULT_BG}" + return + elif [[ "${KUBE_PS1_SHELL}" == "zsh" ]]; then + KUBE_PS1_BG_CODE="%K{$KUBE_PS1_BG_CODE}" + elif [[ "${KUBE_PS1_SHELL}" == "bash" ]]; then + if tput setaf 1 &> /dev/null; then + KUBE_PS1_BG_CODE="$(tput setab ${KUBE_PS1_BG_CODE})" + elif [[ $KUBE_PS1_BG_CODE -ge 0 ]] && [[ $KUBE_PS1_BG_CODE -le 256 ]]; then + KUBE_PS1_BG_CODE="\033[48;5;${KUBE_PS1_BG_CODE}m" + else + KUBE_PS1_BG_CODE="${DEFAULT_BG}" + fi + fi + echo ${OPEN_ESC}${KUBE_PS1_BG_CODE}${CLOSE_ESC} +} _kube_ps1_binary_check() { - command -v "$1" >/dev/null + command -v $1 >/dev/null } _kube_ps1_symbol() { [[ "${KUBE_PS1_SYMBOL_ENABLE}" == false ]] && return - KUBE_PS1_SYMBOL="${KUBE_PS1_SYMBOL_DEFAULT}" - KUBE_PS1_SYMBOL_IMG="\u2638 " + case "${KUBE_PS1_SHELL}" in + bash) + if ((BASH_VERSINFO[0] >= 4)) && [[ $'\u2388 ' != "\\u2388 " ]]; then + KUBE_PS1_SYMBOL="${KUBE_PS1_SYMBOL_DEFAULT}" + # KUBE_PS1_SYMBOL=$'\u2388 ' + KUBE_PS1_SYMBOL_IMG=$'\u2638 ' + else + KUBE_PS1_SYMBOL=$'\xE2\x8E\x88 ' + KUBE_PS1_SYMBOL_IMG=$'\xE2\x98\xB8 ' + fi + ;; + zsh) + KUBE_PS1_SYMBOL="${KUBE_PS1_SYMBOL_DEFAULT}" + KUBE_PS1_SYMBOL_IMG="\u2638 ";; + *) + KUBE_PS1_SYMBOL="k8s" + esac if [[ "${KUBE_PS1_SYMBOL_USE_IMG}" == true ]]; then KUBE_PS1_SYMBOL="${KUBE_PS1_SYMBOL_IMG}" @@ -73,22 +183,24 @@ _kube_ps1_file_newer_than() { local file=$1 local check_time=$2 - zmodload -e "zsh/stat" - if [[ "$?" -eq 0 ]]; then - mtime=$(stat +mtime "${file}") + if [[ "${KUBE_PS1_SHELL}" == "zsh" ]]; then + mtime=$(zstat +mtime "${file}") elif stat -c "%s" /dev/null &> /dev/null; then # GNU stat - mtime=$(stat -c %Y "${file}") + mtime=$(stat -L -c %Y "${file}") else # BSD stat - mtime=$(stat -f %m "$file") + mtime=$(stat -L -f %m "$file") fi [[ "${mtime}" -gt "${check_time}" ]] } _kube_ps1_update_cache() { - KUBECONFIG="${KUBECONFIG:=$HOME/.kube/config}" + local return_code=$? + + [[ "${KUBE_PS1_ENABLED}" == "off" ]] && return $return_code + if ! _kube_ps1_binary_check "${KUBE_PS1_BINARY}"; then # No ability to fetch context/namespace; display N/A. KUBE_PS1_CONTEXT="BINARY-N/A" @@ -113,47 +225,147 @@ _kube_ps1_update_cache() { return fi done + + return $return_code } -_kube_ps1_get_context_ns() { +_kube_ps1_get_context() { + if [[ "${KUBE_PS1_CONTEXT_ENABLE}" == true ]]; then + KUBE_PS1_CONTEXT="$(${KUBE_PS1_BINARY} config current-context 2>/dev/null)" + # Set namespace to 'N/A' if it is not defined + KUBE_PS1_CONTEXT="${KUBE_PS1_CONTEXT:-N/A}" - # Set the command time - KUBE_PS1_LAST_TIME=$EPOCHSECONDS - - KUBE_PS1_CONTEXT="$(${KUBE_PS1_BINARY} config current-context 2>/dev/null)" - if [[ -z "${KUBE_PS1_CONTEXT}" ]]; then - KUBE_PS1_CONTEXT="N/A" - KUBE_PS1_NAMESPACE="N/A" - return - elif [[ "${KUBE_PS1_NS_ENABLE}" == true ]]; then - KUBE_PS1_NAMESPACE="$(${KUBE_PS1_BINARY} config view --minify --output 'jsonpath={..namespace}' 2>/dev/null)" - # Set namespace to 'default' if it is not defined - KUBE_PS1_NAMESPACE="${KUBE_PS1_NAMESPACE:-default}" + if [[ ! -z "${KUBE_PS1_CLUSTER_FUNCTION}" ]]; then + KUBE_PS1_CONTEXT=$($KUBE_PS1_CLUSTER_FUNCTION $KUBE_PS1_CONTEXT) + fi fi } -# function to disable the prompt on the current shell -kubeon(){ - KUBE_PS1_ENABLED=true +_kube_ps1_get_ns() { + if [[ "${KUBE_PS1_NS_ENABLE}" == true ]]; then + KUBE_PS1_NAMESPACE="$(${KUBE_PS1_BINARY} config view --minify --output 'jsonpath={..namespace}' 2>/dev/null)" + # Set namespace to 'default' if it is not defined + KUBE_PS1_NAMESPACE="${KUBE_PS1_NAMESPACE:-default}" + + if [[ ! -z "${KUBE_PS1_NAMESPACE_FUNCTION}" ]]; then + KUBE_PS1_NAMESPACE=$($KUBE_PS1_NAMESPACE_FUNCTION $KUBE_PS1_NAMESPACE) + fi + fi } -# function to disable the prompt on the current shell -kubeoff(){ - KUBE_PS1_ENABLED=false +_kube_ps1_get_context_ns() { + # Set the command time + if [[ "${KUBE_PS1_SHELL}" == "bash" ]]; then + if ((BASH_VERSINFO[0] >= 4 && BASH_VERSINFO[1] >= 2)); then + KUBE_PS1_LAST_TIME=$(printf '%(%s)T') + else + KUBE_PS1_LAST_TIME=$(date +%s) + fi + elif [[ "${KUBE_PS1_SHELL}" == "zsh" ]]; then + KUBE_PS1_LAST_TIME=$EPOCHSECONDS + fi + + _kube_ps1_get_context + _kube_ps1_get_ns +} + +# Set kube-ps1 shell defaults +_kube_ps1_init + +_kubeon_usage() { + cat <<"EOF" +Toggle kube-ps1 prompt on + +Usage: kubeon [-g | --global] [-h | --help] + +With no arguments, turn off kube-ps1 status for this shell instance (default). + + -g --global turn on kube-ps1 status globally + -h --help print this message +EOF +} + +_kubeoff_usage() { + cat <<"EOF" +Toggle kube-ps1 prompt off + +Usage: kubeoff [-g | --global] [-h | --help] + +With no arguments, turn off kube-ps1 status for this shell instance (default). + + -g --global turn off kube-ps1 status globally + -h --help print this message +EOF +} + +kubeon() { + if [[ "${1}" == '-h' || "${1}" == '--help' ]]; then + _kubeon_usage + elif [[ "${1}" == '-g' || "${1}" == '--global' ]]; then + rm -f -- "${KUBE_PS1_DISABLE_PATH}" + elif [[ "$#" -ne 0 ]]; then + echo -e "error: unrecognized flag ${1}\\n" + _kubeon_usage + return + fi + + KUBE_PS1_ENABLED=on +} + +kubeoff() { + if [[ "${1}" == '-h' || "${1}" == '--help' ]]; then + _kubeoff_usage + elif [[ "${1}" == '-g' || "${1}" == '--global' ]]; then + mkdir -p -- "$(dirname "${KUBE_PS1_DISABLE_PATH}")" + touch -- "${KUBE_PS1_DISABLE_PATH}" + elif [[ $# -ne 0 ]]; then + echo "error: unrecognized flag ${1}" >&2 + _kubeoff_usage + return + fi + + KUBE_PS1_ENABLED=off } # Build our prompt -kube_ps1 () { - local reset_color="%{$reset_color%}" - [[ ${KUBE_PS1_ENABLED} != 'true' ]] && return +kube_ps1() { + [[ "${KUBE_PS1_ENABLED}" == "off" ]] && return + [[ -z "${KUBE_PS1_CONTEXT}" ]] && [[ "${KUBE_PS1_CONTEXT_ENABLE}" == true ]] && return - KUBE_PS1="${reset_color}$KUBE_PS1_PREFIX" - KUBE_PS1+="${KUBE_PS1_COLOR_SYMBOL}$(_kube_ps1_symbol)" - KUBE_PS1+="${reset_color}$KUBE_PS1_SEPERATOR" - KUBE_PS1+="${KUBE_PS1_COLOR_CONTEXT}$KUBE_PS1_CONTEXT${reset_color}" - KUBE_PS1+="$KUBE_PS1_DIVIDER" - KUBE_PS1+="${KUBE_PS1_COLOR_NS}$KUBE_PS1_NAMESPACE${reset_color}" - KUBE_PS1+="$KUBE_PS1_SUFFIX" + local KUBE_PS1 + local KUBE_PS1_RESET_COLOR="${_KUBE_PS1_OPEN_ESC}${_KUBE_PS1_DEFAULT_FG}${_KUBE_PS1_CLOSE_ESC}" + + # Background Color + [[ -n "${KUBE_PS1_BG_COLOR}" ]] && KUBE_PS1+="$(_kube_ps1_color_bg ${KUBE_PS1_BG_COLOR})" + + # Prefix + [[ -n "${KUBE_PS1_PREFIX}" ]] && KUBE_PS1+="${KUBE_PS1_PREFIX}" + + # Symbol + KUBE_PS1+="$(_kube_ps1_color_fg $KUBE_PS1_SYMBOL_COLOR)$(_kube_ps1_symbol)${KUBE_PS1_RESET_COLOR}" + + if [[ -n "${KUBE_PS1_SEPARATOR}" ]] && [[ "${KUBE_PS1_SYMBOL_ENABLE}" == true ]]; then + KUBE_PS1+="${KUBE_PS1_SEPARATOR}" + fi + + # Context + if [[ "${KUBE_PS1_CONTEXT_ENABLE}" == true ]]; then + KUBE_PS1+="$(_kube_ps1_color_fg $KUBE_PS1_CTX_COLOR)${KUBE_PS1_CONTEXT}${KUBE_PS1_RESET_COLOR}" + fi + + # Namespace + if [[ "${KUBE_PS1_NS_ENABLE}" == true ]]; then + if [[ -n "${KUBE_PS1_DIVIDER}" ]] && [[ "${KUBE_PS1_CONTEXT_ENABLE}" == true ]]; then + KUBE_PS1+="${KUBE_PS1_DIVIDER}" + fi + KUBE_PS1+="$(_kube_ps1_color_fg ${KUBE_PS1_NS_COLOR})${KUBE_PS1_NAMESPACE}${KUBE_PS1_RESET_COLOR}" + fi + + # Suffix + [[ -n "${KUBE_PS1_SUFFIX}" ]] && KUBE_PS1+="${KUBE_PS1_SUFFIX}" + + # Close Background color if defined + [[ -n "${KUBE_PS1_BG_COLOR}" ]] && KUBE_PS1+="${_KUBE_PS1_OPEN_ESC}${_KUBE_PS1_DEFAULT_BG}${_KUBE_PS1_CLOSE_ESC}" echo "${KUBE_PS1}" } diff --git a/zsh/plugins/kubectl/README.md b/zsh/plugins/kubectl/README.md index c0db593..84f5f8d 100644 --- a/zsh/plugins/kubectl/README.md +++ b/zsh/plugins/kubectl/README.md @@ -33,7 +33,8 @@ plugins=(... kubectl) | kep | `kubectl edit pods` | Edit pods from the default editor | | kdp | `kubectl describe pods` | Describe all pods | | kdelp | `kubectl delete pods` | Delete all pods matching passed arguments | -| kgpl | `kgp -l` | Get pod by label. Example: `kgpl "app=myapp" -n myns` | +| kgpl | `kgp -l` | Get pods by label. Example: `kgpl "app=myapp" -n myns` | +| kgpn | `kgp -n` | Get pods by namespace. Example: `kgpn kube-system` | | | | **Service management** | | kgs | `kubectl get svc` | List all services in ps output format | | kgsw | `kgs --watch` | After listing all services, watch for changes | @@ -105,3 +106,11 @@ plugins=(... kubectl) | kdelss | `kubectl delete statefulset` | Delete the statefulset | | ksss | `kubectl scale statefulset` | Scale a statefulset | | krsss | `kubectl rollout status statefulset`| Check the rollout status of a deployment | + +## Wrappers + +This plugin provides 3 wrappers to colorize kubectl output in JSON and YAML using various tools (which must be installed): + +- `kj`: JSON, colorized with [`jq`](https://stedolan.github.io/jq/). +- `kjx`: JSON, colorized with [`fx`](https://github.com/antonmedv/fx). +- `ky`: YAML, colorized with [`yh`](https://github.com/andreazorzetto/yh). diff --git a/zsh/plugins/kubectl/kubectl.plugin.zsh b/zsh/plugins/kubectl/kubectl.plugin.zsh index 6c1696d..7a0c479 100644 --- a/zsh/plugins/kubectl/kubectl.plugin.zsh +++ b/zsh/plugins/kubectl/kubectl.plugin.zsh @@ -14,7 +14,7 @@ fi alias k=kubectl # Execute a kubectl command against all namespaces -alias kca='f(){ kubectl "$@" --all-namespaces; unset -f f; }; f' +alias kca='_kca(){ kubectl "$@" --all-namespaces; unset -f _kca; }; _kca' # Apply a YML file alias kaf='kubectl apply -f' @@ -37,6 +37,7 @@ alias kdelf='kubectl delete -f' # Pod management. alias kgp='kubectl get pods' +alias kgpa='kubectl get pods --all-namespaces' alias kgpw='kgp --watch' alias kgpwide='kgp -o wide' alias kep='kubectl edit pods' @@ -46,8 +47,12 @@ alias kdelp='kubectl delete pods' # get pod by label: kgpl "app=myapp" -n myns alias kgpl='kgp -l' +# get pod by namespace: kgpn kube-system" +alias kgpn='kgp -n' + # Service management. alias kgs='kubectl get svc' +alias kgsa='kubectl get svc --all-namespaces' alias kgsw='kgs --watch' alias kgswide='kgs -o wide' alias kes='kubectl edit svc' @@ -56,6 +61,7 @@ alias kdels='kubectl delete svc' # Ingress management alias kgi='kubectl get ingress' +alias kgia='kubectl get ingress --all-namespaces' alias kei='kubectl edit ingress' alias kdi='kubectl describe ingress' alias kdeli='kubectl delete ingress' @@ -69,17 +75,20 @@ alias kcn='kubectl config set-context $(kubectl config current-context) --namesp # ConfigMap management alias kgcm='kubectl get configmaps' +alias kgcma='kubectl get configmaps --all-namespaces' alias kecm='kubectl edit configmap' alias kdcm='kubectl describe configmap' alias kdelcm='kubectl delete configmap' # Secret management alias kgsec='kubectl get secret' +alias kgseca='kubectl get secret --all-namespaces' alias kdsec='kubectl describe secret' alias kdelsec='kubectl delete secret' # Deployment management. alias kgd='kubectl get deployment' +alias kgda='kubectl get deployment --all-namespaces' alias kgdw='kgd --watch' alias kgdwide='kgd -o wide' alias ked='kubectl edit deployment' @@ -98,6 +107,7 @@ alias kru='kubectl rollout undo' # Statefulset management. alias kgss='kubectl get statefulset' +alias kgssa='kubectl get statefulset --all-namespaces' alias kgssw='kgss --watch' alias kgsswide='kgss -o wide' alias kess='kubectl edit statefulset' @@ -115,7 +125,13 @@ alias kgaa='kubectl get all --all-namespaces' # Logs alias kl='kubectl logs' +alias kl1h='kubectl logs --since 1h' +alias kl1m='kubectl logs --since 1m' +alias kl1s='kubectl logs --since 1s' alias klf='kubectl logs -f' +alias klf1h='kubectl logs --since 1h -f' +alias klf1m='kubectl logs --since 1m -f' +alias klf1s='kubectl logs --since 1s -f' # File copy alias kcp='kubectl cp' @@ -128,8 +144,19 @@ alias kdelno='kubectl delete node' # PVC management. alias kgpvc='kubectl get pvc' +alias kgpvca='kubectl get pvc --all-namespaces' alias kgpvcw='kgpvc --watch' alias kepvc='kubectl edit pvc' alias kdpvc='kubectl describe pvc' alias kdelpvc='kubectl delete pvc' +# Only run if the user actually has kubectl installed +if (( $+commands[kubectl] )); then + kj() { kubectl "$@" -o json | jq; } + kjx() { kubectl "$@" -o json | fx; } + ky() { kubectl "$@" -o yaml | yh; } + + compdef kj=kubectl + compdef kjx=kubectl + compdef ky=kubectl +fi diff --git a/zsh/plugins/lando/LICENSE b/zsh/plugins/lando/LICENSE new file mode 100644 index 0000000..1d49831 --- /dev/null +++ b/zsh/plugins/lando/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2019 Joshua Bedford + +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/zsh/plugins/lando/README.md b/zsh/plugins/lando/README.md new file mode 100644 index 0000000..928a42b --- /dev/null +++ b/zsh/plugins/lando/README.md @@ -0,0 +1,37 @@ +# Lando ZSH (lando-zsh) + +This plugin adds aliases for using various languages and frameworks with [Lando](https://docs.lando.dev/basics/) for Docker. It will only run within lando-driven project directories. + +To use it, add `lando` to the plugins array in your zshrc file: + +```zsh +plugins=(... lando) +``` + +## ALIASES: + +| Alias | Description | +|:----------:|:----------------:| +| `artisan` | `lando artisan` | +| `composer` | `lando composer` | +| `drush` | `lando drush` | +| `gulp` | `lando gulp` | +| `npm` | `lando npm` | +| `wp` | `lando wp` | +| `yarn` | `lando yarn` | + +## How It Works: + +This plugin removes the requirement to type `lando` before a command. It utilizes the lando version of supported commands run within directories with the following criteria: +- The `.lando.yml` file is found in the current directory or any parent directory within `$LANDO_ZSH_SITES_DIRECTORY`. +- The current directory is within `$LANDO_ZSH_SITES_DIRECTORY` but is not `$LANDO_ZSH_SITES_DIRECTORY` itself. + +## Settings: + +- `LANDO_ZSH_SITES_DIRECTORY`: The plugin will stop searching through parents for `CONFIG_FILE` once it hits this directory. +- `LANDO_ZSH_CONFIG_FILE`: The plugin will check to see if this provided file exists to check for presence of Lando. + +## Author: + +- Author: Joshua Bedford +- URL: [https://github.com/joshuabedford/lando-zsh](https://github.com/joshuabedford/lando-zsh) diff --git a/zsh/plugins/lando/lando.plugin.zsh b/zsh/plugins/lando/lando.plugin.zsh new file mode 100644 index 0000000..aa74c99 --- /dev/null +++ b/zsh/plugins/lando/lando.plugin.zsh @@ -0,0 +1,40 @@ +# Settings +: ${LANDO_ZSH_SITES_DIRECTORY:="$HOME/Sites"} +: ${LANDO_ZSH_CONFIG_FILE:=.lando.yml} + +# Enable multiple commands with lando. +function artisan \ + composer \ + drush \ + gulp \ + npm \ + wp \ + yarn { + if checkForLandoFile; then + lando "$0" "$@" + else + command "$0" "$@" + fi +} + +# Check for the file in the current and parent directories. +checkForLandoFile() { + # Only bother checking for lando within the Sites directory. + if [[ "$PWD/" != "$LANDO_ZSH_SITES_DIRECTORY"/* ]]; then + # Not within $LANDO_ZSH_SITES_DIRECTORY + return 1 + fi + + local curr_dir="$PWD" + # Checking for file: $LANDO_ZSH_CONFIG_FILE within $LANDO_ZSH_SITES_DIRECTORY... + while [[ "$curr_dir" != "$LANDO_ZSH_SITES_DIRECTORY" ]]; do + if [[ -f "$curr_dir/$LANDO_ZSH_CONFIG_FILE" ]]; then + return 0 + fi + curr_dir="${curr_dir:h}" + done + + # Could not find $LANDO_ZSH_CONFIG_FILE in the current directory + # or in any of its parents up to $LANDO_ZSH_SITES_DIRECTORY. + return 1 +} \ No newline at end of file diff --git a/zsh/plugins/laravel/README.md b/zsh/plugins/laravel/README.md index 44798b6..95f5901 100644 --- a/zsh/plugins/laravel/README.md +++ b/zsh/plugins/laravel/README.md @@ -29,6 +29,12 @@ plugins=(... laravel) | `pamc` | `php artisan make:controller` | | `pams` | `php artisan make:seeder` | | `pamt` | `php artisan make:test` | +| `pamfa` | `php artisan make:factory` | +| `pamp` | `php artisan make:policy` | +| `pame` | `php artisan make:event` | +| `pamj` | `php artisan make:job` | +| `paml` | `php artisan make:listener` | +| `pamn` | `php artisan make:notification` | ## Clears @@ -38,3 +44,14 @@ plugins=(... laravel) | `pacoc` | `php artisan config:clear` | | `pavic` | `php artisan view:clear` | | `paroc` | `php artisan route:clear` | + +## Queues + +| Alias | Description | +|:-:|:-:| +| `paqf` | `php artisan queue:failed` | +| `paqft` | `php artisan queue:failed-table` | +| `paql` | `php artisan queue:listen` | +| `paqr` | `php artisan queue:retry` | +| `paqt` | `php artisan queue:table` | +| `paqw` | `php artisan queue:work` | diff --git a/zsh/plugins/laravel/laravel.plugin.zsh b/zsh/plugins/laravel/laravel.plugin.zsh index 7ddfd85..a8382d3 100644 --- a/zsh/plugins/laravel/laravel.plugin.zsh +++ b/zsh/plugins/laravel/laravel.plugin.zsh @@ -17,6 +17,13 @@ alias pamm='php artisan make:model' alias pamc='php artisan make:controller' alias pams='php artisan make:seeder' alias pamt='php artisan make:test' +alias pamfa='php artisan make:factory' +alias pamp='php artisan make:policy' +alias pame='php artisan make:event' +alias pamj='php artisan make:job' +alias paml='php artisan make:listener' +alias pamn='php artisan make:notification' +alias pampp='php artisan make:provider' # Clears @@ -24,3 +31,11 @@ alias pacac='php artisan cache:clear' alias pacoc='php artisan config:clear' alias pavic='php artisan view:clear' alias paroc='php artisan route:clear' + +# queues +alias paqf='php artisan queue:failed' +alias paqft='php artisan queue:failed-table' +alias paql='php artisan queue:listen' +alias paqr='php artisan queue:retry' +alias paqt='php artisan queue:table' +alias paqw='php artisan queue:work' diff --git a/zsh/plugins/laravel4/README.md b/zsh/plugins/laravel4/README.md index c945601..97a6a78 100644 --- a/zsh/plugins/laravel4/README.md +++ b/zsh/plugins/laravel4/README.md @@ -10,9 +10,9 @@ plugins=(... laravel4) ## Aliases -| Alias | Command | Description | -|-----------|-------------------------------------------|-------------------------------------------------------------| -| la4 | `php artisan` | Main Artisan command | -| la4dump | `php artisan dump-autoload` | Regenerate framework autoload files | -| la4cache | `php artisan cache:clear` | Flush the application cache | -| la4routes | `php artisan routes` | List all registered routes | +| Alias | Command | Description | +|-----------|-----------------------------|-------------------------------------| +| la4 | `php artisan` | Main Artisan command | +| la4dump | `php artisan dump-autoload` | Regenerate framework autoload files | +| la4cache | `php artisan cache:clear` | Flush the application cache | +| la4routes | `php artisan routes` | List all registered routes | diff --git a/zsh/plugins/laravel5/laravel5.plugin.zsh b/zsh/plugins/laravel5/laravel5.plugin.zsh index 487a074..70dc4ed 100644 --- a/zsh/plugins/laravel5/laravel5.plugin.zsh +++ b/zsh/plugins/laravel5/laravel5.plugin.zsh @@ -1,20 +1,19 @@ +# Alias +alias la5='php artisan' +alias la5cache='php artisan cache:clear' +alias la5routes='php artisan route:list' +alias la5vendor='php artisan vendor:publish' + # Laravel5 basic command completion _laravel5_get_command_list () { - php artisan --raw --no-ansi list | sed "s/[[:space:]].*//g" + php artisan --raw --no-ansi list | sed "s/[[:space:]].*//g" } _laravel5 () { - if [ -f artisan ]; then - compadd `_laravel5_get_command_list` + if [[ -f artisan ]]; then + compadd $(_laravel5_get_command_list) fi } compdef _laravel5 artisan compdef _laravel5 la5 - -#Alias -alias la5='php artisan' - -alias la5cache='php artisan cache:clear' -alias la5routes='php artisan route:list' -alias la5vendor='php artisan vendor:publish' diff --git a/zsh/plugins/last-working-dir/README.md b/zsh/plugins/last-working-dir/README.md index 4cc4aca..ced9e03 100644 --- a/zsh/plugins/last-working-dir/README.md +++ b/zsh/plugins/last-working-dir/README.md @@ -6,4 +6,10 @@ for new shells, unless: - The plugin is already loaded. - The current `$PWD` is not `$HOME`. -Adds `lwd` function to jump to the last working directory. +Also adds `lwd` function to jump to the last working directory. + +To use it, add `last-working-dir` to the plugins array in your zshrc file: + +```zsh +plugins=(... last-working-dir) +``` diff --git a/zsh/plugins/last-working-dir/last-working-dir.plugin.zsh b/zsh/plugins/last-working-dir/last-working-dir.plugin.zsh index 53bb19e..fd21705 100644 --- a/zsh/plugins/last-working-dir/last-working-dir.plugin.zsh +++ b/zsh/plugins/last-working-dir/last-working-dir.plugin.zsh @@ -2,7 +2,8 @@ typeset -g ZSH_LAST_WORKING_DIRECTORY # Updates the last directory once directory is changed -chpwd_functions+=(chpwd_last_working_dir) +autoload -U add-zsh-hook +add-zsh-hook chpwd chpwd_last_working_dir chpwd_last_working_dir() { if [ "$ZSH_SUBSHELL" = 0 ]; then local cache_file="$ZSH_CACHE_DIR/last-working-dir" diff --git a/zsh/plugins/lein/README.md b/zsh/plugins/lein/README.md new file mode 100644 index 0000000..0c41196 --- /dev/null +++ b/zsh/plugins/lein/README.md @@ -0,0 +1,9 @@ +# Leiningen plugin + +This plugin adds completions for the [Leiningen](https://leiningen.org/) Clojure build tool. + +To use it, add `lein` to the plugins array in your zshrc file: + +```zsh +plugins=(... lein) +``` diff --git a/zsh/plugins/lighthouse/README.md b/zsh/plugins/lighthouse/README.md index 0db29b4..55587b2 100644 --- a/zsh/plugins/lighthouse/README.md +++ b/zsh/plugins/lighthouse/README.md @@ -16,7 +16,8 @@ plugins=(... lighthouse) file in your directory with the URL to the individual project. Example: - ```zsh + + ```console $ cat .lighthouse-url https://rails.lighthouseapp.com/projects/8994 @@ -24,3 +25,5 @@ plugins=(... lighthouse) Opening ticket #23 # The browser goes to https://rails.lighthouseapp.com/projects/8994/tickets/23 ``` + +See a demo: http://screencast.com/t/ZDgwNDUwNT diff --git a/zsh/plugins/lol/README.md b/zsh/plugins/lol/README.md index b0e54f5..ea6b0c3 100644 --- a/zsh/plugins/lol/README.md +++ b/zsh/plugins/lol/README.md @@ -1,67 +1,55 @@ # lol -Plugin for adding catspeak aliases, because why not +Plugin for adding catspeak aliases, because why not. -## Enabling the plugin +To use it, add `lol` to the plugins array in your zshrc file: -1. Open your `.zshrc` file and add `lol` in the plugins section: - - ```zsh - plugins=( - # all your enabled plugins - lol - ) - ``` - -2. Reload the source file or restart your Terminal session: - - ```console - $ source ~/.zshrc - $ - ``` +```zsh +plugins=(... lol) +``` ## Aliases -| Alias | Command | -| ------------ | ---------------------------------------------------------------- | -| `:3` | `echo` | -| `alwayz` | `tail -f` | -| `bringz` | `git pull` | -| `btw` | `nice` | -| `byes` | `exit` | -| `chicken` | `git add` | -| `cya` | `reboot` | -| `donotwant` | `rm` | -| `dowant` | `cp` | -| `gimmeh` | `touch` | -| `gtfo` | `mv` | -| `hackzor` | `git init` | -| `hai` | `cd` | -| `icanhas` | `mkdir` | -| `ihasbucket` | `df -h` | -| `iminurbase` | `finger` | -| `inur` | `locate` | -| `invisible` | `cat` | -| `iz` | `ls` | -| `kthxbai` | `halt` | -| `letcat` | `git checkout` | -| `moar` | `more` | -| `nomnom` | `killall` | -| `nomz` | `ps aux` | -| `nowai` | `chmod` | -| `oanward` | `git commit -m` | -| `obtw` | `nohup` | -| `onoz` | `cat /var/log/errors.log` | -| `ooanward` | `git commit -am` | -| `plz` | `pwd` | -| `pwned` | `ssh` | -| `rtfm` | `man` | -| `rulz` | `git push` | -| `tldr` | `less` | -| `violenz` | `git rebase` | -| `visible` | `echo` | -| `wtf` | `dmesg` | -| `yolo` | `git commit -m "$(curl -s https://whatthecommit.com/index.txt)"` | +| Alias | Command | +| ------------ | --------------------------------------------------------------- | +| `:3` | `echo` | +| `alwayz` | `tail -f` | +| `bringz` | `git pull` | +| `btw` | `nice` | +| `byes` | `exit` | +| `chicken` | `git add` | +| `cya` | `reboot` | +| `donotwant` | `rm` | +| `dowant` | `cp` | +| `gimmeh` | `touch` | +| `gtfo` | `mv` | +| `hackzor` | `git init` | +| `hai` | `cd` | +| `icanhas` | `mkdir` | +| `ihasbucket` | `df -h` | +| `iminurbase` | `finger` | +| `inur` | `locate` | +| `invisible` | `cat` | +| `iz` | `ls` | +| `kthxbai` | `halt` | +| `letcat` | `git checkout` | +| `moar` | `more` | +| `nomnom` | `killall` | +| `nomz` | `ps aux` | +| `nowai` | `chmod` | +| `oanward` | `git commit -m` | +| `obtw` | `nohup` | +| `onoz` | `cat /var/log/errors.log` | +| `ooanward` | `git commit -am` | +| `plz` | `pwd` | +| `pwned` | `ssh` | +| `rtfm` | `man` | +| `rulz` | `git push` | +| `tldr` | `less` | +| `violenz` | `git rebase` | +| `visible` | `echo` | +| `wtf` | `dmesg` | +| `yolo` | `git commit -m "$(curl -s http://whatthecommit.com/index.txt)"` | ## Usage Examples @@ -78,6 +66,6 @@ nowai u=r,go= some.file # ssh root@catserver.org pwned root@catserver.org -# git commit -m "$(curl -s https://whatthecommit.com/index.txt)" +# git commit -m "$(curl -s http://whatthecommit.com/index.txt)" yolo ``` diff --git a/zsh/plugins/lol/lol.plugin.zsh b/zsh/plugins/lol/lol.plugin.zsh index 585f96e..3c30259 100644 --- a/zsh/plugins/lol/lol.plugin.zsh +++ b/zsh/plugins/lol/lol.plugin.zsh @@ -45,7 +45,7 @@ alias bringz='git pull' alias chicken='git add' alias oanward='git commit -m' alias ooanward='git commit -am' -alias yolo='git commit -m "$(curl -s https://whatthecommit.com/index.txt)"' +alias yolo='git commit -m "$(curl -s http://whatthecommit.com/index.txt)"' alias letcat='git checkout' alias violenz='git rebase' diff --git a/zsh/plugins/lxd/README.md b/zsh/plugins/lxd/README.md new file mode 100644 index 0000000..cea45e3 --- /dev/null +++ b/zsh/plugins/lxd/README.md @@ -0,0 +1,9 @@ +# lxd + +This plugin provides completion for [lxd](https://linuxcontainers.org/lxd/), as well as aliases +for frequent lxc commands. + +To use it add `lxd` to the plugins array in your zshrc file. + +```zsh +plugins=(... lxd) diff --git a/zsh/plugins/lxd/lxd.plugin.zsh b/zsh/plugins/lxd/lxd.plugin.zsh new file mode 100644 index 0000000..a6a0742 --- /dev/null +++ b/zsh/plugins/lxd/lxd.plugin.zsh @@ -0,0 +1,26 @@ +_lxc_get_command_list () { + $_comp_command1 | sed "1,/Available Commands/d" | awk '/^[ \t]*[a-z]+/ { print $1 }' +} + +_lxc_get_subcommand_list () { + $_comp_command1 ${words[2]} | sed "1,/Available Commands/d" | awk '/^[ \t]*[a-z]+/ { print $1 }' +} + +_lxc () { + local curcontext="$curcontext" state line + typeset -A opt_args + _arguments \ + '1: :->command'\ + '*: :->args' + + case $state in + command) + compadd $(_lxc_get_command_list) + ;; + *) + compadd $(_lxc_get_subcommand_list) + ;; + esac +} + +compdef _lxc lxc diff --git a/zsh/plugins/macports/_port b/zsh/plugins/macports/_port index 06d7fb4..6a9ebe0 100644 --- a/zsh/plugins/macports/_port +++ b/zsh/plugins/macports/_port @@ -41,6 +41,8 @@ subcmds=( 'patch' 'pkg' 'provides' +'rdependents' +'rdeps' 'rpmpackage' 'search' 'selfupdate' diff --git a/zsh/plugins/magic-enter/README.md b/zsh/plugins/magic-enter/README.md new file mode 100644 index 0000000..78514c6 --- /dev/null +++ b/zsh/plugins/magic-enter/README.md @@ -0,0 +1,17 @@ +## Magic Enter plugin + +This plugin makes your enter key magical, by binding commonly used commands to it. + +To use it, add `magic-enter` to the plugins array in your zshrc file. You can set the +commands to be run in your .zshrc, before the line containing plugins. If no command +is specified in a git directory, `git status` is executed; in other directories, `ls`. + +```zsh +# defaults +MAGIC_ENTER_GIT_COMMAND='git status -u .' +MAGIC_ENTER_OTHER_COMMAND='ls -lh .' + +plugins=(... magic-enter) +``` + +**Maintainer:** [@dufferzafar](https://github.com/dufferzafar) diff --git a/zsh/plugins/magic-enter/Readme.md b/zsh/plugins/magic-enter/Readme.md deleted file mode 100644 index b401ab4..0000000 --- a/zsh/plugins/magic-enter/Readme.md +++ /dev/null @@ -1,14 +0,0 @@ -## 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/zsh/plugins/magic-enter/magic-enter.plugin.zsh b/zsh/plugins/magic-enter/magic-enter.plugin.zsh index 8e18596..2d4d578 100644 --- a/zsh/plugins/magic-enter/magic-enter.plugin.zsh +++ b/zsh/plugins/magic-enter/magic-enter.plugin.zsh @@ -3,7 +3,6 @@ # 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 ." @@ -20,5 +19,9 @@ magic-enter () { zle accept-line fi } + zle -N magic-enter -bindkey "^M" magic-enter + +bindkey -M emacs "^M" magic-enter +bindkey -M vicmd "^M" magic-enter +bindkey -M viins "^M" magic-enter diff --git a/zsh/plugins/man/man.plugin.zsh b/zsh/plugins/man/man.plugin.zsh index 94aa491..dcba613 100644 --- a/zsh/plugins/man/man.plugin.zsh +++ b/zsh/plugins/man/man.plugin.zsh @@ -13,15 +13,25 @@ # ------------------------------------------------------------------------------ man-command-line() { - [[ -z $BUFFER ]] && zle up-history - [[ $BUFFER != man\ * ]] && LBUFFER="man $LBUFFER" + # if there is no command typed, use the last command + [[ -z "$BUFFER" ]] && zle up-history + + # if typed command begins with man, do nothing + [[ "$BUFFER" = man\ * ]] && return + + # get command and possible subcommand + # http://zsh.sourceforge.net/Doc/Release/Expansion.html#Parameter-Expansion-Flags + local -a args + args=(${${(Az)BUFFER}[1]} ${${(Az)BUFFER}[2]}) + + # check if man page exists for command and first argument + if man "${args[1]}-${args[2]}" >/dev/null 2>&1; then + BUFFER="man $args" + else + BUFFER="man ${args[1]}" + fi } + zle -N man-command-line # Defined shortcut keys: [Esc]man bindkey "\e"man man-command-line - - -# ------------------------------------------------------------------------------ -# Also, you might want to use man-preview included in 'osx' plugin -# just substitute "man" in the function with "man-preview" after you included OS X in -# the .zshrc diff --git a/zsh/plugins/mercurial/README.md b/zsh/plugins/mercurial/README.md index f42212d..80ea2de 100644 --- a/zsh/plugins/mercurial/README.md +++ b/zsh/plugins/mercurial/README.md @@ -1,60 +1,66 @@ # Mercurial plugin -### Usage -Update .zshrc: -1. Add name to the list of plugins, e.g. `plugins=(... mercurial ...)` - (that is pretty obvious). -2. Switch to a theme which uses `hg_prompt_info`. +This plugin adds some handy aliases for using Mercurial as well as a few +utility and prompt functions that can be used in a theme. - Or, customize the `$PROMPT` variable of your current theme to contain current folder mercurial repo info. This can be done by putting a custom version of the theme in `$ZSH_CUSTOM` or by changing `$PROMPT` in `.zshrc` after loading the theme. +To use it, add `mercurial` to the plugins array in your zshrc file: - The `robbyrussell` theme is used by default, so you need to modify `$PROMPT` var by adding `$(hg_prompt_info)` after `$(git_prompt_info)`, so it looks like this: +```zsh +plugins=(... mercurial) +``` - ```zsh - PROMPT='${ret_status}%{$fg_bold[green]%}%p %{$fg[cyan]%}%c %{$fg_bold[blue]%}$(git_prompt_info)$(hg_prompt_info)%{$fg_bold[blue]%} % %{$reset_color%}' - ``` +## Aliases -3. Initialize additional vars used in plugin. So in short put next in **.zshrc**: +| Alias | Command | +|--------|-------------------------------------------------------------------------------------------------------------| +| `hga` | `hg add` | +| `hgc` | `hg commit` | +| `hgca` | `hg commit --amend` | +| `hgb` | `hg branch` | +| `hgba` | `hg branches` | +| `hgbk` | `hg bookmarks` | +| `hgco` | `hg checkout` | +| `hgd` | `hg diff` | +| `hged` | `hg diffmerge` | +| `hgp` | `hg push` | +| `hgs` | `hg status` | +| `hgsl` | `hg log --limit 20 --template "{node|short} | {date|isodatesec} | {author|user}: {desc|strip|firstline}\n"` | +| `hgun` | `hg resolve --list` | +| `hgi` | `hg incoming` | +| `hgl` | `hg pull -u` | +| `hglr` | `hg pull --rebase` | +| `hgo` | `hg outgoing` | - ``` - ZSH_THEME_HG_PROMPT_PREFIX="%{$fg_bold[magenta]%}hg:(%{$fg[red]%}" - ZSH_THEME_HG_PROMPT_SUFFIX="%{$reset_color%}" - ZSH_THEME_HG_PROMPT_DIRTY="%{$fg[magenta]%}) %{$fg[yellow]%}✗%{$reset_color%}" - ZSH_THEME_HG_PROMPT_CLEAN="%{$fg[magenta]%})" - ``` +## Prompt usage -### What's inside? -#### Adds handy aliases: -###### general -* `hgc` - `hg commit` -* `hgb` - `hg branch` -* `hgba` - `hg branches` -* `hgbk` - `hg bookmarks` -* `hgco` - `hg checkout` -* `hgd` - `hg diff` -* `hged` - `hg diffmerge` +- Switch to a theme which uses `hg_prompt_info` -###### pull and update -* `hgi` - `hg incoming` -* `hgl` - `hg pull -u` -* `hglr` - `hg pull --rebase` -* `hgo` - `hg outgoing` -* `hgp` - `hg push` -* `hgs` - `hg status` -* `hgsl` - `hg log --limit 20 --template "{node|short} | {date|isodatesec} | {author|user}: {desc|strip|firstline}\n"` +- Or customize the `$PROMPT` variable of your current theme to contain current folder mercurial repo info. + This can be done by putting a custom version of the theme in `$ZSH_CUSTOM` or by changing `$PROMPT` in + `.zshrc` after loading the theme. -###### this is the 'git commit --amend' equivalent -* `hgca` - `hg qimport -r tip ; hg qrefresh -e ; hg qfinish tip` + For example, for the `robbyrussell` theme you need to modify `$PROMPT` var by adding `$(hg_prompt_info)` + after `$(git_prompt_info)`, so it looks like this: -###### list unresolved files (since hg does not list unmerged files in the status command) -* `hgun` - `hg resolve --list` + ```zsh + PROMPT='${ret_status}%{$fg_bold[green]%}%p %{$fg[cyan]%}%c %{$fg_bold[blue]%}$(git_prompt_info)$(hg_prompt_info)%{$fg_bold[blue]%} % %{$reset_color%}' + ``` -#### Displays repo branch and directory status in prompt -This is the same as git plugin does. +You can also redefine additional vars used in the plugin (after Oh My Zsh is sourced): -**Note**: Additional changes to **.zshrc**, or using a theme designed to use `hg_prompt_info`, are required in order for this to work. +```zsh +ZSH_THEME_HG_PROMPT_PREFIX="%{$fg_bold[magenta]%}hg:(%{$fg[red]%}" +ZSH_THEME_HG_PROMPT_SUFFIX="%{$reset_color%}" +ZSH_THEME_HG_PROMPT_DIRTY="%{$fg[magenta]%}) %{$fg[yellow]%}✗%{$reset_color%}" +ZSH_THEME_HG_PROMPT_CLEAN="%{$fg[magenta]%})" +``` -### Mantainers -[ptrv](https://github.com/ptrv) - original creator +### Display repo branch and directory status in prompt -[oshybystyi](https://github.com/oshybystyi) - created this README and know how most of code works +This is the same as git plugin does. **Note**: additional changes to `.zshrc`, or using a theme designed +to use `hg_prompt_info`, are required in order for this to work. + +## Mantainers + +- [ptrv](https://github.com/ptrv): original creator +- [oshybystyi](https://github.com/oshybystyi) diff --git a/zsh/plugins/mercurial/mercurial.plugin.zsh b/zsh/plugins/mercurial/mercurial.plugin.zsh index 58bc571..f134304 100644 --- a/zsh/plugins/mercurial/mercurial.plugin.zsh +++ b/zsh/plugins/mercurial/mercurial.plugin.zsh @@ -1,23 +1,22 @@ -# Mercurial +# aliases alias hga='hg add' alias hgc='hg commit' +alias hgca='hg commit --amend' alias hgb='hg branch' alias hgba='hg branches' alias hgbk='hg bookmarks' alias hgco='hg checkout' alias hgd='hg diff' alias hged='hg diffmerge' +alias hgp='hg push' +alias hgs='hg status' +alias hgsl='hg log --limit 20 --template "{node|short} | {date|isodatesec} | {author|user}: {desc|strip|firstline}\n"' +alias hgun='hg resolve --list' # pull and update alias hgi='hg incoming' alias hgl='hg pull -u' alias hglr='hg pull --rebase' alias hgo='hg outgoing' -alias hgp='hg push' -alias hgs='hg status' -alias hgsl='hg log --limit 20 --template "{node|short} | {date|isodatesec} | {author|user}: {desc|strip|firstline}\n" ' -alias hgca='hg commit --amend' -# 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/zsh/plugins/meteor/README.md b/zsh/plugins/meteor/README.md index 4bee87f..f7c43b7 100644 --- a/zsh/plugins/meteor/README.md +++ b/zsh/plugins/meteor/README.md @@ -1,9 +1,10 @@ -## Introduction +# meteor plugin -The [meteor plugin](https://github.com/robbyrussell/oh-my-zsh/tree/master/plugins/meteor) provides many +The [meteor plugin](https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/meteor) provides many [useful aliases](#aliases) as well as completion for the `meteor` command. Enable it by adding `meteor` to the plugins array in your zshrc file: + ```zsh plugins=(... meteor) ``` diff --git a/zsh/plugins/microk8s/README.md b/zsh/plugins/microk8s/README.md new file mode 100644 index 0000000..2b4ea20 --- /dev/null +++ b/zsh/plugins/microk8s/README.md @@ -0,0 +1,24 @@ +# MicroK8s plugin + +This plugin provides completion and useful aliases for [MicroK8s](https://microk8s.io/). + +To use it, add `microk8s` to the plugins array in your zshrc file. + +```zsh +plugins=(... microk8s) +``` + +## Aliases + +| Alias | Command | Description | +|-------|------------------|----------------------------------------------------------------------------------------------------------| +| mco | microk8s.config | Shows the Kubernetes config file. | +| mct | microk8s.ctr | Interact with containerd CLI. | +| mdi | microk8s.disable | Disables an addon. | +| me | microk8s.enable | Enables an addon. | +| mh | microk8s.helm | Interact with Helm CLI. | +| mis | microk8s.istio | Interact with Istio CLI. | +| mk | microk8s.kubectl | Interact with Kubernetes CLI. | +| msp | microk8s.stop | Stops all Kubernetes services. | +| mst | microk8s.start | Starts MicroK8s after it is being stopped. | +| msts | microk8s.status | Provides an overview of the MicroK8s state (running / not running) as well as the set of enabled addons. | \ No newline at end of file diff --git a/zsh/plugins/microk8s/microk8s.plugin.zsh b/zsh/plugins/microk8s/microk8s.plugin.zsh new file mode 100644 index 0000000..048a9ab --- /dev/null +++ b/zsh/plugins/microk8s/microk8s.plugin.zsh @@ -0,0 +1,82 @@ +# ---------------------------------------------------------- # +# Aliases and Completions for MicroK8s (https://microk8s.io) # +# Author: Shaun Tabone (https://github.com/xontab) # +# ---------------------------------------------------------- # + +# Helper function to cache and load completions +_microk8s_cache_completion() { + local cache="${ZSH_CACHE_DIR}/microk8s_$(echo $1)_completion" + if [[ ! -f $cache ]]; then + $2 $cache + fi + + [[ -f $cache ]] && source $cache +} + +# ---------------------------------------------------------- # +# microk8s.enable # +# ALIAS: me # +# ---------------------------------------------------------- # +_microk8s_enable_get_command_list() { + microk8s.enable --help | tail -n +7 | awk '{$1=$1;print}' +} + +_microk8s_enable() { + compadd -X "MicroK8s Addons" $(_microk8s_enable_get_command_list) +} + +compdef _microk8s_enable microk8s.enable +alias me='microk8s.enable' + +# ---------------------------------------------------------- # +# microk8s.disable # +# ALIAS: mdi # +# ---------------------------------------------------------- # +_microk8s_disable_get_command_list() { + microk8s.disable --help | tail -n +7 | awk '{$1=$1;print}' +} + +_microk8s_disable() { + compadd -X "MicroK8s Addons" $(_microk8s_disable_get_command_list) +} + +compdef _microk8s_disable microk8s.disable +alias mdi='microk8s.disable' + +# ---------------------------------------------------------- # +# microk8s.kubectl # +# ALIAS: mk # +# ---------------------------------------------------------- # +_microk8s_kubectl_completion() { + if [ $commands[microk8s.kubectl] ]; then + microk8s.kubectl 2>/dev/null >/dev/null && microk8s.kubectl completion zsh | sed 's/__start_kubectl kubectl/__start_kubectl microk8s.kubectl/g' >$1 + fi +} + +_microk8s_cache_completion 'kubectl' _microk8s_kubectl_completion + +alias mk='microk8s.kubectl' + +# ---------------------------------------------------------- # +# microk8s.helm # +# ALIAS: mh # +# ---------------------------------------------------------- # +_microk8s_helm_completion() { + if [ $commands[microk8s.helm] ]; then + microk8s.helm completion zsh | sed 's/__start_helm helm/__start_helm microk8s.helm/g' >$1 + fi +} + +_microk8s_cache_completion 'helm' _microk8s_helm_completion + +alias mh='microk8s.helm' + +# ---------------------------------------------------------- # +# Other Aliases # +# ---------------------------------------------------------- # +alias mco='microk8s.config' +alias mct='microk8s.ctr' +alias mis='microk8s.istio' +alias mst='microk8s.start' +alias msts='microk8s.status' +alias msp='microk8s.stop' diff --git a/zsh/plugins/minikube/minikube.plugin.zsh b/zsh/plugins/minikube/minikube.plugin.zsh index d8ebe79..e87abce 100644 --- a/zsh/plugins/minikube/minikube.plugin.zsh +++ b/zsh/plugins/minikube/minikube.plugin.zsh @@ -1,6 +1,13 @@ # Autocompletion for Minikube. # +if (( $+commands[minikube] )); then + __MINIKUBE_COMPLETION_FILE="${ZSH_CACHE_DIR}/minikube_completion" -if [ $commands[minikube] ]; then - source <(minikube completion zsh) + if [[ ! -f $__MINIKUBE_COMPLETION_FILE ]]; then + minikube completion zsh >! $__MINIKUBE_COMPLETION_FILE + fi + + [[ -f $__MINIKUBE_COMPLETION_FILE ]] && source $__MINIKUBE_COMPLETION_FILE + + unset __MINIKUBE_COMPLETION_FILE fi diff --git a/zsh/plugins/mix-fast/mix-fast.plugin.zsh b/zsh/plugins/mix-fast/mix-fast.plugin.zsh index e27e30d..564c505 100644 --- a/zsh/plugins/mix-fast/mix-fast.plugin.zsh +++ b/zsh/plugins/mix-fast/mix-fast.plugin.zsh @@ -12,7 +12,7 @@ _mix_does_task_list_need_generating () { } _mix_generate () { - mix help | grep -v 'iex -S' | tail -n +2 | cut -d " " -f 2 > .mix_tasks + mix help | grep '^mix [^ ]' | sed -E "s/mix ([^ ]*) *# (.*)/\1:\2/" > .mix_tasks } _mix () { @@ -21,7 +21,8 @@ _mix () { echo "\nGenerating .mix_tasks..." > /dev/stderr _mix_generate fi - compadd `cat .mix_tasks` + local tasks=(${(f)"$(cat .mix_tasks)"}) + _describe 'tasks' tasks fi } diff --git a/zsh/plugins/mix/_mix b/zsh/plugins/mix/_mix index 61fa1cf..c0fe68c 100644 --- a/zsh/plugins/mix/_mix +++ b/zsh/plugins/mix/_mix @@ -34,6 +34,7 @@ _1st_arguments=( 'firmware:Nerves - Build a firmware image for the selected target platform' 'firmware.burn:Nerves - Writes the generated firmware image to an attached SDCard or file' 'firmware.image:Nerves - Create a firmware image file that can be copied byte-for-byte' + 'format:Formats the given files and patterns' 'help:Print help information for tasks' 'hex:Print hex help information' 'hex.config:Read or update hex config' @@ -92,7 +93,7 @@ __task_list () local expl declare -a tasks - tasks=(app.start archive archive.build archive.install archive.uninstall clean cmd compile compile.protocols deps deps.clean deps.compile deps.get deps.unlock deps.update do escript.build help hex hex.config hex.docs hex.info hex.key hex.outdated hex.owner hex.publish hex.search hex.user loadconfig local local.hex local.rebar new phoenix.digest phoenix.gen.channel phoenix.gen.html phoenix.gen.json phoenix.gen.model phoenix.gen.secret phoenix.new phoenix.routes phoenix.server phx.digest phx.digest.clean phx.gen.channel phx.gen.context phx.gen.embedded phx.gen.html phx.gen.json phx.gen.presence phx.gen.schema phx.gen.secret phx.new phx.new.ecto phx.new.web phx.routes phx.server run test) + tasks=(app.start archive archive.build archive.install archive.uninstall clean cmd compile compile.protocols deps deps.clean deps.compile deps.get deps.unlock deps.update do escript.build format help hex hex.config hex.docs hex.info hex.key hex.outdated hex.owner hex.publish hex.search hex.user loadconfig local local.hex local.rebar new phoenix.digest phoenix.gen.channel phoenix.gen.html phoenix.gen.json phoenix.gen.model phoenix.gen.secret phoenix.new phoenix.routes phoenix.server phx.digest phx.digest.clean phx.gen.channel phx.gen.context phx.gen.embedded phx.gen.html phx.gen.json phx.gen.presence phx.gen.schema phx.gen.secret phx.new phx.new.ecto phx.new.web phx.routes phx.server run test) _wanted tasks expl 'help' compadd $tasks } diff --git a/zsh/plugins/mvn/README.md b/zsh/plugins/mvn/README.md index 88f5be8..815dfd5 100644 --- a/zsh/plugins/mvn/README.md +++ b/zsh/plugins/mvn/README.md @@ -4,6 +4,7 @@ The mvn plugin provides many [useful aliases](#aliases) as well as completion fo the [Apache Maven](https://maven.apache.org/) command (`mvn`). Enable it by adding `mvn` to the plugins array in your zshrc file: + ```zsh plugins=(... mvn) ``` @@ -18,6 +19,7 @@ if it's found, or the mvn command otherwise. | `mvn!` | `mvn -f /pom.xml` | | `mvnag` | `mvn archetype:generate` | | `mvnboot` | `mvn spring-boot:run` | +| `mvnqdev` | `mvn quarkus:dev` | | `mvnc` | `mvn clean` | | `mvncd` | `mvn clean deploy` | | `mvnce` | `mvn clean eclipse:clean eclipse:eclipse` | @@ -35,6 +37,7 @@ if it's found, or the mvn command otherwise. | `mvndocs` | `mvn dependency:resolve -Dclassifier=javadoc` | | `mvndt` | `mvn dependency:tree` | | `mvne` | `mvn eclipse:eclipse` | +| `mvnfmt` | `mvn fmt:format` | | `mvnjetty` | `mvn jetty:run` | | `mvnp` | `mvn package` | | `mvns` | `mvn site` | @@ -55,4 +58,4 @@ has colored output, so this function will be soon removed from the plugin. ### Known bugs It has a bug where it will swallow mvn prompts for user input, _e.g._ when using -`archetype:generate`. See [#5052](https://github.com/robbyrussell/oh-my-zsh/issues/5052). +`archetype:generate`. See [#5052](https://github.com/ohmyzsh/ohmyzsh/issues/5052). diff --git a/zsh/plugins/mvn/mvn.plugin.zsh b/zsh/plugins/mvn/mvn.plugin.zsh index 01aef81..27d63a6 100644 --- a/zsh/plugins/mvn/mvn.plugin.zsh +++ b/zsh/plugins/mvn/mvn.plugin.zsh @@ -59,8 +59,10 @@ alias mvnd='mvn deploy' alias mvndocs='mvn dependency:resolve -Dclassifier=javadoc' alias mvndt='mvn dependency:tree' alias mvne='mvn eclipse:eclipse' +alias mvnfmt='mvn fmt:format' alias mvnjetty='mvn jetty:run' alias mvnp='mvn package' +alias mvnqdev='mvn quarkus:dev' alias mvns='mvn site' alias mvnsrc='mvn dependency:sources' alias mvnt='mvn test' @@ -71,7 +73,7 @@ alias mvn-updates='mvn versions:display-dependency-updates' function listMavenCompletions { local file new_file - local -a profiles POM_FILES + local -a profiles POM_FILES modules # Root POM POM_FILES=(~/.m2/settings.xml) @@ -107,6 +109,9 @@ function listMavenCompletions { profiles+=($(sed 's///' "$file" | sed '//d' | grep -e "" -A 1 | grep -e ".*" | sed 's?.*\(.*\)<\/id>.*?-P\1?')) done + # List modules + modules=($(find **/pom.xml -type f | grep -v '/target/classes/META-INF/' | grep '/pom.xml' |sed 's|\(.*\)/pom\.xml|\1|')) + reply=( # common lifecycle clean initialize process-resources compile process-test-resources test-compile test package verify install deploy site @@ -183,6 +188,8 @@ function listMavenCompletions { tomee:run tomee:run-war tomee:run-war-only tomee:stop tomee:deploy tomee:undeploy # spring-boot spring-boot:run spring-boot:repackage + # quarkus + quarkus:dev quarkus:list-extensions quarkus:add-extension quarkus:add-extensions quarkus:generate-config quarkus:help # exec exec:exec exec:java # versions @@ -267,6 +274,8 @@ function listMavenCompletions { stage:copy # toolchain toolchain:toolchain + #liberty + liberty:clean-server liberty:compile-jsp liberty:configure-arquillian liberty:create-server liberty:debug liberty:debug-server liberty:deploy liberty:dev liberty:display-url liberty:dump-server liberty:install-apps liberty:install-feature liberty:install-server liberty:java-dump-server liberty:package-server liberty:run liberty:run-server liberty:server-status liberty:start liberty:start-server liberty:status liberty:stop liberty:stop-server liberty:test-start-server liberty:test-stop-server liberty:undeploy liberty:uninstall-feature # options "-Dmaven.test.skip=true" -DskipTests -DskipITs -Dmaven.surefire.debug -DenableCiProfile "-Dpmd.skip=true" "-Dcheckstyle.skip=true" "-Dtycho.mode=maven" "-Dmaven.test.failure.ignore=true" "-DgroupId=" "-DartifactId=" "-Dversion=" "-Dpackaging=jar" "-Dfile=" @@ -317,6 +326,7 @@ function listMavenCompletions { -Dit.test=$(if [ -d ./src/test/java ] ; then find ./src/test/java -type f -name '*.java' | grep -v svn | sed 's?.*/\([^/]*\)\..*?-Dit.test=\1?' ; fi) $profiles + $modules ) } diff --git a/zsh/plugins/mysql-macports/README.md b/zsh/plugins/mysql-macports/README.md new file mode 100644 index 0000000..ff4fb3a --- /dev/null +++ b/zsh/plugins/mysql-macports/README.md @@ -0,0 +1,20 @@ +# MySQL-Macports plugin + +This plugin adds aliases for some of the commonly used [MySQL](https://www.mysql.com/) commands when installed using [MacPorts](https://www.macports.org/) on macOS. + +To use it, add `mysql-macports` to the plugins array in your zshrc file: + +```zsh +plugins=(... mysql-macports) +``` + +For instructions on how to install MySQL using MacPorts, read the [MacPorts wiki](https://trac.macports.org/wiki/howto/MySQL/). + +## Aliases + +| Alias | Command | Description | +| ------------ | ------------------------------------ | ------------------------------------------ | +| mysqlstart | `sudo /path/to/mysql.server start` | Start the MySQL server. | +| mysqlstop | `sudo /path/to/mysql.server stop` | Stop the MySQL server. | +| mysqlrestart | `sudo /path/to/mysql.server restart` | Restart the MySQL server. | +| mysqlstatus | `mysqladmin5 -u root -p ping` | Check whether the MySQL server is running. | diff --git a/zsh/plugins/n98-magerun/README.md b/zsh/plugins/n98-magerun/README.md new file mode 100644 index 0000000..b0abe47 --- /dev/null +++ b/zsh/plugins/n98-magerun/README.md @@ -0,0 +1,21 @@ +# n98-magerun plugin + +The swiss army knife for Magento developers, sysadmins and devops. The tool provides a huge set of well tested command line commands which save hours of work time. + +The [n98-magerun plugin](https://github.com/netz98/n98-magerun) provides many +[useful aliases](#aliases) as well as completion for the `n98-magerun` command. + +Enable it by adding `n98-magerun` to the plugins array in your zshrc file: + +```zsh +plugins=(... n98-magerun) +``` + +## Aliases + +| Alias | Command | Description | +| --------- | -------------------------------------------------- | --------------------------------------------------------------------------------- | +| n98 | `n98-magerun.phar` | The N98-Magerun phar-file (Version 1) | +| n98-2 | `n98-magerun2.phar` | The N98-Magerun phar-file (Version 2) | +| mage-get | `wget https://files.magerun.net/n98-magerun.phar` | Download the latest stable N98-Magerun phar-file from the file-server (Version 1) | +| mage2-get | `wget https://files.magerun.net/n98-magerun2.phar` | Download the latest stable N98-Magerun phar-file from the file-server (Version 2) | diff --git a/zsh/plugins/ng/README.md b/zsh/plugins/ng/README.md index 86ad640..29ac15a 100644 --- a/zsh/plugins/ng/README.md +++ b/zsh/plugins/ng/README.md @@ -1,37 +1,10 @@ -## NG Plugin +# ng plugin -This [ng plugin](https://github.com/robbyrussell/oh-my-zsh/tree/master/plugins/ng) - adds completion support for Angular's CLI (named ng). +This plugin adds autocompletion support for [Angular's CLI](https://github.com/angular/angular-cli) +(named `ng`). -Ng is hosted on [ng home](https://github.com/catull/angular-cli) - -It is used to generate Angular 2 app "stubs", build those apps, configure them, -test them, lint them etc. - -Ahem, "stubs" is not what Angular engineers refer to the items ng can generate -for you. - -"Stubs" can be any one of: -- class -- component -- directive -- enum -- module -- pipe -- route -- service - -At the moment, `ng completion` creates a very rough completion for Zsh and -Bash. - -It is missing most of the options and a few arguments. -In future, this plugin may be shortened to simply being +To use it, add `ng` to the plugins array of your zshrc file: ```zsh -eval `ng completion` +plugins=(... ng) ``` - -There is hope this materialises in the 21st century. - -### CONTRIBUTOR - - Carlo Dapor ([catull](https://github.com/catull)) diff --git a/zsh/plugins/nmap/README.md b/zsh/plugins/nmap/README.md index 5cd6462..0a60068 100644 --- a/zsh/plugins/nmap/README.md +++ b/zsh/plugins/nmap/README.md @@ -1,37 +1,27 @@ -# Nmap aliases plugin +# Nmap plugin -Adds some useful aliases for nmap similar to the profiles in zenmap. +Adds some useful aliases for [Nmap](https://nmap.org/) similar to the profiles in zenmap. -Nmap options are: - * -sS - TCP SYN scan - * -v - verbose - * -T1 - timing of scan. Options are paranoid (0), sneaky (1), polite (2), normal (3), aggressive (4), and insane (5) - * -sF - FIN scan (can sneak through non-stateful firewalls) - * -PE - ICMP echo discovery probe - * -PP - timestamp discovery probe - * -PY - SCTP init ping - * -g - use given number as source port - * -A - enable OS detection, version detection, script scanning, and traceroute (aggressive) - * -O - enable OS detection - * -sA - TCP ACK scan - * -F - fast scan - * --script=vulscan - also access vulnerabilities in target +To use it, add `nmap` to the plugins array in your zshrc file: -## Aliases explained +```zsh +plugins=(... nmap) +``` - * nmap_open_ports - Scan for open ports on target - * nmap_list_interfaces - List all network interfaces on host where the command runs - * nmap_slow - Slow scan that avoids to spam the targets logs - * nmap_fin - Scan to see if hosts are up with TCP FIN scan - * nmap_full - Aggressive full scan that scans all ports, tries to determine OS and service versions - * nmap_check_for_firewall - TCP ACK scan to check for firewall existence - * nmap_ping_through_firewall - Host discovery with SYN and ACK probes instead of just pings to avoid firewall - restrictions - * nmap_fast - Fast scan of the top 300 popular ports - * nmap_detect_versions - Detects versions of services and OS, runs on all ports - * nmap_check_for_vulns - Uses vulscan script to check target services for vulnerabilities - * nmap_full_udp - Same as full but via UDP - * nmap_traceroute - Try to traceroute using the most common ports - * nmap_full_with_scripts - Same as nmap_full but also runs all the scripts - * nmap_web_safe_osscan - Little "safer" scan for OS version as connecting to only HTTP and HTTPS ports doesn't look so attacking. +## Aliases +- `nmap_open_ports`: scan for open ports on target. +- `nmap_list_interfaces`: list all network interfaces on host where the command runs. +- `nmap_slow`: slow scan that avoids to spam the targets logs. +- `nmap_fin`: scan to see if hosts are up with TCP FIN scan. +- `nmap_full`: aggressive full scan that scans all ports, tries to determine OS and service versions. +- `nmap_check_for_firewall`: TCP ACK scan to check for firewall existence. +- `nmap_ping_through_firewall`: host discovery with SYN and ACK probes instead of just pings to avoid firewall restrictions. +- `nmap_fast`: fast scan of the top 300 popular ports. +- `nmap_detect_versions`: detects versions of services and OS, runs on all ports. +- `nmap_check_for_vulns`: uses vulscan script to check target services for vulnerabilities. +- `nmap_full_udp`: same as full but via UDP. +- `nmap_traceroute`: try to traceroute using the most common ports. +- `nmap_full_with_scripts`: same as nmap_full but also runs all the scripts. +- `nmap_web_safe_osscan`: little "safer" scan for OS version as connecting to only HTTP and HTTPS ports doesn't look so attacking. +- `nmap_ping_scan`: ICMP scan for active hosts. diff --git a/zsh/plugins/nmap/nmap.plugin.zsh b/zsh/plugins/nmap/nmap.plugin.zsh index 8c691bd..406870f 100644 --- a/zsh/plugins/nmap/nmap.plugin.zsh +++ b/zsh/plugins/nmap/nmap.plugin.zsh @@ -29,4 +29,4 @@ alias nmap_full_udp="sudo nmap -sS -sU -T4 -A -v -PE -PS22,25,80 -PA21,23,80,443 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 " - +alias nmap_ping_scan="nmap -n -sP" diff --git a/zsh/plugins/node/README.md b/zsh/plugins/node/README.md index c392dc0..911b669 100644 --- a/zsh/plugins/node/README.md +++ b/zsh/plugins/node/README.md @@ -1,16 +1,19 @@ # node plugin +This plugin adds `node-docs` function that opens specific section in [Node.js](https://nodejs.org) +documentation (depending on the installed version). + To use it, add `node` to the plugins array of your zshrc file: + ```zsh plugins=(... node) ``` -This plugin adds `node-docs` function that open specific section in [Node.js](https://nodejs.org) documentation (depending on the installed version). -For example: +## Usage ```zsh # Opens https://nodejs.org/docs/latest-v10.x/api/fs.html $ node-docs fs # Opens https://nodejs.org/docs/latest-v10.x/api/path.html -$ node-docs path +$ node-docs path ``` diff --git a/zsh/plugins/npm/README.md b/zsh/plugins/npm/README.md index 202e2b0..0b1a228 100644 --- a/zsh/plugins/npm/README.md +++ b/zsh/plugins/npm/README.md @@ -1,9 +1,10 @@ -## npm plugin +# npm plugin The npm plugin provides completion as well as adding many useful aliases. To use it, add npm to the plugins array of your zshrc file: -``` + +```zsh plugins=(... npm) ``` diff --git a/zsh/plugins/npm/npm.plugin.zsh b/zsh/plugins/npm/npm.plugin.zsh index f62174a..87c68f3 100644 --- a/zsh/plugins/npm/npm.plugin.zsh +++ b/zsh/plugins/npm/npm.plugin.zsh @@ -1,14 +1,16 @@ (( $+commands[npm] )) && { - __NPM_COMPLETION_FILE="${ZSH_CACHE_DIR:-$ZSH/cache}/npm_completion" + rm -f "${ZSH_CACHE_DIR:-$ZSH/cache}/npm_completion" - if [[ ! -f $__NPM_COMPLETION_FILE ]]; then - npm completion >! $__NPM_COMPLETION_FILE 2>/dev/null - [[ $? -ne 0 ]] && rm -f $__NPM_COMPLETION_FILE - fi - - [[ -f $__NPM_COMPLETION_FILE ]] && source $__NPM_COMPLETION_FILE - - unset __NPM_COMPLETION_FILE + _npm_completion() { + local si=$IFS + compadd -- $(COMP_CWORD=$((CURRENT-1)) \ + COMP_LINE=$BUFFER \ + COMP_POINT=0 \ + npm completion -- "${words[@]}" \ + 2>/dev/null) + IFS=$si + } + compdef _npm_completion npm } # Install dependencies globally diff --git a/zsh/plugins/nvm/README.md b/zsh/plugins/nvm/README.md index 079cf00..749a434 100644 --- a/zsh/plugins/nvm/README.md +++ b/zsh/plugins/nvm/README.md @@ -1,9 +1,26 @@ # nvm plugin -This plugin adds autocompletions for [nvm](https://github.com/creationix/nvm) — a Node.js version manager. +This plugin adds autocompletions for [nvm](https://github.com/nvm-sh/nvm) — a Node.js version manager. It also automatically sources nvm, so you don't need to do it manually in your `.zshrc`. To use it, add `nvm` to the plugins array of your zshrc file: + ```zsh plugins=(... nvm) ``` + +## Settings + +- **`NVM_DIR`**: if you have installed nvm in a directory other than `$HOME/.nvm`, set and export `NVM_DIR` + to be the directory where you installed nvm. + +- **`NVM_HOMEBREW`**: if you installed nvm via Homebrew, in a directory other than `/usr/local/opt/nvm`, you + can set `NVM_HOMEBREW` to be the directory where you installed it. + +- **`NVM_LAZY`**: if you want the plugin to defer the load of nvm to speed-up the start of your zsh session, + set `NVM_LAZY` to `1`. This will use the `--no-use` parameter when loading nvm, and will create a function + for `node`, `npm` and `yarn`, so when you call either of these three, nvm will load with `nvm use default`. + +- **`NVM_AUTOLOAD`**: if `NVM_AUTOLOAD` is set to `1`, the plugin will automatically load a node version when + if finds a [`.nvmrc` file](https://github.com/nvm-sh/nvm#nvmrc) in the current working directory indicating + which node version to load. diff --git a/zsh/plugins/nvm/_nvm b/zsh/plugins/nvm/_nvm index 1eec48b..e292a8d 100644 --- a/zsh/plugins/nvm/_nvm +++ b/zsh/plugins/nvm/_nvm @@ -8,6 +8,7 @@ _1st_arguments=( 'help:show help' '--version:print out the latest released version of nvm' 'install:download and install a version in ' + 'install-latest-npm:download and install the latest npm version' 'uninstall:uninstall a version' 'use:modify PATH to use . Uses .nvmrc if available' 'exec:run on . Uses .nvmrc if available' diff --git a/zsh/plugins/nvm/nvm.plugin.zsh b/zsh/plugins/nvm/nvm.plugin.zsh index 4bab8e9..1e9b26e 100644 --- a/zsh/plugins/nvm/nvm.plugin.zsh +++ b/zsh/plugins/nvm/nvm.plugin.zsh @@ -1,8 +1,77 @@ -# Set NVM_DIR if it isn't already defined -[[ -z "$NVM_DIR" ]] && export NVM_DIR="$HOME/.nvm" - -# Try to load nvm only if command not already available -if ! type "nvm" &> /dev/null; then - # Load nvm if it exists - [[ -f "$NVM_DIR/nvm.sh" ]] && source "$NVM_DIR/nvm.sh" +# See https://github.com/nvm-sh/nvm#installation-and-update +if [[ -z "$NVM_DIR" ]]; then + if [[ -d "$HOME/.nvm" ]]; then + export NVM_DIR="$HOME/.nvm" + elif [[ -d "${XDG_CONFIG_HOME:-$HOME/.config}/nvm" ]]; then + export NVM_DIR="${XDG_CONFIG_HOME:-$HOME/.config}/nvm" + fi fi + +# Don't try to load nvm if command already available +which nvm &> /dev/null && return + +if [[ -f "$NVM_DIR/nvm.sh" ]]; then + # Load nvm if it exists in $NVM_DIR + source "$NVM_DIR/nvm.sh" ${NVM_LAZY+"--no-use"} +else + # Otherwise try to load nvm installed via Homebrew + # User can set this if they have an unusual Homebrew setup + NVM_HOMEBREW="${NVM_HOMEBREW:-/usr/local/opt/nvm}" + # Load nvm from Homebrew location if it exists + if [[ -f "$NVM_HOMEBREW/nvm.sh" ]]; then + source "$NVM_HOMEBREW/nvm.sh" ${NVM_LAZY+"--no-use"} + else + # Exit the plugin if we couldn't find nvm + return + fi +fi + +# Call nvm when first using node, npm or yarn +if (( $+NVM_LAZY )); then + function node npm yarn { + unfunction node npm yarn + nvm use default + command "$0" "$@" + } +fi + +# Autoload nvm when finding a .nvmrc file in the current directory +# Adapted from: https://github.com/nvm-sh/nvm#zsh +if (( $+NVM_AUTOLOAD )); then + load-nvmrc() { + local node_version="$(nvm version)" + local nvmrc_path="$(nvm_find_nvmrc)" + + if [[ -n "$nvmrc_path" ]]; then + local nvmrc_node_version=$(nvm version "$(cat "${nvmrc_path}")") + + if [[ "$nvmrc_node_version" = "N/A" ]]; then + nvm install + elif [[ "$nvmrc_node_version" != "$node_version" ]]; then + nvm use + fi + elif [[ "$node_version" != "$(nvm version default)" ]]; then + echo "Reverting to nvm default version" + nvm use default + fi + } + + autoload -U add-zsh-hook + add-zsh-hook chpwd load-nvmrc + + load-nvmrc +fi + +# Load nvm bash completion +for nvm_completion in "$NVM_DIR/bash_completion" "$NVM_HOMEBREW/etc/bash_completion.d/nvm"; do + if [[ -f "$nvm_completion" ]]; then + # Load bashcompinit + autoload -U +X bashcompinit && bashcompinit + # Bypass compinit call in nvm bash completion script. See: + # https://github.com/nvm-sh/nvm/blob/4436638/bash_completion#L86-L93 + ZSH_VERSION= source "$nvm_completion" + break + fi +done + +unset NVM_HOMEBREW NVM_LAZY NVM_AUTOLOAD nvm_completion diff --git a/zsh/plugins/nyan/README.md b/zsh/plugins/nyan/README.md deleted file mode 100644 index 5929418..0000000 --- a/zsh/plugins/nyan/README.md +++ /dev/null @@ -1,5 +0,0 @@ -# Nyan plugin - -This plugin adds a command to display [Nyan Cat](https://en.wikipedia.org/wiki/Nyan_Cat) right inside your terminal. - -**Plugin is deprecated**. Check [official repo](https://github.com/klange/nyancat) for more information. \ No newline at end of file diff --git a/zsh/plugins/nyan/nyan.plugin.zsh b/zsh/plugins/nyan/nyan.plugin.zsh deleted file mode 100644 index c21c784..0000000 --- a/zsh/plugins/nyan/nyan.plugin.zsh +++ /dev/null @@ -1,10 +0,0 @@ -print -Pn '%F{yellow}' -cat >&2 <<-EOD - nyan plugin: - The nyancat server used by this plugin was shut down due to increased - bandwidth costs, so the nyan plugin no longer works. You can get the - same functionality in some distributions by installing the nyancat package, - or you can compile it yourself. - See https://github.com/klange/nyancat for more information. -EOD -print -Pn '%f' diff --git a/zsh/plugins/oc/README.md b/zsh/plugins/oc/README.md new file mode 100644 index 0000000..deae9b2 --- /dev/null +++ b/zsh/plugins/oc/README.md @@ -0,0 +1,13 @@ +# OC - OpenShift CLI + +This plugin provides autocompletion for [OC](https://docs.openshift.com/container-platform/3.7/cli_reference/index.html) commands, building, managing and updating operations. + +To use it, add `oc` to the plugins array of your zshrc file: + +```bash +plugins=(... oc) +``` + +## Contributors + ++ [kevinkirkup](https://github.com/kevinkirkup) - Plugin Author diff --git a/zsh/plugins/osx/README.md b/zsh/plugins/osx/README.md index 4595ee3..ecc9327 100644 --- a/zsh/plugins/osx/README.md +++ b/zsh/plugins/osx/README.md @@ -1,8 +1,6 @@ # OSX plugin -## Description - -This plugin provides a few utilities to make it more enjoyable on OSX. +This plugin provides a few utilities to make it more enjoyable on macOS (previously named OSX). To start using it, add the `osx` plugin to your plugins array in `~/.zshrc`: @@ -12,6 +10,30 @@ plugins=(... osx) Original author: [Sorin Ionescu](https://github.com/sorin-ionescu) +## Commands + +| Command | Description | +| :-------------- | :---------------------------------------------------- | +| `tab` | Open the current directory in a new tab | +| `split_tab` | Split the current terminal tab horizontally | +| `vsplit_tab` | Split the current terminal tab vertically | +| `ofd` | Open the current directory in a Finder window | +| `pfd` | Return the path of the frontmost Finder window | +| `pfs` | Return the current Finder selection | +| `cdf` | `cd` to the current Finder directory | +| `pushdf` | `pushd` to the current Finder directory | +| `pxd` | Return the current Xcode project directory | +| `cdx` | `cd` to the current Xcode project directory | +| `quick-look` | Quick-Look a specified file | +| `man-preview` | Open a specified man page in Preview app | +| `showfiles` | Show hidden files in Finder | +| `hidefiles` | Hide the hidden files in Finder | +| `itunes` | _DEPRECATED_. Use `music` from macOS Catalina on | +| `music` | Control Apple Music. Use `music -h` for usage details | +| `spotify` | Control Spotify and search by artist, album, track… | +| `rmdsstore` | Remove .DS\_Store files recursively in a directory | +| `btrestart` | Restart the Bluetooth daemon | + ## Acknowledgements This application makes use of the following third party scripts: @@ -38,24 +60,3 @@ 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. - - -## Commands - -| Command | Description | -| :-------------- | :-------------------------------------------------- | -| `tab` | Open the current directory in a new tab | -| `split_tab` | Split the current terminal tab horizontally | -| `vsplit_tab` | Split the current terminal tab vertically | -| `ofd` | Open the current directory in a Finder window | -| `pfd` | Return the path of the frontmost Finder window | -| `pfs` | Return the current Finder selection | -| `cdf` | `cd` to the current Finder directory | -| `pushdf` | `pushd` to the current Finder directory | -| `quick-look` | Quick-Look a specified file | -| `man-preview` | Open a specified man page in Preview app | -| `showfiles` | Show hidden files | -| `hidefiles` | Hide the hidden files | -| `itunes` | Control iTunes. Use `itunes -h` for usage details | -| `spotify` | Control Spotify and search by artist, album, track… | -| `rmdsstore` | Remove .DS\_Store files recursively in a directory | diff --git a/zsh/plugins/osx/_security b/zsh/plugins/osx/_security new file mode 100644 index 0000000..e4ed585 --- /dev/null +++ b/zsh/plugins/osx/_security @@ -0,0 +1,90 @@ +#compdef security + +local -a _1st_arguments +_1st_arguments=( + 'help:Show all commands, or show usage for a command' + 'list-keychains:Display or manipulate the keychain search list' + 'default-keychain:Display or set the default keychain' + 'login-keychain:Display or set the login keychain' + 'create-keychain:Create keychains and add them to the search list' + 'delete-keychain:Delete keychains and remove them from the search list' + 'lock-keychain:Lock the specified keychain' + 'lock-keychain:Unlock the specified keychain' + 'set-keychain-settings:Set settings for a keychain' + 'set-keychain-password:Set password for a keychain' + 'show-keychain-info:Show the settings for keychain' + 'dump-keychain:Dump the contents of one or more keychains' + 'create-keypair:Create an asymmetric key pair' + 'add-generic-password:Add a generic password item' + 'add-internet-password:Add an internet password item' + 'add-certificates:Add certificates to a keychain' + 'find-generic-password:Find a generic password item' + 'delete-generic-password:Delete a generic password item' + 'find-internet-password:Find an internet password item' + 'delete-internet-password:Delete an internet password item' + 'find-certificate:Find a certificate item' + 'find-identity:Find an identity certificate + private key' + 'delete-certificate:Delete a certificate from a keychain' + 'set-identity-preference:Set the preferred identity to use for a service' + 'get-identity-preference:Get the preferred identity to use for a service' + 'create-db:Create a db using the DL' + 'export:Export items from a keychain' + 'import:Import items into a keychain' + 'cms:Encode or decode CMS messages' + 'install-mds:MDS database' + 'add-trusted-cert:Add trusted certificates:' + 'remove-trusted-cert:Remove trusted certificates:' + 'dump-trust-settings:Display contents of trust settings' + 'user-trust-settings-enable:Display or manipulate user-level trust settings' + 'trust-settings-export:Export trust settings' + 'trust-settings-import:Import trust settings' + 'verify-cert:Verify certificates:' + 'authorize:Perform authorization operations' + 'authorizationdb:Make changes to the authorization policy database' + 'execute-with-privileges:Execute tool with privileges' + 'leaks:Run /usr/bin/leaks on this process' + 'error:Display a descriptive message for the given error codes:' + 'create-filevaultmaster-keychain:"Create a keychain containing a key pair for FileVault recovery use' +) +_arguments '*:: :->command' + +if (( CURRENT == 1 )); then + _describe -t commands "security command" _1st_arguments + return +fi + +case "$words[1]" in + find-(generic|internet)-password) + _values \ + 'Usage: find-[internet/generic]-password [-a account] [-s server] [options...] [-g] [keychain...]' \ + '-a[Match "account" string]' \ + '-c[Match "creator" (four-character code)]' \ + '-C[Match "type" (four-character code)]' \ + '-D[Match "kind" string]' \ + '-G[Match "value" string (generic attribute)]' \ + '-j[Match "comment" string]' \ + '-l[Match "label" string]' \ + '-s[Match "service" string]' \ + '-g[Display the password for the item found]' \ + '-w[Display only the password on stdout]' ;; + add-(generic|internet)-password) + _values \ + 'Usage: add-[internet/generic]-password [-a account] [-s server] [-w password] [options...] [-A|-T appPath] [keychain]]' \ + '-a[Specify account name (required)]' \ + '-c[Specify item creator (optional four-character code)]' \ + '-C[Specify item type (optional four-character code)]' \ + '-d[Specify security domain string (optional)]' \ + '-D[Specify kind (default is "Internet password")]' \ + '-j[Specify comment string (optional)]' \ + '-l[Specify label (if omitted, server name is used as default label)]' \ + '-p[Specify path string (optional)]' \ + '-P[Specify port number (optional)]' \ + '-r[Specify protocol (optional four-character SecProtocolType, e.g. "http", "ftp ")]' \ + '-s[Specify server name (required)]' \ + '-t[Specify authentication type (as a four-character SecAuthenticationType, default is "dflt")]' \ + '-w[Specify password to be added]' \ + '-A[Allow any application to access this item without warning (insecure, not recommended!)]' \ + '-T[Specify an application which may access this item (multiple -T options are allowed)]' \ + '-U[Update item if it already exists (if omitted, the item cannot already exist) ]' \ + 'utils)]' ;; +esac diff --git a/zsh/plugins/osx/music b/zsh/plugins/osx/music new file mode 100644 index 0000000..5056679 --- /dev/null +++ b/zsh/plugins/osx/music @@ -0,0 +1,170 @@ +#!/usr/bin/env zsh + +function music itunes() { + local APP_NAME=Music sw_vers=$(sw_vers -productVersion 2>/dev/null) + + autoload is-at-least + if [[ -z "$sw_vers" ]] || is-at-least 10.15 $sw_vers; then + if [[ $0 = itunes ]]; then + echo >&2 The itunes function name is deprecated. Use \'music\' instead. + return 1 + fi + else + APP_NAME=iTunes + fi + + local opt=$1 playlist=$2 + (( $# > 0 )) && shift + case "$opt" in + launch|play|pause|stop|rewind|resume|quit) + ;; + mute) + opt="set mute to true" + ;; + unmute) + opt="set mute to false" + ;; + next|previous) + opt="$opt track" + ;; + vol) + local new_volume volume=$(osascript -e "tell application \"$APP_NAME\" to get sound volume") + if [[ $# -eq 0 ]]; then + echo "Current volume is ${volume}." + return 0 + fi + case $1 in + up) new_volume=$((volume + 10 < 100 ? volume + 10 : 100)) ;; + down) new_volume=$((volume - 10 > 0 ? volume - 10 : 0)) ;; + <0-100>) new_volume=$1 ;; + *) echo "'$1' is not valid. Expected <0-100>, up or down." + return 1 ;; + esac + opt="set sound volume to ${new_volume}" + ;; + playlist) + # Inspired by: https://gist.github.com/nakajijapan/ac8b45371064ae98ea7f + if [[ -n "$playlist" ]]; then + osascript 2>/dev/null </dev/null 2>&1 </dev/null 2>&1 <" + echo "option:" + echo "\t-h|--help\tShow this message and exit" + echo "\tlaunch|play|pause|stop|rewind|resume|quit" + echo "\tmute|unmute\tMute or unmute $APP_NAME" + echo "\tnext|previous\tPlay next or previous track" + echo "\tshuf|shuffle [on|off|toggle]\tSet shuffled playback. Default: toggle. Note: toggle doesn't support the MiniPlayer." + echo "\tvol [0-100|up|down]\tGet or set the volume. 0 to 100 sets the volume. 'up' / 'down' increases / decreases by 10 points. No argument displays current volume." + echo "\tplaying|status\tShow what song is currently playing in Music." + echo "\tplaylist [playlist name]\t Play specific playlist" + return 0 + ;; + *) + print "Unknown option: $opt" + return 1 + ;; + esac + osascript -e "tell application \"$APP_NAME\" to $opt" +} + +function _music() { + local app_name + case "$words[1]" in + itunes) app_name="iTunes" ;; + music|*) app_name="Music" ;; + esac + + local -a cmds subcmds + cmds=( + "launch:Launch the ${app_name} app" + "play:Play ${app_name}" + "pause:Pause ${app_name}" + "stop:Stop ${app_name}" + "rewind:Rewind ${app_name}" + "resume:Resume ${app_name}" + "quit:Quit ${app_name}" + "mute:Mute the ${app_name} app" + "unmute:Unmute the ${app_name} app" + "next:Skip to the next song" + "previous:Skip to the previous song" + "vol:Change the volume" + "playlist:Play a specific playlist" + {playing,status}":Show what song is currently playing" + {shuf,shuff,shuffle}":Set shuffle mode" + {-h,--help}":Show usage" + ) + + if (( CURRENT == 2 )); then + _describe 'command' cmds + elif (( CURRENT == 3 )); then + case "$words[2]" in + vol) subcmds=( 'up:Raise the volume' 'down:Lower the volume' ) + _describe 'command' subcmds ;; + shuf|shuff|shuffle) subcmds=('on:Switch on shuffle mode' 'off:Switch off shuffle mode' 'toggle:Toggle shuffle mode (default)') + _describe 'command' subcmds ;; + esac + elif (( CURRENT == 4 )); then + case "$words[2]" in + playlist) subcmds=('play:Play the playlist (default)' 'stop:Stop the playlist') + _describe 'command' subcmds ;; + esac + fi + + return 0 +} + +compdef _music music itunes diff --git a/zsh/plugins/osx/osx.plugin.zsh b/zsh/plugins/osx/osx.plugin.zsh index eb3c4fb..7842e9f 100644 --- a/zsh/plugins/osx/osx.plugin.zsh +++ b/zsh/plugins/osx/osx.plugin.zsh @@ -1,15 +1,22 @@ # Open the current directory in a Finder window alias ofd='open_command $PWD' +# Show/hide hidden files in the Finder +alias showfiles="defaults write com.apple.finder AppleShowAllFiles -bool true && killall Finder" +alias hidefiles="defaults write com.apple.finder AppleShowAllFiles -bool false && killall Finder" + +# Bluetooth restart +function btrestart() { + sudo kextunload -b com.apple.iokit.BroadcomBluetoothHostControllerUSBTransport + sudo kextload -b com.apple.iokit.BroadcomBluetoothHostControllerUSBTransport +} + function _omz_osx_get_frontmost_app() { - local the_app=$( - osascript 2>/dev/null </dev/null </dev/null <&2 + return 1 fi } @@ -79,7 +82,6 @@ function vsplit_tab() { if [[ "$the_app" == 'iTerm' ]]; then osascript </dev/null </dev/null <&2 - false - + return 1 fi } @@ -142,44 +140,40 @@ function split_tab() { keystroke "${command} \n" end tell EOF - elif [[ "$the_app" == 'iTerm2' ]]; then - osascript </dev/null </dev/null <&2 - false - + return 1 fi } function pfd() { osascript 2>/dev/null </dev/null < 0 )) && qlmanage -p $* &>/dev/null & } @@ -218,121 +227,13 @@ function vncviewer() { open vnc://$@ } -# iTunes control function -function itunes() { - local opt=$1 - local playlist=$2 - shift - case "$opt" in - launch|play|pause|stop|rewind|resume|quit) - ;; - mute) - opt="set mute to true" - ;; - unmute) - opt="set mute to false" - ;; - next|previous) - opt="$opt track" - ;; - vol) - local new_volume volume=$(osascript -e 'tell application "iTunes" to get sound volume') - if [[ $# -eq 0 ]]; then - echo "Current volume is ${volume}." - return 0 - fi - case $1 in - up) new_volume=$((volume + 10 < 100 ? volume + 10 : 100)) ;; - down) new_volume=$((volume - 10 > 0 ? volume - 10 : 0)) ;; - <0-100>) new_volume=$1 ;; - *) echo "'$1' is not valid. Expected <0-100>, up or down." - return 1 ;; - esac - opt="set sound volume to ${new_volume}" - ;; - playlist) - # Inspired by: https://gist.github.com/nakajijapan/ac8b45371064ae98ea7f -if [[ ! -z "$playlist" ]]; then - osascript -e 'tell application "iTunes"' -e "set new_playlist to \"$playlist\" as string" -e "play playlist new_playlist" -e "end tell" 2>/dev/null; - if [[ $? -eq 0 ]]; then - opt="play" - else - opt="stop" - fi - else - opt="set allPlaylists to (get name of every playlist)" - fi - ;; - playing|status) - local state=`osascript -e 'tell application "iTunes" to player state as string'` - if [[ "$state" = "playing" ]]; then - currenttrack=`osascript -e 'tell application "iTunes" to name of current track as string'` - currentartist=`osascript -e 'tell application "iTunes" to artist of current track as string'` - echo -E "Listening to $fg[yellow]$currenttrack$reset_color by $fg[yellow]$currentartist$reset_color"; - else - echo "iTunes is" $state; - fi - return 0 - ;; - shuf|shuff|shuffle) - # The shuffle property of current playlist can't be changed in iTunes 12, - # so this workaround uses AppleScript to simulate user input instead. - # Defaults to toggling when no options are given. - # The toggle option depends on the shuffle button being visible in the Now playing area. - # On and off use the menu bar items. - local state=$1 - - if [[ -n "$state" && ! "$state" =~ "^(on|off|toggle)$" ]] - then - print "Usage: itunes shuffle [on|off|toggle]. Invalid option." - return 1 - fi - - case "$state" in - on|off) - # Inspired by: https://stackoverflow.com/a/14675583 - osascript 1>/dev/null 2>&1 <<-EOF - tell application "System Events" to perform action "AXPress" of (menu item "${state}" of menu "Shuffle" of menu item "Shuffle" of menu "Controls" of menu bar item "Controls" of menu bar 1 of application process "iTunes" ) -EOF - return 0 - ;; - toggle|*) - osascript 1>/dev/null 2>&1 <<-EOF - tell application "System Events" to perform action "AXPress" of (button 2 of process "iTunes"'s window "iTunes"'s scroll area 1) -EOF - return 0 - ;; - esac - ;; - ""|-h|--help) - echo "Usage: itunes