diff options
Diffstat (limited to 'plugins')
104 files changed, 1227 insertions, 658 deletions
diff --git a/plugins/aliases/cheatsheet.py b/plugins/aliases/cheatsheet.py index d6d507b92..694afd31c 100644 --- a/plugins/aliases/cheatsheet.py +++ b/plugins/aliases/cheatsheet.py @@ -26,16 +26,16 @@ def cheatsheet(lines): target_aliases.extend(group_list) return cheatsheet -def pretty_print_group(key, aliases, hightlight=None): +def pretty_print_group(key, aliases, highlight=None): if len(aliases) == 0: return group_hl_formatter = lambda g, hl: termcolor.colored(hl, 'yellow').join([termcolor.colored(part, 'red') for part in ('[%s]' % g).split(hl)]) alias_hl_formatter = lambda alias, hl: termcolor.colored(hl, 'yellow').join([termcolor.colored(part, 'green') for part in ('\t%s = %s' % alias[0:2]).split(hl)]) group_formatter = lambda g: termcolor.colored('[%s]' % g, 'red') alias_formatter = lambda alias: termcolor.colored('\t%s = %s' % alias[0:2], 'green') - if hightlight and len(hightlight)>0: - print (group_hl_formatter(key, hightlight)) - print ('\n'.join([alias_hl_formatter(alias, hightlight) for alias in aliases])) + if highlight and len(highlight)>0: + print (group_hl_formatter(key, highlight)) + print ('\n'.join([alias_hl_formatter(alias, highlight) for alias in aliases])) else: print (group_formatter(key)) print ('\n'.join([alias_formatter(alias) for alias in aliases])) diff --git a/plugins/aliases/termcolor.py b/plugins/aliases/termcolor.py index f11b824b2..bb725e905 100644 --- a/plugins/aliases/termcolor.py +++ b/plugins/aliases/termcolor.py @@ -21,7 +21,7 @@ # # Author: Konstantin Lepa <konstantin.lepa@gmail.com> -"""ANSII Color formatting for output in terminal.""" +"""ANSI Color formatting for output in terminal.""" from __future__ import print_function import os diff --git a/plugins/archlinux/README.md b/plugins/archlinux/README.md index c8ec1de1e..fd772c61a 100644 --- a/plugins/archlinux/README.md +++ b/plugins/archlinux/README.md @@ -17,8 +17,10 @@ plugins=(... archlinux) | pacin | `sudo pacman -S` | Install packages from the repositories | | pacins | `sudo pacman -U` | Install a package from a local file | | pacinsd | `sudo pacman -S --asdeps` | Install packages as dependencies of another package | +| paclean | `sudo pacman -Sc` | Clean out old and unused caches and packages | | pacloc | `pacman -Qi` | Display information about a package in the local database | | paclocs | `pacman -Qs` | Search for packages in the local database | +| paclr | `sudo pacman -Scc` | Remove all files from the cache | | paclsorphans | `sudo pacman -Qdt` | List all orphaned packages | | pacmir | `sudo pacman -Syy` | Force refresh of all package lists after updating mirrorlist | | pacre | `sudo pacman -R` | Remove packages, keeping its settings and dependencies | @@ -52,6 +54,8 @@ upgrades were available. Use `pacman -Que` instead. | Alias | Command | Description | |---------|-------------------------------------------------|-------------------------------------------------------------------------| +| auclean | `sudo aura -Sc` | Clean out old and unused caches and packages | +| auclr | `sudo aura -Scc` | Remove all files from the cache | | auin | `sudo aura -S` | Install packages from the repositories | | aurin | `sudo aura -A` | Install packages from the repositories | | auins | `sudo aura -U` | Install a package from a local file | @@ -84,6 +88,8 @@ upgrades were available. Use `pacman -Que` instead. | Alias | Command | Description | |---------|-----------------------------------|---------------------------------------------------------------------| +| pacclean| `pacaur -Sc` | Clean out old and unused caches and packages | +| pacclr | `pacaur -Scc` | Remove all files from the cache | | pain | `pacaur -S` | Install packages from the repositories | | pains | `pacaur -U` | Install a package from a local file | | painsd | `pacaur -S --asdeps` | Install packages as dependencies of another package | @@ -106,6 +112,8 @@ upgrades were available. Use `pacman -Que` instead. | Alias | Command | Description | |---------|-----------------------------------|---------------------------------------------------------------------| | trconf | `trizen -C` | Fix all configuration files with vimdiff | +| trclean | `trizen -Sc` | Clean out old and unused caches and packages | +| trclr | `trizen -Scc` | Remove all files from the cache | | trin | `trizen -S` | Install packages from the repositories | | trins | `trizen -U` | Install a package from a local file | | trinsd | `trizen -S --asdeps` | Install packages as dependencies of another package | @@ -128,6 +136,8 @@ upgrades were available. Use `pacman -Que` instead. | Alias | Command | Description | |---------|--------------------------------|-------------------------------------------------------------------| | yaconf | `yay -Pg` | Print current configuration | +| yaclean | `yay -Sc` | Clean out old and unused caches and packages | +| yaclr | `yay -Scc` | Remove all files from the cache | | yain | `yay -S` | Install packages from the repositories | | yains | `yay -U` | Install a package from a local file | | yainsd | `yay -S --asdeps` | Install packages as dependencies of another package | @@ -170,3 +180,4 @@ whether the package manager is installed, checked in the following order: - ornicar - thibault.duplessis@gmail.com - Ybalrid (Arthur Brainville) - ybalrid@ybalrid.info - Jeff M. Hubbard - jeffmhubbard@gmail.com +- K. Harishankar(harishnkr) - hari2menon1234@gmail.com diff --git a/plugins/archlinux/archlinux.plugin.zsh b/plugins/archlinux/archlinux.plugin.zsh index 0c5782d98..4f1364779 100644 --- a/plugins/archlinux/archlinux.plugin.zsh +++ b/plugins/archlinux/archlinux.plugin.zsh @@ -5,7 +5,9 @@ # Pacman - https://wiki.archlinux.org/index.php/Pacman_Tips alias pacupg='sudo pacman -Syu' alias pacin='sudo pacman -S' +alias paclean='sudo pacman -Sc' alias pacins='sudo pacman -U' +alias paclr='sudo pacman -Scc' alias pacre='sudo pacman -R' alias pacrem='sudo pacman -Rns' alias pacrep='pacman -Si' @@ -88,6 +90,8 @@ fi if (( $+commands[aura] )); then alias auin='sudo aura -S' alias aurin='sudo aura -A' + alias auclean='sudo aura -Sc' + alias auclr='sudo aura -Scc' alias auins='sudo aura -U' alias auinsd='sudo aura -S --asdeps' alias aurinsd='sudo aura -A --asdeps' @@ -115,6 +119,8 @@ if (( $+commands[aura] )); then fi if (( $+commands[pacaur] )); then + alias pacclean='pacaur -Sc' + alias pacclr='pacaur -Scc' alias paupg='pacaur -Syu' alias pasu='pacaur -Syu --noconfirm' alias pain='pacaur -S' @@ -138,6 +144,8 @@ if (( $+commands[trizen] )); then alias trupg='trizen -Syua' alias trsu='trizen -Syua --noconfirm' alias trin='trizen -S' + alias trclean='trizen -Sc' + alias trclr='trizen -Scc' alias trins='trizen -U' alias trre='trizen -R' alias trrem='trizen -Rns' @@ -155,6 +163,8 @@ fi if (( $+commands[yay] )); then alias yaconf='yay -Pg' + alias yaclean='yay -Sc' + alias yaclr='yay -Scc' alias yaupg='yay -Syu' alias yasu='yay -Syu --noconfirm' alias yain='yay -S' diff --git a/plugins/aws/README.md b/plugins/aws/README.md index 011bbd8b4..24c6429dd 100644 --- a/plugins/aws/README.md +++ b/plugins/aws/README.md @@ -14,6 +14,7 @@ plugins=(... aws) * `asp [<profile>]`: sets `$AWS_PROFILE` and `$AWS_DEFAULT_PROFILE` (legacy) to `<profile>`. It also sets `$AWS_EB_PROFILE` to `<profile>` for the Elastic Beanstalk CLI. Run `asp` without arguments to clear the profile. +* `asp [<profile>] login`: If AWS SSO has been configured in your aws profile, it will run the `aws sso login` command following profile selection. * `acp [<profile>]`: in addition to `asp` functionality, it actually changes the profile by assuming the role specified in the `<profile>` configuration. It supports MFA and sets diff --git a/plugins/aws/aws.plugin.zsh b/plugins/aws/aws.plugin.zsh index 2d095635b..3a3a111b4 100644 --- a/plugins/aws/aws.plugin.zsh +++ b/plugins/aws/aws.plugin.zsh @@ -21,6 +21,10 @@ function asp() { export AWS_DEFAULT_PROFILE=$1 export AWS_PROFILE=$1 export AWS_EB_PROFILE=$1 + + if [[ "$2" == "login" ]]; then + aws sso login + fi } # AWS profile switch diff --git a/plugins/bgnotify/bgnotify.plugin.zsh b/plugins/bgnotify/bgnotify.plugin.zsh index aecde20ea..479796dbe 100644 --- a/plugins/bgnotify/bgnotify.plugin.zsh +++ b/plugins/bgnotify/bgnotify.plugin.zsh @@ -20,6 +20,12 @@ if ! (type bgnotify_formatted | grep -q 'function'); then ## allow custom functi } fi +currentAppId () { + if (( $+commands[osascript] )); then + osascript -e 'tell application (path to frontmost application as text) to id' 2>/dev/null + fi +} + currentWindowId () { if hash osascript 2>/dev/null; then #osx osascript -e 'tell application (path to frontmost application as text) to id of front window' 2&> /dev/null || echo "0" @@ -32,11 +38,20 @@ currentWindowId () { bgnotify () { ## args: (title, subtitle) if hash terminal-notifier 2>/dev/null; then #osx - [[ "$TERM_PROGRAM" == 'iTerm.app' ]] && term_id='com.googlecode.iterm2'; - [[ "$TERM_PROGRAM" == 'Apple_Terminal' ]] && term_id='com.apple.terminal'; + local term_id="$bgnotify_appid" + if [[ -z "$term_id" ]]; then + case "$TERM_PROGRAM" in + iTerm.app) term_id='com.googlecode.iterm2' ;; + Apple_Terminal) term_id='com.apple.terminal' ;; + esac + fi + ## now call terminal-notifier, (hopefully with $term_id!) - [ -z "$term_id" ] && terminal-notifier -message "$2" -title "$1" >/dev/null || - terminal-notifier -message "$2" -title "$1" -activate "$term_id" -sender "$term_id" >/dev/null + if [[ -z "$term_id" ]]; then + terminal-notifier -message "$2" -title "$1" >/dev/null + else + terminal-notifier -message "$2" -title "$1" -activate "$term_id" -sender "$term_id" >/dev/null + fi elif hash growlnotify 2>/dev/null; then #osx growl growlnotify -m "$1" "$2" elif hash notify-send 2>/dev/null; then #ubuntu gnome! @@ -54,6 +69,7 @@ bgnotify () { ## args: (title, subtitle) bgnotify_begin() { bgnotify_timestamp=$EPOCHSECONDS bgnotify_lastcmd="${1:-$2}" + bgnotify_appid="$(currentAppId)" bgnotify_windowid=$(currentWindowId) } @@ -62,7 +78,7 @@ bgnotify_end() { elapsed=$(( EPOCHSECONDS - bgnotify_timestamp )) past_threshold=$(( elapsed >= bgnotify_threshold )) if (( bgnotify_timestamp > 0 )) && (( past_threshold )); then - if [ $(currentWindowId) != "$bgnotify_windowid" ]; then + if [[ $(currentAppId) != "$bgnotify_appid" || $(currentWindowId) != "$bgnotify_windowid" ]]; then print -n "\a" bgnotify_formatted "$didexit" "$bgnotify_lastcmd" "$elapsed" fi diff --git a/plugins/bower/bower.plugin.zsh b/plugins/bower/bower.plugin.zsh index 3a40b3af0..c4f71c2ae 100644 --- a/plugins/bower/bower.plugin.zsh +++ b/plugins/bower/bower.plugin.zsh @@ -9,7 +9,7 @@ _bower_installed_packages () { } _bower () { - local -a _1st_arguments _no_color _dopts _save_dev _force_lastest _production + local -a _1st_arguments _no_color _dopts _save_dev _force_latest _production local expl typeset -A opt_args @@ -22,7 +22,7 @@ _bower () _save_dev=('(--save-dev)--save-dev[Save installed packages into the project"s bower.json devDependencies]') - _force_lastest=('(--force-latest)--force-latest[Force latest version on conflict]') + _force_latest=('(--force-latest)--force-latest[Force latest version on conflict]') _production=('(--production)--production[Do not install project devDependencies]') @@ -54,7 +54,7 @@ _bower () _arguments \ $_dopts \ $_save_dev \ - $_force_lastest \ + $_force_latest \ $_no_color \ $_production ;; @@ -62,7 +62,7 @@ _bower () _arguments \ $_dopts \ $_no_color \ - $_force_lastest + $_force_latest _bower_installed_packages compadd "$@" $(echo $bower_package_list) ;; diff --git a/plugins/branch/README.md b/plugins/branch/README.md index 56ab8da4b..a15dd22df 100644 --- a/plugins/branch/README.md +++ b/plugins/branch/README.md @@ -1,31 +1,47 @@ -# Branch +# Branch plugin -Displays the current Git or Mercurial branch fast. +This plugin displays the current Git or Mercurial branch, fast. If in a Mercurial repository, +also display the current bookmark, if present. + +To use it, add `branch` to the plugins array in your zshrc file: + +```zsh +plugins=(... branch) +``` ## Speed test -### Mercurial +- `hg branch`: -```shell -$ time hg branch -0.11s user 0.14s system 70% cpu 0.355 total -``` + ```console + $ time hg branch + 0.11s user 0.14s system 70% cpu 0.355 total + ``` -### Branch plugin +- branch plugin: -```shell -$ time zsh /tmp/branch_prompt_info_test.zsh -0.00s user 0.01s system 78% cpu 0.014 total -``` + ```console + $ time zsh /tmp/branch_prompt_info_test.zsh + 0.00s user 0.01s system 78% cpu 0.014 total + ``` ## Usage -Edit your theme file (eg.: `~/.oh-my-zsh/theme/robbyrussell.zsh-theme`) -adding `$(branch_prompt_info)` in your prompt like this: +Copy your theme to `$ZSH_CUSTOM/themes/` and modify it to add `$(branch_prompt_info)` in your prompt. +This example is for the `robbyrussell` theme: ```diff -- PROMPT='${ret_status}%{$fg_bold[green]%}%p %{$fg[cyan]%}%c %{$fg_bold[blue]%}$(git_prompt_info)%{$fg_bold[blue]%} % %{$reset_color%}' -+ PROMPT='${ret_status}%{$fg_bold[green]%}%p %{$fg[cyan]%}%c %{$fg_bold[blue]%}$(git_prompt_info)$(branch_prompt_info)%{$fg_bold[blue]%} % %{$reset_color%}' +diff --git a/themes/robbyrussell.zsh-theme b/themes/robbyrussell.zsh-theme +index 2fd5f2cd..9d89a464 100644 +--- a/themes/robbyrussell.zsh-theme ++++ b/themes/robbyrussell.zsh-theme +@@ -1,5 +1,5 @@ + PROMPT="%(?:%{$fg_bold[green]%}➜ :%{$fg_bold[red]%}➜ )" +-PROMPT+=' %{$fg[cyan]%}%c%{$reset_color%} $(git_prompt_info)' ++PROMPT+=' %{$fg[cyan]%}%c%{$reset_color%} $(branch_prompt_info)' + + ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg_bold[blue]%}git:(%{$fg[red]%}" + ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%} " ``` ## Maintainer diff --git a/plugins/branch/branch.plugin.zsh b/plugins/branch/branch.plugin.zsh index 2e5659bdf..dd5871fdc 100644 --- a/plugins/branch/branch.plugin.zsh +++ b/plugins/branch/branch.plugin.zsh @@ -3,29 +3,33 @@ # Oct 2, 2015 function branch_prompt_info() { - # Defines path as current directory - local current_dir=$PWD - # While current path is not root path - while [[ $current_dir != '/' ]] - do - # Git repository - if [[ -d "${current_dir}/.git" ]] - then - echo '±' ${"$(<"$current_dir/.git/HEAD")"##*/} - return; + # Start checking in current working directory + local branch="" dir="$PWD" + while [[ "$dir" != '/' ]]; do + # Found .git directory + if [[ -d "${dir}/.git" ]]; then + branch="${"$(<"${dir}/.git/HEAD")"##*/}" + echo '±' "${branch:gs/%/%%}" + return fi - # Mercurial repository - if [[ -d "${current_dir}/.hg" ]] - then - if [[ -f "$current_dir/.hg/branch" ]] - then - echo '☿' $(<"$current_dir/.hg/branch") + + # Found .hg directory + if [[ -d "${dir}/.hg" ]]; then + if [[ -f "${dir}/.hg/branch" ]]; then + branch="$(<"${dir}/.hg/branch")" else - echo '☿ default' + branch="default" + fi + + if [[ -f "${dir}/.hg/bookmarks.current" ]]; then + branch="${branch}/$(<"${dir}/.hg/bookmarks.current")" fi - return; + + echo '☿' "${branch:gs/%/%%}" + return fi - # Defines path as parent directory and keeps looking for :) - current_dir="${current_dir:h}" + + # Check parent directory + dir="${dir:h}" done } diff --git a/plugins/brew/brew.plugin.zsh b/plugins/brew/brew.plugin.zsh index 532dd9be7..070a083d0 100644 --- a/plugins/brew/brew.plugin.zsh +++ b/plugins/brew/brew.plugin.zsh @@ -1,5 +1,4 @@ alias brewp='brew pin' -alias brews='brew list -1' alias brewsp='brew list --pinned' alias bubo='brew update && brew outdated' alias bubc='brew upgrade && brew cleanup' @@ -7,3 +6,16 @@ alias bubu='bubo && bubc' alias buf='brew upgrade --formula' alias bcubo='brew update && brew outdated --cask' alias bcubc='brew upgrade --cask && brew cleanup' + +function brews() { + local formulae="$(brew leaves | xargs brew deps --installed --for-each)" + local casks="$(brew list --cask)" + + local blue="$(tput setaf 4)" + local bold="$(tput bold)" + local off="$(tput sgr0)" + + echo "${blue}==>${off} ${bold}Formulae${off}" + echo "${formulae}" | sed "s/^\(.*\):\(.*\)$/\1${blue}\2${off}/" + echo "\n${blue}==>${off} ${bold}Casks${off}\n${casks}" +} diff --git a/plugins/bundler/bundler.plugin.zsh b/plugins/bundler/bundler.plugin.zsh index 6293dc28a..c1cbb13dd 100644 --- a/plugins/bundler/bundler.plugin.zsh +++ b/plugins/bundler/bundler.plugin.zsh @@ -40,7 +40,7 @@ bundle_install() { else local cores_num="$(nproc)" fi - bundle install --jobs="$cores_num" "$@" + BUNDLE_JOBS="$cores_num" bundle install "$@" } ## Gem wrapper @@ -81,14 +81,12 @@ bundled_commands=( ) # Remove $UNBUNDLED_COMMANDS from the bundled_commands list -for cmd in $UNBUNDLED_COMMANDS; do - bundled_commands=(${bundled_commands#$cmd}); -done +bundled_commands=(${bundled_commands:|UNBUNDLED_COMMANDS}) +unset UNBUNDLED_COMMANDS # Add $BUNDLED_COMMANDS to the bundled_commands list -for cmd in $BUNDLED_COMMANDS; do - bundled_commands+=($cmd); -done +bundled_commands+=($BUNDLED_COMMANDS) +unset BUNDLED_COMMANDS # Check if in the root or a subdirectory of a bundled project _within-bundled-project() { @@ -126,5 +124,4 @@ for cmd in $bundled_commands; do compdef "_$cmd" "bundled_$cmd"="$cmd" fi done - unset cmd bundled_commands diff --git a/plugins/catimg/catimg.plugin.zsh b/plugins/catimg/catimg.plugin.zsh index ca46444cc..f4ff6f856 100644 --- a/plugins/catimg/catimg.plugin.zsh +++ b/plugins/catimg/catimg.plugin.zsh @@ -2,7 +2,7 @@ # catimg script by Eduardo San Martin Morote aka Posva # # https://posva.net # # # -# Ouput the content of an image to the stdout using the 256 colors of the # +# Output the content of an image to the stdout using the 256 colors of the # # terminal. # # GitHub: https://github.com/posva/catimg # ################################################################################ diff --git a/plugins/catimg/catimg.sh b/plugins/catimg/catimg.sh index 713a03291..f58392428 100644 --- a/plugins/catimg/catimg.sh +++ b/plugins/catimg/catimg.sh @@ -2,7 +2,7 @@ # catimg script by Eduardo San Martin Morote aka Posva # # https://posva.net # # # -# Ouput the content of an image to the stdout using the 256 colors of the # +# Output the content of an image to the stdout using the 256 colors of the # # terminal. # # GitHub: https://github.com/posva/catimg # ################################################################################ diff --git a/plugins/chruby/README.md b/plugins/chruby/README.md index d373006a5..19eb15a8d 100644 --- a/plugins/chruby/README.md +++ b/plugins/chruby/README.md @@ -5,6 +5,7 @@ current Ruby version, and completion and a prompt function to display the Ruby v Supports brew and manual installation of chruby. To use it, add `chruby` to the plugins array in your zshrc file: + ```zsh plugins=(... chruby) ``` @@ -14,7 +15,7 @@ plugins=(... chruby) If you'd prefer to specify an explicit path to load chruby from you can set variables like so: -``` +```zsh zstyle :omz:plugins:chruby path /local/path/to/chruby.sh zstyle :omz:plugins:chruby auto /local/path/to/auto.sh ``` diff --git a/plugins/chruby/chruby.plugin.zsh b/plugins/chruby/chruby.plugin.zsh index 32f0525aa..d7a28d4e2 100644 --- a/plugins/chruby/chruby.plugin.zsh +++ b/plugins/chruby/chruby.plugin.zsh @@ -1,121 +1,94 @@ -# -# INSTRUCTIONS -# -# With either a manual or brew installed chruby things should just work. -# -# 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 -# -# TODO -# - autodetermine correct source path on non OS X systems -# - completion if ruby-install exists +## load chruby from different locations -# rvm and rbenv plugins also provide this alias -alias rubies='chruby' +_source-from-omz-settings() { + local _chruby_path _chruby_auto + + zstyle -s :omz:plugins:chruby path _chruby_path || return 1 + zstyle -s :omz:plugins:chruby auto _chruby_auto || return 1 + if [[ -r ${_chruby_path} ]]; then + source ${_chruby_path} + fi -_homebrew-installed() { - whence brew &> /dev/null - _xit=$? - if [ $_xit -eq 0 ];then - # ok , we have brew installed - # speculatively we check default brew prefix - if [ -h /usr/local/opt/chruby ];then - _brew_prefix="/usr/local/opt/chruby" - else - # ok , it is not default prefix - # this call to brew is expensive ( about 400 ms ), so at least let's make it only once - _brew_prefix=$(brew --prefix chruby) - fi - return 0 - else - return $_xit - fi + if [[ -r ${_chruby_auto} ]]; then + source ${_chruby_auto} + fi } -_chruby-from-homebrew-installed() { - [ -r $_brew_prefix ] &> /dev/null -} +_source-from-homebrew() { + (( $+commands[brew] )) || return 1 -_ruby-build_installed() { - whence ruby-build &> /dev/null -} + local _brew_prefix + # check default brew prefix + if [[ -h /usr/local/opt/chruby ]];then + _brew_prefix="/usr/local/opt/chruby" + else + # ok , it is not default prefix + # this call to brew is expensive ( about 400 ms ), so at least let's make it only once + _brew_prefix=$(brew --prefix chruby) + fi -_ruby-install-installed() { - whence ruby-install &> /dev/null -} + [[ -r "$_brew_prefix" ]] || return 1 -# Simple definition completer for ruby-build -if _ruby-build_installed; then - _ruby-build() { compadd $(ruby-build --definitions) } - compdef _ruby-build ruby-build -fi - -_source_from_omz_settings() { - local _chruby_path - local _chruby_auto - - zstyle -s :omz:plugins:chruby path _chruby_path - zstyle -s :omz:plugins:chruby auto _chruby_auto - - if [[ -r ${_chruby_path} ]]; then - source ${_chruby_path} - fi - - if [[ -r ${_chruby_auto} ]]; then - source ${_chruby_auto} - fi + source $_brew_prefix/share/chruby/chruby.sh + source $_brew_prefix/share/chruby/auto.sh } -_chruby_dirs() { - chrubydirs=($HOME/.rubies/ $PREFIX/opt/rubies) - for dir in chrubydirs; do - if [[ -d $dir ]]; then - RUBIES+=$dir - fi - done +_load-chruby-dirs() { + local dir + for dir in "$HOME/.rubies" "$PREFIX/opt/rubies"; do + if [[ -d "$dir" ]]; then + RUBIES+=("$dir") + fi + done } -if _homebrew-installed && _chruby-from-homebrew-installed ; then - source $_brew_prefix/share/chruby/chruby.sh - source $_brew_prefix/share/chruby/auto.sh - _chruby_dirs +# Load chruby +if _source-from-omz-settings; then + _load-chruby-dirs elif [[ -r "/usr/local/share/chruby/chruby.sh" ]] ; then - source /usr/local/share/chruby/chruby.sh - source /usr/local/share/chruby/auto.sh - _chruby_dirs -else - _source_from_omz_settings - _chruby_dirs + source /usr/local/share/chruby/chruby.sh + source /usr/local/share/chruby/auto.sh + _load-chruby-dirs +elif _source-from-homebrew; then + _load-chruby-dirs fi -function ensure_chruby() { - $(whence chruby) -} +unfunction _source-from-homebrew _source-from-omz-settings _load-chruby-dirs + + +## chruby utility functions and aliases + +# rvm and rbenv plugins also provide this alias +alias rubies='chruby' function current_ruby() { - local _ruby - _ruby="$(chruby |grep \* |tr -d '* ')" - if [[ $(chruby |grep -c \*) -eq 1 ]]; then - echo ${_ruby} - else - echo "system" - fi + local ruby + ruby="$(chruby | grep \* | tr -d '* ')" + if [[ $(chruby | grep -c \*) -eq 1 ]]; then + echo ${ruby} + else + echo "system" + fi } function chruby_prompt_info() { - echo "$(current_ruby)" + echo "${$(current_ruby):gs/%/%%}" } -# complete on installed rubies +# Complete chruby command with installed rubies _chruby() { - compadd $(chruby | tr -d '* ') - local default_path='/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin' - if PATH=${default_path} type ruby &> /dev/null; then - compadd system - fi + compadd $(chruby | tr -d '* ') + if PATH="/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin" command ruby &>/dev/null; then + compadd system + fi } + compdef _chruby chruby + + +# Simple definition completer for ruby-build +if command ruby-build &> /dev/null; then + _ruby-build() { compadd $(ruby-build --definitions) } + compdef _ruby-build ruby-build +fi diff --git a/plugins/chucknorris/fortunes/chucknorris b/plugins/chucknorris/fortunes/chucknorris index 6ba5bb9b5..9e36ce89a 100644 --- a/plugins/chucknorris/fortunes/chucknorris +++ b/plugins/chucknorris/fortunes/chucknorris @@ -228,7 +228,7 @@ Chuck Norris once punched the ground to stop an earthquake. The resulting afters % 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 roundhouse kicked a football. The astronomical society now considers it a planet. % Chuck Norris once thought he was wrong. He was, however, mistaken. % @@ -342,7 +342,7 @@ Every time there's an earthquake, you know Chuck Norris is hungry. The earthquak % 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. +Fear of spiders is arachnophobia. 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. % @@ -426,7 +426,7 @@ 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. +Staring at Chuck Norris for extended periods of time without proper eye protection will cause blindness, and possibly foot sized bruises 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. % @@ -452,7 +452,7 @@ The best part of waking up is not Folgers in your cup. it's knowing that Chuck N % 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 dictionary references Chuck Norris several times, he is mentioned under Fear, Law, Order and Chucktatorship. % The leading causes of death in the United States are: 1. Heart Disease 2. Chuck Norris 3. Cancer. % @@ -468,7 +468,7 @@ 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 producers of the movie "The Last Airbender" are now in talks with Chuck Norris in Order to star him in their next sequel "The Last Skull Bender". % The quickest way to a man's heart is with Chuck Norris' fist. % diff --git a/plugins/colorize/colorize.plugin.zsh b/plugins/colorize/colorize.plugin.zsh index 8ea98f80a..a9da6cf83 100644 --- a/plugins/colorize/colorize.plugin.zsh +++ b/plugins/colorize/colorize.plugin.zsh @@ -82,7 +82,7 @@ colorize_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. + # the ~/.zsh_history. For such files the tty of the preprocessor will be suspended. # 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 diff --git a/plugins/command-not-found/README.md b/plugins/command-not-found/README.md index f267f0c89..5a373c537 100644 --- a/plugins/command-not-found/README.md +++ b/plugins/command-not-found/README.md @@ -29,5 +29,6 @@ It works out of the box with the command-not-found packages for: - [Fedora](https://fedoraproject.org/wiki/Features/PackageKitCommandNotFound) - [NixOS](https://github.com/NixOS/nixpkgs/tree/master/nixos/modules/programs/command-not-found) - [Termux](https://github.com/termux/command-not-found) +- [SUSE](https://www.unix.com/man-page/suse/1/command-not-found/) You can add support for other platforms by submitting a Pull Request. diff --git a/plugins/command-not-found/command-not-found.plugin.zsh b/plugins/command-not-found/command-not-found.plugin.zsh index cb96fe063..cb8a8989c 100644 --- a/plugins/command-not-found/command-not-found.plugin.zsh +++ b/plugins/command-not-found/command-not-found.plugin.zsh @@ -57,6 +57,13 @@ fi # Termux: https://github.com/termux/command-not-found if [[ -x /data/data/com.termux/files/usr/libexec/termux/command-not-found ]]; then command_not_found_handler() { - /data/data/com.termux/files/usr/libexec/termux/command-not-found -- "$1" + /data/data/com.termux/files/usr/libexec/termux/command-not-found "$1" + } +fi + +# SUSE and derivates: https://www.unix.com/man-page/suse/1/command-not-found/ +if [[ -x /usr/bin/command-not-found ]]; then + command_not_found_handler() { + /usr/bin/command-not-found "$1" } fi diff --git a/plugins/cpanm/_cpanm b/plugins/cpanm/_cpanm index ff9ae1c15..f328dd997 100644 --- a/plugins/cpanm/_cpanm +++ b/plugins/cpanm/_cpanm @@ -36,7 +36,7 @@ arguments=( '--reinstall[Reinstall the distribution even if you already have the latest version installed]' '--interactive[Turn on interactive configure]' - '--scandeps[Scan the depencencies of given modules and output the tree in a text format]' + '--scandeps[Scan the dependencies of given modules and output the tree in a text format]' '--format[Specify what format to display the scanned dependency tree]:scandeps format:(tree json yaml dists)' '--save-dists[Specify the optional directory path to copy downloaded tarballs]' diff --git a/plugins/deno/README.md b/plugins/deno/README.md index 828e6af39..691318397 100644 --- a/plugins/deno/README.md +++ b/plugins/deno/README.md @@ -13,6 +13,7 @@ This plugin sets up completion and aliases for [Deno](https://deno.land). | dh | deno help | | dli | deno lint | | drn | deno run | +| drA | deno run -A | | drw | deno run --watch | | dts | deno test | | dup | deno upgrade | diff --git a/plugins/deno/deno.plugin.zsh b/plugins/deno/deno.plugin.zsh index 34adddc37..eb7191971 100644 --- a/plugins/deno/deno.plugin.zsh +++ b/plugins/deno/deno.plugin.zsh @@ -6,6 +6,7 @@ alias dfmt='deno fmt' alias dh='deno help' alias dli='deno lint' alias drn='deno run' +alias drA='deno run -A' alias drw='deno run --watch' alias dts='deno test' alias dup='deno upgrade' diff --git a/plugins/dirhistory/dirhistory.plugin.zsh b/plugins/dirhistory/dirhistory.plugin.zsh index 26ef07494..8268147f6 100644 --- a/plugins/dirhistory/dirhistory.plugin.zsh +++ b/plugins/dirhistory/dirhistory.plugin.zsh @@ -19,14 +19,14 @@ export DIRHISTORY_SIZE=30 # Returns the element if the array was not empty, # otherwise returns empty string. function pop_past() { - eval "$1='$dirhistory_past[$#dirhistory_past]'" + typeset -g $1="${dirhistory_past[$#dirhistory_past]}" if [[ $#dirhistory_past -gt 0 ]]; then dirhistory_past[$#dirhistory_past]=() fi } function pop_future() { - eval "$1='$dirhistory_future[$#dirhistory_future]'" + typeset -g $1="${dirhistory_future[$#dirhistory_future]}" if [[ $#dirhistory_future -gt 0 ]]; then dirhistory_future[$#dirhistory_future]=() fi @@ -182,7 +182,7 @@ bindkey "\e\e[A" dirhistory_zle_dirhistory_up # Putty bindkey "\eO3A" dirhistory_zle_dirhistory_up # GNU screen case "$TERM_PROGRAM" in iTerm.app) bindkey "^[^[[A" dirhistory_zle_dirhistory_up ;; # iTerm2 -Apple_Terminal) bindkey "^[OA" dirhistory_zle_dirhistory_up ;; # Terminal.app +Apple_Terminal) bindkey "^[[A" dirhistory_zle_dirhistory_up ;; # Terminal.app esac if (( ${+terminfo[kcuu1]} )); then bindkey "^[${terminfo[kcuu1]}" dirhistory_zle_dirhistory_up # urxvt @@ -195,7 +195,7 @@ bindkey "\e\e[B" dirhistory_zle_dirhistory_down # Putty bindkey "\eO3B" dirhistory_zle_dirhistory_down # GNU screen case "$TERM_PROGRAM" in iTerm.app) bindkey "^[^[[B" dirhistory_zle_dirhistory_down ;; # iTerm2 -Apple_Terminal) bindkey "^[OB" dirhistory_zle_dirhistory_down ;; # Terminal.app +Apple_Terminal) bindkey "^[[B" dirhistory_zle_dirhistory_down ;; # Terminal.app esac if (( ${+terminfo[kcud1]} )); then bindkey "^[${terminfo[kcud1]}" dirhistory_zle_dirhistory_down # urxvt diff --git a/plugins/docker-compose/docker-compose.plugin.zsh b/plugins/docker-compose/docker-compose.plugin.zsh index 13985fc82..b8a4b067d 100644 --- a/plugins/docker-compose/docker-compose.plugin.zsh +++ b/plugins/docker-compose/docker-compose.plugin.zsh @@ -1,7 +1,5 @@ # support Compose v2 as docker CLI plugin -DOCKER_CONTEXT=default command docker compose &>/dev/null \ - && dccmd='docker compose' \ - || dccmd='docker-compose' +(( ${+commands[docker-compose]} )) && dccmd='docker-compose' || dccmd='docker compose' alias dco="$dccmd" alias dcb="$dccmd build" diff --git a/plugins/docker-machine/_docker-machine b/plugins/docker-machine/_docker-machine index 7c19ba8e7..fbd36d7c6 100644 --- a/plugins/docker-machine/_docker-machine +++ b/plugins/docker-machine/_docker-machine @@ -90,7 +90,7 @@ __docker-machine_filters() { } __get_swarm_discovery() { - declare -a masters serivces + declare -a masters services local service services=() masters=($(docker-machine ls -f {{.Swarm}} |grep '(master)' |awk '{print $1}')) @@ -169,7 +169,7 @@ __get_create_argument() { __docker-machine_subcommand() { local -a opts_help opts_help=("(- :)--help[Print usage]") - local -a opts_only_host opts_driver opts_storage_driver opts_stragery + local -a opts_only_host opts_driver opts_storage_driver opts_state opts_only_host=( "$opts_help" "*:host:__docker-machine_hosts_all" @@ -330,7 +330,7 @@ _docker-machine() { _arguments -C \ "(- :)"{-h,--help}"[Show help]" \ "(-D --debug)"{-D,--debug}"[Enable debug mode]" \ - '(-s --stroage-path)'{-s,--storage-path}'[Configures storage path]:file:_files' \ + '(-s --storage-path)'{-s,--storage-path}'[Configures storage path]:file:_files' \ '--tls-ca-cert[CA to verify remotes against]:file:_files' \ '--tls-ca-key[Private key to generate certificates]:file:_files' \ '--tls-client-cert[Client cert to use for TLS]:file:_files' \ diff --git a/plugins/dotnet/README.md b/plugins/dotnet/README.md index 7554b4e3c..87dfd8f8d 100644 --- a/plugins/dotnet/README.md +++ b/plugins/dotnet/README.md @@ -21,3 +21,4 @@ plugins=(... dotnet) | 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. | +| db | dotnet build | Build a .NET project | diff --git a/plugins/dotnet/dotnet.plugin.zsh b/plugins/dotnet/dotnet.plugin.zsh index 6bd4b7af8..8ea31cdbd 100644 --- a/plugins/dotnet/dotnet.plugin.zsh +++ b/plugins/dotnet/dotnet.plugin.zsh @@ -12,7 +12,7 @@ _dotnet_zsh_complete() return fi - # This is not a variable assigment, don't remove spaces! + # This is not a variable assignment, don't remove spaces! _values = "${(ps:\n:)completions}" } @@ -30,3 +30,4 @@ alias ds='dotnet sln' alias da='dotnet add' alias dp='dotnet pack' alias dng='dotnet nuget' +alias db='dotnet build' diff --git a/plugins/emoji/emoji.plugin.zsh b/plugins/emoji/emoji.plugin.zsh index 7876f1c89..f70e09320 100644 --- a/plugins/emoji/emoji.plugin.zsh +++ b/plugins/emoji/emoji.plugin.zsh @@ -20,7 +20,7 @@ unset _omz_emoji_plugin_dir # These additional emoji are not in the definition file, but are useful in conjunction with it -# This is a combinin character that can be placed after any other character to surround +# This is a combining character that can be placed after any other character to surround # it in a "keycap" symbol. # The digits 0-9 are already in the emoji table as keycap_digit_<N>, keycap_ten, etc. # It's unclear whether this should be in the $emoji array, because those characters are all ones diff --git a/plugins/fastfile/fastfile.plugin.zsh b/plugins/fastfile/fastfile.plugin.zsh index ccbbce3b2..6288bb275 100644 --- a/plugins/fastfile/fastfile.plugin.zsh +++ b/plugins/fastfile/fastfile.plugin.zsh @@ -18,7 +18,7 @@ default fastfile_var_prefix "§" # 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 +# => fastfile_print # function fastfile() { test "$2" || 2="." @@ -75,14 +75,14 @@ function fastfile_print() { # List all shortcuts # # STDOUT: -# (=> fastfle_print) for each shortcut +# (=> fastfile_print) for each shortcut # function fastfile_ls() { for f in "${fastfile_dir}"/*(NF); do - file=`basename "$f"` # To enable simpler handeling of spaces in file names + file=`basename "$f"` # To enable simpler handling of spaces in file names varkey=`echo "$file" | tr " " "_"` - # Special format for colums + # Special format for columns echo "${fastfile_var_prefix}${varkey}|->|$(fastfile_get "$file")" done | column -t -s "|" } @@ -93,7 +93,7 @@ function fastfile_ls() { # Arguments: # 1. name - The name of the shortcut (default: name of the file) # STDOUT: -# => fastfle_print +# => fastfile_print # function fastfile_rm() { fastfile_print "$1" @@ -105,7 +105,7 @@ function fastfile_rm() { # function fastfile_sync() { for f in "${fastfile_dir}"/*(NF); do - file=`basename "$f"` # To enable simpler handeling of spaces in file names + file=`basename "$f"` # To enable simpler handling of spaces in file names varkey=`echo "$file" | tr " " "_"` alias -g "${fastfile_var_prefix}${varkey}"="'$(fastfile_get "$file")'" diff --git a/plugins/fd/README.md b/plugins/fd/README.md index aabd624b8..4d9cf190f 100644 --- a/plugins/fd/README.md +++ b/plugins/fd/README.md @@ -10,4 +10,4 @@ plugins=(... fd) Completion is taken from the fd release [`7.3.0`](https://github.com/sharkdp/fd/releases/tag/v7.3.0). -Updated on Febrary 13th, 2019. +Updated on February 13th, 2019. diff --git a/plugins/flutter/README.md b/plugins/flutter/README.md index be419144f..9c8169afc 100644 --- a/plugins/flutter/README.md +++ b/plugins/flutter/README.md @@ -18,4 +18,4 @@ plugins=(... flutter) | `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 | +| `flc` | `flutter clean` | Cleans flutter project | diff --git a/plugins/frontend-search/_frontend-search.sh b/plugins/frontend-search/_frontend index 15f8d239d..15f8d239d 100644 --- a/plugins/frontend-search/_frontend-search.sh +++ b/plugins/frontend-search/_frontend diff --git a/plugins/fzf/README.md b/plugins/fzf/README.md index 791a3eb6f..15d4d31f3 100644 --- a/plugins/fzf/README.md +++ b/plugins/fzf/README.md @@ -26,7 +26,7 @@ export FZF_BASE=/path/to/fzf/install/dir Set default command to use when input is tty: ```zsh -export FZF_DEFAULT_COMMAND='<your fzf default commmand>' +export FZF_DEFAULT_COMMAND='<your fzf default command>' ``` If not set, the plugin will try to set it to these, in the order in which they're found: diff --git a/plugins/fzf/fzf.plugin.zsh b/plugins/fzf/fzf.plugin.zsh index aabd62cb1..102605958 100644 --- a/plugins/fzf/fzf.plugin.zsh +++ b/plugins/fzf/fzf.plugin.zsh @@ -1,176 +1,201 @@ -function setup_using_base_dir() { - local fzf_base fzf_shell fzfdirs dir - - test -d "${FZF_BASE}" && fzf_base="${FZF_BASE}" +function fzf_setup_using_base_dir() { + local fzf_base fzf_shell fzfdirs dir + + test -d "${FZF_BASE}" && fzf_base="${FZF_BASE}" + + if [[ -z "${fzf_base}" ]]; then + fzfdirs=( + "${HOME}/.fzf" + "${HOME}/.nix-profile/share/fzf" + "${XDG_DATA_HOME:-$HOME/.local/share}/fzf" + "/usr/local/opt/fzf" + "/usr/share/fzf" + "/usr/local/share/examples/fzf" + ) + for dir in ${fzfdirs}; do + if [[ -d "${dir}" ]]; then + fzf_base="${dir}" + break + fi + done if [[ -z "${fzf_base}" ]]; then - fzfdirs=( - "${HOME}/.fzf" - "${HOME}/.nix-profile/share/fzf" - "${XDG_DATA_HOME:-$HOME/.local/share}/fzf" - "/usr/local/opt/fzf" - "/usr/share/fzf" - "/usr/local/share/examples/fzf" - ) - for dir in ${fzfdirs}; do - if [[ -d "${dir}" ]]; then - fzf_base="${dir}" - break - fi - done - - if [[ -z "${fzf_base}" ]]; then - if (( ${+commands[fzf-share]} )) && dir="$(fzf-share)" && [[ -d "${dir}" ]]; then - fzf_base="${dir}" - elif (( ${+commands[brew]} )) && dir="$(brew --prefix fzf 2>/dev/null)"; then - if [[ -d "${dir}" ]]; then - fzf_base="${dir}" - fi - fi + if (( ${+commands[fzf-share]} )) && dir="$(fzf-share)" && [[ -d "${dir}" ]]; then + fzf_base="${dir}" + elif (( ${+commands[brew]} )) && dir="$(brew --prefix fzf 2>/dev/null)"; then + if [[ -d "${dir}" ]]; then + fzf_base="${dir}" fi - fi - - if [[ ! -d "${fzf_base}" ]]; then - return 1 - fi - - # Fix fzf shell directory for Arch Linux, NixOS or Void Linux packages - if [[ ! -d "${fzf_base}/shell" ]]; then - fzf_shell="${fzf_base}" - else - fzf_shell="${fzf_base}/shell" - fi - - # Setup fzf binary path - if (( ! ${+commands[fzf]} )) && [[ "$PATH" != *$fzf_base/bin* ]]; then - export PATH="$PATH:$fzf_base/bin" - fi - - # Auto-completion - if [[ -o interactive && "$DISABLE_FZF_AUTO_COMPLETION" != "true" ]]; then - 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 + fi + fi + fi + + if [[ ! -d "${fzf_base}" ]]; then + return 1 + fi + + # Fix fzf shell directory for Arch Linux, NixOS or Void Linux packages + if [[ ! -d "${fzf_base}/shell" ]]; then + fzf_shell="${fzf_base}" + else + fzf_shell="${fzf_base}/shell" + fi + + # Setup fzf binary path + if (( ! ${+commands[fzf]} )) && [[ "$PATH" != *$fzf_base/bin* ]]; then + export PATH="$PATH:$fzf_base/bin" + fi + + # Auto-completion + if [[ -o interactive && "$DISABLE_FZF_AUTO_COMPLETION" != "true" ]]; then + 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 } -function setup_using_debian_package() { - if (( ! $+commands[dpkg] )) || ! dpkg -s fzf &>/dev/null; then - # Either not a debian based distro, or no fzf installed - return 1 - fi - - # NOTE: There is no need to configure PATH for debian package, all binaries - # are installed to /usr/bin by default - - local completions key_bindings - - case $PREFIX in - *com.termux*) - # Support Termux package - completions="${PREFIX}/share/fzf/completion.zsh" - key_bindings="${PREFIX}/share/fzf/key-bindings.zsh" - ;; - *) - # Determine completion file path: first bullseye/sid, then buster/stretch - completions="/usr/share/doc/fzf/examples/completion.zsh" - [[ -f "$completions" ]] || completions="/usr/share/zsh/vendor-completions/_fzf" - key_bindings="/usr/share/doc/fzf/examples/key-bindings.zsh" - ;; - esac - - # Auto-completion - if [[ -o interactive && "$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 fzf_setup_using_debian() { + if (( ! $+commands[dpkg] )) || ! dpkg -s fzf &>/dev/null; then + # Either not a debian based distro, or no fzf installed + return 1 + fi + + # NOTE: There is no need to configure PATH for debian package, all binaries + # are installed to /usr/bin by default + + local completions key_bindings + + case $PREFIX in + *com.termux*) + # Support Termux package + completions="${PREFIX}/share/fzf/completion.zsh" + key_bindings="${PREFIX}/share/fzf/key-bindings.zsh" + ;; + *) + # Determine completion file path: first bullseye/sid, then buster/stretch + completions="/usr/share/doc/fzf/examples/completion.zsh" + [[ -f "$completions" ]] || completions="/usr/share/zsh/vendor-completions/_fzf" + key_bindings="/usr/share/doc/fzf/examples/key-bindings.zsh" + ;; + esac + + # Auto-completion + if [[ -o interactive && "$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 setup_using_opensuse_package() { - # OpenSUSE installs fzf in /usr/bin/fzf - # If the command is not found, the package isn't installed - (( $+commands[fzf] )) || return 1 +function fzf_setup_using_opensuse() { + # OpenSUSE installs fzf in /usr/bin/fzf + # If the command is not found, the package isn't installed + (( $+commands[fzf] )) || return 1 + + # The fzf-zsh-completion package installs the auto-completion in + local completions="/usr/share/zsh/site-functions/_fzf" + # The fzf-zsh-completion package installs the key-bindings file in + local key_bindings="/etc/zsh_completion.d/fzf-key-bindings" + + # If these are not found: (1) maybe we're not on OpenSUSE, or + # (2) maybe the fzf-zsh-completion package isn't installed. + if [[ ! -f "$completions" || ! -f "$key_bindings" ]]; then + return 1 + fi + + # Auto-completion + if [[ -o interactive && "$DISABLE_FZF_AUTO_COMPLETION" != "true" ]]; then + source "$completions" 2>/dev/null + fi + + # Key bindings + if [[ "$DISABLE_FZF_KEY_BINDINGS" != "true" ]]; then + source "$key_bindings" 2>/dev/null + fi + + return 0 +} - # The fzf-zsh-completion package installs the auto-completion in - local completions="/usr/share/zsh/site-functions/_fzf" - # The fzf-zsh-completion package installs the key-bindings file in - local key_bindings="/etc/zsh_completion.d/fzf-key-bindings" +function fzf_setup_using_openbsd() { + # openBSD installs fzf in /usr/local/bin/fzf + if [[ "$OSTYPE" != openbsd* ]] || (( ! $+commands[fzf] )); then + return 1 + fi - # If these are not found: (1) maybe we're not on OpenSUSE, or - # (2) maybe the fzf-zsh-completion package isn't installed. - if [[ ! -f "$completions" || ! -f "$key_bindings" ]]; then - return 1 - fi + # The fzf package installs the auto-completion in + local completions="/usr/local/share/zsh/site-functions/_fzf_completion" + # The fzf package installs the key-bindings file in + local key_bindings="/usr/local/share/zsh/site-functions/_fzf_key_bindings" - # Auto-completion - if [[ -o interactive && "$DISABLE_FZF_AUTO_COMPLETION" != "true" ]]; then - source "$completions" 2>/dev/null - fi + # Auto-completion + if [[ -o interactive && "$DISABLE_FZF_AUTO_COMPLETION" != "true" ]]; then + source "$completions" 2>/dev/null + fi - # Key bindings - if [[ "$DISABLE_FZF_KEY_BINDINGS" != "true" ]]; then - source "$key_bindings" 2>/dev/null - fi + # Key bindings + if [[ "$DISABLE_FZF_KEY_BINDINGS" != "true" ]]; then + source "$key_bindings" 2>/dev/null + fi - return 0 + return 0 } -function setup_using_openbsd_package() { - # openBSD installs fzf in /usr/local/bin/fzf - if [[ "$OSTYPE" != openbsd* ]] || (( ! $+commands[fzf] )); then - return 1 - fi +function fzf_setup_using_cygwin() { + # Cygwin installs fzf in /usr/local/bin/fzf + if [[ "$OSTYPE" != cygwin* ]] || (( ! $+commands[fzf] )); then + return 1 + fi - # The fzf package installs the auto-completion in - local completions="/usr/local/share/zsh/site-functions/_fzf_completion" - # The fzf package installs the key-bindings file in - local key_bindings="/usr/local/share/zsh/site-functions/_fzf_key_bindings" + # The fzf-zsh-completion package installs the auto-completion in + local completions="/etc/profile.d/fzf-completion.zsh" + # The fzf-zsh package installs the key-bindings file in + local key_bindings="/etc/profile.d/fzf.zsh" - # Auto-completion - if [[ -o interactive && "$DISABLE_FZF_AUTO_COMPLETION" != "true" ]]; then - source "$completions" 2>/dev/null - fi + # Auto-completion + if [[ -o interactive && "$DISABLE_FZF_AUTO_COMPLETION" != "true" ]]; then + source "$completions" 2>/dev/null + fi - # Key bindings - if [[ "$DISABLE_FZF_KEY_BINDINGS" != "true" ]]; then - source "$key_bindings" 2>/dev/null - fi + # Key bindings + if [[ "$DISABLE_FZF_KEY_BINDINGS" != "true" ]]; then + source "$key_bindings" 2>/dev/null + fi - return 0 + return 0 } -function indicate_error() { - cat >&2 <<EOF +# Indicate to user that fzf installation not found if nothing worked +function fzf_setup_error() { + cat >&2 <<'EOF' [oh-my-zsh] fzf plugin: Cannot find fzf installation directory. -Please add \`export FZF_BASE=/path/to/fzf/install/dir\` to your .zshrc +Please add `export FZF_BASE=/path/to/fzf/install/dir` to your .zshrc EOF } -# Indicate to user that fzf installation not found if nothing worked -setup_using_openbsd_package \ - || setup_using_debian_package \ - || setup_using_opensuse_package \ - || setup_using_base_dir \ - || indicate_error +fzf_setup_using_openbsd \ + || fzf_setup_using_debian \ + || fzf_setup_using_opensuse \ + || fzf_setup_using_cygwin \ + || fzf_setup_using_base_dir \ + || fzf_setup_error -unset -f setup_using_opensuse_package setup_using_debian_package setup_using_base_dir indicate_error +unset -f -m 'fzf_setup_*' if [[ -z "$FZF_DEFAULT_COMMAND" ]]; then - if (( $+commands[rg] )); then - export FZF_DEFAULT_COMMAND='rg --files --hidden --glob "!.git/*"' - 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 "" --ignore .git' - fi + if (( $+commands[rg] )); then + export FZF_DEFAULT_COMMAND='rg --files --hidden --glob "!.git/*"' + 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 "" --ignore .git' + fi fi diff --git a/plugins/git/README.md b/plugins/git/README.md index 113080874..b9af3488f 100644 --- a/plugins/git/README.md +++ b/plugins/git/README.md @@ -130,6 +130,7 @@ plugins=(... git) | grbd | git rebase $(git_develop_branch) | | grbi | git rebase -i | | grbm | git rebase $(git_main_branch) | +| grbom | git rebase origin/$(git_main_branch) | | grbo | git rebase --onto | | grbs | git rebase --skip | | grev | git revert | diff --git a/plugins/git/git.plugin.zsh b/plugins/git/git.plugin.zsh index 5a3c98287..648fa0a33 100644 --- a/plugins/git/git.plugin.zsh +++ b/plugins/git/git.plugin.zsh @@ -251,6 +251,7 @@ alias grbc='git rebase --continue' alias grbd='git rebase $(git_develop_branch)' alias grbi='git rebase -i' alias grbm='git rebase $(git_main_branch)' +alias grbom='git rebase origin/$(git_main_branch)' alias grbo='git rebase --onto' alias grbs='git rebase --skip' alias grev='git revert' diff --git a/plugins/gitfast/git-completion.bash b/plugins/gitfast/git-completion.bash index 4497a294f..f7b09b2c1 100644 --- a/plugins/gitfast/git-completion.bash +++ b/plugins/gitfast/git-completion.bash @@ -3383,7 +3383,7 @@ _git_worktree () # Here we are not completing an --option, it's either the # path or a ref. case "$prev" in - -b|-B) # Complete refs for branch to be created/reseted. + -b|-B) # Complete refs for branch to be created/reset. __git_complete_refs ;; -*) # The previous word is an -o|--option without an diff --git a/plugins/grails/grails.plugin.zsh b/plugins/grails/grails.plugin.zsh index 11777738c..ddc257428 100644 --- a/plugins/grails/grails.plugin.zsh +++ b/plugins/grails/grails.plugin.zsh @@ -1,5 +1,5 @@ _enumerateGrailsScripts() { - # Default directoryies + # Default directories directories=($GRAILS_HOME/scripts ~/.grails/scripts ./scripts) # Check all of the plugins directories, if they exist diff --git a/plugins/grunt/grunt.plugin.zsh b/plugins/grunt/grunt.plugin.zsh index 3f9695177..a89469a59 100644 --- a/plugins/grunt/grunt.plugin.zsh +++ b/plugins/grunt/grunt.plugin.zsh @@ -82,7 +82,7 @@ function __grunt() { update_msg=' (cache updated)' fi - # Make optioins completion. + # Make options completion. if [[ ${#__grunt_opts} -gt 0 ]]; then opts+=("${__grunt_opts[@]}") fi @@ -161,7 +161,7 @@ function __grunt_update_cache() { fi if [[ $is_updating -ne 0 ]]; then - # Update caceh. + # Update cache. __grunt_version=$version __grunt_gruntfile=$gruntfile is_updating=1 diff --git a/plugins/heroku/heroku.plugin.zsh b/plugins/heroku/heroku.plugin.zsh index 9a99b4211..d22c1bb2f 100644 --- a/plugins/heroku/heroku.plugin.zsh +++ b/plugins/heroku/heroku.plugin.zsh @@ -1,9 +1,9 @@ -HEROKU_AC_CACHE_DIR="$HOME/.cache" -if [ "$(uname -s)" = "Darwin" ]; then - HEROKU_AC_CACHE_DIR="$HOME/Library/Caches" +if [[ "$OSTYPE" = darwin* ]]; then + cache_dir="${HOME}/Library/Caches" +else + cache_dir="${XDG_CACHE_HOME:-"${HOME}/.cache"}" fi -if [ ! -z "$XDG_CACHE_HOME" ]; then - HEROKU_AC_CACHE_DIR="$XDG_CACHE_DIR" -fi -HEROKU_AC_ZSH_SETUP_PATH=$HEROKU_AC_CACHE_DIR/heroku/autocomplete/zsh_setup -[ -f $HEROKU_AC_ZSH_SETUP_PATH ] && source $HEROKU_AC_ZSH_SETUP_PATH + +setup_path="${cache_dir}/heroku/autocomplete/zsh_setup" +[[ -f "$setup_path" ]] && source $setup_path +unset cache_dir setup_path diff --git a/plugins/history-substring-search/history-substring-search.zsh b/plugins/history-substring-search/history-substring-search.zsh index a791cc4da..c326778d4 100644 --- a/plugins/history-substring-search/history-substring-search.zsh +++ b/plugins/history-substring-search/history-substring-search.zsh @@ -243,8 +243,8 @@ _history-substring-search-begin() { fi # - # Escape and join query parts with wildcard character '*' as seperator - # `(j:CHAR:)` join array to string with CHAR as seperator + # Escape and join query parts with wildcard character '*' as separator + # `(j:CHAR:)` join array to string with CHAR as separator # local search_pattern="*${(j:*:)_history_substring_search_query_parts[@]//(#m)[\][()|\\*?#<>~^]/\\$MATCH}*" diff --git a/plugins/hitokoto/hitokoto.plugin.zsh b/plugins/hitokoto/hitokoto.plugin.zsh index 8646ebf3b..e346d18c5 100644 --- a/plugins/hitokoto/hitokoto.plugin.zsh +++ b/plugins/hitokoto/hitokoto.plugin.zsh @@ -1,14 +1,18 @@ if ! (( $+commands[curl] )); then - echo "hitokoto plugin needs curl to work" >&2 - return + 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') + setopt localoptions nopromptsubst - TXT=$(echo "$Q" | awk -F '\t' '{print $1}') - WHO=$(echo "$Q" | awk -F '\t' '{print $2}') + # Get hitokoto data + local -a data + data=("${(ps:\n:)"$(command curl -s --connect-timeout 2 "https://v1.hitokoto.cn" | command jq -j '.hitokoto+"\n"+.from')"}") - [[ -n "$WHO" && -n "$TXT" ]] && print -P "%F{3}${WHO}%f: “%F{5}${TXT}%f”" + # Exit if could not fetch hitokoto + [[ -n "$data" ]] || return 0 + + local quote="${data[1]}" author="${data[2]}" + print -P "%F{3}${author}%f: “%F{5}${quote}%f”" } diff --git a/plugins/ipfs/_ipfs b/plugins/ipfs/_ipfs index 9ee8bd79c..90c0a61c8 100644 --- a/plugins/ipfs/_ipfs +++ b/plugins/ipfs/_ipfs @@ -596,7 +596,7 @@ case $MAIN_SUBCOMMAND in '(-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.]' \ + '(-s --stream)'{-s,--stream}'[Enable experimental streaming of directory entries as they are traversed.]' \ ;; (mount) _arguments \ diff --git a/plugins/istioctl/README.md b/plugins/istioctl/README.md new file mode 100644 index 000000000..afd4d293c --- /dev/null +++ b/plugins/istioctl/README.md @@ -0,0 +1,9 @@ +# Istioctl - Istio Command-line Tool + +The [istioctl](https://istio.io/latest/docs/ops/diagnostic-tools/istioctl/) tool is a configuration command line utility that allows service operators to debug and diagnose their Istio service mesh deployments. + +To use it, add `istioctl` to the plugins array of your zshrc file: + +```sh +plugins=(... istioctl) +``` diff --git a/plugins/istioctl/istioctl.plugin.zsh b/plugins/istioctl/istioctl.plugin.zsh new file mode 100644 index 000000000..13ead1b2b --- /dev/null +++ b/plugins/istioctl/istioctl.plugin.zsh @@ -0,0 +1,4 @@ +if [ $commands[istioctl] ]; then + source <(istioctl completion zsh) + compdef _istioctl istioctl +fi diff --git a/plugins/iterm2/iterm2.plugin.zsh b/plugins/iterm2/iterm2.plugin.zsh index e4ac72ee3..9d8e40bf6 100644 --- a/plugins/iterm2/iterm2.plugin.zsh +++ b/plugins/iterm2/iterm2.plugin.zsh @@ -8,7 +8,7 @@ if [[ "$OSTYPE" == darwin* ]] && [[ -n "$ITERM_SESSION_ID" ]] ; then ### - # Executes an arbitrary iTerm2 command via an escape code sequce. + # Executes an arbitrary iTerm2 command via an escape code sequence. # See https://iterm2.com/documentation-escape-codes.html for all supported commands. # Example: $ _iterm2_command "1337;StealFocus" function _iterm2_command() { diff --git a/plugins/jenv/README.md b/plugins/jenv/README.md index c043c626e..148794197 100644 --- a/plugins/jenv/README.md +++ b/plugins/jenv/README.md @@ -1,6 +1,6 @@ # jenv plugin -[jenv](https://www.jenv.be/) is a Java version manager similiar to [rbenv](https://github.com/rbenv/rbenv) +[jenv](https://www.jenv.be/) is a Java version manager similar to [rbenv](https://github.com/rbenv/rbenv) and [pyenv](https://github.com/yyuu/pyenv). This plugin initializes jenv and provides the `jenv_prompt_info` function to add Java diff --git a/plugins/jfrog/jfrog.plugin.zsh b/plugins/jfrog/jfrog.plugin.zsh index 064ffa2db..1441bc107 100644 --- a/plugins/jfrog/jfrog.plugin.zsh +++ b/plugins/jfrog/jfrog.plugin.zsh @@ -7,4 +7,5 @@ _jfrog() { fi } -compdef _jfrog jfrog
\ No newline at end of file +compdef _jfrog jfrog +compdef _jfrog jf diff --git a/plugins/kn/README.md b/plugins/kn/README.md new file mode 100644 index 000000000..d2eb9b31d --- /dev/null +++ b/plugins/kn/README.md @@ -0,0 +1,17 @@ +# kn - Knative CLI + +This plugin provides autocompletion for [kn](https://knative.dev/docs/install/client/install-kn/) operations. + +To use it, add `kn` to the plugins array of your zshrc file: + +```zsh +plugins=(... kn) +``` + +## See Also + ++ [kn/client](https://github.com/knative/client) + +## Contributors + ++ [btannous](https://github.com/btannous) - Plugin Author diff --git a/plugins/kn/kn.plugin.zsh b/plugins/kn/kn.plugin.zsh new file mode 100644 index 000000000..f60177dd9 --- /dev/null +++ b/plugins/kn/kn.plugin.zsh @@ -0,0 +1,8 @@ +# Autocompletion for kn, the command line interface for knative +# +# Author: https://github.com/btannous + +if [ $commands[kn] ]; then + source <(kn completion zsh) + compdef _kn kn +fi diff --git a/plugins/macos/macos.plugin.zsh b/plugins/macos/macos.plugin.zsh index 4bcbbaead..6a91be336 100644 --- a/plugins/macos/macos.plugin.zsh +++ b/plugins/macos/macos.plugin.zsh @@ -1,9 +1,3 @@ -# Check if 'osx' is still in the plugins list and prompt to change to 'macos' -if [[ -n "${plugins[(r)osx]}" ]]; then - print ${(%):-"%F{yellow}The \`osx\` plugin is deprecated and has been renamed to \`macos\`."} - print ${(%):-"Please update your .zshrc to use the \`%Bmacos%b\` plugin instead.%f"} -fi - # Open the current directory in a Finder window alias ofd='open_command $PWD' diff --git a/plugins/macos/osx.plugin.zsh b/plugins/macos/osx.plugin.zsh deleted file mode 120000 index 73d718d43..000000000 --- a/plugins/macos/osx.plugin.zsh +++ /dev/null @@ -1 +0,0 @@ -macos.plugin.zsh
\ No newline at end of file diff --git a/plugins/macos/spotify b/plugins/macos/spotify index 663215a74..491a60686 100644 --- a/plugins/macos/spotify +++ b/plugins/macos/spotify @@ -191,7 +191,7 @@ while [ $# -gt 0 ]; do -d "grant_type=client_credentials" \ ) if ! [[ "${SPOTIFY_TOKEN_RESPONSE_DATA}" =~ "access_token" ]]; then - cecho "Autorization failed, please check ${USER_CONFG_FILE}" + cecho "Authorization failed, please check ${USER_CONFG_FILE}" cecho "${SPOTIFY_TOKEN_RESPONSE_DATA}" showAPIHelp return 1 diff --git a/plugins/mercurial/README.md b/plugins/mercurial/README.md index 756964896..19d4a17b1 100644 --- a/plugins/mercurial/README.md +++ b/plugins/mercurial/README.md @@ -11,27 +11,29 @@ plugins=(... mercurial) ## Aliases -| 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` | -| `hglg` | `hg log --stat -v` | -| `hglgp`| `hg log --stat -p -v` | +| Alias | Command | +| ------- | ------------------------------------------- | +| `hga` | `hg add` | +| `hgc` | `hg commit` | +| `hgca` | `hg commit --amend` | +| `hgci` | `hg commit --interactive` | +| `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 "<template>"` | +| `hgun` | `hg resolve --list` | +| `hgi` | `hg incoming` | +| `hgl` | `hg pull -u` | +| `hglr` | `hg pull --rebase` | +| `hgo` | `hg outgoing` | +| `hglg` | `hg log --stat -v` | +| `hglgp` | `hg log --stat -p -v` | + ## Prompt usage - Switch to a theme which uses `hg_prompt_info` @@ -61,7 +63,7 @@ ZSH_THEME_HG_PROMPT_CLEAN="%{$fg[magenta]%})" 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 +## Maintainers - [ptrv](https://github.com/ptrv): original creator - [oshybystyi](https://github.com/oshybystyi) diff --git a/plugins/mercurial/mercurial.plugin.zsh b/plugins/mercurial/mercurial.plugin.zsh index e098664c0..9b85d02f6 100644 --- a/plugins/mercurial/mercurial.plugin.zsh +++ b/plugins/mercurial/mercurial.plugin.zsh @@ -2,6 +2,7 @@ alias hga='hg add' alias hgc='hg commit' alias hgca='hg commit --amend' +alias hgci='hg commit --interactive' alias hgb='hg branch' alias hgba='hg branches' alias hgbk='hg bookmarks' @@ -10,7 +11,7 @@ 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 hgsl='hg log --limit 20 --template "{node|short} | {date|isodatesec} | {author|person}: {desc|strip|firstline}\n" ' alias hgun='hg resolve --list' # pull and update alias hgi='hg incoming' @@ -20,55 +21,98 @@ alias hgo='hg outgoing' alias hglg='hg log --stat -v' alias hglgp='hg log --stat -p -v' +function hgic() { + hg incoming "$@" | grep "changeset" | wc -l +} + +function hgoc() { + hg outgoing "$@" | grep "changeset" | wc -l +} + +# functions +function hg_root() { + local dir="$PWD" + while [[ "$dir" != "/" ]]; do + if [[ -d "$dir/.hg" ]]; then + echo "$dir" + return 0 + fi + dir="${dir:h}" + done + return 1 +} + function in_hg() { - if $(hg branch > /dev/null 2>&1); then - echo 1 - fi + hg_root >/dev/null } function hg_get_branch_name() { - branch=`hg branch 2>/dev/null` - if [ $? -eq 0 ]; then - echo $branch + local dir + if ! dir=$(hg_root); then + return fi - unset branch -} -function hg_prompt_info { - _DISPLAY=`hg branch 2>/dev/null` - if [ $? -eq 0 ]; then - echo "$ZSH_PROMPT_BASE_COLOR$ZSH_THEME_HG_PROMPT_PREFIX\ -$ZSH_THEME_REPO_NAME_COLOR$_DISPLAY$ZSH_PROMPT_BASE_COLOR$ZSH_PROMPT_BASE_COLOR$(hg_dirty)$ZSH_THEME_HG_PROMPT_SUFFIX$ZSH_PROMPT_BASE_COLOR" + if [[ ! -f "$dir/.hg/branch" ]]; then + echo default + return fi - unset _DISPLAY + + echo "$(<"$dir/.hg/branch")" } -function hg_dirty_choose { - hg status -mar 2> /dev/null | command grep -Eq '^\s*[ACDIM!?L]' - if [ $? -eq 0 ]; then - if [ $pipestatus[-1] -eq 0 ]; then - # Grep exits with 0 when "One or more lines were selected", return "dirty". - echo $1 - return - fi +function hg_get_bookmark_name() { + local dir + if ! dir=$(hg_root); then + return fi - echo $2 -} -function hg_dirty { - hg_dirty_choose $ZSH_THEME_HG_PROMPT_DIRTY $ZSH_THEME_HG_PROMPT_CLEAN -} + if [[ ! -f "$dir/.hg/bookmarks.current" ]]; then + return + fi -function hgic() { - hg incoming "$@" | grep "changeset" | wc -l + echo "$(<"$dir/.hg/bookmarks.current")" } -function hgoc() { - hg outgoing "$@" | grep "changeset" | wc -l +function hg_prompt_info { + local dir branch dirty + if ! dir=$(hg_root); then + return + fi + + if [[ ! -f "$dir/.hg/branch" ]]; then + branch=default + else + branch="$(<"$dir/.hg/branch")" + fi + + dirty="$(hg_dirty)" + + echo "${ZSH_THEME_HG_PROMPT_PREFIX}${branch:gs/%/%%}${dirty}${ZSH_THEME_HG_PROMPT_SUFFIX}" } -function hg_get_bookmark_name() { - if [ $(in_hg) ]; then - echo $(hg id -B) +function hg_dirty { + # Do nothing if clean / dirty settings aren't defined + if [[ -z "$ZSH_THEME_HG_PROMPT_DIRTY" && -z "$ZSH_THEME_HG_PROMPT_CLEAN" ]]; then + return + fi + + # Check if there are modifications + local hg_status + if [[ "$DISABLE_UNTRACKED_FILES_DIRTY" = true ]]; then + if ! hg_status="$(hg status -q 2>/dev/null)"; then + return + fi + else + if ! hg_status="$(hg status 2>/dev/null)"; then + return + fi fi + + # grep exits with 0 when dirty + if command grep -Eq '^\s*[ACDIMR!?L].*$' <<< "$hg_status"; then + echo $ZSH_THEME_HG_PROMPT_DIRTY + return + fi + + echo $ZSH_THEME_HG_PROMPT_CLEAN } diff --git a/plugins/npm/README.md b/plugins/npm/README.md index 47d153619..e970c3c7a 100644 --- a/plugins/npm/README.md +++ b/plugins/npm/README.md @@ -10,7 +10,7 @@ plugins=(... npm) ## Aliases -| Alias | Command | Descripton | +| Alias | Command | Description | |:------ |:-----------------------------|:----------------------------------------------------------------| | `npmg` | `npm i -g` | Install dependencies globally | | `npmS` | `npm i -S` | Install and save to dependencies in your package.json | diff --git a/plugins/operator-sdk/README.md b/plugins/operator-sdk/README.md new file mode 100644 index 000000000..3336e36ef --- /dev/null +++ b/plugins/operator-sdk/README.md @@ -0,0 +1,11 @@ +# Operator SDK + +[Operator SDK](https://sdk.operatorframework.io/) is a component of the Operator Framework, an open source toolkit to manage Kubernetes native applications, called Operators, in an effective, automated, and scalable way. + +To use it, add `operator-sdk` to the plugins array of your zshrc file: + +```sh +plugins=(... operator-sdk) +``` + + diff --git a/plugins/operator-sdk/operator-sdk.plugin.zsh b/plugins/operator-sdk/operator-sdk.plugin.zsh new file mode 100644 index 000000000..baeb01a80 --- /dev/null +++ b/plugins/operator-sdk/operator-sdk.plugin.zsh @@ -0,0 +1,4 @@ +if [ $commands[operator-sdk] ]; then + source <(operator-sdk completion zsh) + compdef _operator-sdk operator-sdk +fi diff --git a/plugins/osx b/plugins/osx deleted file mode 120000 index a8d0f9c48..000000000 --- a/plugins/osx +++ /dev/null @@ -1 +0,0 @@ -macos
\ No newline at end of file diff --git a/plugins/osx/README.md b/plugins/osx/README.md new file mode 100644 index 000000000..98d859545 --- /dev/null +++ b/plugins/osx/README.md @@ -0,0 +1,3 @@ +# osx plugin + +**Deprecated: use the [`macos`](https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/macos) plugin instead.** diff --git a/plugins/osx/osx.plugin.zsh b/plugins/osx/osx.plugin.zsh new file mode 100644 index 000000000..9304e7f32 --- /dev/null +++ b/plugins/osx/osx.plugin.zsh @@ -0,0 +1,5 @@ +print ${(%):-'%F{yellow}The `osx` plugin is deprecated and has been renamed to `macos`.'} +print ${(%):-'Please update your .zshrc to use the `%Bmacos%b` plugin instead.%f'} + +(( ${fpath[(Ie)$ZSH/plugins/macos]} )) || fpath=("$ZSH/plugins/macos" $fpath) +source "$ZSH/plugins/macos/macos.plugin.zsh" diff --git a/plugins/pep8/_pep8 b/plugins/pep8/_pep8 index ce19951dc..27b7fc544 100644 --- a/plugins/pep8/_pep8 +++ b/plugins/pep8/_pep8 @@ -29,6 +29,6 @@ _arguments -s -S \ "--max-line-length[set maximum allowed line length (default: 79)]::n:_files" \ "--format[set the error format \[default|pylint|<custom>\]]::format:_files" \ "--diff[report only lines changed according to the unified diff received on STDIN]" \ - "--benchmark[measure processing speed are read from the \[pep8\] section of the tox.ini fg file located in any parent folder of the path(s) llowed options are: exclude, filename, select, ngth, count, format, quiet, show-pep8, show-source, .]" \ + "--benchmark[measure processing speed are read from the \[pep8\] section of the tox.ini fg file located in any parent folder of the path(s) allowed options are: exclude, filename, select, ngth, count, format, quiet, show-pep8, show-source, .]" \ "--config[user config file location (default: /home/gsemet/.config/pep8)]::path:_files" \ "*::args:_files" diff --git a/plugins/percol/README.md b/plugins/percol/README.md index ec5de4f86..78c881f55 100644 --- a/plugins/percol/README.md +++ b/plugins/percol/README.md @@ -1,20 +1,23 @@ -## percol +# percol -Provides some useful function to make [percol](https://github.com/mooz/percol) work with zsh history and [jump plugin](https://github.com/ohmyzsh/ohmyzsh/blob/master/plugins/jump/jump.plugin.zsh) +Provides some useful function to make [percol](https://github.com/mooz/percol) work with zsh history and +the [jump plugin](https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/jump), optionally. -### Requirements +To use it, add `percol` to the plugins array in your zshrc: -```shell -pip install percol +```zsh +plugins=(... percol) ``` -And [jump](https://github.com/ohmyzsh/ohmyzsh/blob/master/plugins/jump/jump.plugin.zsh) for `oh-my-zsh` is a optional requirement. +## Requirements -### Usage +- `percol`: install with `pip install percol`. -For default +- (_Optional_) [`jump`](https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/jump) plugin: needs to be + enabled before the `percol` plugin. -- `^-r` bind to `percol_select_history`.You can use it to grep your history with percol. +## Usage -- `^-b` bind to `percol_select_marks`.You can use it to grep your bookmarks with percol. +- <kbd>CTRL-R</kbd> (bound to `percol_select_history`): you can use it to grep your history with percol. +- <kbd>CTRL-B</kbd> (bound to `percol_select_marks`): you can use it to grep your jump bookmarks with percol. diff --git a/plugins/percol/percol.plugin.zsh b/plugins/percol/percol.plugin.zsh index c6adf4e1e..b78383eee 100644 --- a/plugins/percol/percol.plugin.zsh +++ b/plugins/percol/percol.plugin.zsh @@ -1,22 +1,25 @@ -if which percol &> /dev/null; then - function percol_select_history() { - local tac - which gtac &> /dev/null && tac="gtac" || { which tac &> /dev/null && tac="tac" || { tac="tail -r" } } - BUFFER=$(fc -l -n 1 | eval $tac | percol --query "$LBUFFER") - CURSOR=$#BUFFER - zle -R -c - } +(( ${+commands[percol]} )) || return - zle -N percol_select_history - bindkey '^R' percol_select_history +function percol_select_history() { + # print history in reverse order (from -1 (latest) to 1 (oldest)) + BUFFER=$(fc -l -n -1 1 | percol --query "$LBUFFER") + CURSOR=$#BUFFER + zle -R -c +} +zle -N percol_select_history +bindkey -M emacs '^R' percol_select_history +bindkey -M viins '^R' percol_select_history +bindkey -M vicmd '^R' percol_select_history - if which marks &> /dev/null; then - function percol_select_marks() { - BUFFER=$(marks | percol --query "$LBUFFER" | awk '{print $3}') - CURSOR=$#BUFFER # move cursor - zle -R -c # refresh - } - zle -N percol_select_marks - bindkey '^B' percol_select_marks - fi +if (( ${+functions[marks]} )); then + function percol_select_marks() { + # parse directory from marks output (markname -> path) and quote if necessary + BUFFER=${(q)"$(marks | percol --query "$LBUFFER")"##*-> } + CURSOR=$#BUFFER + zle -R -c + } + zle -N percol_select_marks + bindkey -M emacs '^B' percol_select_marks + bindkey -M viins '^B' percol_select_marks + bindkey -M vicmd '^B' percol_select_marks fi diff --git a/plugins/please/README.md b/plugins/please/README.md index 89bfbf105..0a33f897b 100644 --- a/plugins/please/README.md +++ b/plugins/please/README.md @@ -1,7 +1,7 @@ # please plugin [Please](https://please.build) is a cross-language build system with an emphasis on -high performance, extensibility and reproduceability. It supports a number of popular +high performance, extensibility and reproducibility. It supports a number of popular languages and can automate nearly any aspect of your build process. This plugin adds autocomplete and major aliases for `plz`, the command line tool for diff --git a/plugins/pm2/_pm2 b/plugins/pm2/_pm2 index 6f1e89df5..86412aef1 100644 --- a/plugins/pm2/_pm2 +++ b/plugins/pm2/_pm2 @@ -124,7 +124,7 @@ logs_options=( '--out[only shows standard output]' '--lines[output the last N lines, instead of the last 15 by default]' '--timestamp[add timestamps (default format YYYY-MM-DD-HH:mm:ss)]' - '--nostream[print logs without lauching the log stream]' + '--nostream[print logs without launching the log stream]' '(-h --help)'{-h,--help}'[output usage information]' $id_all_comp ) @@ -139,7 +139,7 @@ case "$words[1]" in stop|restart|delete|reload|reset) _arguments $id_all_comp && return 0 ;; - env|inspect|monitor|unmonitor|discribe) + env|inspect|monitor|unmonitor|describe) _arguments $id_comp && return 0 ;; deploy|startOrRestart|startOrReload) diff --git a/plugins/powify/_powify b/plugins/powify/_powify index 9507f400e..57042aa63 100644 --- a/plugins/powify/_powify +++ b/plugins/powify/_powify @@ -15,7 +15,7 @@ _1st_arguments=( 'restart:restarts the pow app linked to the current directory' 'always_restart:reload the pow app after each request' 'always_restart_off:do not reload the pow app after each request' - 'rename:rename the current pow app to [NAME] or renmae [OLD] to [NEW]' + 'rename:rename the current pow app to [NAME] or rename [OLD] to [NEW]' 'environment:run the this pow app in a different environment (aliased `env`)' 'browse:opens and navigates the default browser to this app' 'logs:tail the application logs' diff --git a/plugins/rake/rake.plugin.zsh b/plugins/rake/rake.plugin.zsh index 121150017..3ceb20fea 100644 --- a/plugins/rake/rake.plugin.zsh +++ b/plugins/rake/rake.plugin.zsh @@ -2,7 +2,7 @@ # over the years. We will miss you dearly. alias jimweirich="rake" -alias rake="noglob rake" # allows square brackts for rake task invocation +alias rake="noglob rake" # allows square brackets for rake task invocation alias brake='noglob bundle exec rake' # execute the bundled rake gem alias srake='noglob sudo rake' # noglob must come before sudo alias sbrake='noglob sudo bundle exec rake' # altogether now ... diff --git a/plugins/rand-quote/rand-quote.plugin.zsh b/plugins/rand-quote/rand-quote.plugin.zsh index 371b997d3..23c21dc8f 100644 --- a/plugins/rand-quote/rand-quote.plugin.zsh +++ b/plugins/rand-quote/rand-quote.plugin.zsh @@ -1,14 +1,23 @@ if ! (( $+commands[curl] )); then - echo "rand-quote plugin needs curl to work" >&2 - return + echo "rand-quote plugin needs curl to work" >&2 + return fi function quote { - emulate -L zsh - Q=$(curl -s --connect-timeout 2 "http://www.quotationspage.com/random.php" | iconv -c -f ISO-8859-1 -t UTF-8 | grep -m 1 "dt ") + setopt localoptions nopromptsubst - TXT=$(echo "$Q" | sed -e 's/<\/dt>.*//g' -e 's/.*html//g' -e 's/^[^a-zA-Z]*//' -e 's/<\/a..*$//g') - WHO=$(echo "$Q" | sed -e 's/.*\/quotes\///g' -e 's/<.*//g' -e 's/.*">//g') + # Get random quote data + local data + data="$(command curl -s --connect-timeout 2 "http://www.quotationspage.com/random.php" \ + | iconv -c -f ISO-8859-1 -t UTF-8 \ + | command grep -a -m 1 'dt class="quote"')" - [[ -n "$WHO" && -n "$TXT" ]] && print -P "%F{3}${WHO}%f: “%F{5}${TXT}%f”" + # Exit if could not fetch random quote + [[ -n "$data" ]] || return 0 + + local quote author + quote=$(sed -e 's|</dt>.*||g' -e 's|.*html||g' -e 's|^[^a-zA-Z]*||' -e 's|</a..*$||g' <<< "$data") + author=$(sed -e 's|.*/quotes/||g' -e 's|<.*||g' -e 's|.*">||g' <<< "$data") + + print -P "%F{3}${author}%f: “%F{5}${quote}%f”" } diff --git a/plugins/rbenv/rbenv.plugin.zsh b/plugins/rbenv/rbenv.plugin.zsh index 0f2d366e2..d758aebae 100644 --- a/plugins/rbenv/rbenv.plugin.zsh +++ b/plugins/rbenv/rbenv.plugin.zsh @@ -4,65 +4,65 @@ FOUND_RBENV=$+commands[rbenv] if [[ $FOUND_RBENV -ne 1 ]]; then - rbenvdirs=("$HOME/.rbenv" "/usr/local/rbenv" "/opt/rbenv" "/usr/local/opt/rbenv") - for dir in $rbenvdirs; do - if [[ -d $dir/bin ]]; then - export PATH="$dir/bin:$PATH" - FOUND_RBENV=1 - break - fi - done + rbenvdirs=("$HOME/.rbenv" "/usr/local/rbenv" "/opt/rbenv" "/usr/local/opt/rbenv") + for dir in $rbenvdirs; do + if [[ -d $dir/bin ]]; then + export PATH="$dir/bin:$PATH" + FOUND_RBENV=1 + break + fi + done fi if [[ $FOUND_RBENV -ne 1 ]]; then - if (( $+commands[brew] )) && dir=$(brew --prefix rbenv 2>/dev/null); then - if [[ -d $dir/bin ]]; then - export PATH="$dir/bin:$PATH" - FOUND_RBENV=1 - fi + if (( $+commands[brew] )) && dir=$(brew --prefix rbenv 2>/dev/null); then + if [[ -d $dir/bin ]]; then + export PATH="$dir/bin:$PATH" + FOUND_RBENV=1 fi + fi fi if [[ $FOUND_RBENV -eq 1 ]]; then - eval "$(rbenv init --no-rehash - zsh)" + eval "$(rbenv init --no-rehash - zsh)" - alias rubies="rbenv versions" - alias gemsets="rbenv gemset list" + alias rubies="rbenv versions" + alias gemsets="rbenv gemset list" - function current_ruby() { - echo "$(rbenv version-name)" - } + function current_ruby() { + echo "$(rbenv version-name)" + } - function current_gemset() { - echo "$(rbenv gemset active 2>/dev/null)" | tr ' ' '+' - } + function current_gemset() { + echo "$(rbenv gemset active 2>/dev/null)" | tr ' ' '+' + } - function gems() { - local rbenv_path=$(rbenv prefix) - gem list $@ | sed -E \ - -e "s/\([0-9a-z, \.]+( .+)?\)/$fg[blue]&$reset_color/g" \ - -e "s|$(echo $rbenv_path)|$fg[magenta]\$rbenv_path$reset_color|g" \ - -e "s/$current_ruby@global/$fg[yellow]&$reset_color/g" \ - -e "s/$current_ruby$current_gemset$/$fg[green]&$reset_color/g" - } + function gems() { + local rbenv_path=$(rbenv prefix) + gem list $@ | sed -E \ + -e "s/\([0-9a-z, \.]+( .+)?\)/$fg[blue]&$reset_color/g" \ + -e "s|$(echo $rbenv_path)|$fg[magenta]\$rbenv_path$reset_color|g" \ + -e "s/$current_ruby@global/$fg[yellow]&$reset_color/g" \ + -e "s/$current_ruby$current_gemset$/$fg[green]&$reset_color/g" + } - function rbenv_prompt_info() { - local ruby=$(current_ruby) gemset=$(current_gemset) - echo -n "${ZSH_THEME_RUBY_PROMPT_PREFIX}" - [[ -n "$gemset" ]] && echo -n "${ruby}@${gemset}" || echo -n "${ruby}" - echo "${ZSH_THEME_RUBY_PROMPT_SUFFIX}" - } + function rbenv_prompt_info() { + local ruby=${$(current_ruby):gs/%/%%} gemset=${$(current_gemset):gs/%/%%} + echo -n "${ZSH_THEME_RUBY_PROMPT_PREFIX}" + [[ -n "$gemset" ]] && echo -n "${ruby}@${gemset}" || echo -n "${ruby}" + echo "${ZSH_THEME_RUBY_PROMPT_SUFFIX}" + } else - alias rubies="ruby -v" - function gemsets() { echo "not supported" } - function current_ruby() { echo "not supported" } - function current_gemset() { echo "not supported" } - function gems() { echo "not supported" } - function rbenv_prompt_info() { - echo -n "${ZSH_THEME_RUBY_PROMPT_PREFIX}" - echo -n "system: $(ruby -v | cut -f-2 -d ' ')" - echo "${ZSH_THEME_RUBY_PROMPT_SUFFIX}" - } + alias rubies="ruby -v" + function gemsets() { echo "not supported" } + function current_ruby() { echo "not supported" } + function current_gemset() { echo "not supported" } + function gems() { echo "not supported" } + function rbenv_prompt_info() { + echo -n "${ZSH_THEME_RUBY_PROMPT_PREFIX}" + echo -n "system: $(ruby -v | cut -f-2 -d ' ' | sed 's/%/%%/g')" + echo "${ZSH_THEME_RUBY_PROMPT_SUFFIX}" + } fi unset FOUND_RBENV rbenvdirs dir diff --git a/plugins/rbfu/README.md b/plugins/rbfu/README.md index f1f9fa2f7..fbcab64de 100644 --- a/plugins/rbfu/README.md +++ b/plugins/rbfu/README.md @@ -4,6 +4,7 @@ This plugin starts [rbfu](https://github.com/hmans/rbfu), a minimal Ruby version manager, and adds some useful functions. To use it, add `rbfu` to the plugins array in your zshrc file: + ```zsh plugins=(... rbfu) ``` diff --git a/plugins/rbfu/rbfu.plugin.zsh b/plugins/rbfu/rbfu.plugin.zsh index 008485205..27dc3eec6 100644 --- a/plugins/rbfu/rbfu.plugin.zsh +++ b/plugins/rbfu/rbfu.plugin.zsh @@ -5,38 +5,45 @@ # rvm_prompt_info function to return the $RBFU_RUBY_VERSION # version. -command -v rbfu &>/dev/null - -if [[ $? -eq 0 ]]; then - eval "$(rbfu --init --auto)" - - # Internal: Print ruby version details, if it's currently - # active etc. - function _rbfu_rubies_print() { - local rb rb_out - rb=$(basename $1) - rb_out="$rb" - [[ -h $1 ]] && rb_out="$rb_out${fg[green]}@${reset_color}" - [[ "x$rb" == "x$2" ]] && rb_out="${fg[red]}$rb_out ${fg[red]}*${reset_color}" - echo $rb_out - } - - # Public: Provide a list with all available rubies, this basically depends - # on `ls -1` and .rfbu/rubies. Highlights the currently active ruby version - # and aliases. - function rbfu-rubies() { - local rbfu_dir active_rb - rbfu_dir=$RBFU_RUBIES - active_rb=$RBFU_RUBY_VERSION - [[ -z "$rbfu_dir" ]] && rbfu_dir="${HOME}/.rbfu/rubies" - [[ -z "$active_rb" ]] && active_rb="system" - _rbfu_rubies_print "${rbfu_dir}/system" $active_rb - for rb in $(ls -1 $rbfu_dir); do - _rbfu_rubies_print "${rbfu_dir}/${rb}" $active_rb - done - } - - # Public: Create rvm_prompt_info command for themes compatibility, unless - # it has already been defined. - [ ! -x rvm_prompt_info ] && function rvm_prompt_info() { echo "${RBFU_RUBY_VERSION:=system}" } -fi +command -v rbfu &>/dev/null || return + +eval "$(rbfu --init --auto)" + +# Internal: Print ruby version details, if it's currently active, etc. +function _rbfu_rubies_print() { + # 1: path to ruby file + # 2: active ruby + local rb rb_out + rb="${$1:t}" + rb_out="$rb" + + # If the ruby is a symlink, add @ to the name. + if [[ -h "$1" ]]; then + rb_out="${rb_out}${fg[green]}@${reset_color}" + fi + + # If the ruby is active, add * to the name and show it in red. + if [[ "$rb" = "$2" ]]; then + rb_out="${fg[red]}${rb_out} ${fg[red]}*${reset_color}" + fi + + echo $rb_out +} + +# Public: Provide a list with all available rubies, this basically depends +# on ~/.rfbu/rubies. Highlights the currently active ruby version and aliases. +function rbfu-rubies() { + local rbfu_dir active_rb + rbfu_dir="${RBFU_RUBIES:-${HOME}/.rbfu/rubies}" + active_rb="${RBFU_RUBY_VERSION:-system}" + + _rbfu_rubies_print "${rbfu_dir}/system" "$active_rb" + for rb in ${rbfu_dir}/*(N); do + _rbfu_rubies_print "$rb" "$active_rb" + done +} + +# Public: Create rvm_prompt_info command for themes compatibility, unless +# it has already been defined. +(( ${+functions[rvm_prompt_info]} )) || \ +function rvm_prompt_info() { echo "${${RBFU_RUBY_VERSION:=system}:gs/%/%%}" } diff --git a/plugins/rebar/_rebar b/plugins/rebar/_rebar index 7ac5a510c..ea0d8a674 100644 --- a/plugins/rebar/_rebar +++ b/plugins/rebar/_rebar @@ -32,7 +32,7 @@ _rebar () { 'create[Create skel based on template and vars]' \ 'create-app[Create simple app skel]' \ 'create-node[Create simple node skel]' \ - 'list-template[List avaiavle templates]' \ + 'list-template[List available templates]' \ 'doc[Generate Erlang program documentation]' \ 'check-deps[Display to be fetched dependencies]' \ 'get-deps[Fetch dependencies]' \ diff --git a/plugins/redis-cli/_redis-cli b/plugins/redis-cli/_redis-cli index 1569f2916..f93624565 100644 --- a/plugins/redis-cli/_redis-cli +++ b/plugins/redis-cli/_redis-cli @@ -8,7 +8,7 @@ _1st_arguments=( 'append:append a value to a key' 'auth:authenticate to the server' 'bgrewriteeaof:asynchronously rewrite the append-only file' - 'bgsave:asynchornously save the dataset to disk' + 'bgsave:asynchronously save the dataset to disk' 'blpop:remove and get the first element in a list, or block until one is available' 'brpop:remove and get the last element in a list, or block until one is available' 'brpoplpush:pop a value from a list, push it to another list and return it; or block until one is available' @@ -17,9 +17,9 @@ _1st_arguments=( # 'config resetstat: reset the stats returned by INFO' 'dbsize:return the number of keys in the selected database' # 'debug object:get debugging information about a key' - # 'debug setgfault:make the server crash' + # 'debug segfault:make the server crash' 'decr:decrement the integer value of a key by one' - 'decrby:decrement the integet value of a key by the given number' + 'decrby:decrement the integer value of a key by the given number' 'del:delete a key' 'discard:discard all commands issued after MULTI' 'echo:echo the given string' @@ -63,7 +63,7 @@ _1st_arguments=( 'mget:get the values of all the given keys' 'monitor:listen for all requests received by the server in real time' 'move:move a key to another database' - 'mset:set multiple keys to muliple values' + 'mset:set multiple keys to multiple values' 'msetnx:set multiple keys tom ultiple values, only if none of the keys exist' 'multi:mark the start of a transaction block' 'object:inspect the internals of Redis objects' @@ -122,7 +122,7 @@ _1st_arguments=( 'zrem:remove a member from a sorted set' 'zremrangebyrank:remove all members in a sorted set within the given indexes' 'zremrangebyscore:remove all members in a sorted set within the given scores' - 'zrevrange:return a range of membrs in a sorted set, by index, with scores ordered from high to low' + 'zrevrange:return a range of members in a sorted set, by index, with scores ordered from high to low' 'zrevrangebyscore:return a range of members in a sorted set, by score, with scores ordered from high to low' 'zrevrank:determine the index of a member in a sorted set, with scores ordered from high to low' 'zscore:get the score associated with the given member in a sorted set' diff --git a/plugins/rvm/README.md b/plugins/rvm/README.md index 1ed8d46a2..b0977f53a 100644 --- a/plugins/rvm/README.md +++ b/plugins/rvm/README.md @@ -18,3 +18,4 @@ plugins=(... rvm) | `rb21` | `rvm use ruby-2.1.2` | | `rvm-update` | `rvm get head` | | `gems` | `gem list` | +| `rvms` | `rvm gemset` | diff --git a/plugins/rvm/rvm.plugin.zsh b/plugins/rvm/rvm.plugin.zsh index 53e809aaf..c5918f289 100644 --- a/plugins/rvm/rvm.plugin.zsh +++ b/plugins/rvm/rvm.plugin.zsh @@ -1,7 +1,8 @@ fpath=($rvm_path/scripts/zsh/Completion $fpath) alias rubies='rvm list rubies' -alias gemsets='rvm gemset list' +alias rvms='rvm gemset' +alias gemsets='rvms list' local ruby18='ruby-1.8.7' local ruby19='ruby-1.9.3' diff --git a/plugins/salt/_salt b/plugins/salt/_salt index 78d8611d2..a1c55f350 100644 --- a/plugins/salt/_salt +++ b/plugins/salt/_salt @@ -145,7 +145,7 @@ _master_options=( '(-v --verbose)'{-v,--verbose}'[Turn on command verbosity, display jid and active job queries]' '--hide-timeout[Hide minions that timeout]' '(-b --batch --batch-size)'{-b,--batch,--batch-size}'[Execute the salt job in batch mode, pass number or percentage to batch.]:Batch Size:' - '(-a --auth --eauth --extrenal-auth)'{-a,--auth,--eauth,--external-auth}'[Specify an external authentication system to use.]:eauth:' + '(-a --auth --eauth --external-auth)'{-a,--auth,--eauth,--external-auth}'[Specify an external authentication system to use.]:eauth:' '(-T --make-token)'{-T,--make-token}'[Generate and save an authentication token for re-use.]' '--return[Set an alternative return method.]:Returners:_path_files -W "$salt_dir/returners" -g "[^_]*.py(\:r)"' '(-d --doc --documentation)'{-d,--doc,--documentation}'[Return the documentation for the specified module]' diff --git a/plugins/scala/_scala b/plugins/scala/_scala index f7511a647..ba7ac3874 100644 --- a/plugins/scala/_scala +++ b/plugins/scala/_scala @@ -190,7 +190,7 @@ Y_opts=( "-Yshow-symkinds[Print abbreviated symbol kinds next to symbol names]" "-Yshow-trees[Print detailed ASTs (requires -Xprint\:phase)]" "-Yshow-trees-compact[Print detailed ASTs in compact form (requires -Xprint\:)]" - "-Yshow-trees-stringified[Print stringifications along with detailed ASTs (requires -Xprint\:)]" + "-Yshow-trees-stringified[Print stringification along with detailed ASTs (requires -Xprint\:)]" "-Ystatistics[Print compiler statistics]" "-Ystruct-dispatch\:-[Structural method dispatch policy (default\: poly-cache)]:policy name:(no-cache mono-cache poly-cache invoke-dynamic)" diff --git a/plugins/scd/scd b/plugins/scd/scd index a7db6c265..7e9654b44 100755 --- a/plugins/scd/scd +++ b/plugins/scd/scd @@ -270,7 +270,7 @@ fi # Determine the last recorded directory if [[ -s ${SCD_HISTFILE} ]]; then - last_directory=${"$(tail -1 ${SCD_HISTFILE})"#*;} + last_directory=${"$(tail -n 1 ${SCD_HISTFILE})"#*;} fi # The "record" function adds its arguments to the directory index. diff --git a/plugins/sfdx/_sfdx b/plugins/sfdx/_sfdx index 42ee55970..3a441f257 100644 --- a/plugins/sfdx/_sfdx +++ b/plugins/sfdx/_sfdx @@ -900,7 +900,7 @@ case "$words[1]" in force:data:tree:export) _command_args=( '(-q|--query)'{-q,--query}'[soql query, or filepath of file containing a soql query, to retrieve records]' \ - '(-p|--plan)'{-p,--plan}'[generate mulitple sobject tree files and a plan definition file for aggregated import]' \ + '(-p|--plan)'{-p,--plan}'[generate multiple sobject tree files and a plan definition file for aggregated import]' \ '(-x|--prefix)'{-x,--prefix}'[prefix of generated files]' \ '(-d|--outputdir)'{-d,--outputdir}'[directory to store files]:file:_files' \ '(-u|--targetusername)'{-u,--targetusername}'[username or alias for the target org; overrides default target org]' \ diff --git a/plugins/shell-proxy/README.md b/plugins/shell-proxy/README.md index 6f2cd13e0..b19888c56 100644 --- a/plugins/shell-proxy/README.md +++ b/plugins/shell-proxy/README.md @@ -1,42 +1,56 @@ -# Shell Proxy oh-my-zsh plugin +# shell-proxy plugin -This a pure user-space program, shell-proxy setter, written Python3 and Bash. +This a pure user-space program, shell-proxy setter, written in Python3 and Zsh. -100% only no side-effects, only effect **environment variables** and **aliases** +To use it, add `shell-proxy` to the plugins array in your zshrc file: -## Key feature +```zsh +plugins=(... shell-proxy) +``` + +## Key features -- Support Ubuntu, Archlinux, etc (Linux) -- Support macOS -- Support git via based-`$GIT_SSH` -- Support ssh, sftp, scp, slogin and ssh-copy-id via based-`alias` -- Built-in Auto-complete +- Supports macOS and Linux (Ubuntu, Archlinux, etc.) +- Supports git via setting `$GIT_SSH` +- Supports ssh, sftp, scp, slogin and ssh-copy-id via setting aliases +- Built-in autocomplete ## Usage -Method 1: +### Method 1 -`$DEFAULT_PROXY` is the proxy URL you will set +Set `SHELLPROXY_URL` environment variable to the URL of the proxy server: -Method 2: +```sh +SHELLPROXY_URL="http://127.0.0.1:8123" +proxy enable +``` -Write a program to `$HOME/.config/proxy` in the file. +### Method 2 -Example program: +Write a program file in `$HOME/.config/proxy` so that the proxy URL is defined dynamically. +Note that the program file must be executable. -```bash +Example: + +```sh #!/bin/bash -# The file path: $HOME/.config/proxy -if [[ "$OSTYPE" == "darwin"* ]]; then + +if [[ "$(uname)" = Darwin ]]; then echo "http://127.0.0.1:6152" # Surge Mac else echo "http://127.0.0.1:8123" # polipo fi ``` -Method 3: +### Method 3 -The working path of **Method 2** can be changed via `$CONFIG_PROXY` +Use [method 2](#method-2) but define the location of the program file by setting the +`SHELLPROXY_CONFIG` environment variable: + +```sh +SHELLPROXY_CONFIG="$HOME/.dotfiles/proxy-config" +``` ## Reference @@ -45,8 +59,4 @@ The working path of **Method 2** can be changed via `$CONFIG_PROXY` ## Maintainer -- <https://github.com/septs> - -## The oh-my-zsh plugin (shell-proxy) - -Public Domain +- [@septs](https://github.com/septs) diff --git a/plugins/shell-proxy/proxy.py b/plugins/shell-proxy/proxy.py index 97f4cf873..14f2944cc 100755 --- a/plugins/shell-proxy/proxy.py +++ b/plugins/shell-proxy/proxy.py @@ -5,16 +5,22 @@ from subprocess import check_output, list2cmdline cwd = os.path.dirname(__file__) ssh_agent = os.path.join(cwd, "ssh-agent.py") -user_proxy = os.environ.get("CONFIG_PROXY", os.path.expandvars("$HOME/.config/proxy")) +proxy_env = "SHELLPROXY_URL" +proxy_config = os.environ.get("SHELLPROXY_CONFIG") or os.path.expandvars("$HOME/.config/proxy") +usage="""shell-proxy: no proxy configuration found. + +Set `{env}` or create a config file at `{config}` +See the plugin README for more information.""".format(env=proxy_env, config=proxy_config) def get_http_proxy(): - default_proxy = os.environ.get("DEFAULT_PROXY") + default_proxy = os.environ.get(proxy_env) if default_proxy: return default_proxy - if os.path.isfile(user_proxy): - return check_output(user_proxy).decode("utf-8").strip() - raise Exception("Not found, Proxy configuration") + if os.path.isfile(proxy_config): + return check_output(proxy_config).decode("utf-8").strip() + print(usage, file=sys.stderr) + sys.exit(1) def make_proxies(url: str): @@ -53,8 +59,7 @@ class CommandSet: cmdline("echo", _) def usage(self): - cmdline("echo", "usage: proxy {enable,disable,status}") - self.status() + print("usage: proxy {enable,disable,status}", file=sys.stderr) def cmdline(*items): @@ -65,7 +70,7 @@ def main(): command = CommandSet() if len(sys.argv) == 1: command.usage() - sys.exit(-1) + sys.exit(1) getattr(command, sys.argv[1], command.usage)() diff --git a/plugins/shell-proxy/shell-proxy.plugin.zsh b/plugins/shell-proxy/shell-proxy.plugin.zsh index 315ade665..9d45b5269 100644 --- a/plugins/shell-proxy/shell-proxy.plugin.zsh +++ b/plugins/shell-proxy/shell-proxy.plugin.zsh @@ -1,16 +1,37 @@ #!/usr/bin/bash -# shellcheck disable=SC1090 - -__PROXY__="${0:A:h}/proxy.py" +# shellcheck disable=SC1090,SC2154 proxy() { - source <(env "DEFAULT_PROXY=$DEFAULT_PROXY" "$__PROXY__" "$1") + # deprecate $DEFAULT_PROXY, use SHELLPROXY_URL instead + if [[ -n "$DEFAULT_PROXY" && -z "$SHELLPROXY_URL" ]]; then + echo >&2 "proxy: DEFAULT_PROXY is deprecated, use SHELLPROXY_URL instead" + SHELLPROXY_URL="$DEFAULT_PROXY" + unset DEFAULT_PROXY + fi + + # deprecate CONFIG_PROXY, use SHELLPROXY_CONFIG instead + if [[ -n "$CONFIG_PROXY" && -z "$SHELLPROXY_CONFIG" ]]; then + echo >&2 "proxy: CONFIG_PROXY is deprecated, use SHELLPROXY_CONFIG instead" + SHELLPROXY_CONFIG="$CONFIG_PROXY" + unset CONFIG_PROXY + fi + + # the proxy.py script is in the same directory as this function + local proxy="${functions_source[$0]:A:h}/proxy.py" + + # capture the output of the proxy script and bail out if it fails + local output + output="$(SHELLPROXY_URL="$SHELLPROXY_URL" SHELLPROXY_CONFIG="$SHELLPROXY_CONFIG" "$proxy" "$1")" || + return $? + + # evaluate the output generated by the proxy script + source <(echo "$output") } _proxy() { - local -r commands=('enable' 'disable' 'status') - compset -P '*,' - compadd -S '' "${commands[@]}" + local -r commands=('enable' 'disable' 'status') + compset -P '*,' + compadd -S '' "${commands[@]}" } -compdef '_proxy' 'proxy' +compdef _proxy proxy diff --git a/plugins/sprunge/README.md b/plugins/sprunge/README.md index 28ed1834a..fb70d42eb 100644 --- a/plugins/sprunge/README.md +++ b/plugins/sprunge/README.md @@ -28,5 +28,5 @@ http://sprunge.us/XxjnKz - Sprunge accepts piped data, stdin redirection, text strings as input or filenames. Only one of these can be used at a time. - Argument precedence goes as follows: stdin > piped input > text strings. -- If a filename is mispelled or doesn't have the necessary path description, it will NOT +- If a filename is misspelled or doesn't have the necessary path description, it will NOT generate an error, but instead treat it as a text string. diff --git a/plugins/ssh-agent/README.md b/plugins/ssh-agent/README.md index 1d6914ec6..fa6a996d4 100644 --- a/plugins/ssh-agent/README.md +++ b/plugins/ssh-agent/README.md @@ -13,28 +13,24 @@ plugins=(... ssh-agent) **IMPORTANT: put these settings _before_ the line that sources oh-my-zsh** +### `agent-forwarding` + To enable **agent forwarding support** add the following to your zshrc file: ```zsh -zstyle :omz:plugins:ssh-agent agent-forwarding on +zstyle :omz:plugins:ssh-agent agent-forwarding yes ``` ----- +### `helper` -To **NOT load any identities on start** use the `lazy` setting. This is particularly -useful when combined with the `AddKeysToAgent` setting (available since OpenSSH 7.2), -since it allows to enter the password only on first use. _NOTE: you can know your -OpenSSH version with `ssh -V`._ +To set an **external helper** to ask for the passwords and possibly store +them in the system keychain use the `helper` style. For example: ```zsh -zstyle :omz:plugins:ssh-agent lazy yes +zstyle :omz:plugins:ssh-agent helper ksshaskpass ``` -You can enable `AddKeysToAgent` by passing `-o AddKeysToAgent=yes` to the `ssh` command, -or by adding `AddKeysToAgent yes` to your `~/.ssh/config` file [1]. -See the [OpenSSH 7.2 Release Notes](http://www.openssh.com/txt/release-7.2). - ----- +### `identities` To **load multiple identities** use the `identities` style (**this has no effect if the `lazy` setting is enabled**). For example: @@ -52,7 +48,22 @@ zstyle :omz:plugins:ssh-agent identities ~/.config/ssh/id_rsa ~/.config/ssh/id_r zstyle :omz:plugins:ssh-agent identities ~/.config/ssh/{id_rsa,id_rsa2,id_github} ``` ----- +### `lazy` + +To **NOT load any identities on start** use the `lazy` setting. This is particularly +useful when combined with the `AddKeysToAgent` setting (available since OpenSSH 7.2), +since it allows to enter the password only on first use. _NOTE: you can know your +OpenSSH version with `ssh -V`._ + +```zsh +zstyle :omz:plugins:ssh-agent lazy yes +``` + +You can enable `AddKeysToAgent` by passing `-o AddKeysToAgent=yes` to the `ssh` command, +or by adding `AddKeysToAgent yes` to your `~/.ssh/config` file [1]. +See the [OpenSSH 7.2 Release Notes](http://www.openssh.com/txt/release-7.2). + +### `lifetime` To **set the maximum lifetime of the identities**, use the `lifetime` style. The lifetime may be specified in seconds or as described in sshd_config(5) @@ -62,7 +73,15 @@ The lifetime may be specified in seconds or as described in sshd_config(5) zstyle :omz:plugins:ssh-agent lifetime 4h ``` ----- +### `quiet` + +To silence the plugin, use the following setting: + +```zsh +zstyle :omz:plugins:ssh-agent quiet yes +``` + +### `ssh-add-args` To **pass arguments to the `ssh-add` command** that adds the identities on startup, use the `ssh-add-args` setting. You can pass multiple arguments separated by spaces: @@ -80,15 +99,6 @@ ssh-add -K -c -a /run/user/1000/ssh-auth <identities> For valid `ssh-add` arguments run `ssh-add --help` or `man ssh-add`. ----- - -To set an **external helper** to ask for the passwords and possibly store -them in the system keychain use the `helper` style. For example: - -```zsh -zstyle :omz:plugins:ssh-agent helper ksshaskpass -``` - ## Credits Based on code from Joseph M. Reagle: https://www.cygwin.com/ml/cygwin/2001-06/msg00537.html diff --git a/plugins/ssh-agent/ssh-agent.plugin.zsh b/plugins/ssh-agent/ssh-agent.plugin.zsh index 47dfef5b0..0d6a35b35 100644 --- a/plugins/ssh-agent/ssh-agent.plugin.zsh +++ b/plugins/ssh-agent/ssh-agent.plugin.zsh @@ -18,7 +18,7 @@ function _start_agent() { zstyle -s :omz:plugins:ssh-agent lifetime lifetime # start ssh-agent and setup environment - echo Starting ssh-agent... + zstyle -t :omz:plugins:ssh-agent quiet || echo >&2 "Starting ssh-agent ..." ssh-agent -s ${lifetime:+-t} ${lifetime} | sed '/^echo/d' >! "$ssh_env_cache" chmod 600 "$ssh_env_cache" . "$ssh_env_cache" > /dev/null @@ -78,7 +78,7 @@ function _add_identities() { if [[ -n "$helper" ]]; then if [[ -z "${commands[$helper]}" ]]; then - echo "ssh-agent: the helper '$helper' has not been found." + echo >&2 "ssh-agent: the helper '$helper' has not been found." else SSH_ASKPASS="$helper" ssh-add "${args[@]}" ${^not_loaded} < /dev/null return $? @@ -88,11 +88,9 @@ function _add_identities() { ssh-add "${args[@]}" ${^not_loaded} } -# test if agent-forwarding is enabled -zstyle -b :omz:plugins:ssh-agent agent-forwarding agent_forwarding - -# Add a nifty symlink for screen/tmux if agent forwarding -if [[ $agent_forwarding = "yes" && -n "$SSH_AUTH_SOCK" && ! -L "$SSH_AUTH_SOCK" ]]; then +# Add a nifty symlink for screen/tmux if agent forwarding is enabled +if zstyle -t :omz:plugins:ssh-agent agent-forwarding \ + && [[ -n "$SSH_AUTH_SOCK" && ! -L "$SSH_AUTH_SOCK" ]]; then ln -sf "$SSH_AUTH_SOCK" /tmp/ssh-agent-$USERNAME-screen else _start_agent diff --git a/plugins/supervisor/_supervisorctl b/plugins/supervisor/_supervisorctl index 9f576c0c0..87cffab86 100644 --- a/plugins/supervisor/_supervisorctl +++ b/plugins/supervisor/_supervisorctl @@ -109,27 +109,27 @@ _supervisorctl_maintail() { _supervisorctl_start() { # TODO: add 'all' _arguments -s \ - '*::supvervisor process:_get_supervisor_procs' + '*::supervisor process:_get_supervisor_procs' } (( $+functions[_supervisorctl_restart] )) || _supervisorctl_restart() { # TODO: add 'all' _arguments -s \ - '*::supvervisor process:_get_supervisor_procs' + '*::supervisor process:_get_supervisor_procs' } (( $+functions[_supervisorctl_status] )) || _supervisorctl_status() { _arguments \ - '*::supvervisor process:_get_supervisor_procs' + '*::supervisor process:_get_supervisor_procs' } (( $+functions[_supervisorctl_stop] )) || _supervisorctl_stop() { # TODO: add 'all' _arguments -s \ - '*::supvervisor process:_get_supervisor_procs' + '*::supervisor process:_get_supervisor_procs' } (( $+functions[_supervisorctl_tail] )) || @@ -137,7 +137,7 @@ _supervisorctl_tail() { # TODO: add 'stderr' _arguments -s \ '-f[Continuous tail of named process stdout Ctrl-C to exit.]' \ - '*::supvervisor process:_get_supervisor_procs' + '*::supervisor process:_get_supervisor_procs' } _supervisorctl "$@" diff --git a/plugins/supervisor/supervisor.plugin.zsh b/plugins/supervisor/supervisor.plugin.zsh index f11f0ed3f..ad5430275 100644 --- a/plugins/supervisor/supervisor.plugin.zsh +++ b/plugins/supervisor/supervisor.plugin.zsh @@ -1,4 +1,4 @@ -# DECLARION: This plugin was created by hhatto. What I did is just making a portal from https://bitbucket.org/hhatto/zshcompfunc4supervisor. +# DECLARATION: This plugin was created by hhatto. What I did is just making a portal from https://bitbucket.org/hhatto/zshcompfunc4supervisor. alias sup='sudo supervisorctl' alias supad='sudo supervisorctl add' diff --git a/plugins/suse/README.md b/plugins/suse/README.md index 06c6d9ef5..f37ec1695 100644 --- a/plugins/suse/README.md +++ b/plugins/suse/README.md @@ -62,7 +62,7 @@ plugins=(... suse) NOTE: `--no-refresh` is passed to zypper for speeding up the calls and avoid errors due to lack of root privileges. If you need to refresh the repositories, call `sudo zypper ref` (`zref` alias) -before runing these aliases. +before running these aliases. Related: [#9798](https://github.com/ohmyzsh/ohmyzsh/pull/9798). diff --git a/plugins/symfony2/README.md b/plugins/symfony2/README.md index 2946d0937..76233472f 100644 --- a/plugins/symfony2/README.md +++ b/plugins/symfony2/README.md @@ -17,7 +17,7 @@ plugins=(... symfony2) | `sfsr` | sf server:run | Run the dev server | | `sfcw` | sf cache:warmup | Use the Bundles warmer | | `sfroute` | sf debug:router | Show the different routes | -| `sfcontainer` | sf debug:contaner | List the different services | +| `sfcontainer` | sf debug:container | List the different services | | `sfgb` | sf generate:bundle | Generate a bundle | | `sfgc` | sf generate:controller | Generate a controller | | `sfgcom` | sf generate:command | Generate a command | diff --git a/plugins/systemadmin/README.md b/plugins/systemadmin/README.md index 052fc6edc..146b58605 100644 --- a/plugins/systemadmin/README.md +++ b/plugins/systemadmin/README.md @@ -17,9 +17,9 @@ plugins=(... systemadmin) | path | `print -l $path` | Displays PATH with each entry on a separate line | | mkdir | `mkdir -pv` | Automatically create parent directories and display verbose output | | psmem | `ps -e -orss=,args= \| sort -b -k1 -nr` | Display the processes using the most memory | -| psmem10 | `ps -e -orss=,args= \| sort -b -k1 -nr \| head -10` | Display the top 10 processes using the most memory | +| psmem10 | `ps -e -orss=,args= \| sort -b -k1 -nr \| head -n 10` | Display the top 10 processes using the most memory | | pscpu | `ps -e -o pcpu,cpu,nice,state,cputime,args \|sort -k1 -nr` | Display the top processes using the most CPU | -| pscpu10 | `ps -e -o pcpu,cpu,nice,state,cputime,args \|sort -k1 -nr \| head -10` | Display the top 10 processes using the most CPU | +| pscpu10 | `ps -e -o pcpu,cpu,nice,state,cputime,args \|sort -k1 -nr \| head -n 10` | Display the top 10 processes using the most CPU | | hist10 | `print -l ${(o)history%% *} \| uniq -c \| sort -nr \| head -n 10` | Display the top 10 most used commands in the history | ## Functions diff --git a/plugins/systemadmin/systemadmin.plugin.zsh b/plugins/systemadmin/systemadmin.plugin.zsh index a77f0069b..9a2129060 100644 --- a/plugins/systemadmin/systemadmin.plugin.zsh +++ b/plugins/systemadmin/systemadmin.plugin.zsh @@ -26,10 +26,10 @@ alias path='print -l $path' alias mkdir='mkdir -pv' # get top process eating memory alias psmem='ps -e -orss=,args= | sort -b -k1 -nr' -alias psmem10='ps -e -orss=,args= | sort -b -k1 -nr | head -10' -# get top process eating cpu if not work try excute : export LC_ALL='C' +alias psmem10='ps -e -orss=,args= | sort -b -k1 -nr | head -n 10' +# get top process eating cpu if not work try execute : export LC_ALL='C' alias pscpu='ps -e -o pcpu,cpu,nice,state,cputime,args|sort -k1,1n -nr' -alias pscpu10='ps -e -o pcpu,cpu,nice,state,cputime,args|sort -k1,1n -nr | head -10' +alias pscpu10='ps -e -o pcpu,cpu,nice,state,cputime,args|sort -k1,1n -nr | head -n 10' # top10 of the history alias hist10='print -l ${(o)history%% *} | uniq -c | sort -nr | head -n 10' @@ -74,7 +74,7 @@ req20() { # top20 of Using tcpdump port 80 access to view http20() { - sudo tcpdump -i eth0 -tnn dst port 80 -c 1000 | awk -F"." '{print $1"."$2"."$3"."$4}' | sort | uniq -c | sort -nr |head -20 + sudo tcpdump -i eth0 -tnn dst port 80 -c 1000 | awk -F"." '{print $1"."$2"."$3"."$4}' | sort | uniq -c | sort -nr |head -n 20 } # top20 of Find time_wait connection @@ -99,14 +99,14 @@ accessip10() { # top20 of Most Visited file or page visitpage20() { - awk '{print $11}' "$(retlog)"|sort|uniq -c|sort -nr|head -20 + awk '{print $11}' "$(retlog)"|sort|uniq -c|sort -nr|head -n 20 } # top100 of Page lists the most time-consuming (more than 60 seconds) as well as the corresponding page number of occurrences consume100() { - awk '($NF > 60 && $7~/\.php/){print $7}' "$(retlog)" |sort -n|uniq -c|sort -nr|head -100 - # if django website or other webiste make by no suffix language - # awk '{print $7}' "$(retlog)" |sort -n|uniq -c|sort -nr|head -100 + awk '($NF > 60 && $7~/\.php/){print $7}' "$(retlog)" |sort -n|uniq -c|sort -nr|head -n 100 + # if django website or other website make by no suffix language + # awk '{print $7}' "$(retlog)" |sort -n|uniq -c|sort -nr|head -n 100 } # Website traffic statistics (G) diff --git a/plugins/terminitor/_terminitor b/plugins/terminitor/_terminitor index 1ce87c3ad..3615350e2 100644 --- a/plugins/terminitor/_terminitor +++ b/plugins/terminitor/_terminitor @@ -11,7 +11,7 @@ local -a _1st_arguments _1st_arguments=( 'create:create a Termfile in directory' 'delete:delete terminitor script' - 'edit:open termitor script' + 'edit:open terminitor script' 'fetch:clone the designated repo and run setup' 'help:Describe available tasks or one specific task' 'init:create initial root terminitor folder' diff --git a/plugins/tmux/README.md b/plugins/tmux/README.md index 2ceaf1ad5..551814a39 100644 --- a/plugins/tmux/README.md +++ b/plugins/tmux/README.md @@ -39,3 +39,4 @@ The plugin also supports the following: | `ZSH_TMUX_FIXTERM_WITH_256COLOR` | `$TERM` to use for 256-color terminals (default: `screen-256color` | | `ZSH_TMUX_CONFIG` | Set the configuration path (default: `$HOME/.tmux.conf`) | | `ZSH_TMUX_UNICODE` | Set `tmux -u` option to support unicode | +| `ZSH_TMUX_DEFAULT_SESSION_NAME` | Set tmux default session name when autostart is enabled | diff --git a/plugins/tmux/tmux.plugin.zsh b/plugins/tmux/tmux.plugin.zsh index e52443a71..0ea3aa02a 100644 --- a/plugins/tmux/tmux.plugin.zsh +++ b/plugins/tmux/tmux.plugin.zsh @@ -76,7 +76,11 @@ function _zsh_tmux_plugin_run() { elif [[ -e "$ZSH_TMUX_CONFIG" ]]; then tmux_cmd+=(-f "$ZSH_TMUX_CONFIG") fi - $tmux_cmd new-session + if [[ -n "$ZSH_TMUX_DEFAULT_SESSION_NAME" ]]; then + $tmux_cmd new-session -s $ZSH_TMUX_DEFAULT_SESSION_NAME + else + $tmux_cmd new-session + fi fi if [[ "$ZSH_TMUX_AUTOQUIT" == "true" ]]; then diff --git a/plugins/ubuntu/README.md b/plugins/ubuntu/README.md index f72182f5c..9efef0732 100644 --- a/plugins/ubuntu/README.md +++ b/plugins/ubuntu/README.md @@ -19,7 +19,7 @@ Commands that use `$APT` will use `apt` if installed or defer to `apt-get` other | acp | `apt-cache policy` | Display the package source priorities | | afs | `apt-file search --regexp` | Perform a regular expression apt-file search | | afu | `sudo apt-file update` | Generates or updates the apt-file package database | -| aga | `sudo $APT autoclean` | Clears out the local reposityory of retrieved package files that can no longer be downloaded | +| aga | `sudo $APT autoclean` | Clears out the local repository of retrieved package files that can no longer be downloaded | | agb | `sudo $APT build-dep <source_pkg>` | Installs/Removes packages to satisfy the dependencies of a specified build pkg | | agc | `sudo $APT clean` | Clears out the local repository of retrieved package files leaving everything from the lock files | | agd | `sudo $APT dselect-upgrade` | Follows dselect choices for package installation | diff --git a/plugins/vault/_vault b/plugins/vault/_vault index c5338dffa..f6bd3517e 100644 --- a/plugins/vault/_vault +++ b/plugins/vault/_vault @@ -53,7 +53,7 @@ mount_tune_args=( typeset -a mount_args mount_args=( $mount_tune_args - '(-path)-path=-[Mount point for the logical backend. This defauls to the type of the mount.]:path:' + '(-path)-path=-[Mount point for the logical backend. This defaults to the type of the mount.]:path:' '(-description)-description=-[Human-friendly description of the purpose for the mount. This shows up in the mounts command.]:description:' ) @@ -189,7 +189,7 @@ _vault_mounts() { } _vault_mount() { - # to find out how many types of backens are there + # to find out how many types of backends are there _arguments : \ ${general_args[@]} \ ${mount_args[@]} \ diff --git a/plugins/volta/README.md b/plugins/volta/README.md new file mode 100644 index 000000000..d5972d56c --- /dev/null +++ b/plugins/volta/README.md @@ -0,0 +1,11 @@ +# Volta + +This plugin provides completion for [Volta](https://volta.sh/). + +To use it add volta to the plugins array in your zshrc file. + +```bash +plugins=(... volta) +``` + +This plugin installs no aliases. diff --git a/plugins/volta/_volta b/plugins/volta/_volta new file mode 100644 index 000000000..295b80362 --- /dev/null +++ b/plugins/volta/_volta @@ -0,0 +1,298 @@ +#compdef volta + +autoload -U is-at-least + +_volta() { + typeset -A opt_args + typeset -a _arguments_options + local ret=1 + + if is-at-least 5.2; then + _arguments_options=(-s -S -C) + else + _arguments_options=(-s -C) + fi + + local context curcontext="$curcontext" state line + _arguments "${_arguments_options[@]}" \ +'--verbose[Enables verbose diagnostics]' \ +'(--verbose)--quiet[Prevents unnecessary output]' \ +'-v[Prints the current version of Volta]' \ +'--version[Prints the current version of Volta]' \ +'-h[Prints help information]' \ +'--help[Prints help information]' \ +":: :_volta_commands" \ +"*::: :->Volta" \ +&& ret=0 + case $state in + (Volta) + words=($line[1] "${words[@]}") + (( CURRENT += 1 )) + curcontext="${curcontext%:*:*}:volta-command-$line[1]:" + case $line[1] in + (fetch) +_arguments "${_arguments_options[@]}" \ +'-h[Prints help information]' \ +'--help[Prints help information]' \ +'-V[Prints version information]' \ +'--version[Prints version information]' \ +'--verbose[Enables verbose diagnostics]' \ +'(--verbose)--quiet[Prevents unnecessary output]' \ +':tool[@version] -- Tools to fetch, like `node`, `yarn@latest` or `your-package@^14.4.3`.:_files' \ +&& ret=0 +;; +(install) +_arguments "${_arguments_options[@]}" \ +'-h[Prints help information]' \ +'--help[Prints help information]' \ +'-V[Prints version information]' \ +'--version[Prints version information]' \ +'--verbose[Enables verbose diagnostics]' \ +'(--verbose)--quiet[Prevents unnecessary output]' \ +':tool[@version] -- Tools to install, like `node`, `yarn@latest` or `your-package@^14.4.3`.:_files' \ +&& ret=0 +;; +(uninstall) +_arguments "${_arguments_options[@]}" \ +'-h[Prints help information]' \ +'--help[Prints help information]' \ +'-V[Prints version information]' \ +'--version[Prints version information]' \ +'--verbose[Enables verbose diagnostics]' \ +'(--verbose)--quiet[Prevents unnecessary output]' \ +':tool -- The tool to uninstall, e.g. `node`, `npm`, `yarn`, or <package>:_files' \ +&& ret=0 +;; +(pin) +_arguments "${_arguments_options[@]}" \ +'-h[Prints help information]' \ +'--help[Prints help information]' \ +'-V[Prints version information]' \ +'--version[Prints version information]' \ +'--verbose[Enables verbose diagnostics]' \ +'(--verbose)--quiet[Prevents unnecessary output]' \ +':tool[@version] -- Tools to pin, like `node@lts` or `yarn@^1.14`.:_files' \ +&& ret=0 +;; +(ls) +_arguments "${_arguments_options[@]}" \ +'--format=[Specify the output format]: :(human plain)' \ +'(-d --default)-c[Show the currently-active tool(s)]' \ +'(-d --default)--current[Show the currently-active tool(s)]' \ +'(-c --current)-d[Show your default tool(s).]' \ +'(-c --current)--default[Show your default tool(s).]' \ +'-h[Prints help information]' \ +'--help[Prints help information]' \ +'-V[Prints version information]' \ +'--version[Prints version information]' \ +'--verbose[Enables verbose diagnostics]' \ +'(--verbose)--quiet[Prevents unnecessary output]' \ +'::tool -- The tool to lookup - `all`, `node`, `yarn`, or the name of a package or binary.:_files' \ +&& ret=0 +;; +(list) +_arguments "${_arguments_options[@]}" \ +'--format=[Specify the output format]: :(human plain)' \ +'(-d --default)-c[Show the currently-active tool(s)]' \ +'(-d --default)--current[Show the currently-active tool(s)]' \ +'(-c --current)-d[Show your default tool(s).]' \ +'(-c --current)--default[Show your default tool(s).]' \ +'-h[Prints help information]' \ +'--help[Prints help information]' \ +'-V[Prints version information]' \ +'--version[Prints version information]' \ +'--verbose[Enables verbose diagnostics]' \ +'(--verbose)--quiet[Prevents unnecessary output]' \ +'::tool -- The tool to lookup - `all`, `node`, `yarn`, or the name of a package or binary.:_files' \ +&& ret=0 +;; +(completions) +_arguments "${_arguments_options[@]}" \ +'-o+[File to write generated completions to]' \ +'--output=[File to write generated completions to]' \ +'-f[Write over an existing file, if any.]' \ +'--force[Write over an existing file, if any.]' \ +'-h[Prints help information]' \ +'--help[Prints help information]' \ +'-V[Prints version information]' \ +'--version[Prints version information]' \ +'--verbose[Enables verbose diagnostics]' \ +'(--verbose)--quiet[Prevents unnecessary output]' \ +':shell -- Shell to generate completions for:(zsh bash fish powershell elvish)' \ +&& ret=0 +;; +(which) +_arguments "${_arguments_options[@]}" \ +'-h[Prints help information]' \ +'--help[Prints help information]' \ +'-V[Prints version information]' \ +'--version[Prints version information]' \ +'--verbose[Enables verbose diagnostics]' \ +'(--verbose)--quiet[Prevents unnecessary output]' \ +':binary -- The binary to find, e.g. `node` or `npm`:_files' \ +&& ret=0 +;; +(use) +_arguments "${_arguments_options[@]}" \ +'-h[Prints help information]' \ +'--help[Prints help information]' \ +'-V[Prints version information]' \ +'--version[Prints version information]' \ +'--verbose[Enables verbose diagnostics]' \ +'(--verbose)--quiet[Prevents unnecessary output]' \ +'::anything:_files' \ +&& ret=0 +;; +(setup) +_arguments "${_arguments_options[@]}" \ +'-h[Prints help information]' \ +'--help[Prints help information]' \ +'-V[Prints version information]' \ +'--version[Prints version information]' \ +'--verbose[Enables verbose diagnostics]' \ +'(--verbose)--quiet[Prevents unnecessary output]' \ +&& ret=0 +;; +(run) +_arguments "${_arguments_options[@]}" \ +'--node=[Set the custom Node version]' \ +'(--bundled-npm)--npm=[Set the custom npm version]' \ +'(--no-yarn)--yarn=[Set the custom Yarn version]' \ +'*--env=[Set an environment variable (can be used multiple times)]' \ +'(--npm)--bundled-npm[Forces npm to be the version bundled with Node]' \ +'(--yarn)--no-yarn[Disables Yarn]' \ +'-h[Prints help information]' \ +'--help[Prints help information]' \ +'-V[Prints version information]' \ +'--version[Prints version information]' \ +'--verbose[Enables verbose diagnostics]' \ +'(--verbose)--quiet[Prevents unnecessary output]' \ +':command -- The command to run:_files' \ +'::args -- Arguments to pass to the command:_files' \ +&& ret=0 +;; +(help) +_arguments "${_arguments_options[@]}" \ +'-h[Prints help information]' \ +'--help[Prints help information]' \ +'-V[Prints version information]' \ +'--version[Prints version information]' \ +'--verbose[Enables verbose diagnostics]' \ +'(--verbose)--quiet[Prevents unnecessary output]' \ +&& ret=0 +;; + esac + ;; +esac +} + +(( $+functions[_volta_commands] )) || +_volta_commands() { + local commands; commands=( + "fetch:Fetches a tool to the local machine" \ +"install:Installs a tool in your toolchain" \ +"uninstall:Uninstalls a tool from your toolchain" \ +"pin:Pins your project's runtime or package manager" \ +"list:Displays the current toolchain" \ +"completions:Generates Volta completions" \ +"which:Locates the actual binary that will be called by Volta" \ +"use:" \ +"setup:Enables Volta for the current user / shell" \ +"run:Run a command with custom Node, npm, and/or Yarn versions" \ +"help:Prints this message or the help of the given subcommand(s)" \ + ) + _describe -t commands 'volta commands' commands "$@" +} +(( $+functions[_volta__completions_commands] )) || +_volta__completions_commands() { + local commands; commands=( + + ) + _describe -t commands 'volta completions commands' commands "$@" +} +(( $+functions[_volta__fetch_commands] )) || +_volta__fetch_commands() { + local commands; commands=( + + ) + _describe -t commands 'volta fetch commands' commands "$@" +} +(( $+functions[_volta__help_commands] )) || +_volta__help_commands() { + local commands; commands=( + + ) + _describe -t commands 'volta help commands' commands "$@" +} +(( $+functions[_volta__install_commands] )) || +_volta__install_commands() { + local commands; commands=( + + ) + _describe -t commands 'volta install commands' commands "$@" +} +(( $+functions[_volta__list_commands] )) || +_volta__list_commands() { + local commands; commands=( + + ) + _describe -t commands 'volta list commands' commands "$@" +} +(( $+functions[_ls_commands] )) || +_ls_commands() { + local commands; commands=( + + ) + _describe -t commands 'ls commands' commands "$@" +} +(( $+functions[_volta__ls_commands] )) || +_volta__ls_commands() { + local commands; commands=( + + ) + _describe -t commands 'volta ls commands' commands "$@" +} +(( $+functions[_volta__pin_commands] )) || +_volta__pin_commands() { + local commands; commands=( + + ) + _describe -t commands 'volta pin commands' commands "$@" +} +(( $+functions[_volta__run_commands] )) || +_volta__run_commands() { + local commands; commands=( + + ) + _describe -t commands 'volta run commands' commands "$@" +} +(( $+functions[_volta__setup_commands] )) || +_volta__setup_commands() { + local commands; commands=( + + ) + _describe -t commands 'volta setup commands' commands "$@" +} +(( $+functions[_volta__uninstall_commands] )) || +_volta__uninstall_commands() { + local commands; commands=( + + ) + _describe -t commands 'volta uninstall commands' commands "$@" +} +(( $+functions[_volta__use_commands] )) || +_volta__use_commands() { + local commands; commands=( + + ) + _describe -t commands 'volta use commands' commands "$@" +} +(( $+functions[_volta__which_commands] )) || +_volta__which_commands() { + local commands; commands=( + + ) + _describe -t commands 'volta which commands' commands "$@" +} + +_volta "$@"
\ No newline at end of file diff --git a/plugins/xcode/README.md b/plugins/xcode/README.md index 664a063a3..27d6a228b 100644 --- a/plugins/xcode/README.md +++ b/plugins/xcode/README.md @@ -26,7 +26,7 @@ plugins=(... xcode) ### `xc` -Opens the current directory in Xcode as an Xcode project or a Swift package. This will open one of the `.xcworkspace`, `.xcodeproj` and `Package.swift` files that it can find in the current working directory. You can also specify a directory to look in for the Xcode files. +Opens the current directory in Xcode as an Xcode project or a Swift package. This will open one of the `.xcworkspace`, `.xcodeproj`, `.swiftpm` and `Package.swift` files that it can find in the current working directory. You can also specify a directory to look in for the Xcode files. Returns 1 if it didn't find any relevant files. ### `xx` diff --git a/plugins/xcode/xcode.plugin.zsh b/plugins/xcode/xcode.plugin.zsh index 41b9e37e4..3bd12cdec 100644 --- a/plugins/xcode/xcode.plugin.zsh +++ b/plugins/xcode/xcode.plugin.zsh @@ -7,7 +7,7 @@ alias xcsel='sudo xcode-select --switch' # source: https://gist.github.com/subdigital/5420709 function xc { local xcode_files - xcode_files=(${1:-.}/{*.{xcworkspace,xcodeproj},Package.swift}(N)) + xcode_files=(${1:-.}/{*.{xcworkspace,xcodeproj,swiftpm},Package.swift}(N)) if [[ ${#xcode_files} -eq 0 ]]; then echo "No Xcode files found in ${1:-the current directory}." >&2 diff --git a/plugins/yarn/_yarn b/plugins/yarn/_yarn index 70ed55929..9173eca20 100644 --- a/plugins/yarn/_yarn +++ b/plugins/yarn/_yarn @@ -157,7 +157,7 @@ _yarn() { '(--emoji)--no-emoji[disable emoji in output]' \ '(--disable-pnp)'{--enable-pnp,--pnp}"[enable the Plug'n'Play installation]" \ '--flat[only allow one version of a package]' \ - '--focus[Focus on a single workspace by installing remote copies of its sibiling workspaces]' \ + '--focus[Focus on a single workspace by installing remote copies of its sibling workspaces]' \ '--force[install and build packages even if they were built before, overwrite lockfile]' \ "--frozen-lockfile[don't generate a lockfile and fail if an update is needed]" \ '--global-folder=[modules folder]:folder:_files -/' \ diff --git a/plugins/yum/yum.plugin.zsh b/plugins/yum/yum.plugin.zsh index 69abfc4ce..d36571133 100644 --- a/plugins/yum/yum.plugin.zsh +++ b/plugins/yum/yum.plugin.zsh @@ -7,7 +7,7 @@ alias ygl="yum grouplist" # list package groups alias yli="yum list installed" # print all installed packages alias ymc="yum makecache" # rebuilds the yum package list -alias yu="sudo yum update" # upgrate packages +alias yu="sudo yum update" # upgrade packages alias yi="sudo yum install" # install package alias ygi="sudo yum groupinstall" # install package group alias yr="sudo yum remove" # remove package |