From dd30cf104c9ca42d89d26a134382ca421869ce7e Mon Sep 17 00:00:00 2001 From: Aleksandr Kozlov Date: Mon, 22 Jan 2018 12:54:02 +0300 Subject: Added kgpall alias --- plugins/kubectl/kubectl.plugin.zsh | 1 + 1 file changed, 1 insertion(+) (limited to 'plugins') diff --git a/plugins/kubectl/kubectl.plugin.zsh b/plugins/kubectl/kubectl.plugin.zsh index 88177b5a0..3c6e8045c 100644 --- a/plugins/kubectl/kubectl.plugin.zsh +++ b/plugins/kubectl/kubectl.plugin.zsh @@ -24,6 +24,7 @@ alias klp='k logs pods' alias kep='k edit pods' alias kdp='k describe pods' alias kdelp='k delete pods' +alias kgpall='k get pods --all-namespaces -o wide' # Service management. alias kgs='k get svc' -- cgit v1.2.3-70-g09d2 From 02ce2c4a2f563c4e092410fe3ddc8b29b6de7fdc Mon Sep 17 00:00:00 2001 From: Roc Date: Sat, 12 Jun 2021 09:50:29 +0800 Subject: add python alias (#7736) --- plugins/python/python.plugin.zsh | 3 +++ 1 file changed, 3 insertions(+) (limited to 'plugins') diff --git a/plugins/python/python.plugin.zsh b/plugins/python/python.plugin.zsh index c3c1474c1..276eb6f91 100644 --- a/plugins/python/python.plugin.zsh +++ b/plugins/python/python.plugin.zsh @@ -1,3 +1,6 @@ +# python command +alias py='python' + # Find python file alias pyfind='find . -name "*.py"' -- cgit v1.2.3-70-g09d2 From a206271460ce49e842b1b410c0424b8c9a0a3d14 Mon Sep 17 00:00:00 2001 From: Nuno Goncalves Date: Sat, 12 Jun 2021 04:03:25 +0200 Subject: ssh-agent: improvements (#6309) * ssh-agent: lock this script with a mkdir style mutex This script is a kind of singleton pattern and is not reentrant. If several shells are oppened in a fast sequence, then several independent ssh-agents would be created, which is not acceptable. A mutex is required. Signed-off-by: Nuno Goncalves * ssh-agent: only start agent if .ssh dir exists To use the same profile system-wide, it might happen that the .ssh directory does not exist (typically $HOME/.ssh/). This would trigger a error. Creating the directory would be a option, but it usually will not make sense to do so because it means the user doesn't have ssh keys or config. Signed-off-by: Nuno Goncalves * ssh-agent: adds lazy option to disable key loading on start Option is documented on updated README.md Signed-off-by: Nuno Goncalves * ssh-agent: simplify agent-forwarding checking Signed-off-by: Nuno Goncalves Co-authored-by: Robby Russell --- plugins/ssh-agent/README.md | 12 ++++++++++-- plugins/ssh-agent/ssh-agent.plugin.zsh | 29 +++++++++++++++++++++-------- 2 files changed, 31 insertions(+), 10 deletions(-) (limited to 'plugins') diff --git a/plugins/ssh-agent/README.md b/plugins/ssh-agent/README.md index 8765a9c7e..aa96f9cc9 100644 --- a/plugins/ssh-agent/README.md +++ b/plugins/ssh-agent/README.md @@ -19,9 +19,17 @@ To enable **agent forwarding support** add the following to your zshrc file: zstyle :omz:plugins:ssh-agent agent-forwarding on ``` ----- +To **NOT load any identities on start** use the `lazy` style. +This is particularly usefull when combined with the AddKeysToAgent +(available from OpenSSH 7.2), since it allows to enter the password only +on first use. + +```zsh +zstyle :omz:plugins:ssh-agent lazy yes +``` -To **load multiple identities** use the `identities` style, For example: +To **load multiple identities** use the `identities` style. This have no +effect if `lazy` is enabled. ```zsh zstyle :omz:plugins:ssh-agent identities id_rsa id_rsa2 id_github diff --git a/plugins/ssh-agent/ssh-agent.plugin.zsh b/plugins/ssh-agent/ssh-agent.plugin.zsh index d45406f63..494cf1393 100644 --- a/plugins/ssh-agent/ssh-agent.plugin.zsh +++ b/plugins/ssh-agent/ssh-agent.plugin.zsh @@ -1,4 +1,16 @@ -typeset _agent_forwarding _ssh_env_cache +lockdir=/tmp/oh-my-zsh-ssh-agent.lock + +while true; do + if mkdir "$lockdir" 2>/dev/null + then # directory did not exist, but was created successfully + trap 'rm -rf "$lockdir"' 0 # remove directory when script finishes + break # continue with script + else + sleep 0.1 # sleep for 0.2 and try again + fi +done + +typeset _ssh_env_cache function _start_agent() { local lifetime @@ -56,10 +68,7 @@ function _add_identities() { # Get the filename to store/lookup the environment from _ssh_env_cache="$HOME/.ssh/environment-$SHORT_HOST" -# test if agent-forwarding is enabled -zstyle -b :omz:plugins:ssh-agent agent-forwarding _agent_forwarding - -if [[ $_agent_forwarding == "yes" && -n "$SSH_AUTH_SOCK" ]]; then +if zstyle -t :omz:plugins:ssh-agent agent-forwarding && [[ -n "$SSH_AUTH_SOCK" ]]; then # Add a nifty symlink for screen/tmux if agent forwarding [[ -L $SSH_AUTH_SOCK ]] || ln -sf "$SSH_AUTH_SOCK" /tmp/ssh-agent-$USERNAME-screen elif [[ -f "$_ssh_env_cache" ]]; then @@ -73,12 +82,16 @@ elif [[ -f "$_ssh_env_cache" ]]; then ps $FILTER | grep ssh-agent | grep -q $SSH_AGENT_PID || { _start_agent } -else +elif [[ -d $HOME/.ssh ]]; then _start_agent fi -_add_identities +if ! zstyle -t :omz:plugins:ssh-agent lazy; then + _add_identities +fi # tidy up after ourselves -unset _agent_forwarding _ssh_env_cache +unset _ssh_env_cache unfunction _start_agent _add_identities + +rm -rf "$lockdir" -- cgit v1.2.3-70-g09d2 From e47a8e2321be9e7af49872588619c031a757d6ea Mon Sep 17 00:00:00 2001 From: hqingyi Date: Sat, 12 Jun 2021 10:45:05 +0800 Subject: feat(plugins): add aliases cheatsheet plugin (#4662) * add: explore alias quickly with aliases plugin. * change: add compatibility with python2 & python3. - add compatibility. - add termcolor.py. - remove aliass(search), just use acs. - detect python. --- plugins/aliases/aliases.plugin.zsh | 10 +++ plugins/aliases/cheatsheet.py | 55 ++++++++++++ plugins/aliases/termcolor.py | 168 +++++++++++++++++++++++++++++++++++++ 3 files changed, 233 insertions(+) create mode 100644 plugins/aliases/aliases.plugin.zsh create mode 100644 plugins/aliases/cheatsheet.py create mode 100644 plugins/aliases/termcolor.py (limited to 'plugins') diff --git a/plugins/aliases/aliases.plugin.zsh b/plugins/aliases/aliases.plugin.zsh new file mode 100644 index 000000000..28d8fba24 --- /dev/null +++ b/plugins/aliases/aliases.plugin.zsh @@ -0,0 +1,10 @@ +# with lots of 3rd-party amazing aliases installed, just need something to explore it quickly. +# +# - acs: alias cheatsheet +# group alias by command, pass addition argv to grep. +ALIASES_PLUGIN_ROOT=$(cd `dirname $0` && pwd) +function acs(){ + which python >>/dev/null + [[ $? -eq 1 ]] && echo "[error]no python executable detected!" && return + alias | python $ALIASES_PLUGIN_ROOT/cheatsheet.py $@ +} diff --git a/plugins/aliases/cheatsheet.py b/plugins/aliases/cheatsheet.py new file mode 100644 index 000000000..d6d507b92 --- /dev/null +++ b/plugins/aliases/cheatsheet.py @@ -0,0 +1,55 @@ +#!/usr/bin/env python +import sys +import itertools +import termcolor + +def parse(line): + left = line[0:line.find('=')].strip() + right = line[line.find('=')+1:].strip('\'"\n ') + try: + cmd = next(part for part in right.split() if len([char for char in '=<>' if char in part])==0) + except StopIteration: + cmd = right + return (left, right, cmd) + +def cheatsheet(lines): + exps = [ parse(line) for line in lines ] + cheatsheet = {'_default': []} + for key, group in itertools.groupby(exps, lambda exp:exp[2]): + group_list = [ item for item in group ] + if len(group_list)==1: + target_aliases = cheatsheet['_default'] + else: + if key not in cheatsheet: + cheatsheet[key] = [] + target_aliases = cheatsheet[key] + target_aliases.extend(group_list) + return cheatsheet + +def pretty_print_group(key, aliases, hightlight=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])) + else: + print (group_formatter(key)) + print ('\n'.join([alias_formatter(alias) for alias in aliases])) + print ('') + +def pretty_print(cheatsheet, wfilter): + sorted_key = sorted(cheatsheet.keys()) + for key in sorted_key: + aliases = cheatsheet.get(key) + if not wfilter: + pretty_print_group(key, aliases, wfilter) + else: + pretty_print_group(key, [ alias for alias in aliases if alias[0].find(wfilter)>-1 or alias[1].find(wfilter)>-1], wfilter) + +if __name__ == '__main__': + lines = sys.stdin.readlines() + pretty_print(cheatsheet(lines), sys.argv[1] if len(sys.argv)>1 else None) diff --git a/plugins/aliases/termcolor.py b/plugins/aliases/termcolor.py new file mode 100644 index 000000000..f11b824b2 --- /dev/null +++ b/plugins/aliases/termcolor.py @@ -0,0 +1,168 @@ +# coding: utf-8 +# Copyright (c) 2008-2011 Volvox Development Team +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +# THE SOFTWARE. +# +# Author: Konstantin Lepa + +"""ANSII Color formatting for output in terminal.""" + +from __future__ import print_function +import os + + +__ALL__ = [ 'colored', 'cprint' ] + +VERSION = (1, 1, 0) + +ATTRIBUTES = dict( + list(zip([ + 'bold', + 'dark', + '', + 'underline', + 'blink', + '', + 'reverse', + 'concealed' + ], + list(range(1, 9)) + )) + ) +del ATTRIBUTES[''] + + +HIGHLIGHTS = dict( + list(zip([ + 'on_grey', + 'on_red', + 'on_green', + 'on_yellow', + 'on_blue', + 'on_magenta', + 'on_cyan', + 'on_white' + ], + list(range(40, 48)) + )) + ) + + +COLORS = dict( + list(zip([ + 'grey', + 'red', + 'green', + 'yellow', + 'blue', + 'magenta', + 'cyan', + 'white', + ], + list(range(30, 38)) + )) + ) + + +RESET = '\033[0m' + + +def colored(text, color=None, on_color=None, attrs=None): + """Colorize text. + + Available text colors: + red, green, yellow, blue, magenta, cyan, white. + + Available text highlights: + on_red, on_green, on_yellow, on_blue, on_magenta, on_cyan, on_white. + + Available attributes: + bold, dark, underline, blink, reverse, concealed. + + Example: + colored('Hello, World!', 'red', 'on_grey', ['blue', 'blink']) + colored('Hello, World!', 'green') + """ + if os.getenv('ANSI_COLORS_DISABLED') is None: + fmt_str = '\033[%dm%s' + if color is not None: + text = fmt_str % (COLORS[color], text) + + if on_color is not None: + text = fmt_str % (HIGHLIGHTS[on_color], text) + + if attrs is not None: + for attr in attrs: + text = fmt_str % (ATTRIBUTES[attr], text) + + text += RESET + return text + + +def cprint(text, color=None, on_color=None, attrs=None, **kwargs): + """Print colorize text. + + It accepts arguments of print function. + """ + + print((colored(text, color, on_color, attrs)), **kwargs) + + +if __name__ == '__main__': + print('Current terminal type: %s' % os.getenv('TERM')) + print('Test basic colors:') + cprint('Grey color', 'grey') + cprint('Red color', 'red') + cprint('Green color', 'green') + cprint('Yellow color', 'yellow') + cprint('Blue color', 'blue') + cprint('Magenta color', 'magenta') + cprint('Cyan color', 'cyan') + cprint('White color', 'white') + print(('-' * 78)) + + print('Test highlights:') + cprint('On grey color', on_color='on_grey') + cprint('On red color', on_color='on_red') + cprint('On green color', on_color='on_green') + cprint('On yellow color', on_color='on_yellow') + cprint('On blue color', on_color='on_blue') + cprint('On magenta color', on_color='on_magenta') + cprint('On cyan color', on_color='on_cyan') + cprint('On white color', color='grey', on_color='on_white') + print('-' * 78) + + print('Test attributes:') + cprint('Bold grey color', 'grey', attrs=['bold']) + cprint('Dark red color', 'red', attrs=['dark']) + cprint('Underline green color', 'green', attrs=['underline']) + cprint('Blink yellow color', 'yellow', attrs=['blink']) + cprint('Reversed blue color', 'blue', attrs=['reverse']) + cprint('Concealed Magenta color', 'magenta', attrs=['concealed']) + cprint('Bold underline reverse cyan color', 'cyan', + attrs=['bold', 'underline', 'reverse']) + cprint('Dark blink concealed white color', 'white', + attrs=['dark', 'blink', 'concealed']) + print(('-' * 78)) + + print('Test mixing:') + cprint('Underline red on grey color', 'red', 'on_grey', + ['underline']) + cprint('Reversed green on red color', 'green', 'on_red', ['reverse']) + -- cgit v1.2.3-70-g09d2 From 5cdba87025b9dca3c6f2378a58595c613464fc63 Mon Sep 17 00:00:00 2001 From: Robby Russell Date: Fri, 11 Jun 2021 19:43:24 -0700 Subject: Aliases: Adding a README file for the plugin. #4662 --- plugins/aliases/README.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 plugins/aliases/README.md (limited to 'plugins') diff --git a/plugins/aliases/README.md b/plugins/aliases/README.md new file mode 100644 index 000000000..481c1bd4e --- /dev/null +++ b/plugins/aliases/README.md @@ -0,0 +1,21 @@ +## Aliases Cheatsheet + +**Maintainer:** [@hqingyi](https://github.com/hqingyi) + +With lots of 3rd-party amazing aliases installed, this plugin helps list the shortcuts +that are currently available based on the plugins you have enabled. + +Enable this plugin by adding it to your `plugins` definition in `~/.zshrc`. + + ``` + plugins=(aliases) + ``` + +Requirements: Python needs to be installed. + +### Usage + +``` + acs: group all alias + acs $keywordquickly filter alias & highlight +``` -- cgit v1.2.3-70-g09d2 From 00ccb449907d322c6bfa53f17e96cbf48651fee3 Mon Sep 17 00:00:00 2001 From: Hugo Stijns Date: Sat, 12 Jun 2021 05:04:58 +0200 Subject: fix(vagrant): Allow dot in Vagrant box name (#4803) --- plugins/vagrant/_vagrant | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins') diff --git a/plugins/vagrant/_vagrant b/plugins/vagrant/_vagrant index 3e16dbebf..e88835506 100644 --- a/plugins/vagrant/_vagrant +++ b/plugins/vagrant/_vagrant @@ -69,7 +69,7 @@ __box_list () __vm_list () { - _wanted application expl 'command' compadd $(command grep "${VAGRANT_CWD:-.}/Vagrantfile" -oe '^[^#]*\.vm\.define *[:"]\([a-zA-Z0-9_-]\+\)' 2>/dev/null | awk '{print substr($2, 2)}') + _wanted application expl 'command' compadd $(command grep "${VAGRANT_CWD:-.}/Vagrantfile" -oe '^[^#]*\.vm\.define *[:"]\([a-zA-Z0-9\._-]\+\)' 2>/dev/null | awk '{print substr($2, 2)}') _wanted application expl 'command' compadd $(command ls "${VAGRANT_CWD:-.}/.vagrant/machines/" 2>/dev/null) } -- cgit v1.2.3-70-g09d2 From 580c28dedd60e9262cd7240a9417e0302a6476da Mon Sep 17 00:00:00 2001 From: Eric Liu Date: Sat, 12 Jun 2021 11:07:21 +0800 Subject: feat(rails): add 'rails server --bind' alias (#4977) --- plugins/rails/rails.plugin.zsh | 1 + 1 file changed, 1 insertion(+) (limited to 'plugins') diff --git a/plugins/rails/rails.plugin.zsh b/plugins/rails/rails.plugin.zsh index 5b0be4f85..aa7576916 100644 --- a/plugins/rails/rails.plugin.zsh +++ b/plugins/rails/rails.plugin.zsh @@ -52,6 +52,7 @@ alias ru='rails runner' alias rs='rails server' alias rsd='rails server --debugger' alias rsp='rails server --port' +alias rsb='rails server --bind' # Rake aliases alias rdm='rake db:migrate' -- cgit v1.2.3-70-g09d2 From 42f56c5601f814ca34239324eefc9cb96cb4cdbc Mon Sep 17 00:00:00 2001 From: Dzianis Dashkevich Date: Sat, 12 Jun 2021 06:10:00 +0300 Subject: feat(rails): Add `rdmd` and `rdmu` aliases to Rails plugin (#6126) * `rdmd` is aliased to `rake db:migrate:down` * `rdmu` is aliased to `rake db:migrate:up` * These tasks allow you to run a specific migration up or down by specifying the appropriate `VERSION` env variable, which contains the numerical prefix of the migration's filename --- plugins/rails/rails.plugin.zsh | 2 ++ 1 file changed, 2 insertions(+) (limited to 'plugins') diff --git a/plugins/rails/rails.plugin.zsh b/plugins/rails/rails.plugin.zsh index aa7576916..34aebbc2c 100644 --- a/plugins/rails/rails.plugin.zsh +++ b/plugins/rails/rails.plugin.zsh @@ -56,7 +56,9 @@ alias rsb='rails server --bind' # Rake aliases alias rdm='rake db:migrate' +alias rdmd='rake db:migrate:down' alias rdms='rake db:migrate:status' +alias rdmu='rake db:migrate:up' alias rdr='rake db:rollback' alias rdc='rake db:create' alias rds='rake db:seed' -- cgit v1.2.3-70-g09d2 From 81db2af60131025f1bb1e25b27fc530066cdba3a Mon Sep 17 00:00:00 2001 From: Dzianis Dashkevich Date: Sat, 12 Jun 2021 06:12:13 +0300 Subject: feat(rails): Add `rdmr` (`rake db:migrate:redo`) alias to Rails plugin (#6124) Co-authored-by: Robby Russell --- plugins/rails/rails.plugin.zsh | 1 + 1 file changed, 1 insertion(+) (limited to 'plugins') diff --git a/plugins/rails/rails.plugin.zsh b/plugins/rails/rails.plugin.zsh index 34aebbc2c..29b413434 100644 --- a/plugins/rails/rails.plugin.zsh +++ b/plugins/rails/rails.plugin.zsh @@ -56,6 +56,7 @@ alias rsb='rails server --bind' # Rake aliases alias rdm='rake db:migrate' +alias rdmr='rake db:migrate:redo' alias rdmd='rake db:migrate:down' alias rdms='rake db:migrate:status' alias rdmu='rake db:migrate:up' -- cgit v1.2.3-70-g09d2 From 0869a57cb585ad6279abf108c742e3c6650ed9d5 Mon Sep 17 00:00:00 2001 From: Wenli Wan Date: Sat, 12 Jun 2021 11:49:04 +0800 Subject: fix(kubectl): remove duplicated alias for kubectl plugin `kgsa` (#9927) --- plugins/kubectl/README.md | 1 - plugins/kubectl/kubectl.plugin.zsh | 1 - 2 files changed, 2 deletions(-) (limited to 'plugins') diff --git a/plugins/kubectl/README.md b/plugins/kubectl/README.md index 8937b2b80..f6651c8cd 100644 --- a/plugins/kubectl/README.md +++ b/plugins/kubectl/README.md @@ -107,7 +107,6 @@ plugins=(... kubectl) | ksss | `kubectl scale statefulset` | Scale a statefulset | | krsss | `kubectl rollout status statefulset`| Check the rollout status of a deployment | | | | **Service Accounts management** | -| kgsa | `kubectl get sa` | List all service accounts | | kdsa | `kubectl describe sa` | Describe a service account in details | | kdelsa | `kubectl delete sa` | Delete the service account | | | | **DaemonSet management** | diff --git a/plugins/kubectl/kubectl.plugin.zsh b/plugins/kubectl/kubectl.plugin.zsh index 56135274f..58a401120 100644 --- a/plugins/kubectl/kubectl.plugin.zsh +++ b/plugins/kubectl/kubectl.plugin.zsh @@ -151,7 +151,6 @@ alias kdpvc='kubectl describe pvc' alias kdelpvc='kubectl delete pvc' # Service account management. -alias kgsa="kubectl get sa" alias kdsa="kubectl describe sa" alias kdelsa="kubectl delete sa" -- cgit v1.2.3-70-g09d2 From 94ea7b4516561c8a7587c7b74351bd6dd4f74583 Mon Sep 17 00:00:00 2001 From: Dom Sekotill Date: Sat, 12 Jun 2021 04:52:22 +0100 Subject: fix(virtualenvwrapper): several changes for checking git directory, including fixes (#5663) * Test only for the presence of a .git directory in virtualenvwrapper Instead of using both $(git rev-parse --show-toplevel) and a check for a .git directory, use just the latter. As well as being redundant the former does not work quite so well when using multiple worktrees; each worktree will be treated as a separate project. * Unset ENV_NAME & deactivate if no virtualenv found This addresses #4603 without breaking current behaviour (where current behaviour is correct). When changing directories, if there is no environment matching ENV_NAME, ENV_NAME is emptied and deactivate called if there is a current environment active (based on CD_VIRTUAL_ENV). * Use path comparison not string comparison for paths This will solve part of issue #4255 where WORKON_HOME is defined with a trailing slash or not normalised in some way, as well as instances where symlinks are used, and any other instances where constructed paths don't exactly match even though they go to the same file. Co-authored-by: Robby Russell --- .../virtualenvwrapper/virtualenvwrapper.plugin.zsh | 23 +++++++++++----------- 1 file changed, 11 insertions(+), 12 deletions(-) (limited to 'plugins') diff --git a/plugins/virtualenvwrapper/virtualenvwrapper.plugin.zsh b/plugins/virtualenvwrapper/virtualenvwrapper.plugin.zsh index 88217a7f5..c30216f51 100644 --- a/plugins/virtualenvwrapper/virtualenvwrapper.plugin.zsh +++ b/plugins/virtualenvwrapper/virtualenvwrapper.plugin.zsh @@ -35,27 +35,19 @@ if [[ ! $DISABLE_VENV_CD -eq 1 ]]; then function workon_cwd { if [[ -z "$WORKON_CWD" ]]; then local WORKON_CWD=1 - # Check if this is a Git repo - local GIT_REPO_ROOT="" - local GIT_TOPLEVEL="$(git rev-parse --show-toplevel 2> /dev/null)" - if [[ $? == 0 ]]; then - GIT_REPO_ROOT="$GIT_TOPLEVEL" - fi # Get absolute path, resolving symlinks local PROJECT_ROOT="${PWD:A}" while [[ "$PROJECT_ROOT" != "/" && ! -e "$PROJECT_ROOT/.venv" \ - && ! -d "$PROJECT_ROOT/.git" && "$PROJECT_ROOT" != "$GIT_REPO_ROOT" ]]; do + && ! -d "$PROJECT_ROOT/.git" ]]; do PROJECT_ROOT="${PROJECT_ROOT:h}" done - if [[ "$PROJECT_ROOT" == "/" ]]; then - PROJECT_ROOT="." - fi + # Check for virtualenv name override if [[ -f "$PROJECT_ROOT/.venv" ]]; then ENV_NAME="$(cat "$PROJECT_ROOT/.venv")" elif [[ -f "$PROJECT_ROOT/.venv/bin/activate" ]];then ENV_NAME="$PROJECT_ROOT/.venv" - elif [[ "$PROJECT_ROOT" != "." ]]; then + elif [[ "$PROJECT_ROOT" != "/" ]]; then ENV_NAME="${PROJECT_ROOT:t}" else ENV_NAME="" @@ -68,14 +60,21 @@ if [[ ! $DISABLE_VENV_CD -eq 1 ]]; then fi if [[ "$ENV_NAME" != "" ]]; then # Activate the environment only if it is not already active - if [[ "$VIRTUAL_ENV" != "$WORKON_HOME/$ENV_NAME" ]]; then + if [[ ! "$VIRTUAL_ENV" -ef "$WORKON_HOME/$ENV_NAME" ]]; then if [[ -e "$WORKON_HOME/$ENV_NAME/bin/activate" ]]; then workon "$ENV_NAME" && export CD_VIRTUAL_ENV="$ENV_NAME" elif [[ -e "$ENV_NAME/bin/activate" ]]; then source $ENV_NAME/bin/activate && export CD_VIRTUAL_ENV="$ENV_NAME" + else + ENV_NAME="" fi fi fi + if [[ "$ENV_NAME" == "" && -n $CD_VIRTUAL_ENV && -n $VIRTUAL_ENV ]]; then + # We've just left the repo, deactivate the environment + # Note: this only happens if the virtualenv was activated automatically + deactivate && unset CD_VIRTUAL_ENV + fi fi } -- cgit v1.2.3-70-g09d2 From a2e6a85bf30332005262c312bdd110ae9548a259 Mon Sep 17 00:00:00 2001 From: Francesco Giannelli Date: Sat, 12 Jun 2021 05:57:04 +0200 Subject: fix(plugins): cache thefuck aliases (#5522) --- plugins/thefuck/thefuck.plugin.zsh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'plugins') diff --git a/plugins/thefuck/thefuck.plugin.zsh b/plugins/thefuck/thefuck.plugin.zsh index b8586c70d..2ab4eb6e2 100644 --- a/plugins/thefuck/thefuck.plugin.zsh +++ b/plugins/thefuck/thefuck.plugin.zsh @@ -5,7 +5,8 @@ if [[ -z $commands[thefuck] ]]; then fi # Register alias -eval "$(thefuck --alias)" +[[ ! -a $ZSH_CACHE_DIR/thefuck ]] && thefuck --alias > $ZSH_CACHE_DIR/thefuck +source $ZSH_CACHE_DIR/thefuck fuck-command-line() { local FUCK="$(THEFUCK_REQUIRE_CONFIRMATION=0 thefuck $(fc -ln -1 | tail -n 1) 2> /dev/null)" -- cgit v1.2.3-70-g09d2 From a3d90624df4ca9c4f438e8905f5c56399747db73 Mon Sep 17 00:00:00 2001 From: Gabo Esquivel Date: Fri, 11 Jun 2021 22:06:06 -0600 Subject: feature(plugins): add bower commands aliases (#3387) --- plugins/bower/bower.plugin.zsh | 2 ++ 1 file changed, 2 insertions(+) (limited to 'plugins') diff --git a/plugins/bower/bower.plugin.zsh b/plugins/bower/bower.plugin.zsh index 6019b9d37..3a40b3af0 100644 --- a/plugins/bower/bower.plugin.zsh +++ b/plugins/bower/bower.plugin.zsh @@ -1,4 +1,6 @@ alias bi="bower install" +alias bisd="bower install --save-dev" +alias bis="bower install --save" alias bl="bower list" alias bs="bower search" -- cgit v1.2.3-70-g09d2 From 9bdbe08aa2c2ba4106f17082a9ee303b51167ba1 Mon Sep 17 00:00:00 2001 From: Daniel Wu Date: Sat, 12 Jun 2021 21:06:09 +0800 Subject: feat(plugins): add gpr alias for /git pull -rebase/ which is easier to remember (#9964) --- plugins/git/README.md | 1 + plugins/git/git.plugin.zsh | 1 + 2 files changed, 2 insertions(+) (limited to 'plugins') diff --git a/plugins/git/README.md b/plugins/git/README.md index 4f051db8d..93c9cc915 100644 --- a/plugins/git/README.md +++ b/plugins/git/README.md @@ -116,6 +116,7 @@ plugins=(... git) | gpf | git push --force-with-lease | | gpf! | git push --force | | gpoat | git push origin --all && git push origin --tags | +| gpr | git pull --rebase | | gpu | git push upstream | | gpv | git push -v | | gr | git remote | diff --git a/plugins/git/git.plugin.zsh b/plugins/git/git.plugin.zsh index 35ebfbfa3..a364b6162 100644 --- a/plugins/git/git.plugin.zsh +++ b/plugins/git/git.plugin.zsh @@ -215,6 +215,7 @@ alias gpd='git push --dry-run' alias gpf='git push --force-with-lease' alias gpf!='git push --force' alias gpoat='git push origin --all && git push origin --tags' +alias gpr='git pull --rebase' alias gpu='git push upstream' alias gpv='git push -v' -- cgit v1.2.3-70-g09d2 From 6779e10759c7c45f18a3ade1efac4d87b5ded7f1 Mon Sep 17 00:00:00 2001 From: Frani Date: Sat, 12 Jun 2021 10:08:27 -0300 Subject: feat(plugins): Add new isodate plugin for friendly date formatting commands (#9963) * add isodate plugin --- plugins/isodate/README.md | 22 ++++++++++++++++++++++ plugins/isodate/isodate.plugin.zsh | 7 +++++++ 2 files changed, 29 insertions(+) create mode 100644 plugins/isodate/README.md create mode 100644 plugins/isodate/isodate.plugin.zsh (limited to 'plugins') diff --git a/plugins/isodate/README.md b/plugins/isodate/README.md new file mode 100644 index 000000000..1ec75b2d4 --- /dev/null +++ b/plugins/isodate/README.md @@ -0,0 +1,22 @@ +# Isodate plugin + +**Maintainer:** [@Frani](https://github.com/frani) + +This plugin adds completion for the [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601), +as well as some aliases for common Date commands. + +To use it, add `isodate` to the plugins array in your zshrc file: + +```zsh +plugins=(... isodate) +``` + +## Aliases + +| Alias | Command | Description | +|---------------|--------------------------------------|----------------------------------------------------------------------------| +| isodate | `date +%Y-%m-%dT%H:%M:%S%z` | Display the current date with UTC offset and ISO 8601-2 extended format | +| isodate_utc | `date -u +%Y-%m-%dT%H:%M:%SZ` | Display the current date in UTC and ISO 8601-2 extended format | +| isodate_basic | `date -u +%Y%m%dT%H%M%SZ` | Display the current date in UTC and ISO 8601 basic format | +| unixstamp | `date +%s` | Display the current date as a Unix timestamp (seconds since the Unix epoch)| +| date_locale | `date +"%c"` | Display the current date using the default locale's format | diff --git a/plugins/isodate/isodate.plugin.zsh b/plugins/isodate/isodate.plugin.zsh new file mode 100644 index 000000000..1a827e785 --- /dev/null +++ b/plugins/isodate/isodate.plugin.zsh @@ -0,0 +1,7 @@ +# work with date ISO 8601 easy + +alias isodate="date +%Y-%m-%dT%H:%M:%S%z" +alias isodate_utc="date -u +%Y-%m-%dT%H:%M:%SZ" +alias isodate_basic="date -u +%Y%m%dT%H%M%SZ" +alias unixstamp="date +%s" +alias date_locale="date +"%c"" -- cgit v1.2.3-70-g09d2 From 3cdc36fc1eb096804a448ded93da1667e1b3f230 Mon Sep 17 00:00:00 2001 From: Oshadha Gunawardena Date: Sat, 12 Jun 2021 18:53:29 +0530 Subject: feat(plugins): Add a new showpkg alias to ubuntu plugin (#4653) Add an alias for ```showpkg``` to get the reverse and recursive dependencies on a package --- plugins/ubuntu/ubuntu.plugin.zsh | 3 +++ 1 file changed, 3 insertions(+) (limited to 'plugins') diff --git a/plugins/ubuntu/ubuntu.plugin.zsh b/plugins/ubuntu/ubuntu.plugin.zsh index a53752fb2..989ffd1ff 100644 --- a/plugins/ubuntu/ubuntu.plugin.zsh +++ b/plugins/ubuntu/ubuntu.plugin.zsh @@ -15,6 +15,9 @@ alias agli='apt list --installed' # List available updates only alias aglu='apt list --upgradable' +alias acsp='apt-cache showpkg' +compdef _acsp acsp='apt-cache showpkg' + # superuser operations ###################################################### alias afu='sudo apt-file update' -- cgit v1.2.3-70-g09d2 From 81a6cc5050136399ea0c664bacb8f83a999fe866 Mon Sep 17 00:00:00 2001 From: Mirko Lelansky Date: Sat, 12 Jun 2021 16:01:26 +0200 Subject: feat(plugins): Add helper function to get current mercurial bookmark (#4970) Add a new function to get the current mercurial bookmark which can be used in the theme prompts for example. --- plugins/mercurial/mercurial.plugin.zsh | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'plugins') diff --git a/plugins/mercurial/mercurial.plugin.zsh b/plugins/mercurial/mercurial.plugin.zsh index f13430476..a50dcb523 100644 --- a/plugins/mercurial/mercurial.plugin.zsh +++ b/plugins/mercurial/mercurial.plugin.zsh @@ -63,3 +63,9 @@ function hgic() { function hgoc() { hg outgoing "$@" | grep "changeset" | wc -l } + +function hg_get_bookmark_name() { + if [ $(in_hg) ]; then + echo $(hg id -B) + fi +} -- cgit v1.2.3-70-g09d2 From 26e9cead1a7c9264962986fdc3038ad7266c92bd Mon Sep 17 00:00:00 2001 From: Felix Stupp Date: Sat, 12 Jun 2021 14:10:06 +0000 Subject: feat(plugins): Plugin "debian": Switch order of "apt" and "aptitude" for detection (#7533) * Switch order of "apt" and "aptitude" for detection "apt" is installed by default at Debian (maybe Ubuntu too), while "aptitude" does not seem to be installed by default. For that, it may be better for most of the users to prefer "aptitude" if installed. * plugins/debian/README: Change of order mirroded into documentation --- plugins/debian/README.md | 2 +- plugins/debian/debian.plugin.zsh | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'plugins') diff --git a/plugins/debian/README.md b/plugins/debian/README.md index da5675c66..922d68cb3 100644 --- a/plugins/debian/README.md +++ b/plugins/debian/README.md @@ -10,7 +10,7 @@ plugins=(... debian) ## Settings -- `$apt_pref`: use apt or aptitude if installed, fallback is apt-get. +- `$apt_pref`: use aptitude or apt if installed, fallback is apt-get. - `$apt_upgr`: use upgrade or safe-upgrade (for aptitude). Set `$apt_pref` and `$apt_upgr` to whatever command you want (before sourcing Oh My Zsh) to override this behavior. diff --git a/plugins/debian/debian.plugin.zsh b/plugins/debian/debian.plugin.zsh index 108396784..bde97cd30 100644 --- a/plugins/debian/debian.plugin.zsh +++ b/plugins/debian/debian.plugin.zsh @@ -1,13 +1,13 @@ -# Use apt or aptitude if installed, fallback is apt-get +# Use aptitude or apt if installed, fallback is apt-get # You can just set apt_pref='apt-get' to override it. if [[ -z $apt_pref || -z $apt_upgr ]]; then - if [[ -e $commands[apt] ]]; then - apt_pref='apt' - apt_upgr='upgrade' - elif [[ -e $commands[aptitude] ]]; then + if [[ -e $commands[aptitude] ]]; then apt_pref='aptitude' apt_upgr='safe-upgrade' + elif [[ -e $commands[apt] ]]; then + apt_pref='apt' + apt_upgr='upgrade' else apt_pref='apt-get' apt_upgr='upgrade' -- cgit v1.2.3-70-g09d2 From e701fa49e7fc5f8aaef4ba680e012a14bce00c4b Mon Sep 17 00:00:00 2001 From: Rolf Schröder Date: Sat, 12 Jun 2021 16:12:07 +0200 Subject: feat(plugins): New plugins for samtools and bedtools (#3574) * Add first impl of samtools autocompletion * Just autocomplete with files all the time * Add init impl of bedtools completion * Add readme.md for bedtools plugin * Add readme for samtools Co-authored-by: Rolf Schroeder --- plugins/bedtools/README.md | 5 ++++ plugins/bedtools/_bedtools | 64 ++++++++++++++++++++++++++++++++++++++++++++++ plugins/samtools/README.md | 5 ++++ plugins/samtools/_samtools | 40 +++++++++++++++++++++++++++++ 4 files changed, 114 insertions(+) create mode 100644 plugins/bedtools/README.md create mode 100644 plugins/bedtools/_bedtools create mode 100644 plugins/samtools/README.md create mode 100644 plugins/samtools/_samtools (limited to 'plugins') diff --git a/plugins/bedtools/README.md b/plugins/bedtools/README.md new file mode 100644 index 000000000..c4de4e3a9 --- /dev/null +++ b/plugins/bedtools/README.md @@ -0,0 +1,5 @@ +# Bedtools plugin + +This plugin adds support for the [bedtools suite](http://bedtools.readthedocs.org/en/latest/): + +* Adds autocomplete options for all bedtools sub commands. diff --git a/plugins/bedtools/_bedtools b/plugins/bedtools/_bedtools new file mode 100644 index 000000000..ef6c4179a --- /dev/null +++ b/plugins/bedtools/_bedtools @@ -0,0 +1,64 @@ +#compdef bedtools +#autoload + +local curcontext="$curcontext" state line ret=1 +local -a _files + +_arguments -C \ + '1: :->cmds' \ + '2:: :->args' && ret=0 + +case $state in + cmds) + _values "bedtools command" \ + "--contact[Feature requests, bugs, mailing lists, etc.]" \ + "--help[Print this help menu.]" \ + "--version[What version of bedtools are you using?.]" \ + "annotate[Annotate coverage of features from multiple files.]" \ + "bamtobed[Convert BAM alignments to BED (& other) formats.]" \ + "bamtofastq[Convert BAM records to FASTQ records.]" \ + "bed12tobed6[Breaks BED12 intervals into discrete BED6 intervals.]" \ + "bedpetobam[Convert BEDPE intervals to BAM records.]" \ + "bedtobam[Convert intervals to BAM records.]" \ + "closest[Find the closest, potentially non-overlapping interval.]" \ + "cluster[Cluster (but don't merge) overlapping/nearby intervals.]" \ + "complement[Extract intervals _not_ represented by an interval file.]" \ + "coverage[Compute the coverage over defined intervals.]" \ + "expand[Replicate lines based on lists of values in columns.]" \ + "fisher[Calculate Fisher statistic b/w two feature files.]" \ + "flank[Create new intervals from the flanks of existing intervals.]" \ + "genomecov[Compute the coverage over an entire genome.]" \ + "getfasta[Use intervals to extract sequences from a FASTA file.]" \ + "groupby[Group by common cols. & summarize oth. cols. (~ SQL "groupBy")]" \ + "igv[Create an IGV snapshot batch script.]" \ + "intersect[Find overlapping intervals in various ways.]" \ + "jaccard[Calculate the Jaccard statistic b/w two sets of intervals.]" \ + "links[Create a HTML page of links to UCSC locations.]" \ + "makewindows[Make interval "windows" across a genome.]" \ + "map[Apply a function to a column for each overlapping interval.]" \ + "maskfasta[Use intervals to mask sequences from a FASTA file.]" \ + "merge[Combine overlapping/nearby intervals into a single interval.]" \ + "multicov[Counts coverage from multiple BAMs at specific intervals.]" \ + "multiinter[Identifies common intervals among multiple interval files.]" \ + "nuc[Profile the nucleotide content of intervals in a FASTA file.]" \ + "overlap[Computes the amount of overlap from two intervals.]" \ + "pairtobed[Find pairs that overlap intervals in various ways.]" \ + "pairtopair[Find pairs that overlap other pairs in various ways.]" \ + "random[Generate random intervals in a genome.]" \ + "reldist[Calculate the distribution of relative distances b/w two files.]" \ + "sample[Sample random records from file using reservoir sampling.]" \ + "shuffle[Randomly redistrubute intervals in a genome.]" \ + "slop[Adjust the size of intervals.]" \ + "sort[Order the intervals in a file.]" \ + "subtract[Remove intervals based on overlaps b/w two files.]" \ + "tag[Tag BAM alignments based on overlaps with interval files.]" \ + "unionbedg[Combines coverage intervals from multiple BEDGRAPH files.]" \ + "window[Find overlapping intervals within a window around an interval.]" \ + ret=0 + ;; + *) + _files + ;; +esac + +return ret diff --git a/plugins/samtools/README.md b/plugins/samtools/README.md new file mode 100644 index 000000000..f4baf41f7 --- /dev/null +++ b/plugins/samtools/README.md @@ -0,0 +1,5 @@ +# Samtools plugin + +This plugin adds support for [samtools](http://www.htslib.org/): + +* Adds autocomplete options for all samtools sub commands. diff --git a/plugins/samtools/_samtools b/plugins/samtools/_samtools new file mode 100644 index 000000000..ddb002ae2 --- /dev/null +++ b/plugins/samtools/_samtools @@ -0,0 +1,40 @@ +#compdef samtools +#autoload + +local curcontext="$curcontext" state line ret=1 +local -a _files + +_arguments -C \ + '1: :->cmds' \ + '2:: :->args' && ret=0 + +case $state in + cmds) + _values "samtools command" \ + "view[SAM<->BAM conversion]" \ + "sort[sort alignment file]" \ + "mpileup[multi-way pileup]" \ + "depth[compute the depth]" \ + "faidx[index/extract FASTA]" \ + "tview[text alignment viewer]" \ + "index[index alignment]" \ + "idxstats[BAM index stats (r595 or later)]" \ + "fixmate[fix mate information]" \ + "flagstat[simple stats]" \ + "calmd[recalculate MD/NM tags and '=' bases]" \ + "merge[merge sorted alignments]" \ + "rmdup[remove PCR duplicates]" \ + "reheader[replace BAM header]" \ + "cat[concatenate BAMs]" \ + "bedcov[read depth per BED region]" \ + "targetcut[cut fosmid regions (for fosmid pool only)]" \ + "phase[phase heterozygotes]" \ + "bamshuf[shuffle and group alignments by name]" + ret=0 + ;; + *) + _files + ;; +esac + +return ret -- cgit v1.2.3-70-g09d2 From 5b3657a454efdd5d27753c049cc2e2f1c4d82bc7 Mon Sep 17 00:00:00 2001 From: Guillermo Alcantara Date: Sat, 12 Jun 2021 10:49:08 -0500 Subject: feat(plugins): Add Ag completion (#3534) * Add Ag completion A replacement for ack/grep https://github.com/ggreer/the_silver_searcher * Create README.md As requested in the PR: https://github.com/ohmyzsh/ohmyzsh/pull/3534 --- plugins/ag/README.md | 13 +++++++++++ plugins/ag/_ag | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 79 insertions(+) create mode 100644 plugins/ag/README.md create mode 100644 plugins/ag/_ag (limited to 'plugins') diff --git a/plugins/ag/README.md b/plugins/ag/README.md new file mode 100644 index 000000000..6acc54067 --- /dev/null +++ b/plugins/ag/README.md @@ -0,0 +1,13 @@ +# The Silver Searcher + +This plugin provides completion support for [`ag`](https://github.com/ggreer/the_silver_searcher). + +To use it, add ag to the plugins array in your zshrc file. + +```zsh +plugins=(... aws) +``` + +## INSTALLATION NOTES + +Besides oh-my-zsh, `ag` needs to be installed by following these steps: https://github.com/ggreer/the_silver_searcher#installing. diff --git a/plugins/ag/_ag b/plugins/ag/_ag new file mode 100644 index 000000000..25b0c27a7 --- /dev/null +++ b/plugins/ag/_ag @@ -0,0 +1,66 @@ +#compdef ag +#autoload + +typeset -A opt_args + +# Took the liberty of not listing every option… specially aliases and -D +_ag () { + local -a _1st_arguments + _1st_arguments=( + '--ackmate:Print results in AckMate-parseable format' + {'-A','--after'}':[LINES] Print lines after match (Default: 2)' + {'-B','--before'}':[LINES] Print lines before match (Default: 2)' + '--break:Print newlines between matches in different files' + '--nobreak:Do not print newlines between matches in different files' + {'-c','--count'}':Only print the number of matches in each file' + '--color:Print color codes in results (Default: On)' + '--nocolor:Do not print color codes in results' + '--color-line-number:Color codes for line numbers (Default: 1;33)' + '--color-match:Color codes for result match numbers (Default: 30;43)' + '--color-path:Color codes for path names (Default: 1;32)' + '--column:Print column numbers in results' + {'-H','--heading'}':Print file names (On unless searching a single file)' + '--noheading:Do not print file names (On unless searching a single file)' + '--line-numbers:Print line numbers even for streams' + {'-C','--context'}':[LINES] Print lines before and after matches (Default: 2)' + '-g:[PATTERN] Print filenames matching PATTERN' + {'-l','--files-with-matches'}':Only print filenames that contain matches' + {'-L','--files-without-matches'}':Only print filenames that do not contain matches' + '--no-numbers:Do not print line numbers' + {'-o','--only-matching'}':Prints only the matching part of the lines' + '--print-long-lines:Print matches on very long lines (Default: 2k characters)' + '--passthrough:When searching a stream, print all lines even if they do not match' + '--silent:Suppress all log messages, including errors' + '--stats:Print stats (files scanned, time taken, etc.)' + '--vimgrep:Print results like vim :vimgrep /pattern/g would' + {'-0','--null'}':Separate filenames with null (for "xargs -0")' + + {'-a','--all-types'}':Search all files (does not include hidden files / .gitignore)' + '--depth:[NUM] Search up to NUM directories deep (Default: 25)' + {'-f','--follow'}':Follow symlinks' + {'-G','--file-search-regex'}':[PATTERN] Limit search to filenames matching PATTERN' + '--hidden:Search hidden files (obeys .*ignore files)' + {'-i','--ignore-case'}':Match case insensitively' + '--ignore:[PATTERN] Ignore files/directories matching PATTERN' + {'-m','--max-count'}':[NUM] Skip the rest of a file after NUM matches (Default: 10k)' + {'-p','--path-to-agignore'}':[PATH] Use .agignore file at PATH' + {'-Q','--literal'}':Do not parse PATTERN as a regular expression' + {'-s','--case-sensitive'}':Match case' + {'-S','--smart-case'}':Insensitive match unless PATTERN has uppercase (Default: On)' + '--search-binary:Search binary files for matches' + {'-t','--all-text'}':Search all text files (Hidden files not included)' + {'-u','--unrestricted'}':Search all files (ignore .agignore and _all_)' + {'-U','--skip-vcs-ignores'}':Ignore VCS files (stil obey .agignore)' + {'-v','--invert-match'}':Invert match' + {'-w','--word-regexp'}':Only match whole words' + {'-z','--search-zip'}':Search contents of compressed (e.g., gzip) files' + + '--list-file-types:list of supported file types' + ) + + if [[ $words[-1] =~ "^-" ]]; then + _describe -t commands "ag options" _1st_arguments && ret=0 + else + _files && ret=0 + fi +} -- cgit v1.2.3-70-g09d2 From baced0cdcf491b1ecf7176f5bba16a3a95dd0460 Mon Sep 17 00:00:00 2001 From: Robby Russell Date: Sun, 13 Jun 2021 08:10:29 -0700 Subject: style(kubectl): Being more explicit alias to the main CLI tool instead of to another alias (#6567) --- plugins/kubectl/kubectl.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins') diff --git a/plugins/kubectl/kubectl.plugin.zsh b/plugins/kubectl/kubectl.plugin.zsh index b79b7c941..3630facaa 100644 --- a/plugins/kubectl/kubectl.plugin.zsh +++ b/plugins/kubectl/kubectl.plugin.zsh @@ -43,7 +43,7 @@ alias kgpwide='kgp -o wide' alias kep='kubectl edit pods' alias kdp='kubectl describe pods' alias kdelp='kubectl delete pods' -alias kgpall='k get pods --all-namespaces -o wide' +alias kgpall='kubectl get pods --all-namespaces -o wide' # get pod by label: kgpl "app=myapp" -n myns alias kgpl='kgp -l' -- cgit v1.2.3-70-g09d2 From 5152d381bb828a4ed41fdbb430eb05970a8bb25c Mon Sep 17 00:00:00 2001 From: Stanisław Szydło Date: Sun, 13 Jun 2021 17:23:13 +0200 Subject: feat(kubectx): adding a new plugin for 'kubectx' (#6114) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Marc Cornellà Co-authored-by: Robby Russell --- lib/prompt_info_functions.zsh | 1 + plugins/kubectx/README.md | 26 ++++++++++++++++++++++++++ plugins/kubectx/kubectx.plugin.zsh | 14 ++++++++++++++ plugins/kubectx/prod.png | Bin 0 -> 3834 bytes plugins/kubectx/stage.png | Bin 0 -> 3829 bytes 5 files changed, 41 insertions(+) create mode 100644 plugins/kubectx/README.md create mode 100644 plugins/kubectx/kubectx.plugin.zsh create mode 100644 plugins/kubectx/prod.png create mode 100644 plugins/kubectx/stage.png (limited to 'plugins') diff --git a/lib/prompt_info_functions.zsh b/lib/prompt_info_functions.zsh index 48f033da6..e29fb27a5 100644 --- a/lib/prompt_info_functions.zsh +++ b/lib/prompt_info_functions.zsh @@ -19,6 +19,7 @@ function chruby_prompt_info \ virtualenv_prompt_info \ jenv_prompt_info \ tf_prompt_info \ + kubectx_prompt_info \ { return 1 } diff --git a/plugins/kubectx/README.md b/plugins/kubectx/README.md new file mode 100644 index 000000000..9a1df2617 --- /dev/null +++ b/plugins/kubectx/README.md @@ -0,0 +1,26 @@ +# kubectx - show active kubectl context + +This plugins adds ```kubectx_prompt_info()``` function. It shows name of the +active kubectl context (```kubectl config current-context```). + +You can use it to customize prompt and know if You are on prod cluster ;) + +_Example_. Add to **.zshrc**: + +``` +RPS1='$(kubectx_prompt_info)' +``` + +### custom ctx names + +One can rename default context name for better readability. + +_Example_. Add to **.zshrc**: +``` +kubectx_mapping[minikube] = "mini" +kubectx_mapping[context_name_from_kubeconfig]="$emoji[wolf_face]" +kubectx_mapping[production_cluster]="%{$fg[yellow]%}prod!%{$reset_color%}" +``` + +![staging](stage.png) +![production](prod.png) diff --git a/plugins/kubectx/kubectx.plugin.zsh b/plugins/kubectx/kubectx.plugin.zsh new file mode 100644 index 000000000..56b7217f1 --- /dev/null +++ b/plugins/kubectx/kubectx.plugin.zsh @@ -0,0 +1,14 @@ +typeset -A kubectx_mapping + +function kubectx_prompt_info() { + if [ $commands[kubectl] ]; then + local current_ctx=`kubectl config current-context` + + #if associative array declared + if [[ -n $kubectx_mapping ]]; then + echo "${kubectx_mapping[$current_ctx]}" + else + echo $current_ctx + fi + fi +} diff --git a/plugins/kubectx/prod.png b/plugins/kubectx/prod.png new file mode 100644 index 000000000..0c194a66d Binary files /dev/null and b/plugins/kubectx/prod.png differ diff --git a/plugins/kubectx/stage.png b/plugins/kubectx/stage.png new file mode 100644 index 000000000..ac15b3929 Binary files /dev/null and b/plugins/kubectx/stage.png differ -- cgit v1.2.3-70-g09d2 From 960483b76b536a525bb6b458f5705b2653064e46 Mon Sep 17 00:00:00 2001 From: Sagar Yadav <47110215+SagarYadav17@users.noreply.github.com> Date: Sun, 13 Jun 2021 22:53:58 +0530 Subject: feat(pip): add alias for updating all requirements via pip (#9965) * feat(plugins): add alias for pip commands * feat(plugins): updated README.md and add alias --- plugins/pip/README.md | 9 +++++++++ plugins/pip/pip.plugin.zsh | 11 +++++++++++ 2 files changed, 20 insertions(+) (limited to 'plugins') diff --git a/plugins/pip/README.md b/plugins/pip/README.md index f07b5c058..88d88227e 100644 --- a/plugins/pip/README.md +++ b/plugins/pip/README.md @@ -17,3 +17,12 @@ or you can run `zsh-pip-cache-packages` directly. To reset the cache, run `zsh-pip-clear-cache` and it will be rebuilt next the next time you autocomplete `pip install`. + +## Aliases + +| Alias | Description | +| :------- | :-------------------------------------------- | +| pipreq | Create requirements file | +| pipir | Install packages from `requirements.txt` file | +| pipupall | Update all installed packages | +| pipunall | Uninstall all installed packages | diff --git a/plugins/pip/pip.plugin.zsh b/plugins/pip/pip.plugin.zsh index a46e7658c..629147bae 100644 --- a/plugins/pip/pip.plugin.zsh +++ b/plugins/pip/pip.plugin.zsh @@ -84,3 +84,14 @@ zsh-pip-test-clean-packages() { alias pip="noglob pip" # allows square brackets for pip command invocation +# Create requirements file +alias pipreq="pip freeze > requirements.txt" + +# Update all installed packages +alias pipupall="pipreq && sed -i 's/==/>=/g' requirements.txt && pip install -r requirements.txt --upgrade && rm -rf requirements.txt" + +# Install packages from requirements file +alias pipir="pip install -r requirements.txt" + +# Uninstalled all installed packages +alias pipunall="pipreq && pip uninstall -r requirements.txt -y && rm -rf requirements.txt" -- cgit v1.2.3-70-g09d2 From 3ea66642e8d86b597e6c789358b82540859b178a Mon Sep 17 00:00:00 2001 From: Lasse Peters Date: Sun, 13 Jun 2021 19:25:27 +0200 Subject: feat(git): Add alias for 'git checkout --recurse-submodules' (#9958) --- plugins/git/README.md | 1 + plugins/git/git.plugin.zsh | 1 + 2 files changed, 2 insertions(+) (limited to 'plugins') diff --git a/plugins/git/README.md b/plugins/git/README.md index 93c9cc915..e00f4cf92 100644 --- a/plugins/git/README.md +++ b/plugins/git/README.md @@ -53,6 +53,7 @@ plugins=(... git) | gcd | git checkout develop | | gcmsg | git commit -m | | gco | git checkout | +| gcor | git checkout --recurse-submodules | | gcount | git shortlog -sn | | gcp | git cherry-pick | | gcpa | git cherry-pick --abort | diff --git a/plugins/git/git.plugin.zsh b/plugins/git/git.plugin.zsh index a364b6162..6664551eb 100644 --- a/plugins/git/git.plugin.zsh +++ b/plugins/git/git.plugin.zsh @@ -91,6 +91,7 @@ alias gcm='git checkout $(git_main_branch)' alias gcd='git checkout develop' alias gcmsg='git commit -m' alias gco='git checkout' +alias gcor='git checkout --recurse-submodules' alias gcount='git shortlog -sn' alias gcp='git cherry-pick' alias gcpa='git cherry-pick --abort' -- cgit v1.2.3-70-g09d2 From 36cc94f3dcd8d6214b5a4bedf180bc723eb49a3f Mon Sep 17 00:00:00 2001 From: Ajeet D'Souza <98ajeet@gmail.com> Date: Sun, 13 Jun 2021 23:00:58 +0530 Subject: feat(zoxide): add new plugin for zoxide (a smarter cd CLI tool) (#9950) --- .github/CODEOWNERS | 1 + plugins/zoxide/README.md | 14 ++++++++++++++ plugins/zoxide/zoxide.plugin.zsh | 5 +++++ 3 files changed, 20 insertions(+) create mode 100644 plugins/zoxide/README.md create mode 100644 plugins/zoxide/zoxide.plugin.zsh (limited to 'plugins') diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 1b1340554..6c3eac6e7 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -7,3 +7,4 @@ plugins/gitfast/ @felipec plugins/sdk/ @rgoldberg plugins/universalarchive/ @Konfekt plugins/wp-cli/ @joshmedeski +plugins/zoxide/ @ajeetdsouza diff --git a/plugins/zoxide/README.md b/plugins/zoxide/README.md new file mode 100644 index 000000000..f326effe6 --- /dev/null +++ b/plugins/zoxide/README.md @@ -0,0 +1,14 @@ +# zoxide plugin + +Initializes [zoxide](https://github.com/ajeetdsouza/zoxide), a smarter cd +command for your terminal. + +![Tutorial](https://raw.githubusercontent.com/ajeetdsouza/zoxide/97dc08347d9dbf5b5a4516b79e0ac27366b962ce/contrib/tutorial.webp) + +To use it, add `zoxide` to the plugins array in your `.zshrc` file: + +```zsh +plugins=(... zoxide) +``` + +**Note:** you have to [install zoxide](https://github.com/ajeetdsouza/zoxide#step-1-install-zoxide) first. diff --git a/plugins/zoxide/zoxide.plugin.zsh b/plugins/zoxide/zoxide.plugin.zsh new file mode 100644 index 000000000..e5658b8f0 --- /dev/null +++ b/plugins/zoxide/zoxide.plugin.zsh @@ -0,0 +1,5 @@ +if (( $+commands[zoxide] )); then + eval "$(zoxide init zsh)" +else + echo '[oh-my-zsh] zoxide not found, please install it from https://github.com/ajeetdsouza/zoxide' +fi -- cgit v1.2.3-70-g09d2 From 70a0577712bc8f78e14173c8032df3701ea2887f Mon Sep 17 00:00:00 2001 From: "Guo, Quan" <1118270+guoquan@users.noreply.github.com> Date: Mon, 14 Jun 2021 01:32:47 +0800 Subject: feat(nvm): introduce customizable list of command that triggers lazy loading (#9946) * Add customizable list of command that triggers lazy loading * Add $NVM_LAZY_CMD * Add instruction to `NVM_LAZY_CMD` in README.md --- plugins/nvm/README.md | 6 +++++- plugins/nvm/nvm.plugin.zsh | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) (limited to 'plugins') diff --git a/plugins/nvm/README.md b/plugins/nvm/README.md index 700613085..0c2bbf9f0 100644 --- a/plugins/nvm/README.md +++ b/plugins/nvm/README.md @@ -21,7 +21,11 @@ These settings should go in your zshrc file, before Oh My Zsh is sourced: - **`NVM_LAZY`**: if you want the plugin to defer the load of nvm to speed-up the start of your zsh session, set `NVM_LAZY` to `1`. This will use the `--no-use` parameter when loading nvm, and will create a function - for `node`, `npm` and `yarn`, so when you call either of these three, nvm will load with `nvm use default`. + for `node`, `npm`, `yarn`, and the command(s) specified by `NVM_LAZY_CMD`, so when you call either of them, + nvm will load with `nvm use default`. + +- **`NVM_LAZY_CMD`**: if you want additional command(s) to trigger lazy loading of nvm, set `NVM_LAZY_CMD` to + the command or an array of the commands. - **`NVM_AUTOLOAD`**: if `NVM_AUTOLOAD` is set to `1`, the plugin will automatically load a node version when if finds a [`.nvmrc` file](https://github.com/nvm-sh/nvm#nvmrc) in the current working directory indicating diff --git a/plugins/nvm/nvm.plugin.zsh b/plugins/nvm/nvm.plugin.zsh index 1e9b26e7a..3ef8cc1d8 100644 --- a/plugins/nvm/nvm.plugin.zsh +++ b/plugins/nvm/nvm.plugin.zsh @@ -28,8 +28,8 @@ fi # Call nvm when first using node, npm or yarn if (( $+NVM_LAZY )); then - function node npm yarn { - unfunction node npm yarn + function node npm yarn $NVM_LAZY_CMD { + unfunction node npm yarn $NVM_LAZY_CMD nvm use default command "$0" "$@" } -- cgit v1.2.3-70-g09d2 From 027189b294d14a7d313cdbf611982843f921555d Mon Sep 17 00:00:00 2001 From: Michał Duszyk Date: Sun, 13 Jun 2021 19:40:07 +0200 Subject: perf(mercurial): speed up mercurial plugin (#4591) * speed up mercurial plugin * removed unnecesay limit to current dir from hg status --- plugins/mercurial/mercurial.plugin.zsh | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) (limited to 'plugins') diff --git a/plugins/mercurial/mercurial.plugin.zsh b/plugins/mercurial/mercurial.plugin.zsh index a50dcb523..f4efc2b4a 100644 --- a/plugins/mercurial/mercurial.plugin.zsh +++ b/plugins/mercurial/mercurial.plugin.zsh @@ -19,37 +19,38 @@ alias hglr='hg pull --rebase' alias hgo='hg outgoing' function in_hg() { - if [[ -d .hg ]] || $(hg summary > /dev/null 2>&1); then + if $(hg branch > /dev/null 2>&1); then echo 1 fi } function hg_get_branch_name() { - if [ $(in_hg) ]; then - echo $(hg branch) + branch=`hg branch 2>/dev/null` + if [ $? -eq 0 ]; then + echo $branch fi + unset branch } function hg_prompt_info { - if [ $(in_hg) ]; then - _DISPLAY=$(hg_get_branch_name) + _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" - unset _DISPLAY fi + unset _DISPLAY } function hg_dirty_choose { - if [ $(in_hg) ]; then - hg status 2> /dev/null | command grep -Eq '^\s*[ACDIM!?L]' + 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 - else - # Otherwise, no lines were found, or an error occurred. Return clean. - echo $2 + return fi fi + echo $2 } function hg_dirty { @@ -57,11 +58,11 @@ function hg_dirty { } function hgic() { - hg incoming "$@" | grep "changeset" | wc -l + hg incoming "$@" | grep "changeset" | wc -l } function hgoc() { - hg outgoing "$@" | grep "changeset" | wc -l + hg outgoing "$@" | grep "changeset" | wc -l } function hg_get_bookmark_name() { -- cgit v1.2.3-70-g09d2 From 241c7dde2b6afc4025fc74774f51a71fb3b128d3 Mon Sep 17 00:00:00 2001 From: Shubham Chaudhary Date: Sun, 13 Jun 2021 13:50:36 -0400 Subject: feat(supervisor): Add aliases for supervisor (#5819) --- plugins/supervisor/supervisor.plugin.zsh | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'plugins') diff --git a/plugins/supervisor/supervisor.plugin.zsh b/plugins/supervisor/supervisor.plugin.zsh index cf1997c5b..f11f0ed3f 100644 --- a/plugins/supervisor/supervisor.plugin.zsh +++ b/plugins/supervisor/supervisor.plugin.zsh @@ -1 +1,14 @@ # DECLARION: 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' +alias supa='sudo supervisorctl avail' +alias suprl='sudo supervisorctl reload' +alias suprm='sudo supervisorctl remove' +alias suprr='sudo supervisorctl reread' +alias suprs='sudo supervisorctl restart' +alias sups='sudo supervisorctl status' +alias supsr='sudo supervisorctl start' +alias supso='sudo supervisorctl stop' +alias supt='sudo supervisorctl tail' +alias supu='sudo supervisorctl update' -- cgit v1.2.3-70-g09d2 From bd5d0066b908af0db1c4e8b1fb18888d8965d3a0 Mon Sep 17 00:00:00 2001 From: Myoungdo Park Date: Mon, 14 Jun 2021 02:58:44 +0900 Subject: feat(pm2): Adding a pm2 plugin (#7684) * Add pm2 plugin * Add description of pm2 plugin --- plugins/pm2/README.md | 19 +++++ plugins/pm2/_pm2 | 168 +++++++++++++++++++++++++++++++++++++++++++++ plugins/pm2/pm2.plugin.zsh | 6 ++ 3 files changed, 193 insertions(+) create mode 100644 plugins/pm2/README.md create mode 100644 plugins/pm2/_pm2 create mode 100644 plugins/pm2/pm2.plugin.zsh (limited to 'plugins') diff --git a/plugins/pm2/README.md b/plugins/pm2/README.md new file mode 100644 index 000000000..5dfd540b6 --- /dev/null +++ b/plugins/pm2/README.md @@ -0,0 +1,19 @@ +# pm2 plugin + +The plugin adds several aliases and completions for common [pm2](http://pm2.keymetrics.io/) commands. + +To use it, add `pm2` to the plugins array of your zshrc file: +``` +plugins=(... pm2) +``` + +## Aliases + +| Alias | Command | +|--------|----------------------| +| p2s | `pm2 start` | +| p2o | `pm2 stop` | +| p2d | `pm2 delete` | +| p2r | `pm2 restart` | +| p2i | `pm2 list` | +| p2l | `pm2 logs` | diff --git a/plugins/pm2/_pm2 b/plugins/pm2/_pm2 new file mode 100644 index 000000000..6f1e89df5 --- /dev/null +++ b/plugins/pm2/_pm2 @@ -0,0 +1,168 @@ +#!/bin/zsh -f +#compdef pm2 +#autoload + +local -a _1st_arguments + +_1st_arguments=( + "start:start and daemonize an app" + "trigger:trigger process action" + "deploy:deploy your json" + "startOrRestart:start or restart JSON file" + "startOrReload:start or gracefully reload JSON file" + "pid:return pid of [app_name] or all" + "stop:stop a process" + "restart:restart a process" + "scale:scale up/down a process in cluster mode depending on total_number param" + "profile\:mem:Sample PM2 heap memory" + "profile\:cpu:Profile PM2 cpu" + "reload:reload processes (note that its for app using HTTP/HTTPS)" + "id:get process id by name" + "inspect:inspect a process" + "delete:stop and delete a process from pm2 process list" + "sendSignal:send a system signal to the target process" + "ping:ping pm2 daemon - if not up it will launch it" + "updatePM2:update in-memory PM2 with local PM2" + "install:install or update a module and run it forever" + "module\:update:update a module and run it forever" + "module\:generate:Generate a sample module in current folder" + "uninstall:stop and uninstall a module" + "package:Check & Package TAR type module" + "publish:Publish the module you are currently on" + "set:sets the specified config " + "multiset:multiset eg \"key1 val1 key2 val2\"" + "get:get value for " + "config:get / set module config values" + "unset:clears the specified config " + "report:give a full pm2 report for https\://github.com/Unitech/pm2/issues" + "link:link with the pm2 monitoring dashboard" + "unlink:unlink with the pm2 monitoring dashboard" + "monitor:monitor target process" + "unmonitor:unmonitor target process" + "open:open the pm2 monitoring dashboard" + "plus:enable pm2 plus" + "login:Login to pm2 plus" + "logout:Logout from pm2 plus" + "web:launch a health API on 0.0.0.0\:9615" + "dump:dump all processes for resurrecting them later" + "cleardump:Create empty dump file" + "send:send stdin to " + "attach:attach stdin/stdout to application identified by " + "resurrect:resurrect previously dumped processes" + "unstartup:disable the pm2 startup hook" + "startup:enable the pm2 startup hook" + "logrotate:copy default logrotate configuration" + "ecosystem:generate a process conf file. (mode = null or simple)" + "reset:reset counters for process" + "describe:describe all parameters of a process id" + "list:list all processes" + "jlist:list all processes in JSON format" + "prettylist:print json in a prettified JSON" + "monit:launch termcaps monitoring" + "imonit:launch legacy termcaps monitoring" + "dashboard:launch dashboard with monitoring and logs" + "flush:flush logs" + "reloadLogs:reload all logs" + "logs:stream logs file. Default stream all logs" + "kill:kill daemon" + "pull:updates repository for a given app" + "forward:updates repository to the next commit for a given app" + "backward:downgrades repository to the previous commit for a given app" + "deepUpdate:performs a deep update of PM2" + "serve:serve a directory over http via port" + "examples:display pm2 usage examples" +) + +local -a id_names + +_id_names() { + local app_list + app_list=`pm2 list -m` + + local -a names ids + names=(`echo $app_list | grep '+---' | awk '{print $2}'`) + ids=(`echo $app_list | grep 'pm2 id' | awk '{print $4}'`) + + if (( ${#ids} > 0 )); then + for i in {1..${#ids}}; do + id_names+=( "${ids[i]}:${names[i]}" ) + done + fi +} + +_arguments \ + '(-v --version)'{-v,--version}'[output version]' \ + '(-h --help)'{-h,--help}'[output usage information]' \ + '*:: :->subcmds' && return 0 + +if (( CURRENT == 1 )); then + _describe "command" _1st_arguments + return +fi + +local -a id_comp id_all_comp id_all_files_comp start_options logs_options +id_comp=('1: :->id_comp') +id_all_comp=('1: :->id_all_comp') +id_all_files_comp=('1: :->id_all_files_comp') +start_options=( + '--watch[Watch folder for changes]' + '--fresh[Rebuild Dockerfile]' + '--daemon[Run container in Daemon mode (debug purposes)]' + '--container[Start application in container mode]' + '--dist[with --container; change local Dockerfile to containerize all files in current directory]' + '--image-name[with --dist; set the exported image name]' + '--node-version[with --container, set a specific major Node.js version]' + '--dockerdaemon[for debugging purpose]' + '(-h --help)'{-h,--help}'[output usage information]' + $id_all_files_comp +) +logs_options=( + '--json[json log output]' + '--format[formated log output]' + '--raw[raw output]' + '--err[only shows error output]' + '--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]' + '(-h --help)'{-h,--help}'[output usage information]' + $id_all_comp +) + +case "$words[1]" in + start) + _arguments $start_options && return 0 + ;; + logs) + _arguments $logs_options && return 0 + ;; + stop|restart|delete|reload|reset) + _arguments $id_all_comp && return 0 + ;; + env|inspect|monitor|unmonitor|discribe) + _arguments $id_comp && return 0 + ;; + deploy|startOrRestart|startOrReload) + _files ;; +esac + +case "$state" in + id_comp) + _id_names + _alternative \ + 'args:app args:(($id_names))' + ;; + id_all_comp) + _id_names + id_names+=(all) + _alternative \ + 'args:app args:(($id_names))' + ;; + id_all_files_comp) + _id_names + id_names+=(all) + _alternative \ + 'args:app args:(($id_names))' \ + 'files:filename:_files' + ;; +esac diff --git a/plugins/pm2/pm2.plugin.zsh b/plugins/pm2/pm2.plugin.zsh new file mode 100644 index 000000000..f05d8db8b --- /dev/null +++ b/plugins/pm2/pm2.plugin.zsh @@ -0,0 +1,6 @@ +alias p2s='pm2 start' +alias p2o='pm2 stop' +alias p2d='pm2 delete' +alias p2r='pm2 restart' +alias p2i='pm2 list' +alias p2l='pm2 logs' -- cgit v1.2.3-70-g09d2 From 08751210e3204c4ba330bce1ff52b1906b92f850 Mon Sep 17 00:00:00 2001 From: Nick Revin Date: Sun, 13 Jun 2021 21:59:31 +0400 Subject: feat(git): Add aliases for 'git commit -S -s [-m]' (#7616) I thought it would be useful to add these aliases. There are already aliases for `git commit -S` and `git commit -s` but there is none for both simultaneously =) --- plugins/git/git.plugin.zsh | 2 ++ 1 file changed, 2 insertions(+) (limited to 'plugins') diff --git a/plugins/git/git.plugin.zsh b/plugins/git/git.plugin.zsh index 6664551eb..2a7c7290d 100644 --- a/plugins/git/git.plugin.zsh +++ b/plugins/git/git.plugin.zsh @@ -97,6 +97,8 @@ alias gcp='git cherry-pick' alias gcpa='git cherry-pick --abort' alias gcpc='git cherry-pick --continue' alias gcs='git commit -S' +alias gcss='git commit -S -s' +alias gcssm='git commit -S -s -m' alias gd='git diff' alias gdca='git diff --cached' -- cgit v1.2.3-70-g09d2 From 77087aaa8d9ff92ef84ae727411f0eca100ed5de Mon Sep 17 00:00:00 2001 From: Fabio Vitale Date: Sun, 13 Jun 2021 20:05:09 +0200 Subject: refactor(git-glow): Add config interpolation for git-flow messages (#7481) Changed commands: gcd: uses gitflow.branch.develop to get user-set development branch gch: uses gitflow.prefix.hotfix to get user-set hotfix prefix gcr: uses gitflow.prefix.release to get user-set release prefix Co-authored-by: Fabio 'c0m3tx' Vitale --- plugins/git-flow/git-flow.plugin.zsh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'plugins') diff --git a/plugins/git-flow/git-flow.plugin.zsh b/plugins/git-flow/git-flow.plugin.zsh index 916cd5693..8f0714b16 100644 --- a/plugins/git-flow/git-flow.plugin.zsh +++ b/plugins/git-flow/git-flow.plugin.zsh @@ -23,9 +23,9 @@ #Alias alias gfl='git flow' alias gfli='git flow init' -alias gcd='git checkout develop' -alias gch='git checkout hotfix' -alias gcr='git checkout release' +alias gcd='git checkout $(git config gitflow.branch.develop)' +alias gch='git checkout $(git config gitflow.prefix.hotfix)' +alias gcr='git checkout $(git config gitflow.prefix.release)' alias gflf='git flow feature' alias gflh='git flow hotfix' alias gflr='git flow release' -- cgit v1.2.3-70-g09d2 From 3e7998aec33ff7551d06d4510f9e8769aab5db93 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Mon, 14 Jun 2021 10:57:50 +0200 Subject: Revert "ssh-agent: improvements (#6309)" This reverts commit a206271460ce49e842b1b410c0424b8c9a0a3d14. --- plugins/ssh-agent/README.md | 12 ++---------- plugins/ssh-agent/ssh-agent.plugin.zsh | 29 ++++++++--------------------- 2 files changed, 10 insertions(+), 31 deletions(-) (limited to 'plugins') diff --git a/plugins/ssh-agent/README.md b/plugins/ssh-agent/README.md index aa96f9cc9..8765a9c7e 100644 --- a/plugins/ssh-agent/README.md +++ b/plugins/ssh-agent/README.md @@ -19,17 +19,9 @@ To enable **agent forwarding support** add the following to your zshrc file: zstyle :omz:plugins:ssh-agent agent-forwarding on ``` -To **NOT load any identities on start** use the `lazy` style. -This is particularly usefull when combined with the AddKeysToAgent -(available from OpenSSH 7.2), since it allows to enter the password only -on first use. - -```zsh -zstyle :omz:plugins:ssh-agent lazy yes -``` +---- -To **load multiple identities** use the `identities` style. This have no -effect if `lazy` is enabled. +To **load multiple identities** use the `identities` style, For example: ```zsh zstyle :omz:plugins:ssh-agent identities id_rsa id_rsa2 id_github diff --git a/plugins/ssh-agent/ssh-agent.plugin.zsh b/plugins/ssh-agent/ssh-agent.plugin.zsh index 494cf1393..d45406f63 100644 --- a/plugins/ssh-agent/ssh-agent.plugin.zsh +++ b/plugins/ssh-agent/ssh-agent.plugin.zsh @@ -1,16 +1,4 @@ -lockdir=/tmp/oh-my-zsh-ssh-agent.lock - -while true; do - if mkdir "$lockdir" 2>/dev/null - then # directory did not exist, but was created successfully - trap 'rm -rf "$lockdir"' 0 # remove directory when script finishes - break # continue with script - else - sleep 0.1 # sleep for 0.2 and try again - fi -done - -typeset _ssh_env_cache +typeset _agent_forwarding _ssh_env_cache function _start_agent() { local lifetime @@ -68,7 +56,10 @@ function _add_identities() { # Get the filename to store/lookup the environment from _ssh_env_cache="$HOME/.ssh/environment-$SHORT_HOST" -if zstyle -t :omz:plugins:ssh-agent agent-forwarding && [[ -n "$SSH_AUTH_SOCK" ]]; then +# test if agent-forwarding is enabled +zstyle -b :omz:plugins:ssh-agent agent-forwarding _agent_forwarding + +if [[ $_agent_forwarding == "yes" && -n "$SSH_AUTH_SOCK" ]]; then # Add a nifty symlink for screen/tmux if agent forwarding [[ -L $SSH_AUTH_SOCK ]] || ln -sf "$SSH_AUTH_SOCK" /tmp/ssh-agent-$USERNAME-screen elif [[ -f "$_ssh_env_cache" ]]; then @@ -82,16 +73,12 @@ elif [[ -f "$_ssh_env_cache" ]]; then ps $FILTER | grep ssh-agent | grep -q $SSH_AGENT_PID || { _start_agent } -elif [[ -d $HOME/.ssh ]]; then +else _start_agent fi -if ! zstyle -t :omz:plugins:ssh-agent lazy; then - _add_identities -fi +_add_identities # tidy up after ourselves -unset _ssh_env_cache +unset _agent_forwarding _ssh_env_cache unfunction _start_agent _add_identities - -rm -rf "$lockdir" -- cgit v1.2.3-70-g09d2 From c44b99e901d7ef58f60247995152de1b937e2e9c Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Mon, 28 Jun 2021 15:54:24 +0200 Subject: fix(dotenv): draw confirmation prompt in next empty line Without this fix the confirmation prompt appears wherever the cursor is, which means that it might appear in the command line when using a widget that changes the directory without redrawing the prompt (an example of this are the dircycle and dirhistory plugins). --- plugins/dotenv/dotenv.plugin.zsh | 72 +++++++++++++++++++++++----------------- 1 file changed, 41 insertions(+), 31 deletions(-) (limited to 'plugins') diff --git a/plugins/dotenv/dotenv.plugin.zsh b/plugins/dotenv/dotenv.plugin.zsh index 24f285df5..40ec5c46f 100644 --- a/plugins/dotenv/dotenv.plugin.zsh +++ b/plugins/dotenv/dotenv.plugin.zsh @@ -11,41 +11,51 @@ ## Functions source_env() { - if [[ -f $ZSH_DOTENV_FILE ]]; then - if [[ "$ZSH_DOTENV_PROMPT" != false ]]; then - local confirmation dirpath="${PWD:A}" - - # make sure there is an (dis-)allowed file - touch "$ZSH_DOTENV_ALLOWED_LIST" - touch "$ZSH_DOTENV_DISALLOWED_LIST" - - # early return if disallowed - if grep -q "$dirpath" "$ZSH_DOTENV_DISALLOWED_LIST" &>/dev/null; then - return; - fi - - # check if current directory's .env file is allowed or ask for confirmation - if ! grep -q "$dirpath" "$ZSH_DOTENV_ALLOWED_LIST" &>/dev/null; then - # print same-line prompt and output newline character if necessary - echo -n "dotenv: found '$ZSH_DOTENV_FILE' file. Source it? ([Y]es/[n]o/[a]lways/n[e]ver) " - read -k 1 confirmation; [[ "$confirmation" != $'\n' ]] && echo - - # check input - case "$confirmation" in - [nN]) return ;; - [aA]) echo "$dirpath" >> "$ZSH_DOTENV_ALLOWED_LIST" ;; - [eE]) echo "$dirpath" >> "$ZSH_DOTENV_DISALLOWED_LIST"; return ;; - *) ;; # interpret anything else as a yes - esac - fi + if [[ ! -f "$ZSH_DOTENV_FILE" ]]; then + return + fi + + if [[ "$ZSH_DOTENV_PROMPT" != false ]]; then + local confirmation dirpath="${PWD:A}" + + # make sure there is an (dis-)allowed file + touch "$ZSH_DOTENV_ALLOWED_LIST" + touch "$ZSH_DOTENV_DISALLOWED_LIST" + + # early return if disallowed + if command grep -q "$dirpath" "$ZSH_DOTENV_DISALLOWED_LIST" &>/dev/null; then + return fi - # test .env syntax - zsh -fn $ZSH_DOTENV_FILE || echo "dotenv: error when sourcing '$ZSH_DOTENV_FILE' file" >&2 + # check if current directory's .env file is allowed or ask for confirmation + if ! command grep -q "$dirpath" "$ZSH_DOTENV_ALLOWED_LIST" &>/dev/null; then + # get cursor column and print new line before prompt if not at line beginning + local column + echo -ne "\e[6n" > /dev/tty + read -t 1 -s -d R column < /dev/tty + column="${column##*\[*;}" + [[ $column -eq 1 ]] || echo - setopt localoptions allexport - source $ZSH_DOTENV_FILE + # print same-line prompt and output newline character if necessary + echo -n "dotenv: found '$ZSH_DOTENV_FILE' file. Source it? ([Y]es/[n]o/[a]lways/n[e]ver) " + read -k 1 confirmation + [[ "$confirmation" = $'\n' ]] || echo + + # check input + case "$confirmation" in + [nN]) return ;; + [aA]) echo "$dirpath" >> "$ZSH_DOTENV_ALLOWED_LIST" ;; + [eE]) echo "$dirpath" >> "$ZSH_DOTENV_DISALLOWED_LIST"; return ;; + *) ;; # interpret anything else as a yes + esac + fi fi + + # test .env syntax + zsh -fn $ZSH_DOTENV_FILE || echo "dotenv: error when sourcing '$ZSH_DOTENV_FILE' file" >&2 + + setopt localoptions allexport + source $ZSH_DOTENV_FILE } autoload -U add-zsh-hook -- cgit v1.2.3-70-g09d2