Update 13.05.2022

This commit is contained in:
Дмитрий Рамазанов 2022-05-13 22:49:55 +05:00
parent 04423b8c5c
commit b40b4515e3
126 changed files with 2457 additions and 6430 deletions

View File

@ -23,7 +23,7 @@ cp -f "$HOME/.vimrc" "$HOME/.vimrc.bak" 2>/dev/null || true
# Create symlinks # Create symlinks
ln -sf .dots/tmux/tmux.conf "$HOME"/.tmux.conf ln -sf .dots/tmux/tmux.conf "$HOME"/.tmux.conf
ln -sf .dots/zsh/zshrc "$HOME"/.zshrc ln -sf .dots/zshrc "$HOME"/.zshrc
ln -sf .dots/vim/vimrc "$HOME"/.vimrc ln -sf .dots/vim/vimrc "$HOME"/.vimrc
printf "OK: Completed\n" printf "OK: Completed\n"

View File

@ -1,2 +1,2 @@
github: [ohmyzsh, robbyrussell, mcornella, larson-carter] github: [ohmyzsh, robbyrussell, mcornella, larson-carter, carlosala]
open_collective: ohmyzsh open_collective: ohmyzsh

View File

@ -1,15 +0,0 @@
# check-spelling/check-spelling configuration
File | Purpose | Format | Info
-|-|-|-
[dictionary.txt](dictionary.txt) | Replacement dictionary (creating this file will override the default dictionary) | one word per line | [dictionary](https://github.com/check-spelling/check-spelling/wiki/Configuration#dictionary)
[allow.txt](allow.txt) | Add words to the dictionary | one word per line (only letters and `'`s allowed) | [allow](https://github.com/check-spelling/check-spelling/wiki/Configuration#allow)
[reject.txt](reject.txt) | Remove words from the dictionary (after allow) | grep pattern matching whole dictionary words | [reject](https://github.com/check-spelling/check-spelling/wiki/Configuration-Examples%3A-reject)
[excludes.txt](excludes.txt) | Files to ignore entirely | perl regular expression | [excludes](https://github.com/check-spelling/check-spelling/wiki/Configuration-Examples%3A-excludes)
[only.txt](only.txt) | Only check matching files (applied after excludes) | perl regular expression | [only](https://github.com/check-spelling/check-spelling/wiki/Configuration-Examples%3A-only)
[patterns.txt](patterns.txt) | Patterns to ignore from checked lines | perl regular expression (order matters, first match wins) | [patterns](https://github.com/check-spelling/check-spelling/wiki/Configuration-Examples%3A-patterns)
[expect.txt](expect.txt) | Expected words that aren't in the dictionary | one word per line (sorted, alphabetically) | [expect](https://github.com/check-spelling/check-spelling/wiki/Configuration#expect)
[advice.md](advice.md) | Supplement for GitHub comment when unrecognized words are found | GitHub Markdown | [advice](https://github.com/check-spelling/check-spelling/wiki/Configuration-Examples%3A-advice)
Note: you can replace any of these files with a directory by the same name (minus the suffix)
and then include multiple files inside that directory (with that suffix) to merge multiple files together.

View File

@ -1,25 +0,0 @@
<!-- See https://github.com/check-spelling/check-spelling/wiki/Configuration-Examples%3A-advice --> <!-- markdownlint-disable MD033 MD041 -->
<details><summary>If the flagged items do not appear to be text</summary>
If items relate to a ...
* well-formed pattern.
If you can write a [pattern](https://github.com/check-spelling/check-spelling/wiki/Configuration-Examples:-patterns) that would match it,
try adding it to the `patterns.txt` file.
Patterns are Perl 5 Regular Expressions - you can [test](
https://www.regexplanet.com/advanced/perl/) yours before committing to verify it will match your lines.
Note that patterns can't match multiline strings.
* binary file.
Please add a file path to the `excludes.txt` file matching the containing file.
File paths are Perl 5 Regular Expressions - you can [test](
https://www.regexplanet.com/advanced/perl/) yours before committing to verify it will match your files.
`^` refers to the file's path from the root of the repository, so `^README\.md$` would exclude [README.md](
../tree/HEAD/README.md) (on whichever branch you're using).
</details>

View File

@ -1,41 +0,0 @@
# See https://github.com/check-spelling/check-spelling/wiki/Configuration-Examples:-excludes
(?:^|/)(?i)COPYRIGHT
(?:^|/)(?i)LICEN[CS]E
(?:^|/)package(?:-lock|)\.json$
(?:^|/)vendor/
ignore$
\.avi$
\.ico$
\.jpe?g$
\.lock$
\.map$
\.min\..
\.mod$
\.mp[34]$
\.png$
\.wav$
^\.github/
^\Qplugins/archlinux/archlinux.plugin.zsh\E$
^\Qplugins/cp/cp.plugin.zsh\E$
^\Qplugins/extract/_extract\E$
^\Qplugins/genpass/genpass.plugin.zsh\E$
^\Qplugins/gitignore/gitignore.plugin.zsh\E$
^\Qplugins/gnu-utils/gnu-utils.plugin.zsh\E$
^\Qplugins/hitchhiker/fortunes/hitchhiker\E$
^\Qplugins/jhbuild/jhbuild.plugin.zsh\E$
^\Qplugins/jhbuild/README.md\E$
^\Qplugins/jruby/jruby.plugin.zsh\E$
^\Qplugins/kubectl/kubectl.plugin.zsh\E$
^\Qplugins/lol/lol.plugin.zsh\E$
^\Qplugins/mosh/mosh.plugin.zsh\E$
^\Qplugins/npx/npx.plugin.zsh\E$
^\Qplugins/powder/_powder\E$
^\Qplugins/suse/suse.plugin.zsh\E$
^\Qplugins/thor/_thor\E$
^\Qplugins/universalarchive/_universalarchive\E$
^\Qplugins/vagrant/vagrant.plugin.zsh\E$
^\Qplugins/wp-cli/README.md\E$
^\Qplugins/wp-cli/wp-cli.plugin.zsh\E$
^\Qthemes/clean.zsh-theme\E$
^\Qthemes/philips.zsh-theme\E$
^\Qthemes/tonotdo.zsh-theme\E$

File diff suppressed because it is too large Load Diff

View File

@ -1,73 +0,0 @@
# See https://github.com/check-spelling/check-spelling/wiki/Configuration-Examples:-patterns
# YouTube
https?://(?:(?:www\.|)youtube\.com|youtu.be)/(?:channel/|embed/|playlist\?list=|watch\?v=|v/|)[-a-zA-Z0-9?&=_]*
<\s*youtube\s+id=['"][-a-zA-Z0-9?_]*['"]
\bimg\.youtube\.com/vi/[-a-zA-Z0-9?&=_]*
# Google Analytics
\bgoogle-analytics\.com/collect.[-0-9a-zA-Z?%=&_.~]*
# Google APIs
\bgoogleapis\.com/[a-z]+/v\d+/[a-z]+/[@./?=\w]+
\b[-a-zA-Z0-9.]*\bstorage\d*\.googleapis\.com(?:/\S*|)
# Google Calendar
\bcalendar\.google\.com/calendar(?:/u/\d+|)/embed\?src=[@./?=\w&%]+
\w+\@group\.calendar\.google\.com\b
# Google DataStudio
\bdatastudio\.google\.com/(?:(?:c/|)u/\d+/|)(?:embed/|)(?:open|reporting|datasources|s)/[-0-9a-zA-Z]+(?:/page/[-0-9a-zA-Z]+|)
# The leading `/` here is as opposed to the `\b` above
# ... a short way to match `https://` or `http://` since most urls have one of those prefixes
# Google Docs
/docs\.google\.com/[a-z]+/d/(?:e/|)[0-9a-zA-Z_-]+/?
# Google Drive
\bdrive\.google\.com/file/d/[0-9a-zA-Z_?=]*
# Google Groups
\bgroups\.google\.com/(?:forum/#!|d/)(?:msg|topic)/[^/]+/[a-zA-Z0-9]+(?:/[a-zA-Z0-9]+|)
# Google themes
themes\.googleusercontent\.com/static/fonts/[^/]+/v\d+/[^.]+.
# Google CDN
\bclients2\.google(?:usercontent|)\.com[-0-9a-zA-Z/.]*
# Goo.gl
/goo\.gl/[a-zA-Z0-9]+
# Google Chrome Store
\bchrome\.google\.com/webstore/detail/\w*(?:/\w*|)
# Google Books
\bbooks\.google\.(?:\w{2,4})/books\?[-\w\d=&#.]*
# Google Fonts
\bfonts\.(?:googleapis|gstatic)\.com/[-/?=:;+&0-9a-zA-Z]*
# GitHub SHAs
\bapi.github\.com/repos/[^/]+/[^/]+/[^/]+/[0-9a-f]+\b
(?:\[[0-9a-f]+\]\(https:/|)/(?:www\.|)github\.com/[^/]+/[^/]+(?:/[^/]+/[0-9a-f]+(?:[-0-9a-zA-Z/#.]*|)\b|)
\bgithub\.com/[^/]+/[^/]+[@#][0-9a-f]+\b
# githubusercontent
/[-a-z0-9]+\.githubusercontent\.com/[-a-zA-Z0-9?&=_\/.]*
# gist github
/gist\.github\.com/[^/]+/[0-9a-f]+
# git.io
\bgit\.io/[0-9a-zA-Z]+
# GitHub JSON
"node_id": "[-a-zA-Z=;:/0-9+]*"
# Contributor
\[[^\]]+]\(https://github\.com/[^/]+\)
# GHSA
GHSA(?:-[0-9a-z]{4}){3}
LS_COLORS=(["']).*?\g{-1}
(\\?)%[a-zA-Z]+\g{-1}(?!%)
# URL escaped characters
\%[0-9A-F]{2}
# hex digits including css/html color classes:
(?:[\\0][xX]|\\u|[uU]\+|#x?|\%23)[0-9a-fA-FgGrR_]{2,}(?:[uU]?[lL]{0,2}|u\d+)\b
# https://www.gnu.org/software/groff/manual/groff.html
# man troff content
\\f[BCIPR]
# Compiler flags
[\t "'`=]-[LPWXY]
[\t "'`=]-D(?!ebian)
# ignore long runs of a single character:
\b([A-Za-z])\g{-1}{3,}\b

View File

@ -1,7 +0,0 @@
^attache$
benefitting
occurence
Sorce
^[Ss]pae
^untill
^wether

View File

@ -10,6 +10,10 @@ on:
branches: branches:
- master - master
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs: jobs:
tests: tests:
name: Run tests name: Run tests

View File

@ -1,9 +1,13 @@
name: Project tracking name: Project tracking
on: on:
issues: issues:
types: [opened] types: [opened, reopened]
pull_request_target: pull_request_target:
types: [opened, synchronize] types: [opened, reopened, synchronize]
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs: jobs:
add-to-project: add-to-project:

View File

@ -47,7 +47,7 @@ It should include the data gathered as indicated above, along with:
2. What the correct behavior should be 2. What the correct behavior should be
3. What the actual behavior is 3. What the actual behavior is
Please copy to anyone relevant (_eg_ plugin maintainers) by mentioning their GitHub handle Please copy to anyone relevant (e.g. plugin maintainers) by mentioning their GitHub handle
(starting with `@`) in your message. (starting with `@`) in your message.
We will do our very best to help you. We will do our very best to help you.
@ -59,7 +59,7 @@ your suggestion.
If you find one, comment on it so we can know there are more people supporting it. If you find one, comment on it so we can know there are more people supporting it.
If not, you can go ahead and create an issue. Please copy to anyone relevant (_eg_ plugin If not, you can go ahead and create an issue. Please copy to anyone relevant (e.g. plugin
maintainers) by mentioning their GitHub handle (starting with `@`) in your message. maintainers) by mentioning their GitHub handle (starting with `@`) in your message.
## Submitting Pull Requests ## Submitting Pull Requests
@ -99,10 +99,10 @@ covering or related to what you want to add.
If you find one, try it out and work with the author on a common solution. If you find one, try it out and work with the author on a common solution.
If not, then go ahead and submit a PR. Please copy to anyone relevant (_eg_ plugin If not, then go ahead and submit a PR. Please copy to anyone relevant (e.g. plugin
maintainers) by mentioning their GitHub handle (starting with `@`) in your message. maintainers) by mentioning their GitHub handle (starting with `@`) in your message.
For any extensive change, _eg_ a new plugin, you will have to find testers to +1 your PR. For any extensive change, such as a new plugin, you will have to find testers to +1 your PR.
---- ----

View File

@ -1,6 +1,6 @@
MIT License MIT License
Copyright (c) 2009-2021 Robby Russell and contributors (https://github.com/ohmyzsh/ohmyzsh/contributors) Copyright (c) 2009-2022 Robby Russell and contributors (https://github.com/ohmyzsh/ohmyzsh/contributors)
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal

View File

@ -1,4 +1,4 @@
<p align="center"><img src="https://s3.amazonaws.com/ohmyzsh/oh-my-zsh-logo.png" alt="Oh My Zsh"></p> <p align="center"><img src="https://ohmyzsh.s3.amazonaws.com/omz-ansi-github.png" alt="Oh My Zsh"></p>
Oh My Zsh is an open source, community-driven framework for managing your [zsh](https://www.zsh.org/) configuration. Oh My Zsh is an open source, community-driven framework for managing your [zsh](https://www.zsh.org/) configuration.
@ -18,6 +18,41 @@ To learn more, visit [ohmyz.sh](https://ohmyz.sh), follow [@ohmyzsh](https://twi
[![Gitpod ready](https://img.shields.io/badge/Gitpod-ready-blue?logo=gitpod)](https://gitpod.io/#https://github.com/ohmyzsh/ohmyzsh) [![Gitpod ready](https://img.shields.io/badge/Gitpod-ready-blue?logo=gitpod)](https://gitpod.io/#https://github.com/ohmyzsh/ohmyzsh)
[![huntr.dev](https://cdn.huntr.dev/huntr_security_badge_mono.svg)](https://huntr.dev/bounties/disclose/?utm_campaign=ohmyzsh%2Fohmyzsh&utm_medium=social&utm_source=github&target=https%3A%2F%2Fgithub.com%2Fohmyzsh%2Fohmyzsh) [![huntr.dev](https://cdn.huntr.dev/huntr_security_badge_mono.svg)](https://huntr.dev/bounties/disclose/?utm_campaign=ohmyzsh%2Fohmyzsh&utm_medium=social&utm_source=github&target=https%3A%2F%2Fgithub.com%2Fohmyzsh%2Fohmyzsh)
<details>
<summary>Table of Contents</summary>
- [Getting Started](#getting-started)
- [Prerequisites](#prerequisites)
- [Basic Installation](#basic-installation)
- [Manual inspection](#manual-inspection)
- [Using Oh My Zsh](#using-oh-my-zsh)
- [Plugins](#plugins)
- [Enabling Plugins](#enabling-plugins)
- [Using Plugins](#using-plugins)
- [Themes](#themes)
- [Selecting a Theme](#selecting-a-theme)
- [FAQ](#faq)
- [Advanced Topics](#advanced-topics)
- [Advanced Installation](#advanced-installation)
- [Custom Directory](#custom-directory)
- [Unattended install](#unattended-install)
- [Installing from a forked repository](#installing-from-a-forked-repository)
- [Manual Installation](#manual-installation)
- [Installation Problems](#installation-problems)
- [Custom Plugins and Themes](#custom-plugins-and-themes)
- [Getting Updates](#getting-updates)
- [Manual Updates](#manual-updates)
- [Uninstalling Oh My Zsh](#uninstalling-oh-my-zsh)
- [How do I contribute to Oh My Zsh?](#how-do-i-contribute-to-oh-my-zsh)
- [Do NOT send us themes](#do-not-send-us-themes)
- [Contributors](#contributors)
- [Follow Us](#follow-us)
- [Merchandise](#merchandise)
- [License](#license)
- [About Planet Argon](#about-planet-argon)
</details>
## Getting Started ## Getting Started
### Prerequisites ### Prerequisites
@ -32,12 +67,12 @@ To learn more, visit [ohmyz.sh](https://ohmyz.sh), follow [@ohmyzsh](https://twi
Oh My Zsh is installed by running one of the following commands in your terminal. You can install this via the command-line with either `curl`, `wget` or another similar tool. Oh My Zsh is installed by running one of the following commands in your terminal. You can install this via the command-line with either `curl`, `wget` or another similar tool.
| Method | Command | | Method | Command |
|:----------|:--------------------------------------------------------------------------------------------------| | :-------- | :------------------------------------------------------------------------------------------------ |
| **curl** | `sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"` | | **curl** | `sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"` |
| **wget** | `sh -c "$(wget -O- https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"` | | **wget** | `sh -c "$(wget -O- https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"` |
| **fetch** | `sh -c "$(fetch -o - https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"` | | **fetch** | `sh -c "$(fetch -o - https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"` |
_Note that previous configuration in `.zshrc` will be placed in `.pre-oh-my-zsh`. After installation you can move configuration you want to preserve into `.zshrc`._ _Note that any previous `.zshrc` will be renamed to `.zshrc.pre-oh-my-zsh`. After installation, you can move the configuration you want to preserve into the new `.zshrc`._
#### Manual inspection #### Manual inspection
@ -82,7 +117,7 @@ _Note that the plugins are separated by whitespace (spaces, tabs, new lines...).
#### Using Plugins #### Using Plugins
Each plugin includes a __README__, documenting it. This README should show the aliases (if the plugin adds any) and extra goodies that are included in that particular plugin. Each built-in plugin includes a **README**, documenting it. This README should show the aliases (if the plugin adds any) and extra goodies that are included in that particular plugin.
### Themes ### Themes
@ -105,7 +140,7 @@ ZSH_THEME="agnoster" # (this is one of the fancy ones)
# see https://github.com/ohmyzsh/ohmyzsh/wiki/Themes#agnoster # see https://github.com/ohmyzsh/ohmyzsh/wiki/Themes#agnoster
``` ```
_Note: many themes require installing the [Powerline Fonts](https://github.com/powerline/fonts) in order to render properly._ _Note: many themes require installing a [Powerline Font](https://github.com/powerline/fonts) or a [Nerd Font](https://github.com/ryanoasis/nerd-fonts) in order to render properly. Without them, these themes will render [weird prompt symbols](https://github.com/ohmyzsh/ohmyzsh/wiki/FAQ#i-have-a-weird-character-in-my-prompt)_
Open up a new terminal window and your prompt should look something like this: Open up a new terminal window and your prompt should look something like this:
@ -161,9 +196,9 @@ ZSH="$HOME/.dotfiles/oh-my-zsh" sh install.sh
#### Unattended install #### Unattended install
If you're running the Oh My Zsh install script as part of an automated install, you can pass the If you're running the Oh My Zsh install script as part of an automated install, you can pass the `--unattended`
flag `--unattended` to the `install.sh` script. This will have the effect of not trying to change flag to the `install.sh` script. This will have the effect of not trying to change
the default shell, and also won't run `zsh` when the installation has finished. the default shell, and it also won't run `zsh` when the installation has finished.
```sh ```sh
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" "" --unattended sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" "" --unattended
@ -194,19 +229,19 @@ REPO=apjanke/oh-my-zsh BRANCH=edge sh install.sh
#### Manual Installation #### Manual Installation
##### 1. Clone the repository ##### 1. Clone the repository <!-- omit in toc -->
```sh ```sh
git clone https://github.com/ohmyzsh/ohmyzsh.git ~/.oh-my-zsh git clone https://github.com/ohmyzsh/ohmyzsh.git ~/.oh-my-zsh
``` ```
##### 2. *Optionally*, backup your existing `~/.zshrc` file ##### 2. _Optionally_, backup your existing `~/.zshrc` file <!-- omit in toc -->
```sh ```sh
cp ~/.zshrc ~/.zshrc.orig cp ~/.zshrc ~/.zshrc.orig
``` ```
##### 3. Create a new zsh configuration file ##### 3. Create a new zsh configuration file <!-- omit in toc -->
You can create a new zsh config file by copying the template that we have included for you. You can create a new zsh config file by copying the template that we have included for you.
@ -214,7 +249,7 @@ You can create a new zsh config file by copying the template that we have includ
cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc
``` ```
##### 4. Change your default shell ##### 4. Change your default shell <!-- omit in toc -->
```sh ```sh
chsh -s $(which zsh) chsh -s $(which zsh)
@ -222,7 +257,7 @@ chsh -s $(which zsh)
You must log out from your user session and log back in to see this change. You must log out from your user session and log back in to see this change.
##### 5. Initialize your new zsh configuration ##### 5. Initialize your new zsh configuration <!-- omit in toc -->
Once you open up a new terminal window, it should load zsh with Oh My Zsh's configuration. Once you open up a new terminal window, it should load zsh with Oh My Zsh's configuration.
@ -230,10 +265,8 @@ Once you open up a new terminal window, it should load zsh with Oh My Zsh's conf
If you have any hiccups installing, here are a few common fixes. If you have any hiccups installing, here are a few common fixes.
- You _might_ need to modify your `PATH` in `~/.zshrc` if you're not able to find some commands after - You _might_ need to modify your `PATH` in `~/.zshrc` if you're not able to find some commands after switching to `oh-my-zsh`.
switching to `oh-my-zsh`. - If you installed manually or changed the install location, check the `ZSH` environment variable in `~/.zshrc`.
- If you installed manually or changed the install location, check the `ZSH` environment variable in
`~/.zshrc`.
### Custom Plugins and Themes ### Custom Plugins and Themes
@ -296,7 +329,7 @@ Before you participate in our delightful community, please read the [code of con
I'm far from being a [Zsh](https://www.zsh.org/) expert and suspect there are many ways to improve if you have ideas on how to make the configuration easier to maintain (and faster), don't hesitate to fork and send pull requests! I'm far from being a [Zsh](https://www.zsh.org/) expert and suspect there are many ways to improve if you have ideas on how to make the configuration easier to maintain (and faster), don't hesitate to fork and send pull requests!
We also need people to test out pull-requests. So take a look through [the open issues](https://github.com/ohmyzsh/ohmyzsh/issues) and help where you can. We also need people to test out pull requests. So take a look through [the open issues](https://github.com/ohmyzsh/ohmyzsh/issues) and help where you can.
See [Contributing](CONTRIBUTING.md) for more details. See [Contributing](CONTRIBUTING.md) for more details.

View File

@ -105,7 +105,10 @@ function _omz {
return 0 return 0
} }
compdef _omz omz # If run from a script, do not set the completion function
if (( ${+functions[compdef]} )); then
compdef _omz omz
fi
## Utility functions ## Utility functions
@ -299,10 +302,8 @@ multi == 1 && length(\$0) > 0 {
# Restart the zsh session if there were no errors # Restart the zsh session if there were no errors
_omz::log info "plugins disabled: ${(j:, :)dis_plugins}." _omz::log info "plugins disabled: ${(j:, :)dis_plugins}."
# Old zsh versions don't have ZSH_ARGZERO # Only reload zsh if run in an interactive session
local zsh="${ZSH_ARGZERO:-${functrace[-1]%:*}}" [[ ! -o interactive ]] || _omz::reload
# Check whether to run a login shell
[[ "$zsh" = -* || -o login ]] && exec -l "${zsh#-}" || exec "$zsh"
} }
function _omz::plugin::enable { function _omz::plugin::enable {
@ -375,10 +376,8 @@ multi == 1 && /^[^#]*\)/ {
# Restart the zsh session if there were no errors # Restart the zsh session if there were no errors
_omz::log info "plugins enabled: ${(j:, :)add_plugins}." _omz::log info "plugins enabled: ${(j:, :)add_plugins}."
# Old zsh versions don't have ZSH_ARGZERO # Only reload zsh if run in an interactive session
local zsh="${ZSH_ARGZERO:-${functrace[-1]%:*}}" [[ ! -o interactive ]] || _omz::reload
# Check whether to run a login shell
[[ "$zsh" = -* || -o login ]] && exec -l "${zsh#-}" || exec "$zsh"
} }
function _omz::plugin::info { function _omz::plugin::info {
@ -574,12 +573,27 @@ function _omz::pr::test {
# Rebase pull request branch against the current master # Rebase pull request branch against the current master
_omz::log info "rebasing PR #$1..." _omz::log info "rebasing PR #$1..."
command git rebase master ohmyzsh/pull-$1 || { local ret gpgsign
command git rebase --abort &>/dev/null {
_omz::log warn "could not rebase PR #$1 on top of master." # Back up commit.gpgsign setting: use --local to get the current repository
_omz::log warn "you might not see the latest stable changes." # setting, not the global one. If --local is not a known option, it will
_omz::log info "run \`zsh\` to test the changes." # exit with a 129 status code.
return 1 gpgsign=$(command git config --local commit.gpgsign 2>/dev/null) || ret=$?
[[ $ret -ne 129 ]] || gpgsign=$(command git config commit.gpgsign 2>/dev/null)
command git config commit.gpgsign false
command git rebase master ohmyzsh/pull-$1 || {
command git rebase --abort &>/dev/null
_omz::log warn "could not rebase PR #$1 on top of master."
_omz::log warn "you might not see the latest stable changes."
_omz::log info "run \`zsh\` to test the changes."
return 1
}
} always {
case "$gpgsign" in
"") command git config --unset commit.gpgsign ;;
*) command git config commit.gpgsign "$gpgsign" ;;
esac
} }
_omz::log info "fetch of PR #${1} successful." _omz::log info "fetch of PR #${1} successful."
@ -731,10 +745,8 @@ EOF
# Restart the zsh session if there were no errors # Restart the zsh session if there were no errors
_omz::log info "'$1' theme set correctly." _omz::log info "'$1' theme set correctly."
# Old zsh versions don't have ZSH_ARGZERO # Only reload zsh if run in an interactive session
local zsh="${ZSH_ARGZERO:-${functrace[-1]%:*}}" [[ ! -o interactive ]] || _omz::reload
# Check whether to run a login shell
[[ "$zsh" = -* || -o login ]] && exec -l "${zsh#-}" || exec "$zsh"
} }
function _omz::theme::use { function _omz::theme::use {

View File

@ -17,7 +17,7 @@ function title {
: ${2=$1} : ${2=$1}
case "$TERM" in case "$TERM" in
cygwin|xterm*|putty*|rxvt*|konsole*|ansi|mlterm*|alacritty|st*) cygwin|xterm*|putty*|rxvt*|konsole*|ansi|mlterm*|alacritty|st*|foot)
print -Pn "\e]2;${2:q}\a" # set window name print -Pn "\e]2;${2:q}\a" # set window name
print -Pn "\e]1;${1:q}\a" # set tab name print -Pn "\e]1;${1:q}\a" # set tab name
;; ;;

53
zsh/lib/vcs_info.zsh Normal file
View File

@ -0,0 +1,53 @@
# Don't skip this file until a Zsh release does the necessary quoting.
# This is because even though 5.8.1 undid recursive prompt_subst inside
# prompt sequences, % characters in relevant fields will still be rendered
# incorrectly in vcs_info, on all Zsh releases up to writing this.
#
# There is no release yet that does this right, since it requires changing
# how what vcs_info hooks expect to receive. Even so, I'd rather be correct
# and break custom vcs_info hooks than have a broken prompt.
# Quote necessary $hook_com[<field>] items just before they are used
# in the line "VCS_INFO_hook 'post-backend'" of the VCS_INFO_formats
# function, where <field> is:
#
# base: the full path of the repository's root directory.
# base-name: the name of the repository's root directory.
# branch: the name of the currently checked out branch.
# misc: a string that may contain anything the vcs_info backend wants.
# revision: an identifier of the currently checked out revision.
# subdir: the path of the current directory relative to the
# repository's root directory.
#
# This patch %-quotes these fields previous to their use in vcs_info hooks and
# the zformat call and, eventually, when they get expanded in the prompt.
# It's important to quote these here, and not later after hooks have modified the
# fields, because then we could be quoting % characters from valid prompt sequences,
# like %F{color}, %B, etc.
#
# 32 │ hook_com[subdir]="$(VCS_INFO_reposub ${hook_com[base]})"
# 33 │ hook_com[subdir_orig]="${hook_com[subdir]}"
# 34 │
# 35 + │ for tmp in base base-name branch misc revision subdir; do
# 36 + │ hook_com[$tmp]="${hook_com[$tmp]//\%/%%}"
# 37 + │ done
# 38 + │
# 39 │ VCS_INFO_hook 'post-backend'
#
# This is especially important so that no command substitution is performed
# due to malicious input as a consequence of CVE-2021-45444, which affects
# zsh versions from 5.0.3 to 5.8.
#
autoload -Uz +X regexp-replace VCS_INFO_formats 2>/dev/null || return
# We use $tmp here because it's already a local variable in VCS_INFO_formats
typeset PATCH='for tmp (base base-name branch misc revision subdir) hook_com[$tmp]="${hook_com[$tmp]//\%/%%}"'
# Unique string to avoid reapplying the patch if this code gets called twice
typeset PATCH_ID=vcs_info-patch-9b9840f2-91e5-4471-af84-9e9a0dc68c1b
# Only patch the VCS_INFO_formats function if not already patched
if [[ "$functions[VCS_INFO_formats]" != *$PATCH_ID* ]]; then
regexp-replace 'functions[VCS_INFO_formats]' \
"VCS_INFO_hook 'post-backend'" \
': ${PATCH_ID}; ${PATCH}; ${MATCH}'
fi
unset PATCH PATCH_ID

View File

@ -57,14 +57,14 @@ mkdir -p "$ZSH_CACHE_DIR/completions"
(( ${fpath[(Ie)"$ZSH_CACHE_DIR/completions"]} )) || fpath=("$ZSH_CACHE_DIR/completions" $fpath) (( ${fpath[(Ie)"$ZSH_CACHE_DIR/completions"]} )) || fpath=("$ZSH_CACHE_DIR/completions" $fpath)
# Check for updates on initial load... # Check for updates on initial load...
if [ "$DISABLE_AUTO_UPDATE" != "true" ]; then if [[ "$DISABLE_AUTO_UPDATE" != true ]]; then
source $ZSH/tools/check_for_upgrade.sh source "$ZSH/tools/check_for_upgrade.sh"
fi fi
# Initializes Oh My Zsh # Initializes Oh My Zsh
# add a function path # add a function path
fpath=($ZSH/functions $ZSH/completions $fpath) fpath=("$ZSH/functions" "$ZSH/completions" $fpath)
# Load all stock functions (from $fpath files) called below. # Load all stock functions (from $fpath files) called below.
autoload -U compaudit compinit autoload -U compaudit compinit
@ -75,7 +75,6 @@ if [[ -z "$ZSH_CUSTOM" ]]; then
ZSH_CUSTOM="$ZSH/custom" ZSH_CUSTOM="$ZSH/custom"
fi fi
is_plugin() { is_plugin() {
local base_dir=$1 local base_dir=$1
local name=$2 local name=$2
@ -86,10 +85,10 @@ is_plugin() {
# Add all defined plugins to fpath. This must be done # Add all defined plugins to fpath. This must be done
# before running compinit. # before running compinit.
for plugin ($plugins); do for plugin ($plugins); do
if is_plugin $ZSH_CUSTOM $plugin; then if is_plugin "$ZSH_CUSTOM" "$plugin"; then
fpath=($ZSH_CUSTOM/plugins/$plugin $fpath) fpath=("$ZSH_CUSTOM/plugins/$plugin" $fpath)
elif is_plugin $ZSH $plugin; then elif is_plugin "$ZSH" "$plugin"; then
fpath=($ZSH/plugins/$plugin $fpath) fpath=("$ZSH/plugins/$plugin" $fpath)
else else
echo "[oh-my-zsh] plugin '$plugin' not found" echo "[oh-my-zsh] plugin '$plugin' not found"
fi fi
@ -98,14 +97,14 @@ done
# Figure out the SHORT hostname # Figure out the SHORT hostname
if [[ "$OSTYPE" = darwin* ]]; then if [[ "$OSTYPE" = darwin* ]]; then
# macOS's $HOST changes with dhcp, etc. Use ComputerName if possible. # macOS's $HOST changes with dhcp, etc. Use ComputerName if possible.
SHORT_HOST=$(scutil --get ComputerName 2>/dev/null) || SHORT_HOST=${HOST/.*/} SHORT_HOST=$(scutil --get ComputerName 2>/dev/null) || SHORT_HOST="${HOST/.*/}"
else else
SHORT_HOST=${HOST/.*/} SHORT_HOST="${HOST/.*/}"
fi fi
# Save the location of the current completion dump file. # Save the location of the current completion dump file.
if [ -z "$ZSH_COMPDUMP" ]; then if [[ -z "$ZSH_COMPDUMP" ]]; then
ZSH_COMPDUMP="${ZDOTDIR:-${HOME}}/.zcompdump-${SHORT_HOST}-${ZSH_VERSION}" ZSH_COMPDUMP="${ZDOTDIR:-$HOME}/.zcompdump-${SHORT_HOST}-${ZSH_VERSION}"
fi fi
# Construct zcompdump OMZ metadata # Construct zcompdump OMZ metadata
@ -119,19 +118,20 @@ if ! command grep -q -Fx "$zcompdump_revision" "$ZSH_COMPDUMP" 2>/dev/null \
zcompdump_refresh=1 zcompdump_refresh=1
fi fi
if [[ $ZSH_DISABLE_COMPFIX != true ]]; then if [[ "$ZSH_DISABLE_COMPFIX" != true ]]; then
source $ZSH/lib/compfix.zsh source "$ZSH/lib/compfix.zsh"
# If completion insecurities exist, warn the user
handle_completion_insecurities
# Load only from secure directories # Load only from secure directories
compinit -i -C -d "${ZSH_COMPDUMP}" compinit -i -d "$ZSH_COMPDUMP"
# If completion insecurities exist, warn the user
handle_completion_insecurities &|
else else
# If the user wants it, load from all found directories # If the user wants it, load from all found directories
compinit -u -C -d "${ZSH_COMPDUMP}" compinit -u -d "$ZSH_COMPDUMP"
fi fi
# Append zcompdump metadata if missing # Append zcompdump metadata if missing
if (( $zcompdump_refresh )); then if (( $zcompdump_refresh )) \
|| ! command grep -q -Fx "$zcompdump_revision" "$ZSH_COMPDUMP" 2>/dev/null; then
# Use `tee` in case the $ZSH_COMPDUMP filename is invalid, to silence the error # Use `tee` in case the $ZSH_COMPDUMP filename is invalid, to silence the error
# See https://github.com/ohmyzsh/ohmyzsh/commit/dd1a7269#commitcomment-39003489 # See https://github.com/ohmyzsh/ohmyzsh/commit/dd1a7269#commitcomment-39003489
tee -a "$ZSH_COMPDUMP" &>/dev/null <<EOF tee -a "$ZSH_COMPDUMP" &>/dev/null <<EOF
@ -140,40 +140,48 @@ $zcompdump_revision
$zcompdump_fpath $zcompdump_fpath
EOF EOF
fi fi
unset zcompdump_revision zcompdump_fpath zcompdump_refresh unset zcompdump_revision zcompdump_fpath zcompdump_refresh
# Load all of the config files in ~/oh-my-zsh that end in .zsh # Load all of the config files in ~/oh-my-zsh that end in .zsh
# TIP: Add files you don't want in git to .gitignore # TIP: Add files you don't want in git to .gitignore
for config_file ($ZSH/lib/*.zsh); do for config_file ("$ZSH"/lib/*.zsh); do
custom_config_file="${ZSH_CUSTOM}/lib/${config_file:t}" custom_config_file="$ZSH_CUSTOM/lib/${config_file:t}"
[ -f "${custom_config_file}" ] && config_file=${custom_config_file} [[ -f "$custom_config_file" ]] && config_file="$custom_config_file"
source $config_file source "$config_file"
done done
unset custom_config_file
# Load all of the plugins that were defined in ~/.zshrc # Load all of the plugins that were defined in ~/.zshrc
for plugin ($plugins); do for plugin ($plugins); do
if [ -f $ZSH_CUSTOM/plugins/$plugin/$plugin.plugin.zsh ]; then if [[ -f "$ZSH_CUSTOM/plugins/$plugin/$plugin.plugin.zsh" ]]; then
source $ZSH_CUSTOM/plugins/$plugin/$plugin.plugin.zsh source "$ZSH_CUSTOM/plugins/$plugin/$plugin.plugin.zsh"
elif [ -f $ZSH/plugins/$plugin/$plugin.plugin.zsh ]; then elif [[ -f "$ZSH/plugins/$plugin/$plugin.plugin.zsh" ]]; then
source $ZSH/plugins/$plugin/$plugin.plugin.zsh source "$ZSH/plugins/$plugin/$plugin.plugin.zsh"
fi fi
done done
unset plugin
# Load all of your custom configurations from custom/ # Load all of your custom configurations from custom/
for config_file ($ZSH_CUSTOM/*.zsh(N)); do for config_file ("$ZSH_CUSTOM"/*.zsh(N)); do
source $config_file source "$config_file"
done done
unset config_file unset config_file
# Load the theme # Load the theme
if [ ! "$ZSH_THEME" = "" ]; then is_theme() {
if [ -f "$ZSH_CUSTOM/$ZSH_THEME.zsh-theme" ]; then local base_dir=$1
local name=$2
builtin test -f $base_dir/$name.zsh-theme
}
if [[ -n "$ZSH_THEME" ]]; then
if is_theme "$ZSH_CUSTOM" "$ZSH_THEME"; then
source "$ZSH_CUSTOM/$ZSH_THEME.zsh-theme" source "$ZSH_CUSTOM/$ZSH_THEME.zsh-theme"
elif [ -f "$ZSH_CUSTOM/themes/$ZSH_THEME.zsh-theme" ]; then elif is_theme "$ZSH_CUSTOM/themes" "$ZSH_THEME"; then
source "$ZSH_CUSTOM/themes/$ZSH_THEME.zsh-theme" source "$ZSH_CUSTOM/themes/$ZSH_THEME.zsh-theme"
else elif is_theme "$ZSH/themes" "$ZSH_THEME"; then
source "$ZSH/themes/$ZSH_THEME.zsh-theme" source "$ZSH/themes/$ZSH_THEME.zsh-theme"
else
echo "[oh-my-zsh] theme '$ZSH_THEME' not found"
fi fi
fi fi

View File

@ -1,46 +1,9 @@
if (( ${+commands[op]} )); then # Do nothing if op is not installed
eval "$(op completion zsh)" (( ${+commands[op]} )) || return
compdef _op op
fi
# opswd puts the password of the named service into the clipboard. If there's a # Load op completion
# one time password, it will be copied into the clipboard after 5 seconds. The eval "$(op completion zsh)"
# clipboard is cleared after another 10 seconds. compdef _op op
function opswd() {
if [[ $# -lt 1 ]]; then
echo "Usage: opswd <service>"
return 1
fi
local service=$1 # Load opswd function
autoload -Uz opswd
# If not logged in, print error and return
op list users > /dev/null || return
local password
# Copy the password to the clipboard
if ! password=$(op get item "$service" --fields password 2>/dev/null); then
echo "error: could not obtain password for $service"
return 1
fi
echo -n "$password" | clipcopy
echo "✔ password for $service copied to clipboard"
# If there's a one time password, copy it to the clipboard after 5 seconds
local totp
if totp=$(op get totp "$service" 2>/dev/null) && [[ -n "$totp" ]]; then
sleep 10 && echo -n "$totp" | clipcopy
echo "✔ TOTP for $service copied to clipboard"
fi
(sleep 20 && clipcopy </dev/null 2>/dev/null) &!
}
function _opswd() {
local -a services
services=("${(@f)$(op list items --categories Login 2>/dev/null | op get item - --fields title 2>/dev/null)}")
[[ -z "$services" ]] || compadd -a -- services
}
compdef _opswd opswd

View File

@ -25,11 +25,14 @@ which service you want to get.
For example, `opswd github.com` will put your GitHub password into your clipboard, and if For example, `opswd github.com` will put your GitHub password into your clipboard, and if
a TOTP is available, it will be copied to the clipboard after 10 seconds. a TOTP is available, it will be copied to the clipboard after 10 seconds.
> NOTE: you need to be logged in for `opswd` to work. See: > NOTE: you need to be signed in for `opswd` to work. If you are using biometric unlock,
> 1Password CLI will automatically prompt you to sign in. See:
> >
> - [Sign in or out](https://support.1password.com/command-line/#sign-in-or-out) > - [Get started with 1Password CLI 2: Sign in](https://developer.1password.com/docs/cli/get-started#sign-in)
> - [Session management](https://support.1password.com/command-line/#appendix-session-management) > - [Sign in to your 1Password account manually](https://developer.1password.com/docs/cli/sign-in-manually)
## Requirements ## Requirements
- [1Password's command line utility](https://1password.com/downloads/command-line/). - [1Password CLI 2](https://developer.1password.com/docs/cli/get-started#install)
> NOTE: if you're using 1Password CLI 1, [see how to upgrade to CLI 2](https://developer.1password.com/docs/cli/upgrade).

View File

@ -0,0 +1,19 @@
#compdef opswd
function _opswd() {
local -a services
services=("${(@f)$(op item list --categories Login --cache 2>/dev/null | awk 'NR != 1 { print $2 }')}")
[[ -z "$services" ]] || compadd -a -- services
}
# TODO: 2022-03-26: Remove support for op CLI 1
autoload -Uz is-at-least
is-at-least 2.0.0 $(op --version) || {
function _opswd() {
local -a services
services=("${(@f)$(op list items --categories Login 2>/dev/null | op get item - --fields title 2>/dev/null)}")
[[ -z "$services" ]] || compadd -a -- services
}
}
_opswd "$@"

View File

@ -0,0 +1,78 @@
#autoload
# opswd puts the password of the named service into the clipboard. If there's a
# one time password, it will be copied into the clipboard after 10 seconds. The
# clipboard is cleared after another 20 seconds.
function opswd() {
if [[ $# -lt 1 ]]; then
echo "Usage: opswd <service>"
return 1
fi
local service=$1
# If not logged in, print error and return
op user list > /dev/null || return
local password
# Copy the password to the clipboard
if ! password=$(op item get "$service" --fields password 2>/dev/null); then
echo "error: could not obtain password for $service"
return 1
fi
echo -n "$password" | clipcopy
echo "✔ password for $service copied to clipboard"
# If there's a one time password, copy it to the clipboard after 10 seconds
local totp
if totp=$(op item get --otp "$service" 2>/dev/null) && [[ -n "$totp" ]]; then
sleep 10 && echo -n "$totp" | clipcopy
echo "✔ TOTP for $service copied to clipboard"
fi
(sleep 20 && clipcopy </dev/null 2>/dev/null) &!
}
# TODO: 2022-03-26: Remove support for op CLI 1
autoload -Uz is-at-least
is-at-least 2.0.0 $(op --version) || {
print -ru2 ${(%):-"%F{yellow}opswd: usage with op version $(op --version) is deprecated. Upgrade to CLI 2 and reload zsh.
For instructions, see https://developer.1password.com/docs/cli/upgrade.%f"}
# opswd puts the password of the named service into the clipboard. If there's a
# one time password, it will be copied into the clipboard after 10 seconds. The
# clipboard is cleared after another 20 seconds.
function opswd() {
if [[ $# -lt 1 ]]; then
echo "Usage: opswd <service>"
return 1
fi
local service=$1
# If not logged in, print error and return
op list users > /dev/null || return
local password
# Copy the password to the clipboard
if ! password=$(op get item "$service" --fields password 2>/dev/null); then
echo "error: could not obtain password for $service"
return 1
fi
echo -n "$password" | clipcopy
echo "✔ password for $service copied to clipboard"
# If there's a one time password, copy it to the clipboard after 5 seconds
local totp
if totp=$(op get totp "$service" 2>/dev/null) && [[ -n "$totp" ]]; then
sleep 10 && echo -n "$totp" | clipcopy
echo "✔ TOTP for $service copied to clipboard"
fi
(sleep 20 && clipcopy </dev/null 2>/dev/null) &!
}
}
opswd "$@"

View File

@ -3,9 +3,9 @@
# - acs: alias cheatsheet # - acs: alias cheatsheet
# group alias by command, pass addition argv to grep. # group alias by command, pass addition argv to grep.
function acs(){ function acs(){
(( $+commands[python] )) || { (( $+commands[python3] )) || {
echo "[error] No python executable detected" echo "[error] No python executable detected"
return return
} }
alias | python ${functions_source[$0]:h}/cheatsheet.py $@ alias | python3 ${functions_source[$0]:h}/cheatsheet.py $@
} }

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python #!/usr/bin/env python3
import sys import sys
import itertools import itertools
import termcolor import termcolor

View File

@ -13,6 +13,7 @@ if ! type autoenv_init >/dev/null; then
~/.autoenv ~/.autoenv
~/.local/bin ~/.local/bin
/usr/local/opt/autoenv /usr/local/opt/autoenv
/opt/homebrew/opt/autoenv
/usr/local/bin /usr/local/bin
/usr/share/autoenv-git /usr/share/autoenv-git
~/Library/Python/bin ~/Library/Python/bin

View File

@ -158,7 +158,7 @@ compctl -K _aws_profiles asp acp aws_change_access_key
# AWS prompt # AWS prompt
function aws_prompt_info() { function aws_prompt_info() {
[[ -n "$AWS_PROFILE" ]] || return [[ -n "$AWS_PROFILE" ]] || return
echo "${ZSH_THEME_AWS_PREFIX:=<aws:}${AWS_PROFILE:gs/%/%%}${ZSH_THEME_AWS_SUFFIX:=>}" echo "${ZSH_THEME_AWS_PREFIX=<aws:}${AWS_PROFILE:gs/%/%%}${ZSH_THEME_AWS_SUFFIX=>}"
} }
if [[ "$SHOW_AWS_PROMPT" != false && "$RPROMPT" != *'$(aws_prompt_info)'* ]]; then if [[ "$SHOW_AWS_PROMPT" != false && "$RPROMPT" != *'$(aws_prompt_info)'* ]]; then

View File

@ -1,5 +1,14 @@
## Bazel autocomplete plugin # Bazel plugin
A copy of the completion script from the This plugin adds completion for [bazel](https://bazel.build), an open-source build and
[bazelbuild/bazel](https://github.com/bazelbuild/bazel/master/scripts/zsh_completion/_bazel) test tool that scalably supports multi-language and multi-platform projects.
git repo.
To use it, add `bazel` to the plugins array in your zshrc file:
```zsh
plugins=(... bazel)
```
The plugin has a copy of [the completion script from the git repository][1].
[1]: https://github.com/bazelbuild/bazel/blob/master/scripts/zsh_completion/_bazel

View File

@ -1,6 +0,0 @@
## Boot2docker autocomplete plugin
- Adds autocomplete options for all boot2docker commands.
Maintainer : Manfred Touron ([@moul](https://github.com/moul))

View File

@ -1,73 +0,0 @@
#compdef boot2docker
# Boot2docker autocompletion for oh-my-zsh
# Requires: Boot2docker installed
# Author: Manfred Touron (@moul)
local -a _1st_arguments
_1st_arguments=(
"init":"Create a new Boot2Docker VM."
"up":"Start VM from any states."
"start":"Start VM from any states."
"boot":"Start VM from any states."
"ssh":"[ssh-command] Login to VM via SSH."
"save":"Suspend VM and save state to disk."
"suspend":"Suspend VM and save state to disk."
"down":"Gracefully shutdown the VM."
"stop":"Gracefully shutdown the VM."
"halt":"Gracefully shutdown the VM."
"restart":"Gracefully reboot the VM."
"poweroff":"Forcefully power off the VM (may corrupt disk image)."
"reset":"Forcefully power cycle the VM (may corrupt disk image)."
"delete":"Delete Boot2Docker VM and its disk image."
"destroy":"Delete Boot2Docker VM and its disk image."
"config":"Show selected profile file settings."
"cfg":"Show selected profile file settings."
"info":"Display detailed information of VM."
"ip":"Display the IP address of the VM's Host-only network."
"socket":"Display the DOCKER_HOST socket to connect to."
"shellinit":"Display the shell command to set up the Docker client."
"status":"Display current state of VM."
"download":"Download Boot2Docker ISO image."
"upgrade":"Upgrade the Boot2Docker ISO image (restart if running)."
"version":"Display version information."
)
_arguments \
'(--basevmdk)--basevmdk[Path to VMDK to use as base for persistent partition]' \
'(--cpus)'{-c,--cpus}'[number of CPUs for boot2docker.]' \
'(--clobber)--clobber[overwrite Docker client binary on boot2docker upgrade]' \
'(--dhcp)--dhcp[enable VirtualBox host-only network DHCP.]' \
'(--dhcpip)--dhcpip[VirtualBox host-only network DHCP server address.]' \
'(-s --disksize)'{-s,--disksize}'[boot2docker disk image size (in MB).]' \
'(--dockerport)--dockerport[host Docker port (forward to port 2376 in VM). (deprecated - use with care)]' \
'(--driver)--driver[hypervisor driver.]' \
'(--force-upgrade-download)--force-upgrade-download[always download on boot2docker upgrade, never skip.]' \
'(--hostip)--hostip[VirtualBox host-only network IP address.]' \
'(--iso)--iso[path to boot2docker ISO image.]' \
'(--iso-url)--iso-url[/api.github.com/repos/boot2docker/boot2docker/releases": source URL to provision the boot2docker ISO image.]' \
'(--lowerip)--lowerip[VirtualBox host-only network DHCP lower bound.]' \
'(--memory)'{-m,--memory}'[virtual machine memory size (in MB).]' \
'(--netmask)--netmask[VirtualBox host-only network mask.]' \
'(--no-dummy)--no-dummy[Example parameter for the dummy driver.]' \
'(--retries)--retries[number of port knocking retries during 'start']' \
'(--serial)--serial[try serial console to get IP address (experimental)]' \
'(--serialfile)--serialfile[path to the serial socket/pipe.]' \
'(--ssh)--ssh[path to SSH client utility.]' \
'(--ssh-keygen)--ssh-keygen[path to ssh-keygen utility.]' \
'(--sshkey)--sshkey[path to SSH key to use.]' \
'(--sshport)--sshport[host SSH port (forward to port 22 in VM).]' \
'(--upperip)--upperip[VirtualBox host-only network DHCP upper bound.]' \
'(--vbm)--vbm[path to VirtualBox management utility.]' \
'(--vbox-share)--vbox-share[(defaults to "/Users=Users" if no shares are specified; use "disable" to explicitly prevent any shares from being created) List of directories to share during "up|start|boot" via VirtualBox Guest Additions, with optional labels]' \
'(--verbose)'{-v,--verbose}'[display verbose command invocations.]' \
'(--vm)--vm[virtual machine name.]' \
'(--waittime)--waittime[Time in milliseconds to wait between port knocking retries during 'start']' \
'*:: :->subcmds' && return 0
#_arguments '*:: :->command'
if (( CURRENT == 1 )); then
_describe -t commands "boot2docker command" _1st_arguments
return
fi

View File

@ -1,14 +1,6 @@
print ${(%):-'%F{yellow}The `cargo` plugin is deprecated and has been moved to the `rust` plugin.'} print ${(%):-'%F{yellow}The `cargo` plugin is deprecated and has been moved to the `rust` plugin.'}
print ${(%):-'Please update your .zshrc to use the `%Brust%b` plugin instead.%f'} print ${(%):-'Please update your .zshrc to use the `%Brust%b` plugin instead.%f'}
# TODO: 2021-12-28: remove this block
# Handle $0 according to the standard:
# https://zdharma-continuum.github.io/Zsh-100-Commits-Club/Zsh-Plugin-Standard.html
0="${${ZERO:-${0:#$ZSH_ARGZERO}}:-${(%):-%N}}"
0="${${(M)0:#/*}:-$PWD/$0}"
# Remove old generated completion file
command rm -f "${0:A:h}/_cargo" "$ZSH_CACHE_DIR/cargo_version"
(( ${fpath[(Ie)$ZSH/plugins/rust]} )) || { (( ${fpath[(Ie)$ZSH/plugins/rust]} )) || {
fpath=("$ZSH/plugins/rust" $fpath) fpath=("$ZSH/plugins/rust" $fpath)
source "$ZSH/plugins/rust/rust.plugin.zsh" source "$ZSH/plugins/rust/rust.plugin.zsh"

View File

@ -0,0 +1,9 @@
# Charm plugin
This plugin adds completion for the [charm](https://github.com/charmbracelet/charm) CLI.
To use it, add `charm` to the plugins array in your zshrc file:
```zsh
plugins=(... charm)
```

View File

@ -0,0 +1,14 @@
# Autocompletion for the Charm CLI (charm).
if (( ! $+commands[charm] )); then
return
fi
# If the completion file doesn't exist yet, we need to autoload it and
# bind it to `charm`. Otherwise, compinit will have already done that.
if [[ ! -f "$ZSH_CACHE_DIR/completions/_charm" ]]; then
typeset -g -A _comps
autoload -Uz _charm
_comps[charm]=_charm
fi
charm completion zsh >| "$ZSH_CACHE_DIR/completions/_charm" &|

View File

@ -39,14 +39,14 @@
# #
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
local curcontext="$curcontext" state line ret=1 version opts first second third local curcontext="$curcontext" state line ret=1 version
local -a opts
typeset -A opt_args typeset -A opt_args
version=(${(f)"$(_call_program version $words[1] --version)"}) version=(${(f)"$(_call_program version $words[1] --version)"}) || return ret
version=${${(z)${version[1]}}[3]} version=${${(z)${version[1]}}[3]}
first=$(echo $version|cut -d '.' -f 1)
second=$(echo $version|cut -d '.' -f 2) autoload -Uz is-at-least
third=$(echo $version|cut -d '.' -f 3) if ! is-at-least 1.6.3 "$version"; then
if (( $first < 2 )) && (( $second < 7 )) && (( $third < 3 ));then
opts+=('(-l --lint)'{-l,--lint}'[pipe the compiled JavaScript through JavaScript Lint]' opts+=('(-l --lint)'{-l,--lint}'[pipe the compiled JavaScript through JavaScript Lint]'
'(-r --require)'{-r,--require}'[require a library before executing your script]:library') '(-r --require)'{-r,--require}'[require a library before executing your script]:library')
fi fi

View File

@ -1,10 +1,3 @@
# copydir plugin # copydir plugin
Copies the path of your current folder to the system clipboard. This plugin is deprecated. Use the [`copypath` plugin](https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/copypath) instead.
To use, add `copydir` to your plugins array:
```
plugins=(... copydir)
```
Then use the command `copydir` to copy the $PWD.

View File

@ -1,5 +1,7 @@
# Copies the pathname of the current directory to the system or X Windows clipboard echo ${(%):-'%F{yellow}The `%Bcopydir%b` plugin is deprecated. Use the `%Bcopypath%b` plugin instead.%f'}
source "$ZSH/plugins/copypath/copypath.plugin.zsh"
# TODO: 2022-02-22: Remove deprecated copydir function.
function copydir { function copydir {
emulate -L zsh copypath
print -n $PWD | clipcopy
} }

View File

@ -0,0 +1,15 @@
# copypath plugin
Copies the path of given directory or file to the system clipboard.
To use it, add `copypath` to the plugins array in your zshrc file:
```zsh
plugins=(... copypath)
```
## Usage
- `copypath`: copies the absolute path of the current directory.
- `copypath <file_or_directory>`: copies the absolute path of the given file.

View File

@ -0,0 +1,15 @@
# Copies the path of given directory or file to the system or X Windows clipboard.
# Copy current directory if no parameter.
function copypath {
# If no argument passed, use current directory
local file="${1:-.}"
# If argument is not an absolute path, prepend $PWD
[[ $file = /* ]] || file="$PWD/$file"
# Copy the absolute path without resolving symlinks
# If clipcopy fails, exit the function with an error
print -n "${file:a}" | clipcopy || return 1
echo ${(%):-"%B${file:a}%b copied to clipboard."}
}

View File

@ -1,80 +1,84 @@
# Usage: dash [keyword:]query # Usage: dash [keyword:]query
dash() { open dash://"$*" } dash() { open -a Dash.app dash://"$*" }
compdef _dash dash compdef _dash dash
_dash() { _dash() {
# No sense doing this for anything except the 2nd position and if we haven't # No sense doing this for anything except the 2nd position and if we haven't
# specified which docset to query against # specified which docset to query against
if [[ $CURRENT -eq 2 && ! "$words[2]" =~ ":" ]]; then if [[ $CURRENT -ne 2 || "$words[2]" =~ ":" ]]; then
local -a _all_docsets return
_all_docsets=() fi
# Use defaults to get the array of docsets from preferences
# Have to smash it into one big line so that each docset is an element of
# our DOCSETS array
DOCSETS=("${(@f)$(defaults read com.kapeli.dashdoc docsets | tr -d '\n' | grep -oE '\{.*?\}')}")
# remove all newlines since defaults prints so pretty like local -aU docsets
# Now get each docset and output each on their own line docsets=()
for doc in "$DOCSETS[@]"; do
# Only output docsets that are actually enabled # Use defaults to get the array of docsets from preferences
if [[ "`echo $doc | grep -Eo \"isEnabled = .*?;\" | sed 's/[^01]//g'`" == "0" ]]; then # Have to smash it into one big line so that each docset is an element of our docsets array
# Only output docsets that are actually enabled
local -a enabled_docsets
enabled_docsets=("${(@f)$(defaults read com.kapeli.dashdoc docsets \
| tr -d '\n' | grep -oE '\{.*?\}' | grep -E 'isEnabled = 1;')}")
local docset name keyword
# Now get each docset and output each on their own line
for docset in "$enabled_docsets[@]"; do
keyword=''
# Order of preference as explained to me by @kapeli via email
for locator in keyword suggestedKeyword platform; do
# Echo the docset, try to find the appropriate keyword
# Strip doublequotes and colon from any keyword so that everything has the
# same format when output (we'll add the colon in the completion)
if [[ "$docset" =~ "$locator = ([^;]*);" ]]; then
keyword="${match[1]//[\":]}"
fi
if [[ -z "$keyword" ]]; then
continue continue
fi fi
keyword='' # if we fall back to platform, we should do some checking per @kapeli
if [[ "$locator" == "platform" ]]; then
# Order of preference as explained to me by @kapeli via email # Since these are the only special cases right now, let's not do the
KEYWORD_LOCATORS=(keyword suggestedKeyword platform) # expensive processing unless we have to
for locator in "$KEYWORD_LOCATORS[@]"; do if [[ "$keyword" = (python|java|qt|cocos2d) ]]; then
# Echo the docset, try to find the appropriate keyword if [[ "$docset" =~ "docsetName = ([^;]*);" ]]; then
# Strip doublequotes and colon from any keyword so that everything has the name="${match[1]//[\":]}"
# same format when output (we'll add the colon in the completion) case "$keyword" in
keyword=`echo $doc | grep -Eo "$locator = .*?;" | sed -e "s/$locator = \(.*\);/\1/" -e "s/[\":]//g"` python)
if [[ ! -z "$keyword" ]]; then case "$name" in
# if we fall back to platform, we should do some checking per @kapeli "Python 2") keyword="python2" ;;
if [[ "$locator" == "platform" ]]; then "Python 3") keyword="python3" ;;
# Since these are the only special cases right now, let's not do the esac ;;
# expensive processing unless we have to java)
if [[ "$keyword" = (python|java|qt|cocos2d) ]]; then case "$name" in
docsetName=`echo $doc | grep -Eo "docsetName = .*?;" | sed -e "s/docsetName = \(.*\);/\1/" -e "s/[\":]//g"` "Java SE7") keyword="java7" ;;
case "$keyword" in "Java SE6") keyword="java6" ;;
python) "Java SE8") keyword="java8" ;;
case "$docsetName" in esac ;;
"Python 2") keyword="python2" ;; qt)
"Python 3") keyword="python3" ;; case "$name" in
esac ;; "Qt 5") keyword="qt5" ;;
java) "Qt 4"|Qt) keyword="qt4" ;;
case "$docsetName" in esac ;;
"Java SE7") keyword="java7" ;; cocos2d)
"Java SE6") keyword="java6" ;; case "$name" in
"Java SE8") keyword="java8" ;; Cocos3D) keyword="cocos3d" ;;
esac ;; esac ;;
qt) esac
case "$docsetName" in
"Qt 5") keyword="qt5" ;;
"Qt 4"|Qt) keyword="qt4" ;;
esac ;;
cocos2d)
case "$docsetName" in
Cocos3D) keyword="cocos3d" ;;
esac ;;
esac
fi
fi fi
# Bail once we have a match
break
fi fi
done
# If we have a keyword, add it to the list!
if [[ ! -z "$keyword" ]]; then
_all_docsets+=($keyword)
fi fi
# Bail once we have a match
break
done done
# special thanks to [arx] on #zsh for getting me sorted on this piece # If we have a keyword, add it to the list!
compadd -qS: -- "$_all_docsets[@]" if [[ -n "$keyword" ]]; then
return docsets+=($keyword)
fi fi
done
# special thanks to [arx] on #zsh for getting me sorted on this piece
compadd -qS: -- "$docsets[@]"
} }

View File

@ -16,19 +16,6 @@ if (( ! $+commands[deno] )); then
return return
fi fi
# TODO: 2021-12-28: remove this block
# Handle $0 according to the standard:
# https://zdharma-continuum.github.io/Zsh-100-Commits-Club/Zsh-Plugin-Standard.html
0="${${ZERO:-${0:#$ZSH_ARGZERO}}:-${(%):-%N}}"
0="${${(M)0:#/*}:-$PWD/$0}"
# Remove old generated files
command rm -f "${0:A:h}/_deno" "$ZSH_CACHE_DIR/deno_version"
# TODO: 2021-12-28: remove this bit of code as it exists in oh-my-zsh.sh
# Add completions folder in $ZSH_CACHE_DIR
command mkdir -p "$ZSH_CACHE_DIR/completions"
(( ${fpath[(Ie)"$ZSH_CACHE_DIR/completions"]} )) || fpath=("$ZSH_CACHE_DIR/completions" $fpath)
# If the completion file doesn't exist yet, we need to autoload it and # If the completion file doesn't exist yet, we need to autoload it and
# bind it to `deno`. Otherwise, compinit will have already done that. # bind it to `deno`. Otherwise, compinit will have already done that.
if [[ ! -f "$ZSH_CACHE_DIR/completions/_deno" ]]; then if [[ ! -f "$ZSH_CACHE_DIR/completions/_deno" ]]; then

View File

@ -1,12 +0,0 @@
# Django plugin
This plugin adds completion for the [Django Project](https://www.djangoproject.com/) commands
(`manage.py`, `django-admin`, ...).
## Deprecation (2021-09-22)
The plugin used to provide completion for `./manage.py` and `django-admin`, but Zsh already provides
a better, more extensive completion for those, so this plugin is no longer needed.
Right now a warning message is shown, but in the near future the plugin will stop working altogether.
So you can remove it from your plugins and you'll automatically start using Zsh's django completion.

View File

@ -1,407 +0,0 @@
#compdef manage.py
typeset -ga nul_args
nul_args=(
'--verbosity=-[verbosity level; 0=minimal output, 1=normal output, 2=all output.]:Verbosity:((0\:minimal 1\:normal 2\:all))'
'--settings=-[the Python path to a settings module.]:file:_files'
'--pythonpath=-[a directory to add to the Python path.]:directory:_directories'
'--traceback[print traceback on exception.]'
"--no-color[Don't colorize the command output.]"
"--version[show program's version number and exit.]"
{-h,--help}'[show this help message and exit.]'
)
typeset -ga start_args
start_args=(
'--template=-[The path or URL to load the template from.]:directory:_directories'
'--extension=-[The file extension(s) to render (default: "py").]'
'--name=-[The file name(s) to render.]:file:_files'
)
typeset -ga db_args
db_args=(
'--database=-[Nominates a database. Defaults to the "default" database.]'
)
typeset -ga noinput_args
noinput_args=(
'--noinput[tells Django to NOT prompt the user for input of any kind.]'
)
typeset -ga no_init_data_args
no_init_data_args=(
'--no-initial-data[Tells Django not to load any initial data after database synchronization.]'
)
typeset -ga tag_args
tag_args=(
'--tag=-[Run only checks labeled with given tag.]'
'--list-tags[List available tags.]'
)
_managepy-check(){
_arguments -s : \
$tag_args \
$nul_args && ret=0
}
_managepy-changepassword(){
_arguments -s : \
$db_args \
$nul_args && ret=0
}
_managepy-createcachetable(){
_arguments -s : \
$db_args \
$nul_args && ret=0
}
_managepy-createsuperuser(){
_arguments -s : \
'--username=-[Specifies the login for the superuser.]' \
'--email=-[Specifies the email for the superuser.]' \
$noinput_args \
$db_args \
$nul_args && ret=0
}
_managepy-collectstatic(){
_arguments -s : \
'--link[Create a symbolic link to each file instead of copying.]' \
'--no-post-process[Do NOT post process collected files.]' \
'--ignore=-[Ignore files or directories matching this glob-style pattern. Use multiple times to ignore more.]' \
'--dry-run[Do everything except modify the filesystem.]' \
'--clear[Clear the existing files using the storage before trying to copy or link the original file.]' \
'--link[Create a symbolic link to each file instead of copying.]' \
'--no-default-ignore[Do not ignore the common private glob-style patterns "CVS", ".*" and "*~".]' \
$noinput_args \
$nul_args && ret=0
}
_managepy-dbshell(){
_arguments -s : \
$db_args \
$nul_args && ret=0
}
_managepy-diffsettings(){
_arguments -s : \
"--all[Display all settings, regardless of their value.]"
$nul_args && ret=0
}
_managepy-dumpdata(){
_arguments -s : \
'--format=-[Specifies the output serialization format for fixtures.]:format:(json yaml xml)' \
'--indent=-[Specifies the indent level to use when pretty-printing output.]' \
'--exclude=-[An app_label or app_label.ModelName to exclude (use multiple --exclude to exclude multiple apps/models).]' \
'--natural-foreign[Use natural foreign keys if they are available.]' \
'--natural-primary[Use natural primary keys if they are available.]' \
"--all[Use Django's base manager to dump all models stored in the database.]" \
'--pks=-[Only dump objects with given primary keys.]' \
$db_args \
$nul_args \
'*::appname:_applist' && ret=0
}
_managepy-flush(){
_arguments -s : \
$no_init_data_args \
$db_args \
$noinput_args \
$nul_args && ret=0
}
_managepy-help(){
_arguments -s : \
'*:command:_managepy_cmds' \
$nul_args && ret=0
}
_managepy_cmds(){
local line
local -a cmd
_call_program help-command ./manage.py help \
|& sed -n '/^ /s/[(), ]/ /gp' \
| while read -A line; do cmd=($line $cmd) done
_describe -t managepy-command 'manage.py command' cmd
}
_managepy-inspectdb(){
_arguments -s : \
$db_args \
$nul_args && ret=0
}
_managepy-loaddata(){
_arguments -s : \
'--ignorenonexistent[Ignores entries in the serialized data for fields that do not currently exist on the model.]' \
'--app=-[Only look for fixtures in the specified app.]:appname:_applist' \
'*::file:_files' \
$db_args \
$nul_args && ret=0
}
_managepy-makemessages(){
_arguments -s : \
'--locale=-[Creates or updates the message files for the given locale(s) (e.g. pt_BR).]' \
'--domain=-[The domain of the message files (default: "django").]' \
'--all[Updates the message files for all existing locales.]' \
'--extension=-[The file extension(s) to examine (default: "html,txt", or "js" if the domain is "djangojs").]' \
'--symlinks[Follows symlinks to directories when examining source code and templates for translation strings.]' \
'--ignore=-[Ignore files or directories matching this glob-style pattern.]' \
"--no-default-ignore[Don't ignore the common glob-style patterns 'CVS', '.*', '*~' and '*.pyc'.]" \
"--no-wrap[Don't break long message lines into several lines.]" \
"--no-location[Don't write '#: filename:line' lines.]" \
'--no-obsolete[Remove obsolete message strings.]' \
'--keep-pot[Keep .pot file after making messages.]' \
$nul_args && ret=0
}
_managepy-makemigrations(){
_arguments -s : \
'--dry-run[Just show what migrations would be made]' \
'--merge[Enable fixing of migration conflicts.]' \
'--empty[Create an empty migration.]' \
$noinput_args \
$nul_args && ret=0
}
_managepy-migrate(){
_arguments -s : \
'--fake[Mark migrations as run without actually running them]' \
'--list[Show a list of all known migrations and which are applied]' \
$no_init_data_args \
$noinput_args \
$db_args \
$nul_args && ret=0
}
_managepy-runfcgi(){
local state
local fcgi_opts
fcgi_opts=(
'protocol[fcgi, scgi, ajp, ... (default fcgi)]:protocol:(fcgi scgi ajp)'
'host[hostname to listen on..]:'
'port[port to listen on.]:'
'socket[UNIX socket to listen on.]:file:_files'
'method[prefork or threaded (default prefork)]:method:(prefork threaded)'
'maxrequests[number of requests a child handles before it is killed and a new child is forked (0 = no limit).]:'
'maxspare[max number of spare processes / threads.]:'
'minspare[min number of spare processes / threads.]:'
'maxchildren[hard limit number of processes / threads.]:'
'daemonize[whether to detach from terminal.]:boolean:(False True)'
'pidfile[write the spawned process-id to this file.]:file:_files'
'workdir[change to this directory when daemonizing.]:directory:_files'
'outlog[write stdout to this file.]:file:_files'
'errlog[write stderr to this file.]:file:_files'
)
_arguments -s : \
$nul_args \
'*: :_values "FCGI Setting" $fcgi_opts' && ret=0
}
_managepy-runserver(){
_arguments -s : \
'--ipv6[Tells Django to use an IPv6 address.]' \
'--nothreading[Tells Django to NOT use threading.]' \
'--noreload[Tells Django to NOT use the auto-reloader.]' \
'--nostatic[Tells Django to NOT automatically serve static files at STATIC_URL.]' \
'--insecure[Allows serving static files even if DEBUG is False.]' \
$nul_args && ret=0
}
_managepy-shell(){
_arguments -s : \
'--plain[Tells Django to use plain Python, not IPython.]' \
'--no-startup[When using plain Python, ignore the PYTHONSTARTUP environment variable and ~/.pythonrc.py script.]' \
'--interface=-[Specify an interactive interpreter interface.]:INTERFACE:((ipython bpython))' \
$nul_args && ret=0
}
_managepy-sql(){
_arguments -s : \
$db_args \
$nul_args && ret=0
}
_managepy-sqlall(){
_arguments -s : \
$db_args \
$nul_args && ret=0
}
_managepy-sqlclear(){
_arguments -s : \
$db_args \
$nul_args && ret=0
}
_managepy-sqlcustom(){
_arguments -s : \
$db_args \
$nul_args && ret=0
}
_managepy-dropindexes(){
_arguments -s : \
$db_args \
$nul_args && ret=0
}
_managepy-sqlflush(){
_arguments -s : \
$db_args \
$nul_args && ret=0
}
_managepy-sqlindexes(){
_arguments -s : \
$db_args \
$nul_args && ret=0
}
_managepy-sqlinitialdata(){
_arguments -s : \
$nul_args && ret=0
}
_managepy-sqlsequencereset(){
_arguments -s : \
$db_args \
$nul_args && ret=0
}
_managepy-squashmigrations(){
_arguments -s : \
'--no-optimize[Do not try to optimize the squashed operations.]' \
$noinput_args \
$nul_args && ret=0
}
_managepy-startapp(){
_arguments -s : \
$start_args \
$nul_args && ret=0
}
_managepy-startproject(){
_arguments -s : \
$start_args \
$nul_args && ret=0
}
_managepy-syncdb() {
_arguments -s : \
$noinput_args \
$no_init_data_args \
$db_args \
$nul_args && ret=0
}
_managepy-test() {
_arguments -s : \
'--failfast[Tells Django to stop running the test suite after first failed test.]' \
'--testrunner=-[Tells Django to use specified test runner class instead of the one specified by the TEST_RUNNER setting.]' \
'--liveserver=-[Overrides the default address where the live server (used with LiveServerTestCase) is expected to run from. The default value is localhost:8081.]' \
'--top-level-directory=-[Top level of project for unittest discovery.]' \
'--pattern=-[The test matching pattern. Defaults to test*.py.]:' \
$noinput_args \
'*::appname:_applist' \
$nul_args && ret=0
}
_managepy-testserver() {
_arguments -s : \
'--addrport=-[port number or ipaddr:port to run the server on.]' \
'--ipv6[Tells Django to use an IPv6 address.]' \
$noinput_args \
'*::fixture:_files' \
$nul_args && ret=0
}
_managepy-validate() {
_arguments -s : \
$tag_args \
$nul_args && ret=0
}
_managepy-commands() {
local -a commands
commands=(
"changepassword:Change a user's password for django.contrib.auth."
'check:Checks the entire Django project for potential problems.'
'compilemessages:Compiles .po files to .mo files for use with builtin gettext support.'
'createcachetable:Creates the table needed to use the SQL cache backend.'
'createsuperuser:Used to create a superuser.'
'collectstatic:Collect static files in a single location.'
'dbshell:Runs the command-line client for the current DATABASE_ENGINE.'
"diffsettings:Displays differences between the current settings.py and Django's default settings."
'dumpdata:Output the contents of the database as a fixture of the given format.'
'flush:Executes ``sqlflush`` on the current database.'
'help:manage.py help.'
'inspectdb:Introspects the database tables in the given database and outputs a Django model module.'
'loaddata:Installs the named fixture(s) in the database.'
'makemessages:Runs over the entire source tree of the current directory and pulls out all strings marked for translation.'
'makemigrations:Creates new migration(s) for apps.'
'migrate:Updates database schema. Manages both apps with migrations and those without.'
'runfcgi:Run this project as a fastcgi (or some other protocol supported by flup) application,'
'runserver:Starts a lightweight Web server for development.'
'shell:Runs a Python interactive interpreter.'
'showmigrations:Shows all available migrations for the current project.'
'sql:Prints the CREATE TABLE SQL statements for the given app name(s).'
'sqlall:Prints the CREATE TABLE, custom SQL and CREATE INDEX SQL statements for the given model module name(s).'
'sqlclear:Prints the DROP TABLE SQL statements for the given app name(s).'
'sqlcustom:Prints the custom table modifying SQL statements for the given app name(s).'
'sqldropindexes:Prints the DROP INDEX SQL statements for the given model module name(s).'
'sqlflush:Returns a list of the SQL statements required to return all tables in the database to the state they were in just after they were installed.'
'sqlindexes:Prints the CREATE INDEX SQL statements for the given model module name(s).'
"sqlinitialdata:RENAMED: see 'sqlcustom'"
'sqlsequencereset:Prints the SQL statements for resetting sequences for the given app name(s).'
'squashmigrations:Squashes an existing set of migrations (from first until specified) into a single new one.'
"startapp:Creates a Django app directory structure for the given app name in this project's directory."
"startproject:Creates a Django project directory structure for the given project name in this current directory."
"syncdb:Create the database tables for all apps in INSTALLED_APPS whose tables haven't already been created."
'test:Runs the test suite for the specified applications, or the entire site if no apps are specified.'
'testserver:Runs a development server with data from the given fixture(s).'
'validate:Validates all installed models.'
)
_describe -t commands 'manage.py command' commands && ret=0
}
_applist() {
local line
local -a apps
_call_program help-command "python -c \"import sys; del sys.path[0];\\
import os.path as op, re, django.conf;\\
bn=op.basename(op.abspath(op.curdir));[sys\\
.stdout.write(str(re.sub(r'^%s\.(.*?)$' %
bn, r'\1', i)) + '\n') for i in django.conf.settings.\\
INSTALLED_APPS if re.match(r'^%s' % bn, i)]\"" \
| while read -A line; do apps=($line $apps) done
_values 'Application' $apps && ret=0
}
_managepy() {
local curcontext=$curcontext ret=1
if ((CURRENT == 2)); then
_managepy-commands
else
shift words
(( CURRENT -- ))
curcontext="${curcontext%:*:*}:managepy-$words[1]:"
_call_function ret _managepy-$words[1]
fi
}
compdef _managepy manage.py
compdef _managepy django
compdef _managepy django-admin
compdef _managepy django-admin.py
compdef _managepy django-manage
print -P "%F{yellow}The django plugin is deprecated in favor of Zsh's Django completion.
%BPlease remove it from your plugins to stop using it.%b%f"

View File

@ -1,6 +1,6 @@
# Docker plugin # Docker plugin
This plugin adds auto-completion for [docker](https://www.docker.com/). This plugin adds auto-completion and aliases for [docker](https://www.docker.com/).
To use it add `docker` to the plugins array in your zshrc file. To use it add `docker` to the plugins array in your zshrc file.
@ -28,7 +28,46 @@ the lines below to your zshrc file**, but be aware of the side effects:
> >
> Therefore, this behavior is disabled by default. To enable it: > Therefore, this behavior is disabled by default. To enable it:
> >
> ``` > ```sh
> zstyle ':completion:*:*:docker:*' option-stacking yes > zstyle ':completion:*:*:docker:*' option-stacking yes
> zstyle ':completion:*:*:docker-*:*' option-stacking yes > zstyle ':completion:*:*:docker-*:*' option-stacking yes
> ``` > ```
## Aliases
| Alias | Command | Description |
| :------ | :-------------------------- | :--------------------------------------------------------------------------------------- |
| dbl | `docker build` | Build an image from a Dockerfile |
| dcin | `docker container inspect` | Display detailed information on one or more containers |
| dlo | `docker container logs` | Fetch the logs of a docker container |
| dcls | `docker container ls` | List all the running docker containers |
| dclsa | `docker container ls -a` | List all running and stopped containers |
| dpo | `docker container port` | List port mappings or a specific mapping for the container |
| dpu | `docker pull` | Pull an image or a repository from a registry |
| dr | `docker container run` | Create a new container and start it using the specified command |
| drit | `docker container run -it` | Create a new container and start it in an interactive shell |
| drm | `docker container rm` | Remove the specified container(s) |
| drm! | `docker container rm -f` | Force the removal of a running container (uses SIGKILL) |
| dst | `docker container start` | Start one or more stopped containers |
| dstp | `docker container stop` | Stop one or more running containers |
| dtop | `docker top` | Display the running processes of a container |
| dxc | `docker container exec` | Run a new command in a running container |
| dxcit | `docker container exec -it` | Run a new command in a running container in an interactive shell |
| | | **Docker Images** |
| dib | `docker image build` | Build an image from a Dockerfile (same as docker build) |
| dii | `docker image inspect` | Display detailed information on one or more images |
| dils | `docker image ls` | List docker images |
| dip | `docker image push` | Push an image or repository to a remote registry |
| dirm | `docker image rm` | Remove one or more images |
| dit | `docker image tag` | Add a name and tag to a particular image |
| | | **Docker Network** |
| dnc | `docker network create` | Create a new network |
| dncn | `docker network connect` | Connect a container to a network |
| dndcn | `docker network disconnect` | Disconnect a container from a network |
| dni | `docker network inspect` | Return information about one or more networks |
| dnls | `docker network ls` | List all networks the engine daemon knows about, including those spanning multiple hosts |
| dnrm | `docker network rm` | Remove one or more networks |
| | | **Docker Volume** |
| dvi | `docker volume inspect` | Display detailed information about one or more volumes |
| dvls | `docker volume ls` | List all the volumes known to docker |
| dvprune | `docker volume prune` | Cleanup dangling volumes |

View File

@ -0,0 +1,39 @@
alias dbl='docker build'
alias dpu='docker pull'
alias dtop='docker top'
# docker containers
alias dcin='docker container inspect'
alias dlo='docker container logs'
alias dcls='docker container ls'
alias dclsa='docker container ls -a'
alias dpo='docker container port'
alias dr='docker container run'
alias drit='docker container run -it'
alias drm='docker container rm'
alias 'drm!'='docker container rm -f'
alias dst='docker container start'
alias dstp='docker container stop'
alias dxc='docker container exec'
alias dxcit='docker container exec -it'
# docker images
alias dib='docker image build'
alias dii='docker image inspect'
alias dils='docker image ls'
alias dip='docker image push'
alias dirm='docker image rm'
alias dit='docker image tag'
# docker network
alias dnc='docker network create'
alias dncn='docker network connect'
alias dndcn='docker network disconnect'
alias dni='docker network inspect'
alias dnls='docker network ls'
alias dnrm='docker network rm'
# docker volume
alias dvi='docker volume inspect'
alias dvls='docker volume ls'
alias dvprune='docker volume prune'

View File

@ -52,7 +52,10 @@ source_env() {
fi fi
# test .env syntax # test .env syntax
zsh -fn $ZSH_DOTENV_FILE || echo "dotenv: error when sourcing '$ZSH_DOTENV_FILE' file" >&2 zsh -fn $ZSH_DOTENV_FILE || {
echo "dotenv: error when sourcing '$ZSH_DOTENV_FILE' file" >&2
return 1
}
setopt localoptions allexport setopt localoptions allexport
source $ZSH_DOTENV_FILE source $ZSH_DOTENV_FILE

View File

@ -7,7 +7,3 @@ To use it, add `fd` to the plugins array in your zshrc file:
```zsh ```zsh
plugins=(... fd) plugins=(... fd)
``` ```
Completion is taken from the fd release [`8.2.1`](https://github.com/sharkdp/fd/releases/tag/v8.2.1).
Updated on April 1st, 2021.

View File

@ -1,4 +1,4 @@
#compdef fd fdfind #compdef fd
## ##
# zsh completion function for fd # zsh completion function for fd
@ -57,6 +57,7 @@ _fd() {
+ no-ignore-partial # some ignore files + no-ignore-partial # some ignore files
"(no-ignore-full --no-ignore-vcs)--no-ignore-vcs[don't respect .gitignore files]" "(no-ignore-full --no-ignore-vcs)--no-ignore-vcs[don't respect .gitignore files]"
"!(no-ignore-full --no-global-ignore-file)--no-global-ignore-file[don't respect the global ignore file]" "!(no-ignore-full --no-global-ignore-file)--no-global-ignore-file[don't respect the global ignore file]"
$no'(no-ignore-full --no-ignore-parent)--no-ignore-parent[]'
+ '(case)' # case-sensitivity + '(case)' # case-sensitivity
{-s,--case-sensitive}'[perform a case-sensitive search]' {-s,--case-sensitive}'[perform a case-sensitive search]'
@ -138,6 +139,7 @@ _fd() {
+ '(exec-cmds)' # execute command + '(exec-cmds)' # execute command
'(long-listing max-results)'{-x+,--exec=}'[execute command for each search result]:command: _command_names -e:*\;::program arguments: _normal' '(long-listing max-results)'{-x+,--exec=}'[execute command for each search result]:command: _command_names -e:*\;::program arguments: _normal'
'(long-listing max-results)'{-X+,--exec-batch=}'[execute command for all search results at once]:command: _command_names -e:*\;::program arguments: _normal' '(long-listing max-results)'{-X+,--exec-batch=}'[execute command for all search results at once]:command: _command_names -e:*\;::program arguments: _normal'
'(long-listing max-results)--batch-size=[max number of args for each -X call]:size'
+ other + other
'!(--max-buffer-time)--max-buffer-time=[set amount of time to buffer before showing output]:time (ms)' '!(--max-buffer-time)--max-buffer-time=[set amount of time to buffer before showing output]:time (ms)'
@ -153,6 +155,9 @@ _fd() {
$no'(--base-directory)--base-directory=[change the current working directory to the given path]:directory:_files -/' $no'(--base-directory)--base-directory=[change the current working directory to the given path]:directory:_files -/'
$no'(*)*--search-path=[set search path (instead of positional <path> arguments)]:directory:_files -/' $no'(*)*--search-path=[set search path (instead of positional <path> arguments)]:directory:_files -/'
+ strip-cwd-prefix
$no'(strip-cwd-prefix exec-cmds)--strip-cwd-prefix[Strip ./ prefix when output is redirected]'
+ args # positional arguments + args # positional arguments
'1: :_guard "^-*" pattern' '1: :_guard "^-*" pattern'
'(--search-path)*:directory:_files -/' '(--search-path)*:directory:_files -/'
@ -220,7 +225,7 @@ _fd() {
_fd "$@" _fd "$@"
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# Copyright (c) 2011 Github zsh-users - http://github.com/zsh-users # Copyright (c) 2011 GitHub zsh-users - http://github.com/zsh-users
# All rights reserved. # All rights reserved.
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without

View File

@ -2,19 +2,6 @@ if (( ! $+commands[fnm] )); then
return return
fi fi
# TODO: 2021-12-28: remove this block
# Handle $0 according to the standard:
# https://zdharma-continuum.github.io/Zsh-100-Commits-Club/Zsh-Plugin-Standard.html
0="${${ZERO:-${0:#$ZSH_ARGZERO}}:-${(%):-%N}}"
0="${${(M)0:#/*}:-$PWD/$0}"
# remove old generated files
command rm -f "${0:A:h}/_fnm" "$ZSH_CACHE_DIR/fnm_version"
# TODO: 2021-12-28: remove this bit of code as it exists in oh-my-zsh.sh
# Add completions folder in $ZSH_CACHE_DIR
command mkdir -p "$ZSH_CACHE_DIR/completions"
(( ${fpath[(Ie)"$ZSH_CACHE_DIR/completions"]} )) || fpath=("$ZSH_CACHE_DIR/completions" $fpath)
# If the completion file doesn't exist yet, we need to autoload it and # If the completion file doesn't exist yet, we need to autoload it and
# bind it to `fnm`. Otherwise, compinit will have already done that. # bind it to `fnm`. Otherwise, compinit will have already done that.
if [[ ! -f "$ZSH_CACHE_DIR/completions/_fnm" ]]; then if [[ ! -f "$ZSH_CACHE_DIR/completions/_fnm" ]]; then

View File

@ -103,8 +103,7 @@ function frontend() {
# build search url: # build search url:
# join arguments passed with '%20', then append to search context URL # join arguments passed with '%20', then append to search context URL
# TODO substitute for proper urlencode method url="${urls[$1]}$(omz_urlencode -P ${@[2,-1]})"
url="${urls[$1]}${(j:%20:)@[2,-1]}"
echo "Opening $url ..." echo "Opening $url ..."

View File

@ -31,8 +31,8 @@ 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: If not set, the plugin will try to set it to these, in the order in which they're found:
- [`rg`](https://github.com/BurntSushi/ripgrep)
- [`fd`](https://github.com/sharkdp/fd) - [`fd`](https://github.com/sharkdp/fd)
- [`rg`](https://github.com/BurntSushi/ripgrep)
- [`ag`](https://github.com/ggreer/the_silver_searcher) - [`ag`](https://github.com/ggreer/the_silver_searcher)
### `DISABLE_FZF_AUTO_COMPLETION` ### `DISABLE_FZF_AUTO_COMPLETION`

View File

@ -173,6 +173,32 @@ function fzf_setup_using_cygwin() {
return 0 return 0
} }
function fzf_setup_using_macports() {
# 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="/opt/local/share/zsh/site-functions/fzf"
# The fzf-zsh-completion package installs the key-bindings file in
local key_bindings="/opt/local/share/fzf/shell/key-bindings.zsh"
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
}
# Indicate to user that fzf installation not found if nothing worked # Indicate to user that fzf installation not found if nothing worked
function fzf_setup_error() { function fzf_setup_error() {
cat >&2 <<'EOF' cat >&2 <<'EOF'
@ -185,16 +211,17 @@ fzf_setup_using_openbsd \
|| fzf_setup_using_debian \ || fzf_setup_using_debian \
|| fzf_setup_using_opensuse \ || fzf_setup_using_opensuse \
|| fzf_setup_using_cygwin \ || fzf_setup_using_cygwin \
|| fzf_setup_using_macports \
|| fzf_setup_using_base_dir \ || fzf_setup_using_base_dir \
|| fzf_setup_error || fzf_setup_error
unset -f -m 'fzf_setup_*' unset -f -m 'fzf_setup_*'
if [[ -z "$FZF_DEFAULT_COMMAND" ]]; then if [[ -z "$FZF_DEFAULT_COMMAND" ]]; then
if (( $+commands[rg] )); then if (( $+commands[fd] )); then
export FZF_DEFAULT_COMMAND='rg --files --hidden --glob "!.git/*"'
elif (( $+commands[fd] )); then
export FZF_DEFAULT_COMMAND='fd --type f --hidden --exclude .git' export FZF_DEFAULT_COMMAND='fd --type f --hidden --exclude .git'
elif (( $+commands[rg] )); then
export FZF_DEFAULT_COMMAND='rg --files --hidden --glob "!.git/*"'
elif (( $+commands[ag] )); then elif (( $+commands[ag] )); then
export FZF_DEFAULT_COMMAND='ag -l --hidden -g "" --ignore .git' export FZF_DEFAULT_COMMAND='ag -l --hidden -g "" --ignore .git'
fi fi

View File

@ -3,19 +3,6 @@ if (( ! $+commands[gh] )); then
return return
fi fi
# TODO: 2021-12-28: remove this block
# Handle $0 according to the standard:
# https://zdharma-continuum.github.io/Zsh-100-Commits-Club/Zsh-Plugin-Standard.html
0="${${ZERO:-${0:#$ZSH_ARGZERO}}:-${(%):-%N}}"
0="${${(M)0:#/*}:-$PWD/$0}"
# Remove old generated files
command rm -f "${0:A:h}/_gh" "$ZSH_CACHE_DIR/gh_version"
# TODO: 2021-12-28: remove this bit of code as it exists in oh-my-zsh.sh
# Add completions folder in $ZSH_CACHE_DIR
command mkdir -p "$ZSH_CACHE_DIR/completions"
(( ${fpath[(Ie)"$ZSH_CACHE_DIR/completions"]} )) || fpath=("$ZSH_CACHE_DIR/completions" $fpath)
# If the completion file doesn't exist yet, we need to autoload it and # If the completion file doesn't exist yet, we need to autoload it and
# bind it to `gh`. Otherwise, compinit will have already done that. # bind it to `gh`. Otherwise, compinit will have already done that.
if [[ ! -f "$ZSH_CACHE_DIR/completions/_gh" ]]; then if [[ ! -f "$ZSH_CACHE_DIR/completions/_gh" ]]; then

View File

@ -13,7 +13,7 @@ See the [original repository](https://github.com/olivierverdier/zsh-git-prompt).
## Requirements ## Requirements
This plugin uses `python`, so your host needs to have it installed This plugin uses `python3`, so your host needs to have it installed.
## Examples ## Examples

View File

@ -36,7 +36,7 @@ function update_current_git_vars() {
unset __CURRENT_GIT_STATUS unset __CURRENT_GIT_STATUS
local gitstatus="$__GIT_PROMPT_DIR/gitstatus.py" local gitstatus="$__GIT_PROMPT_DIR/gitstatus.py"
_GIT_STATUS=$(python ${gitstatus} 2>/dev/null) _GIT_STATUS=$(python3 ${gitstatus} 2>/dev/null)
__CURRENT_GIT_STATUS=("${(@s: :)_GIT_STATUS}") __CURRENT_GIT_STATUS=("${(@s: :)_GIT_STATUS}")
GIT_BRANCH=$__CURRENT_GIT_STATUS[1] GIT_BRANCH=$__CURRENT_GIT_STATUS[1]
GIT_AHEAD=$__CURRENT_GIT_STATUS[2] GIT_AHEAD=$__CURRENT_GIT_STATUS[2]

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python #!/usr/bin/env python3
from __future__ import print_function from __future__ import print_function
import os import os

View File

@ -33,8 +33,9 @@ if [ -z "$script" ]; then
bash_completion='/usr/share/bash-completion/completions/' bash_completion='/usr/share/bash-completion/completions/'
locations=( locations=(
"$(dirname ${funcsourcetrace[1]%:*})"/git-completion.bash "${${funcsourcetrace[1]%:*}:A:h}"/git-completion.bash
"$HOME/.local/share/bash-completion/completions/git" "$HOME/.local/share/bash-completion/completions/git"
'/usr/local/share/bash-completion/completions/git'
"$bash_completion/git" "$bash_completion/git"
'/etc/bash_completion.d/git' # old debian '/etc/bash_completion.d/git' # old debian
) )
@ -51,13 +52,20 @@ functions[complete]="$old_complete"
__gitcompadd () __gitcompadd ()
{ {
compadd -Q -p "${2-}" -S "${3- }" ${@[4,-1]} -- ${=1} && _ret=0 compadd -p "${2-}" -S "${3- }" -q -- ${=1} && _ret=0
} }
__gitcomp () __gitcomp ()
{ {
emulate -L zsh emulate -L zsh
IFS=$' \t\n' __gitcompadd "$1" "${2-}" "${4- }"
}
__gitcomp_opts ()
{
emulate -L zsh
local cur_="${3-$cur}" local cur_="${3-$cur}"
[[ "$cur_" == *= ]] && return [[ "$cur_" == *= ]] && return
@ -70,7 +78,7 @@ __gitcomp ()
break break
fi fi
if [[ -z "${4-}" ]]; then if [[ -z "${4+set}" ]]; then
case $c in case $c in
*=) c="${c%=}"; sfx="=" ;; *=) c="${c%=}"; sfx="=" ;;
*.) sfx="" ;; *.) sfx="" ;;
@ -79,7 +87,7 @@ __gitcomp ()
else else
sfx="$4" sfx="$4"
fi fi
__gitcompadd "$c" "${2-}" "$sfx" -q __gitcompadd "$c" "${2-}" "$sfx"
done done
} }
@ -87,7 +95,10 @@ __gitcomp_nl ()
{ {
emulate -L zsh emulate -L zsh
IFS=$'\n' __gitcompadd "$1" "${2-}" "${4- }" # words that don't end up in space
compadd -p "${2-}" -S "${4- }" -q -- ${${(f)1}:#*\ } && _ret=0
# words that end in space
compadd -p "${2-}" -S " ${4- }" -q -- ${${(M)${(f)1}:#*\ }% } && _ret=0
} }
__gitcomp_file () __gitcomp_file ()
@ -107,21 +118,6 @@ __gitcomp_file_direct ()
__gitcomp_file "$1" "" __gitcomp_file "$1" ""
} }
__gitcomp_nl_append ()
{
__gitcomp_nl "$@"
}
__gitcomp_direct_append ()
{
__gitcomp_direct "$@"
}
_git_zsh ()
{
__gitcomp "v1.2"
}
__git_complete_command () __git_complete_command ()
{ {
emulate -L zsh emulate -L zsh
@ -206,9 +202,7 @@ __git_zsh_main ()
{ {
local curcontext="$curcontext" state state_descr line local curcontext="$curcontext" state state_descr line
typeset -A opt_args typeset -A opt_args
local -a orig_words __git_C_args local -a __git_C_args
orig_words=( ${words[@]} )
_arguments -C \ _arguments -C \
'(-p --paginate -P --no-pager)'{-p,--paginate}'[pipe all output into ''less'']' \ '(-p --paginate -P --no-pager)'{-p,--paginate}'[pipe all output into ''less'']' \
@ -245,7 +239,7 @@ __git_zsh_main ()
emulate ksh -c __git_complete_config_variable_name_and_value emulate ksh -c __git_complete_config_variable_name_and_value
;; ;;
(arg) (arg)
local command="${words[1]}" __git_dir local command="${words[1]}" __git_dir __git_cmd_idx=1
if (( $+opt_args[--bare] )); then if (( $+opt_args[--bare] )); then
__git_dir='.' __git_dir='.'
@ -259,7 +253,7 @@ __git_zsh_main ()
(( $+opt_args[--help] )) && command='help' (( $+opt_args[--help] )) && command='help'
words=( ${orig_words[@]} ) words=( git ${words[@]} )
__git_zsh_bash_func $command __git_zsh_bash_func $command
;; ;;
@ -269,7 +263,7 @@ __git_zsh_main ()
_git () _git ()
{ {
local _ret=1 local _ret=1
local cur cword prev local cur cword prev __git_cmd_idx=0
cur=${words[CURRENT]} cur=${words[CURRENT]}
prev=${words[CURRENT-1]} prev=${words[CURRENT-1]}

File diff suppressed because it is too large Load Diff

View File

@ -138,6 +138,7 @@ __git_ps1_show_upstream ()
done <<< "$output" done <<< "$output"
# parse configuration values # parse configuration values
local option
for option in ${GIT_PS1_SHOWUPSTREAM}; do for option in ${GIT_PS1_SHOWUPSTREAM}; do
case "$option" in case "$option" in
git|svn) upstream="$option" ;; git|svn) upstream="$option" ;;
@ -432,8 +433,8 @@ __git_ps1 ()
fi fi
local sparse="" local sparse=""
if [ -z "${GIT_PS1_COMPRESSSPARSESTATE}" ] && if [ -z "${GIT_PS1_COMPRESSSPARSESTATE-}" ] &&
[ -z "${GIT_PS1_OMITSPARSESTATE}" ] && [ -z "${GIT_PS1_OMITSPARSESTATE-}" ] &&
[ "$(git config --bool core.sparseCheckout)" = "true" ]; then [ "$(git config --bool core.sparseCheckout)" = "true" ]; then
sparse="|SPARSE" sparse="|SPARSE"
fi fi
@ -542,7 +543,7 @@ __git_ps1 ()
u="%${ZSH_VERSION+%}" u="%${ZSH_VERSION+%}"
fi fi
if [ -n "${GIT_PS1_COMPRESSSPARSESTATE}" ] && if [ -n "${GIT_PS1_COMPRESSSPARSESTATE-}" ] &&
[ "$(git config --bool core.sparseCheckout)" = "true" ]; then [ "$(git config --bool core.sparseCheckout)" = "true" ]; then
h="?" h="?"
fi fi

View File

@ -1,7 +1,7 @@
#!/bin/sh #!/bin/sh
url="https://raw.githubusercontent.com/felipec/git-completion" url="https://raw.githubusercontent.com/felipec/git-completion"
version="1.2" version="1.3.6"
curl -s -o _git "${url}/v${version}/git-completion.zsh" && curl -s -o _git "${url}/v${version}/git-completion.zsh" &&
curl -s -o git-completion.bash "${url}/v${version}/git-completion.bash" && curl -s -o git-completion.bash "${url}/v${version}/git-completion.bash" &&

View File

@ -35,6 +35,9 @@ __gnu_utils() {
# Not part of either coreutils or findutils, installed separately. # Not part of either coreutils or findutils, installed separately.
gcmds+=('gsed' 'gtar' 'gtime' 'gmake' 'ggrep') gcmds+=('gsed' 'gtar' 'gtime' 'gmake' 'ggrep')
# can be built optionally
gcmds+=('ghostname')
for gcmd in "${gcmds[@]}"; do for gcmd in "${gcmds[@]}"; do
# Do nothing if the command isn't found # Do nothing if the command isn't found
(( ${+commands[$gcmd]} )) || continue (( ${+commands[$gcmd]} )) || continue

View File

@ -9,7 +9,7 @@ autoload -U add-zsh-hook
add-zsh-hook preexec _gpg-agent_update-tty_preexec add-zsh-hook preexec _gpg-agent_update-tty_preexec
# If enable-ssh-support is set, fix ssh agent integration # If enable-ssh-support is set, fix ssh agent integration
if [[ $(gpgconf --list-options gpg-agent | awk -F: '$1=="enable-ssh-support" {print $10}') = 1 ]]; then if [[ $(gpgconf --list-options gpg-agent 2>/dev/null | awk -F: '$1=="enable-ssh-support" {print $10}') = 1 ]]; then
unset SSH_AGENT_PID unset SSH_AGENT_PID
if [[ "${gnupg_SSH_AUTH_SOCK_by:-0}" -ne $$ ]]; then if [[ "${gnupg_SSH_AUTH_SOCK_by:-0}" -ne $$ ]]; then
export SSH_AUTH_SOCK="$(gpgconf --list-dirs agent-ssh-socket)" export SSH_AUTH_SOCK="$(gpgconf --list-dirs agent-ssh-socket)"

View File

@ -2,21 +2,12 @@ if (( ! $+commands[helm] )); then
return return
fi fi
# TODO: 2021-12-28: delete this block
# Remove old generated file
command rm -f "${ZSH_CACHE_DIR}/helm_completion"
# TODO: 2021-12-28: remove this bit of code as it exists in oh-my-zsh.sh
# Add completions folder in $ZSH_CACHE_DIR
command mkdir -p "$ZSH_CACHE_DIR/completions"
(( ${fpath[(Ie)"$ZSH_CACHE_DIR/completions"]} )) || fpath=("$ZSH_CACHE_DIR/completions" $fpath)
# If the completion file does not exist, generate it and then source it # If the completion file does not exist, generate it and then source it
# Otherwise, source it and regenerate in the background # Otherwise, source it and regenerate in the background
if [[ ! -f "$ZSH_CACHE_DIR/completions/_helm" ]]; then if [[ ! -f "$ZSH_CACHE_DIR/completions/_helm" ]]; then
helm completion zsh >| "$ZSH_CACHE_DIR/completions/_helm" helm completion zsh | tee "$ZSH_CACHE_DIR/completions/_helm" >/dev/null
source "$ZSH_CACHE_DIR/completions/_helm" source "$ZSH_CACHE_DIR/completions/_helm"
else else
source "$ZSH_CACHE_DIR/completions/_helm" source "$ZSH_CACHE_DIR/completions/_helm"
helm completion zsh >| "$ZSH_CACHE_DIR/completions/_helm" &| helm completion zsh | tee "$ZSH_CACHE_DIR/completions/_helm" >/dev/null &|
fi fi

View File

@ -11,10 +11,4 @@ plugins=(... httpie)
It uses completion from [zsh-completions](https://github.com/zsh-users/zsh-completions). It uses completion from [zsh-completions](https://github.com/zsh-users/zsh-completions).
## Aliases
| Alias | Command |
| ------------ | ---------------------------------------------------------------- |
| `https` | `http --default-scheme=https` |
**Maintainer:** [lululau](https://github.com/lululau) **Maintainer:** [lululau](https://github.com/lululau)

View File

@ -1,7 +0,0 @@
#
# Aliases
# (sorted alphabetically)
#
alias https='http --default-scheme=https'

View File

@ -8,7 +8,7 @@ fi
# If method undefined, find the first one that is installed # If method undefined, find the first one that is installed
if [[ -z "$JSONTOOLS_METHOD" ]]; then if [[ -z "$JSONTOOLS_METHOD" ]]; then
for JSONTOOLS_METHOD in node python ruby; do for JSONTOOLS_METHOD in node python3 ruby; do
# If method found, break out of loop # If method found, break out of loop
(( $+commands[$JSONTOOLS_METHOD] )) && break (( $+commands[$JSONTOOLS_METHOD] )) && break
# Otherwise unset the variable # Otherwise unset the variable
@ -45,12 +45,12 @@ case "$JSONTOOLS_METHOD" in
xargs -0 node -e "console.log(decodeURIComponent(process.argv[1]))" xargs -0 node -e "console.log(decodeURIComponent(process.argv[1]))"
} }
;; ;;
python) python3)
function pp_json() { function pp_json() {
python -c 'import sys; del sys.path[0]; import runpy; runpy._run_module_as_main("json.tool")' python3 -c 'import sys; del sys.path[0]; import runpy; runpy._run_module_as_main("json.tool")'
} }
function is_json() { function is_json() {
python -c ' python3 -c '
import sys; del sys.path[0]; import sys; del sys.path[0];
import json import json
try: try:
@ -61,14 +61,14 @@ except ValueError:
' '
} }
function urlencode_json() { function urlencode_json() {
python -c ' python3 -c '
import sys; del sys.path[0]; import sys; del sys.path[0];
from urllib.parse import quote_plus from urllib.parse import quote_plus
print(quote_plus(sys.stdin.read())) print(quote_plus(sys.stdin.read()))
' '
} }
function urldecode_json() { function urldecode_json() {
python -c ' python3 -c '
import sys; del sys.path[0]; import sys; del sys.path[0];
from urllib.parse import unquote_plus from urllib.parse import unquote_plus
print(unquote_plus(sys.stdin.read())) print(unquote_plus(sys.stdin.read()))

View File

@ -15,34 +15,46 @@ Naming convention:
- `!` suffix: `--force --no-wait -y`. - `!` suffix: `--force --no-wait -y`.
- `ds` suffix: `--destroy-storage`. - `ds` suffix: `--destroy-storage`.
- `jsh` prefix means `juju show-*`.
### General ### General
| Alias | Command | Description | | Alias | Command | Description |
|--------|---------------------------------------------|--------------------------------------------------------| |---------|---------------------------------------------|--------------------------------------------------------|
| `jdl` | `juju debug-log --ms` | Display log, with millisecond resolution | | `j` | `juju` | The juju command |
| `jdlr` | `juju debug-log --ms --replay` | Replay entire log | | `jcld` | `juju clouds` | Lists all clouds with registered credentials |
| `jh` | `juju help` | Show help on a command or other topic | | `jclda` | `juju clouds --all` | Lists all clouds available to Juju |
| `jssl` | `juju juju show-status-log` | Output past statuses for the specified entity | | `jdl` | `juju debug-log --ms` | Display log, with millisecond resolution |
| `jstj` | `juju status --format=json` | Show status in json format (more detailed) | | `jdlr` | `juju debug-log --ms --replay` | Replay entire log |
| `jst` | `juju status --relations --storage --color` | Show status, including relations and storage, in color | | `jh` | `juju help` | Show help on a command or other topic |
| `jshsl` | `juju show-status-log` | Output past statuses for the specified entity |
| `jstj` | `juju status --format=json` | Show status in json format (more detailed) |
| `jst` | `juju status --relations --color` | Show status, including relations, in color |
| `jsts` | `juju status --relations --storage --color` | Show status, including relations and storage, in color |
### Bootstrap ### Bootstrap
| Alias | Command | Description | | Alias | Command | Description |
|-------|---------------------------|-------------------------------------------| |---------|-------------------------------------|-------------------------------------------------------|
| `jb` | `juju bootstrap` | Initializing a Juju cloud environment | | `jb` | `juju bootstrap` | Initializing a Juju cloud environment |
| `jbm` | `juju bootstrap microk8s` | Initializing a MicroK8s cloud environment | | `jbng` | `juju bootstrap --no-gui` | Initializing a Juju cloud environment without GUI |
| `jbl` | `juju bootstrap localhost` | Initializing an lxd cloud environment |
| `jblng` | `juju bootstrap --no-gui localhost` | Initializing an lxd cloud environment without GUI |
| `jbm` | `juju bootstrap microk8s` | Initializing a MicroK8s cloud environment |
| `jbmng` | `juju bootstrap --no-gui microk8s` | Initializing a MicroK8s cloud environment without GUI |
### Controller ### Controller
| Alias | Command | Description | | Alias | Command | Description |
|----------|---------------------------------------------------------------------------------------|-------------------------------------------------------------------| |----------|---------------------------------------------------------------------------------------|-------------------------------------------------------------------|
| `jctl` | `juju controllers` | List all controllers |
| `jctlr` | `juju controllers --refresh` | List all controllers (download latest details) |
| `jdc` | `juju destroy-controller --destroy-all-models` | Destroy a controller | | `jdc` | `juju destroy-controller --destroy-all-models` | Destroy a controller |
| `jdc!` | `juju destroy-controller --destroy-all-models --force --no-wait -y` | Destroy a controller | | `jdc!` | `juju destroy-controller --destroy-all-models --force --no-wait -y` | Destroy a controller |
| `jdcds` | `juju destroy-controller --destroy-all-models --destroy-storage` | Destroy a controller and associated storage | | `jdcds` | `juju destroy-controller --destroy-all-models --destroy-storage` | Destroy a controller and associated storage |
| `jdcds!` | `juju destroy-controller --destroy-all-models --destroy-storage --force --no-wait -y` | Destroy a controller and associated storage | | `jdcds!` | `juju destroy-controller --destroy-all-models --destroy-storage --force --no-wait -y` | Destroy a controller and associated storage |
| `jkc` | `juju kill-controller -y -t 0` | Forcibly terminate all associated resources for a Juju controller | | `jkc` | `juju kill-controller -y -t 0` | Forcibly terminate all associated resources for a Juju controller |
| `jshc` | `juju show-controller` | Shows detailed information of a controller |
| `jsw` | `juju switch` | Select or identify the current controller and model | | `jsw` | `juju switch` | Select or identify the current controller and model |
### Model ### Model
@ -74,9 +86,9 @@ Naming convention:
| `jrmds!` | `juju remove-application --destroy-storage --force --no-wait` | Remove application forcefully, destroying attached storage | | `jrmds!` | `juju remove-application --destroy-storage --force --no-wait` | Remove application forcefully, destroying attached storage |
| `jrp` | `juju refresh --path` | Upgrade charm from local charm file | | `jrp` | `juju refresh --path` | Upgrade charm from local charm file |
| `jsa` | `juju scale-application` | Set the desired number of application units | | `jsa` | `juju scale-application` | Set the desired number of application units |
| `jsh` | `juju ssh` | Initiate an SSH session or execute a command on a Juju target | | `jssh` | `juju ssh` | Initiate an SSH session or execute a command on a Juju target |
| `jshc` | `juju ssh --container` | Initiate an SSH session or execute a command on a given container | | `jsshc` | `juju ssh --container` | Initiate an SSH session or execute a command on a given container |
| `jsu` | `juju show-unit` | Displays information about a unit | | `jshu` | `juju show-unit` | Displays information about a unit |
### Storage ### Storage
@ -113,5 +125,6 @@ Naming convention:
- `jaddr <app_name> [unit_num]`: display app or unit IP address. - `jaddr <app_name> [unit_num]`: display app or unit IP address.
- `jreld <relation_name> <app_name> <unit_num>`: display app and unit relation data. - `jreld <relation_name> <app_name> <unit_num>`: display app and unit relation data.
- `jclean`: destroy all controllers
- `wjst [interval_secs] [args_for_watch]`: watch juju status, with optional interval - `wjst [interval_secs] [args_for_watch]`: watch juju status, with optional interval
(default: 5s); you may pass additional arguments to `watch`. (default: 5s); you may pass additional arguments to `watch`.

View File

@ -16,12 +16,22 @@ unset completion_file
# Generally, # # Generally, #
# - `!` means --force --no-wait -y # # - `!` means --force --no-wait -y #
# - `ds` suffix means --destroy-storage # # - `ds` suffix means --destroy-storage #
# - `jsh` prefix means juju show-* #
# ---------------------------------------------------------- # # ---------------------------------------------------------- #
alias j="juju"
alias jam="juju add-model --config logging-config=\"<root>=WARNING; unit=DEBUG\"\ alias jam="juju add-model --config logging-config=\"<root>=WARNING; unit=DEBUG\"\
--config update-status-hook-interval=\"60m\"" --config update-status-hook-interval=\"60m\""
alias jb='juju bootstrap' alias jb='juju bootstrap'
alias jbng='juju bootstrap --no-gui'
alias jbl='juju bootstrap localhost'
alias jblng='juju bootstrap --no-gui localhost'
alias jbm='juju bootstrap microk8s' alias jbm='juju bootstrap microk8s'
alias jbmng='juju bootstrap --no-gui microk8s'
alias jc='juju config' alias jc='juju config'
alias jcld='juju clouds'
alias jclda='juju clouds --all'
alias jctl='juju controllers'
alias jctlr='juju controllers --refresh'
alias jdc='juju destroy-controller --destroy-all-models' alias jdc='juju destroy-controller --destroy-all-models'
alias 'jdc!'='juju destroy-controller --destroy-all-models --force --no-wait -y' alias 'jdc!'='juju destroy-controller --destroy-all-models --force --no-wait -y'
alias jdcds='juju destroy-controller --destroy-all-models --destroy-storage' alias jdcds='juju destroy-controller --destroy-all-models --destroy-storage'
@ -56,13 +66,16 @@ alias jrp='juju refresh --path'
alias jrs='juju remove-storage' alias jrs='juju remove-storage'
alias 'jrs!'='juju remove-storage --force' alias 'jrs!'='juju remove-storage --force'
alias jsa='juju scale-application' alias jsa='juju scale-application'
alias jsh='juju ssh' alias jsha='juju show-application'
alias jshc='juju ssh --container' alias jshc='juju show-controller'
alias jshm='juju show-model' alias jshm='juju show-model'
alias jssl='juju show-status-log' alias jshsl='juju show-status-log'
alias jshu='juju show-unit'
alias jssh='juju ssh'
alias jsshc='juju ssh --container'
alias jstj='juju status --format=json' alias jstj='juju status --format=json'
alias jst='juju status --relations --storage --color' alias jst='juju status --relations --color'
alias jsu='juju show-unit' alias jsts='juju status --relations --storage --color'
alias jsw='juju switch' alias jsw='juju switch'
# ---------------------------------------------------------- # # ---------------------------------------------------------- #
@ -95,6 +108,37 @@ jaddr() {
fi fi
} }
# Destroy all controllers
jclean() {
if (( ! ${+commands[jq]} )); then
echo "jq is required but could not be found." >&2
return 1
fi
local controllers=$(juju controllers --format=json | jq -r '.controllers | keys[]' 2>/dev/null)
if [[ -z "$controllers" ]]; then
echo "No controllers registered"
return 0
fi
echo "This will forcefully destroy all storages, models and controllers."
echo "Controllers to be destroyed:"
echo "$controllers"
if ! read -q '?Are you sure (y/n)? '; then
echo
echo "Aborted."
return 0
fi
echo
for controller in ${=controllers}; do
timeout 2m juju destroy-controller --destroy-all-models --destroy-storage --force --no-wait -y $controller
timeout 2m juju kill-controller -y -t 0 $controller 2>/dev/null
timeout 10s juju unregister $controller 2>/dev/null
done
}
# Display app and unit relation data # Display app and unit relation data
jreld() { jreld() {
# $1 = relation name # $1 = relation name
@ -123,5 +167,6 @@ jreld() {
wjst() { wjst() {
local interval="${1:-5}" local interval="${1:-5}"
shift $(( $# > 0 )) shift $(( $# > 0 ))
watch -n "$interval" --color juju status --relations --storage --color "$@" watch -n "$interval" --color juju status --relations --color "$@"
} }

View File

@ -22,7 +22,7 @@ plugins=(... kubectl)
| kcsc | `kubectl config set-context` | Set a context entry in kubeconfig | | kcsc | `kubectl config set-context` | Set a context entry in kubeconfig |
| kcdc | `kubectl config delete-context` | Delete the specified context from the kubeconfig | | kcdc | `kubectl config delete-context` | Delete the specified context from the kubeconfig |
| kccc | `kubectl config current-context` | Display the current-context | | kccc | `kubectl config current-context` | Display the current-context |
| kcgc | `kubectl config get-contexts` | List of contexts available | kcgc | `kubectl config get-contexts` | List of contexts available |
| | | **General aliases** | | | | **General aliases** |
| kdel | `kubectl delete` | Delete resources by filenames, stdin, resources and names, or by resources and label selector | | kdel | `kubectl delete` | Delete resources by filenames, stdin, resources and names, or by resources and label selector |
| kdelf | `kubectl delete -f` | Delete a pod using the type and name specified in -f argument | | kdelf | `kubectl delete -f` | Delete a pod using the type and name specified in -f argument |
@ -71,9 +71,11 @@ plugins=(... kubectl)
| kdeld | `kubectl delete deployment` | Delete the deployment | | kdeld | `kubectl delete deployment` | Delete the deployment |
| ksd | `kubectl scale deployment` | Scale a deployment | | ksd | `kubectl scale deployment` | Scale a deployment |
| krsd | `kubectl rollout status deployment` | Check the rollout status of a deployment | | krsd | `kubectl rollout status deployment` | Check the rollout status of a deployment |
| kres | `kubectl set env $@ REFRESHED_AT=...` | Recreate all pods in deployment with zero-downtime | | kres | `kubectl set env $@ REFRESHED_AT=...` | Recreate all pods in deployment with zero-downtime |
| | | **Rollout management** | | | | **Rollout management** |
| kgrs | `kubectl get rs` | To see the ReplicaSet `rs` created by the deployment | | kgrs | `kubectl get replicaset` | List all ReplicaSets `rs` created by the deployment |
| kdrs | `kubectl describe replicaset` | Describe ReplicaSet in detail |
| kers | `kubectl edit replicaset` | Edit ReplicaSet from the default editor |
| krh | `kubectl rollout history` | Check the revisions of this deployment | | krh | `kubectl rollout history` | Check the revisions of this deployment |
| kru | `kubectl rollout undo` | Rollback to the previous revision | | kru | `kubectl rollout undo` | Rollback to the previous revision |
| | | **Port forwarding** | | | | **Port forwarding** |
@ -120,6 +122,11 @@ plugins=(... kubectl)
| kecj | `kubectl edit cronjob` | Edit CronJob from the default editor | | kecj | `kubectl edit cronjob` | Edit CronJob from the default editor |
| kdcj | `kubectl describe cronjob` | Describe a CronJob in details | | kdcj | `kubectl describe cronjob` | Describe a CronJob in details |
| kdelcj | `kubectl delete cronjob` | Delete the CronJob | | kdelcj | `kubectl delete cronjob` | Delete the CronJob |
| | | **Job management** |
| kgj | `kubectl get job` | List all Job in ps output format |
| kej | `kubectl edit job` | Edit a Job in details |
| kdj | `kubectl describe job` | Describe the Job |
| kdelj | `kubectl delete job` | Delete the Job |
## Wrappers ## Wrappers

View File

@ -1,21 +1,12 @@
if (( $+commands[kubectl] )); then if (( $+commands[kubectl] )); then
# TODO: 2022-01-05: remove this block
# remove old generated files
command rm -f "$ZSH_CACHE_DIR/kubectl_completion"
# TODO: 2022-01-05: remove this bit of code as it exists in oh-my-zsh.sh
# Add completions folder in $ZSH_CACHE_DIR
command mkdir -p "$ZSH_CACHE_DIR/completions"
(( ${fpath[(Ie)"$ZSH_CACHE_DIR/completions"]} )) || fpath=("$ZSH_CACHE_DIR/completions" $fpath)
# If the completion file does not exist, generate it and then source it # If the completion file does not exist, generate it and then source it
# Otherwise, source it and regenerate in the background # Otherwise, source it and regenerate in the background
if [[ ! -f "$ZSH_CACHE_DIR/completions/_kubectl" ]]; then if [[ ! -f "$ZSH_CACHE_DIR/completions/_kubectl" ]]; then
kubectl completion zsh >| "$ZSH_CACHE_DIR/completions/_kubectl" kubectl completion zsh | tee "$ZSH_CACHE_DIR/completions/_kubectl" >/dev/null
source "$ZSH_CACHE_DIR/completions/_kubectl" source "$ZSH_CACHE_DIR/completions/_kubectl"
else else
source "$ZSH_CACHE_DIR/completions/_kubectl" source "$ZSH_CACHE_DIR/completions/_kubectl"
kubectl completion zsh >| "$ZSH_CACHE_DIR/completions/_kubectl" &| kubectl completion zsh | tee "$ZSH_CACHE_DIR/completions/_kubectl" >/dev/null &|
fi fi
fi fi
@ -29,7 +20,7 @@ alias kca='_kca(){ kubectl "$@" --all-namespaces; unset -f _kca; }; _kca'
alias kaf='kubectl apply -f' alias kaf='kubectl apply -f'
# Drop into an interactive terminal on a container # Drop into an interactive terminal on a container
alias keti='kubectl exec -ti' alias keti='kubectl exec -t -i'
# Manage configuration quickly to switch contexts between local, dev ad staging. # Manage configuration quickly to switch contexts between local, dev ad staging.
alias kcuc='kubectl config use-context' alias kcuc='kubectl config use-context'
@ -112,7 +103,9 @@ function kres(){
} }
# Rollout management. # Rollout management.
alias kgrs='kubectl get rs' alias kgrs='kubectl get replicaset'
alias kdrs='kubectl describe replicaset'
alias kers='kubectl edit replicaset'
alias krh='kubectl rollout history' alias krh='kubectl rollout history'
alias kru='kubectl rollout undo' alias kru='kubectl rollout undo'
@ -178,6 +171,12 @@ alias kecj='kubectl edit cronjob'
alias kdcj='kubectl describe cronjob' alias kdcj='kubectl describe cronjob'
alias kdelcj='kubectl delete cronjob' alias kdelcj='kubectl delete cronjob'
# Job management.
alias kgj='kubectl get job'
alias kej='kubectl edit job'
alias kdj='kubectl describe job'
alias kdelj='kubectl delete job'
# Only run if the user actually has kubectl installed # Only run if the user actually has kubectl installed
if (( ${+_comps[kubectl]} )); then if (( ${+_comps[kubectl]} )); then
function kj() { kubectl "$@" -o json | jq; } function kj() { kubectl "$@" -o json | jq; }

View File

@ -3,7 +3,9 @@ typeset -g -A kubectx_mapping
function kubectx_prompt_info() { function kubectx_prompt_info() {
(( $+commands[kubectl] )) || return (( $+commands[kubectl] )) || return
local current_ctx=$(kubectl config current-context) local current_ctx=$(kubectl config current-context 2> /dev/null)
[[ -n "$current_ctx" ]] || return
# use value in associative array if it exists # use value in associative array if it exists
# otherwise fall back to the context name # otherwise fall back to the context name

View File

@ -0,0 +1,22 @@
# multipass
This plugin provides completion for [multipass](https://multipass.run), as well as aliases
for multipass commands.
To use it, add `multipass` to the plugins array in your zshrc file:
```zsh
plugins=(... multipass)
```
## Aliases
| Alias | Command |
| ------ | ------------------------------------------------------------------- |
| `mp` | `multipass` |
| `mpl` | `multipass list` |
| `mpla` | `multipass launch` |
| `mpln` | `multipass launch --network en0 --network name=bridge0,mode=manual` |
| `mps` | `multipass shell` |
| `mpsp` | `multipass stop` |
| `mpst` | `multipass start` |

View File

@ -0,0 +1,73 @@
#compdef multipass
_multipass_get_command_list () {
# Sample output:
# $ multipass --help
# ...
# Options:
# -h, --help Display this help
# -v, --verbose Increase logging verbosity. Repeat the 'v' in the short option
# for more detail. Maximum verbosity is obtained with 4 (or more)
# v's, i.e. -vvvv.
# ...
# Available commands:
# alias Create an alias
# aliases List available aliases
# ...
#
$_comp_command1 --help | sed '1,/Available commands/d' | awk '/^[ \t]*[a-z]+/ { print $1 }'
}
_multipass_get_args_list () {
# Sample output:
# $ multpass help stop
# ...
# Options:
# -h, --help Display this help
# -v, --verbose Increase logging verbosity. Repeat the 'v' in the short
# option for more detail. Maximum verbosity is obtained with
# 4 (or more) v's, i.e. -vvvv.
# --all Stop all instances
# -t, --time <time> Time from now, in minutes, to delay shutdown of the
# instance
# -c, --cancel Cancel a pending delayed shutdown
#
# Arguments:
# name Names of instances to stop. If omitted, and without the
# --all option, 'primary' will be assumed.
#
local arg_name=$($_comp_command1 help ${words[2]} | sed '1,/Arguments/d' | awk '/^[ \t]*[a-z]+/ { print $1; exit }')
case $arg_name in
name)
# Sample output:
# $ multipass list
# Name State IPv4 Image
# workable-poacher Running 10.2.0.28 Ubuntu openHAB Home Appliance
#
$_comp_command1 list | sed '1d' | awk '/^[ \t]*[^ ]+/ { print $1 }'
;;
command)
_multipass_get_command_list
;;
esac
}
_multipass () {
typeset -A opt_args
_arguments \
'1: :->command'\
'*: :->args'
case $state in
command)
compadd $(_multipass_get_command_list)
;;
*)
compadd $(_multipass_get_args_list)
;;
esac
}
_multipass "$@"

View File

@ -0,0 +1,7 @@
alias mp="multipass"
alias mpl="multipass list"
alias mpla="multipass launch"
alias mpln="multipass launch --network en0 --network name=bridge0,mode=manual"
alias mps="multipass shell"
alias mpsp="multipass stop"
alias mpst="multipass start"

View File

@ -8,22 +8,24 @@ if [[ -z "$NVM_DIR" ]]; then
fi fi
# Don't try to load nvm if command already available # Don't try to load nvm if command already available
which nvm &> /dev/null && return # Note: nvm is a function so we need to use `which`
! which nvm &>/dev/null || return
if [[ -f "$NVM_DIR/nvm.sh" ]]; then if [[ -f "$NVM_DIR/nvm.sh" ]]; then
# Load nvm if it exists in $NVM_DIR # Load nvm if it exists in $NVM_DIR
source "$NVM_DIR/nvm.sh" ${NVM_LAZY+"--no-use"} source "$NVM_DIR/nvm.sh" ${NVM_LAZY+"--no-use"}
else elif (( $+commands[brew] )); then
# Otherwise try to load nvm installed via Homebrew # Otherwise try to load nvm installed via Homebrew
# User can set this if they have an unusual Homebrew setup # User can set this if they have an unusual Homebrew setup
NVM_HOMEBREW="${NVM_HOMEBREW:-/usr/local/opt/nvm}" NVM_HOMEBREW="${NVM_HOMEBREW:-${HOMEBREW_PREFIX:-$(brew --prefix)}/opt/nvm}"
# Load nvm from Homebrew location if it exists # Load nvm from Homebrew location if it exists
if [[ -f "$NVM_HOMEBREW/nvm.sh" ]]; then if [[ -f "$NVM_HOMEBREW/nvm.sh" ]]; then
source "$NVM_HOMEBREW/nvm.sh" ${NVM_LAZY+"--no-use"} source "$NVM_HOMEBREW/nvm.sh" ${NVM_LAZY+"--no-use"}
else else
# Exit the plugin if we couldn't find nvm
return return
fi fi
else
return
fi fi
# Call nvm when first using node, npm or yarn # Call nvm when first using node, npm or yarn

View File

@ -89,7 +89,7 @@ if [[ $FOUND_PYENV -eq 1 ]]; then
else else
# Fall back to system python # Fall back to system python
function pyenv_prompt_info() { function pyenv_prompt_info() {
local version="$(python -V 2>&1 | cut -d' ' -f2)" local version="$(python3 -V 2>&1 | cut -d' ' -f2)"
echo "system: ${version:gs/%/%%}" echo "system: ${version:gs/%/%%}"
} }
fi fi

View File

@ -12,7 +12,7 @@ plugins=(... python)
| Command | Description | | Command | Description |
| ---------------- | -------------------------------------------------------------------------------------- | | ---------------- | -------------------------------------------------------------------------------------- |
| `py` | Runs `python` | | `py` | Runs `python3` |
| `ipython` | Runs the appropriate `ipython` version according to the activated virtualenv | | `ipython` | Runs the appropriate `ipython` version according to the activated virtualenv |
| `pyfind` | Finds .py files recursively in the current directory | | `pyfind` | Finds .py files recursively in the current directory |
| `pyclean [dirs]` | Deletes byte-code and cache files from a list of directories or the current one | | `pyclean [dirs]` | Deletes byte-code and cache files from a list of directories or the current one |

View File

@ -1,5 +1,5 @@
# python command # python command
alias py='python' alias py='python3'
# Find python file # Find python file
alias pyfind='find . -name "*.py"' alias pyfind='find . -name "*.py"'
@ -44,10 +44,10 @@ function pyuserpaths() {
alias pygrep='grep -nr --include="*.py"' alias pygrep='grep -nr --include="*.py"'
# Run proper IPython regarding current virtualenv (if any) # Run proper IPython regarding current virtualenv (if any)
alias ipython="python -c 'import IPython; IPython.terminal.ipapp.launch_new_instance()'" alias ipython="python3 -c 'import IPython; IPython.terminal.ipapp.launch_new_instance()'"
# Share local directory as a HTTP server # Share local directory as a HTTP server
alias pyserver="python -m http.server" alias pyserver="python3 -m http.server"
## venv utilities ## venv utilities

View File

@ -1,6 +1,7 @@
# Rails # Rails
This plugin adds completion for [Ruby On Rails Framework](https://rubyonrails.org/) and [Rake](https://ruby.github.io/rake/) commands, as well as some aliases for logs and environment variables. This plugin adds completion for [Ruby On Rails Framework](https://rubyonrails.org/) and
[Rake](https://ruby.github.io/rake/) commands, as well as some aliases for logs and environment variables.
To use it, add `rails` to the plugins array in your zshrc file: To use it, add `rails` to the plugins array in your zshrc file:
@ -12,47 +13,52 @@ plugins=(... rails)
### Rails aliases ### Rails aliases
| Alias | Command | Description | | Alias | Command | Description |
|-------|----------------------------|----------------------------------------------------| | ------- | -------------------------------- | ------------------------------------------------------ |
| `rc` | `rails console` | Interact with your Rails app from the CLI | | `rc` | `rails console` | Interact with your Rails app from the CLI |
| `rcs` | `rails console --sandbox` | Test code in a sandbox, without changing any data | | `rcs` | `rails console --sandbox` | Test code in a sandbox, without changing any data |
| `rd` | `rails destroy` | Undo a generate operation | | `rd` | `rails destroy` | Undo a generate operation |
| `rdb` | `rails dbconsole` | Interact with your db from the console | | `rdb` | `rails dbconsole` | Interact with your db from the console |
| `rgen`| `rails generate` | Generate boilerplate code | | `rdc` | `rails db:create` | Create the database |
| `rgm` | `rails generate migration` | Generate a db migration | | `rdd` | `rails db:drop` | Delete the database |
| `rp` | `rails plugin` | Run a Rails plugin command | | `rdm` | `rails db:migrate` | Run pending db migrations |
| `rr` | `rails routes` | List all defined routes | | `rdmd` | `rails db:migrate:down` | Undo specific db migration |
| `rrg` | `rails routes \| grep` | List and filter the defined routes | | `rdmr` | `rails db:migrate:redo` | Redo specific db migration |
| `ru` | `rails runner` | Run Ruby code in the context of Rails | | `rdms` | `rails db:migrate:status` | Show current db migration status |
| `rs` | `rails server` | Launch a web server | | `rdmtc` | `rails db:migrate db:test:clone` | Run pending migrations and clone db into test database |
| `rsd` | `rails server --debugger` | Launch a web server with debugger | | `rdmu` | `rails db:migrate:up` | Run specific db migration |
| `rsp` | `rails server --port` | Launch a web server and specify the listening port | | `rdr` | `rails db:rollback` | Roll back the last migration |
| `rdrs` | `rails db:reset` | Delete the database and set it up again |
| `rds` | `rails db:seed` | Seed the database |
| `rdsl` | `rails db:schema:load` | Load the database schema |
| `rdtc` | `rails db:test:clone` | Clone the database into the test database |
| `rdtp` | `rails db:test:prepare` | Duplicate the db schema into your test database |
| `rgen` | `rails generate` | Generate boilerplate code |
| `rgm` | `rails generate migration` | Generate a db migration |
| `rlc` | `rails log:clear` | Clear Rails logs |
| `rmd` | `rails middleware` | Interact with Rails middlewares |
| `rn` | `rails notes` | Search for notes (`FIXME`, `TODO`) in code comments |
| `rp` | `rails plugin` | Run a Rails plugin command |
| `rr` | `rails routes` | List all defined routes |
| `rrg` | `rails routes \| grep` | List and filter the defined routes |
| `rs` | `rails server` | Launch a web server |
| `rsb` | `rails server --bind` | Launch a web server binding it to a specific IP |
| `rsd` | `rails server --debugger` | Launch a web server with debugger |
| `rsp` | `rails server --port` | Launch a web server and specify the listening port |
| `rsts` | `rails stats` | Print code statistics |
| `rt` | `rails test` | Run Rails tests |
| `ru` | `rails runner` | Run Ruby code in the context of Rails |
### Rake aliases ### Foreman
| Alias | Command | Description | | Alias | Command | Description |
|---------|---------------------------------|--------------------------------------------------------| | ------ | --------------- | ----------------------------------------- |
| `rdm` | `rake db:migrate` | Run pending db migrations | | `fmns` | `foreman start` | Interact with your Rails app from the CLI |
| `rdms` | `rake db:migrate:status` | Show current db migration status |
| `rdmtc` | `rake db:migrate db:test:clone` | Run pending migrations and clone db into test database |
| `rdr` | `rake db:rollback` | Roll back the last migration |
| `rdc` | `rake db:create` | Create the database |
| `rds` | `rake db:seed` | Seed the database |
| `rdd` | `rake db:drop` | Delete the database |
| `rdrs` | `rake db:reset` | Delete the database and set it up again |
| `rdtc` | `rake db:test:clone` | Clone the database into the test database |
| `rdtp` | `rake db:test:prepare` | Duplicate the db schema into your test database |
| `rdsl` | `rake db:schema:load` | Load the database schema |
| `rlc` | `rake log:clear` | Clear Rails logs |
| `rn` | `rake notes` | Search for notes (`FIXME`, `TODO`) in code comments |
| `rt` | `rake test` | Run Rails tests |
| `rmd` | `rake middleware` | Interact with Rails middlewares |
| `rsts` | `rake stats` | Print code statistics |
### Utility aliases ### Utility aliases
| Alias | Command | Description | | Alias | Command | Description |
|-----------|-------------------------------|------------------------------------------------| | --------- | ----------------------------- | ---------------------------------------------- |
| `devlog` | `tail -f log/development.log` | Show and follow changes to the development log | | `devlog` | `tail -f log/development.log` | Show and follow changes to the development log |
| `prodlog` | `tail -f log/production.log` | Show and follow changes to the production log | | `prodlog` | `tail -f log/production.log` | Show and follow changes to the production log |
| `testlog` | `tail -f log/test.log` | Show and follow changes to the test log | | `testlog` | `tail -f log/test.log` | Show and follow changes to the test log |
@ -60,7 +66,7 @@ plugins=(... rails)
### Environment settings ### Environment settings
| Alias | Command | Description | | Alias | Command | Description |
|-------|-------------------------|---------------------------------| | ----- | ----------------------- | ------------------------------- |
| `RED` | `RAILS_ENV=development` | Sets `RAILS_ENV` to development | | `RED` | `RAILS_ENV=development` | Sets `RAILS_ENV` to development |
| `REP` | `RAILS_ENV=production` | Sets `RAILS_ENV` to production | | `REP` | `RAILS_ENV=production` | Sets `RAILS_ENV` to production |
| `RET` | `RAILS_ENV=test` | Sets `RAILS_ENV` to test | | `RET` | `RAILS_ENV=test` | Sets `RAILS_ENV` to test |
@ -68,15 +74,45 @@ plugins=(... rails)
These are global aliases. Use in combination with a command or just run them These are global aliases. Use in combination with a command or just run them
separately. For example: `REP rake db:migrate` will migrate the production db. separately. For example: `REP rake db:migrate` will migrate the production db.
### Legacy stuff ## Legacy
### Rake aliases
The following commands are run [using `rails` instead of `rake` since Rails v5][1], but are preserved under the
prefix `rk` for backwards compatibility.
[1]: https://guides.rubyonrails.org/v5.2/command_line.html#bin-rails
| Alias | Command | Description |
| -------- | ------------------------------- | ------------------------------------------------------ |
| `rkdc` | `rake db:create` | Create the database |
| `rkdd` | `rake db:drop` | Delete the database |
| `rkdm` | `rake db:migrate` | Run pending db migrations |
| `rkdms` | `rake db:migrate:status` | Show current db migration status |
| `rkdmtc` | `rake db:migrate db:test:clone` | Run pending migrations and clone db into test database |
| `rkdr` | `rake db:rollback` | Roll back the last migration |
| `rkdrs` | `rake db:reset` | Delete the database and set it up again |
| `rkds` | `rake db:seed` | Seed the database |
| `rkdsl` | `rake db:schema:load` | Load the database schema |
| `rkdtc` | `rake db:test:clone` | Clone the database into the test database |
| `rkdtp` | `rake db:test:prepare` | Duplicate the db schema into your test database |
| `rklc` | `rake log:clear` | Clear Rails logs |
| `rkmd` | `rake middleware` | Interact with Rails middlewares |
| `rkn` | `rake notes` | Search for notes (`FIXME`, `TODO`) in code comments |
| `rksts` | `rake stats` | Print code statistics |
| `rkt` | `rake test` | Run Rails tests |
### Other
| Alias | Command | | Alias | Command |
|---------|------------------------------------| | ------- | ---------------------------------- |
| `sstat` | `thin --stats "/thin/stats" start` | | `sc` | `ruby script/console` |
| `sg` | `ruby script/generate` |
| `sd` | `ruby script/destroy` | | `sd` | `ruby script/destroy` |
| `sd` | `ruby script/server --debugger` |
| `sg` | `ruby script/generate` |
| `sp` | `ruby script/plugin` | | `sp` | `ruby script/plugin` |
| `sr` | `ruby script/runner` | | `sr` | `ruby script/runner` |
| `ssp` | `ruby script/spec` | | `ssp` | `ruby script/spec` |
| `sc` | `ruby script/console` | | `sstat` | `thin --stats "/thin/stats" start` |
| `sd` | `ruby script/server --debugger` |
- `remote_console <server> <directory>`: runs `ruby script/console production` on a remote server.

View File

@ -1,66 +1,624 @@
#compdef rails #compdef rails
#autoload # ------------------------------------------------------------------------------
# Copyright (c) 2016 Github zsh-users - http://github.com/zsh-users
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of the zsh-users nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# ------------------------------------------------------------------------------
# Description
# -----------
#
# Completion script for Ruby on Rails (http://rubyonrails.org/).
#
# ------------------------------------------------------------------------------
# Authors
# -------
#
# * Kazuya Takeshima (https://github.com/mitukiii)
#
# ------------------------------------------------------------------------------
local -a _1st_arguments
_1st_arguments=(
'generate:Generate new code (short-cut alias: "g")'
'console:Start the Rails console (short-cut alias: "c")'
'server:Start the Rails server (short-cut alias: "s")'
'dbconsole:Start a console for the database specified in config/database.yml (short-cut alias: "db")'
'new:Create a new Rails application. "rails new my_app" creates a new application called MyApp in "./my_app"'
'application:Generate the Rails application code'
'destroy:Undo code generated with "generate"'
'benchmarker:See how fast a piece of code runs' _rails() {
'profiler:Get profile information from a piece of code' local context state line curcontext="$curcontext"
'plugin:Install a plugin'
'plugin new:Generates skeleton for developing a Rails plugin' if (( CURRENT > 2 )); then
'runner:Run a piece of code in the application environment (short-cut alias: "r")' (( CURRENT-- ))
) shift words
_call_function - "_rails_${words[1]}" || _nothing
_rails_generate_arguments() { else
generate_arguments=( __rails_commands
assets fi
controller
decorator
generator
helper
integration_test
mailer
migration
model
observer
performance_test
plugin
resource
scaffold
scaffold_controller
session_migration
stylesheets
task
)
} }
__rails_commands() {
local context state line curcontext="$curcontext"
_arguments \ local -a rails_options
'(--version)--version[show version]' \ __rails_setup_rails_options
'(--help)--help[show help]' \
'*:: :->subcmds' && return 0
if (( CURRENT == 1 )); then _arguments -C \
_describe -t commands "rails subcommand" _1st_arguments $rails_options \
return ': :->command'
else
_files
return
fi
case "$words[1]" in case "$state" in
g|generate) command)
_rails_generate_arguments local -a commands
_wanted generate_arguments expl 'all generate' compadd -a generate_arguments ;; local application_directory
d|destroy) __rails_setup_application_directory
_rails_generate_arguments
_wanted generate_arguments expl 'all generate' compadd -a generate_arguments ;; if [ -n "$application_directory" ]; then
esac commands=(
{generate,g}'[Generate new code]'
{console,c}'[Start the Rails console]'
{server,s}'[Start the Rails server]'
{dbconsole,db}'[Start a console for the database specified in config/database.yml]'
application'[Generate the Rails application code]'
{destroy,d}'[Undo code generated with "generate"]'
benchmarker'[See how fast a piece of code runs]'
profiler'[Get profile information from a piece of code]'
plugin'[Install a plugin]'
{runner,r}'[Run a piece of code in the application environment]'
{test,t}'[Run tests]'
)
else
commands=(
new'[Create a new Rails application]'
)
fi
_values 'command' $commands
;;
esac
}
__rails_setup_application_directory() {
application_directory="$(pwd)"
while [ -n "$application_directory" ]; do
if [ -f "${application_directory}/script/rails" -o -f "${application_directory}/bin/rails" ]; then
return
fi
application_directory="${application_directory%/*}"
done
application_directory=
}
__rails_setup_rails_options() {
rails_options=(
{-h,--help}'[Show this help message and quit]'
{-v,--version}'[Show Rails version number and quit]'
)
}
__rails_setup_runtime_options() {
runtime_options=(
'(-f --force)'{-f,--force}'[Overwrite files that already exist]'
'(-p --pretend)'{-p,--pretend}'[Run but do not make any changes]'
'(-q --quiet)'{-q,--quiet}'[Suppress status output]'
'(-s --skip)'{-s,--skip}'[Skip files that already exist]'
)
}
__rails_setup_generators_options() {
local -a runtime_options
__rails_setup_runtime_options
generators_options=(
$runtime_options
--skip-namespace'[Skip namespace (affects only isolated applications)]'
--old-style-hash"[Force using old style hash (:foo => 'bar') on Ruby >= 1.9]"
)
}
__rails_setup_model_generators_options() {
local -a generators_options
__rails_setup_generators_options
model_generators_options=(
$generators_options
'(-o --orm)'{-o,--orm=}'[Orm to be invoked]:orm'
)
}
__rails_setup_resource_generators_options() {
local -a model_generators_options
__rails_setup_model_generators_options
resource_generators_options=(
$model_generators_options
--force-plural'[Forces the use of a plural ModelName]'
--resource-route'[Indicates when to generate resource route]: :__rails_boolean'
)
}
__rails_boolean() {
_values 'boolean' 'true' 'false'
}
__rails_migration_fields() {
if compset -P '*:*:'; then
_values 'index' 'index' 'uniq'
else
if compset -P '*:'; then
_values -s ':' 'type' 'string' 'text' 'integer' 'float' 'decimal' 'datetime' 'timestamp' 'time' 'date' 'binary' 'boolean' 'references'
else
_guard '[[:alnum:]_]#' 'field'
fi
fi
}
_rails_generate() {
local context state line curcontext="$curcontext"
if (( CURRENT > 2 )); then
(( CURRENT-- ))
shift words
_call_function - "_rails_generate_${words[1]}" || _rails_generate_default
else
__rails_generate_commands
fi
}
_rails_g() {
_rails_generate
}
__rails_generate_commands() {
local context curcontext="$curcontext" update_policy
zstyle -s ":completion:${curcontext}:" cache-policy update_policy
if [ -z "$update_policy" ]; then
zstyle ":completion:${curcontext}:" cache-policy _rails_generate_commands_caching_policy
fi
local application_directory
__rails_setup_application_directory
local cache_name
cache_name="rails/${application_directory##*/}/all_generators"
if ! _retrieve_cache ${cache_name}; then
local -a all_generators
all_generators=($(_call_program rails_generators rails generate 2> /dev/null | awk '/^ [a-zA-Z_]+/{ print $1 }'))
_store_cache ${cache_name} all_generators
fi
local -a rails_generators
rails_generators=(${all_generators:#*:*})
_describe -t rails_generators 'rails generator' rails_generators
local -a -U namespaces
local namespace
local -a generators
namespaces=(${(R)${(M)all_generators:#*:*}%:*})
for namespace in $namespaces; do
generators=(${${(M)all_generators:#${namespace}:*}/:/\\:})
_describe -t ${namespace}_generators "${namespace/_/ } generator" generators
done
}
_rails_generate_commands_caching_policy() {
local application_directory
__rails_setup_application_directory
if [ "${application_directory}/Gemfile" -nt "$1" ]; then
return 0
fi
local -a oldp
oldp=( "$1"(Nmw+1) )
(( $#oldp ))
}
_rails_generate_default() {
local -a generators_options
__rails_setup_generators_options
_arguments \
$generators_options \
'*:argument'
}
_rails_generate_assets() {
local -a generators_options
__rails_setup_generators_options
_arguments \
$generators_options \
'(-j --javascripts)'{-j,--javascripts}'[Generate JavaScripts]: :__rails_boolean' \
'(-y --stylesheets)'{-y,--stylesheets}'[Generate Stylesheets]: :__rails_boolean' \
'(-je --javascript-engine)'{-je,--javascript-engine=}'[Engine for JavaScripts]:javascript engine' \
'(-se --stylesheet-engine)'{-se,--stylesheet-engine=}'[Engine for Stylesheets]:stylesheet engine' \
': :_guard "^-*" "name"'
}
_rails_generate_controller() {
local -a generators_options
__rails_setup_generators_options
_arguments \
$generators_options \
'(-e --template-engine)'{-e,--template-engine=}'[Template engine to be invoked]:template engine' \
'(-t --test-framework)'{-t,--test-framework=}'[Test framework to be invoked]:test framework' \
--helper'[Indicates when to generate helper]: :__rails_boolean' \
--assets'[Indicates when to generate assets]: :__rails_boolean' \
': :_guard "^-*" "name"' \
'*: :_guard "^-*" "action"'
}
_rails_generate_generator() {
local -a generators_options
__rails_setup_generators_options
_arguments \
$generators_options \
--namespace'[Namespace generator under lib/generators/name]: :__rails_boolean' \
': :_guard "^-*" "name"'
}
_rails_generate_helper() {
local -a generators_options
__rails_setup_generators_options
_arguments \
$generators_options \
'(-t --test-framework)'{-t,--test-framework=}'[Test framework to be invoked]:test framework' \
': :_guard "^-*" "name"' \
}
_rails_generate_integration_test() {
local -a generators_options
__rails_setup_generators_options
_arguments \
$generators_options \
--integration-tool='[Integration tool to be invoke]:integration tool' \
': :_guard "^-*" "name"' \
}
_rails_generate_jbuilder() {
local -a generators_options
__rails_setup_generators_options
_arguments \
$generators_options \
': :_guard "^-*" "name"' \
'*: :__rails_migration_fields'
}
_rails_generate_mailer() {
local -a generators_options
__rails_setup_generators_options
_arguments \
$generators_options \
'(-e --template-engine)'{-e,--template-engine=}'[Template engine to be invoked]:template engine' \
'(-t --test-framework)'{-t,--test-framework=}'[Test framework to be invoked]:test framework' \
': :_guard "^-*" "name"' \
'*: :_guard "^-*" "method"'
}
_rails_generate_migration() {
local -a modelgenerators_options
__rails_setup_model_generators_options
_arguments \
$model_generators_options \
': :_guard "^-*" "name"' \
'*: :__rails_migration_fields'
}
_rails_generate_model() {
_rails_generate_migration
}
_rails_generate_observer() {
local -a model_generators_options
__rails_setup_model_generators_options
_arguments \
$model_generators_options \
': :_guard "^-*" "name"'
}
_rails_generate_performance_test() {
local -a generators_options
__rails_setup_generators_options
_arguments \
$generators_options \
--performance-tool='[Performance tool to be invoked]:performance tool' \
': :_guard "^-*" "name"' \
}
_rails_generate_resource() {
local context state line curcontext="$curcontext"
local -a resource_generators_options
__rails_setup_resource_generators_options
_arguments -C \
$resource_generators_options \
'(-c --resource-controller)'{-c,--resource-controller=}'[Resource controller to be invoked]:name' \
'(-a --actions)'{-a,--actions=}'[Actions for the resource controller]: :->actions' \
': :->name' \
'*: :->fields'
if (( words[(I)(--actions=*|-a)] > 0 && words[(I)(--actions=*|-a)] == words[(I)-*] )); then
state=actions
fi
case "$state" in
actions)
_guard "[[:alnum:]_]#" "actions"
;;
name)
_guard "^-*" "name"
;;
fields)
__rails_migration_fields
;;
esac
}
_rails_generate_scaffold() {
local -a resource_generators_options
__rails_setup_resource_generators_options
_arguments \
$resource_generators_options \
'(-y --stylesheets)'{-y,--stylesheets}'[Generate Stylesheets]: :__rails_boolean' \
'(-se --stylesheet-engine)'{-se,--stylesheet-engine=}'[Engine for Stylesheets]:stylesheet engine' \
'(-c --scaffold-controller)'{-c,--scaffold-controller=}'[Scaffold controller to be invoked]:name' \
--assets'[Indicates when to generate assets]:boolean:(true false)' \
': :_guard "^-*" "name"' \
'*: :__rails_migration_fields'
}
_rails_generate_scaffold_controller() {
local -a model_generators_options
__rails_setup_model_generators_options
_arguments \
$model_generators_options \
'(-e --template-engine)'{-e,--template-engine=}'[Template engine to be invoked]:template engine' \
'(-t --test-framework)'{-t,--test-framework=}'[Test framework to be invoked]:test framework' \
--helper'[Indicates when to generate helper]: :__rails_boolean' \
': :_guard "^-*" "name"'
}
_rails_generate_session_migration() {
local -a model_generators_options
__rails_setup_model_generators_options
_arguments \
$model_generators_options \
': :_guard "^-*" "name"'
}
_rails_generate_task() {
local -a generators_options
__rails_setup_generators_options
_arguments \
$generators_options \
': :_guard "^-*" "name"' \
'*: :_guard "^-*" "action"'
}
_rails_console() {
_arguments \
'(- *)'{-h,--help}'[Show this help message]' \
'(-s --sandbox)'{-s,--sandbox}'[Rollback database modifications on exit]' \
--debugger'[Enable ruby-debugging for the console]'
}
_rails_c() {
_rails_console
}
_rails_server() {
_arguments \
'(- *)'{-h,--help}'[Show this help message]' \
'(-p --port)'{-p,--port=}'[Runs Rails on the specified port]: :_guard "[[\:digit\:]]#" "port"' \
'(-b --binding)'{-b,--binding=}'[Binds Rails to the specified ip]:ip:_hosts' \
'(-c --config)'{-c,--config=}'[Use custom rackup configuration file]:file:_files -g "*.ru"' \
'(-d --daemon)'{-d,--daemon}'[Make server run as a Daemon]' \
'(-u --debugger)'{-u,--debugger}'[Enable ruby-debugging for the server]' \
'(-e --environment)'{-e,--environment=}'[Specifies the environment to run this server under (test/development/production)]:name:(test development production)' \
'(-P --pid)'{-P,--pid=}'[Specifies the PID file]:pid:_files -g "*.pid"'
}
_rails_s() {
_rails_server
}
_rails_dbconsole() {
_arguments \
'(- *)'--help'[Show this help message]' \
'(-p --include-password)'{-p,--include-password}'[Automatically provide the password from database.yml]' \
--mode'[Automatically put the sqlite3 database in the specified mode (html, list, line, column)]:mode:(html list line column)' \
--header
}
_rails_new() {
local context state line curcontext="$curcontext"
local _a rails_options runtime_options
__rails_setup_rails_options
__rails_setup_runtime_options
_arguments -C \
$rails_options \
$runtime_options \
'(-r --ruby)'{-r,--ruby=}'[Path to the Ruby binary of your choice]:path' \
'(-b --builder)'{-b,--builder=}'[Path to a application builder (can be a filesystem path or URL)]: :->path_or_url' \
'(-m --template)'{-m,--template=}'[Path to an application template (can be a filesystem path or URL)]: :->path_or_url' \
--skip-gemfile"[Don't create a Gemfile]" \
--skip-bundle"[Don't run bundle install]" \
'(-G --skip-git)'{-G,--skip-git}'[Skip Git ignores and keeps]' \
'(-O --skip-active-record)'{-O,--skip-active-record}'[Skip Active Record files]' \
'(-S --skip-sprockets)'{-S,--skip-sprockets}'[Skip Sprockets files]' \
'(-d --database)'{-d,--database=}'[Preconfigure for selected database]:database:(mysql oracle postgresql sqlite3 frontbase ibm_db sqlserver jdbcmysql jdbcsqlite3 jdbcpostgresql jdbc)' \
'(-j --javascript)'{-j,--javascript=}'[Preconfigure for selected JavaScript library]:javascript' \
'(-J --skip-javascript)'{-J,--skip-javascript}'[Skip JavaScript files]' \
--dev'[Setup the application with Gemfile pointing to your Rails checkout]' \
--edge'[Setup the application with Gemfile pointing to Rails repository]' \
'(-T --skip-test-unit)'{-T,--skip-test-unit}'[Skip Test::Unit files]' \
--old-style-hash"[Force using old style hash (:foo => 'bar') on Ruby >= 1.9]" \
':app path:_directories'
case "$state" in
path_or_url)
_alternative \
'files:path:_files -g "*.rb"' \
'url:url:_urls'
;;
esac
}
_rails_application() {
_rails_new
}
_rails_db() {
_rails_dbconsole
}
_rails_destroy() {
_rails_generate
}
_rails_d() {
_rails_destroy
}
_rails_benchmarker() {
_arguments \
'(- *)'{-h,--help}'[Show this help message]' \
'(-r --runs)'{-r,--runs}'[Number of runs]: :_guard "[[\:digit\:]]#" "number"' \
'(-o --output)'{-o,--output}'[Directory to use when writing the results]:directory:_directories' \
'(-m --metrics)'{-m,--metrics}'[Metrics to use]: :_values -s "," "metrics" "wall_time" "memory" "objects" "gc_runs" "gc_time"' \
'*: :_guard "^-*" "ruby code"'
}
_rails_profiler() {
_arguments \
'(- *)'{-h,--help}'[Show this help message]' \
'(-r --runs)'{-r,--runs}'[Number of runs]: :_guard "[[\:digit\:]]#" "number"' \
'(-o --output)'{-o,--output}'[Directory to use when writing the results]:directory:_directories' \
'(-m --metrics)'{-m,--metrics}'[Metrics to use]: :_values -s "," "metrics" "process_time" "memory" "objects"' \
'(-f --formats)'{-f,--formats}'[Formats to output to]: :_values -s "," "formats" "flat" "graph" "html" "call_tree" "call_stack"' \
'*: :_guard "^-*" "ruby code"'
}
_rails_plugin() {
local context state line curcontext="$curcontext"
if (( CURRENT > 2 )); then
(( CURRENT-- ))
shift words
_call_function - "_rails_plugin_${words[1]}" || _nothing
else
__rails_plugin_commands
fi
}
__rails_plugin_commands() {
_values 'plugin command' \
install'[Install plugin(s) from known repositories or URLs]' \
remove'[Uninstall plugins]' \
new
}
_rails_plugin_install() {
_arguments \
'(-x --externals)'{-x,--externals}'[Use svn:externals to grab the plugin. Enables plugin updates and plugin versioning]' \
'(-o --checkout)'{-o,--checkout}'[Use svn checkout to grab the plugin. Enables updating but does not add a svn:externals entry]' \
'(-e --export)'{-e,--export}'[Use svn export to grab the plugin. Exports the plugin, allowing you to check it into your local repository. Does not enable updates or add an svn:externals entry]' \
'(-q --quiet)'{-q,--quiet}'[Suppresses the output from installation. Ignored if -v is passed (rails plugin -v install ...)]' \
'(-r --revision)'{-r,--revision=}'[Checks out the given revision from subversion or git. Ignored if subversion/git is not used]:revision' \
'(-f --force)'{-f,--force}"[Reinstalls a plugin if it's already installed]" \
'*:plugin:_urls'
}
_rails_plugin_remove() {
local -a plugins
plugins=($(_call_program rails_plugins ls -1 vendor/plugins))
_describe -t plugins 'plugin' plugins
}
_rails_plugin_new() {
_rails_new
}
_rails_runner() {
local context state line curcontext="$curcontext"
_arguments -C \
'(- *)'{-h,--help}'[Show this help message]' \
'(-e --environment)'{-e,--environment=}'[Specifies the environment for the runner to operate under (test/development/production)]:name:(test development production)' \
': :->code_or_path'
case "$state" in
code_or_path)
_alternative \
'files:filename:_files -g "*.rb"' \
'codes:ruby code:_guard "^-*" "ruby code"'
;;
esac
}
_rails_r() {
_rails_runner
}
_rails_test() {
local context state line curcontext="$curcontext"
_arguments -C \
': :->path'
case "$state" in
path)
_alternative \
'files:filename:_files -g "*.rb"'
;;
esac
}
_rails_t() {
_rails_test
}
_rails "$@"
# Local Variables:
# mode: Shell-Script
# sh-indentation: 2
# indent-tabs-mode: nil
# sh-basic-offset: 2
# End:
# vim: ft=zsh sw=2 ts=2 et

View File

@ -1,3 +1,4 @@
# rails command wrapper
function _rails_command () { function _rails_command () {
if [ -e "bin/stubs/rails" ]; then if [ -e "bin/stubs/rails" ]; then
bin/stubs/rails $@ bin/stubs/rails $@
@ -12,28 +13,31 @@ function _rails_command () {
fi fi
} }
alias rails='_rails_command'
compdef _rails_command=rails
# rake command wrapper
function _rake_command () { function _rake_command () {
if [ -e "bin/stubs/rake" ]; then if [ -e "bin/stubs/rake" ]; then
bin/stubs/rake $@ bin/stubs/rake $@
elif [ -e "bin/rake" ]; then elif [ -e "bin/rake" ]; then
bin/rake $@ bin/rake $@
elif type bundle &> /dev/null && ([ -e "Gemfile" ] || [ -e "gems.rb" ]); then elif type bundle &> /dev/null && [[ -e "Gemfile" || -e "gems.rb" ]]; then
bundle exec rake $@ bundle exec rake $@
else else
command rake $@ command rake $@
fi fi
} }
alias rails='_rails_command'
compdef _rails_command=rails
alias rake='_rake_command' alias rake='_rake_command'
compdef _rake_command=rake compdef _rake_command=rake
# Log aliases
alias devlog='tail -f log/development.log' alias devlog='tail -f log/development.log'
alias prodlog='tail -f log/production.log' alias prodlog='tail -f log/production.log'
alias testlog='tail -f log/test.log' alias testlog='tail -f log/test.log'
# Environment settings
alias -g RED='RAILS_ENV=development' alias -g RED='RAILS_ENV=development'
alias -g REP='RAILS_ENV=production' alias -g REP='RAILS_ENV=production'
alias -g RET='RAILS_ENV=test' alias -g RET='RAILS_ENV=test'
@ -43,47 +47,69 @@ alias rc='rails console'
alias rcs='rails console --sandbox' alias rcs='rails console --sandbox'
alias rd='rails destroy' alias rd='rails destroy'
alias rdb='rails dbconsole' alias rdb='rails dbconsole'
alias rdc='rails db:create'
alias rdd='rails db:drop'
alias rdm='rails db:migrate'
alias rdmd='rails db:migrate:down'
alias rdmr='rails db:migrate:redo'
alias rdms='rails db:migrate:status'
alias rdmtc='rails db:migrate db:test:clone'
alias rdmu='rails db:migrate:up'
alias rdr='rails db:rollback'
alias rdrs='rails db:reset'
alias rds='rails db:seed'
alias rdsl='rails db:schema:load'
alias rdtc='rails db:test:clone'
alias rdtp='rails db:test:prepare'
alias rgen='rails generate' alias rgen='rails generate'
alias rgm='rails generate migration' alias rgm='rails generate migration'
alias rlc='rails log:clear'
alias rmd='rails middleware'
alias rn='rails notes'
alias rp='rails plugin' alias rp='rails plugin'
alias rr='rails routes' alias rr='rails routes'
alias rrg='rails routes | grep' alias rrg='rails routes | grep'
alias ru='rails runner'
alias rs='rails server' alias rs='rails server'
alias rsb='rails server --bind'
alias rsd='rails server --debugger' alias rsd='rails server --debugger'
alias rsp='rails server --port' alias rsp='rails server --port'
alias rsb='rails server --bind' alias rsts='rails stats'
alias rt='rails test'
alias ru='rails runner'
# Foreman aliases
alias fmns='foreman start'
# Rake aliases # Rake aliases
alias rdm='rake db:migrate' alias rkdc='rake db:create'
alias rdmr='rake db:migrate:redo' alias rkdd='rake db:drop'
alias rdmd='rake db:migrate:down' alias rkdm='rake db:migrate'
alias rdms='rake db:migrate:status' alias rkdmd='rake db:migrate:down'
alias rdmu='rake db:migrate:up' alias rkdmr='rake db:migrate:redo'
alias rdr='rake db:rollback' alias rkdms='rake db:migrate:status'
alias rdc='rake db:create' alias rkdmtc='rake db:migrate db:test:clone'
alias rds='rake db:seed' alias rkdmu='rake db:migrate:up'
alias rdd='rake db:drop' alias rkdr='rake db:rollback'
alias rdrs='rake db:reset' alias rkdrs='rake db:reset'
alias rdtc='rake db:test:clone' alias rkds='rake db:seed'
alias rdtp='rake db:test:prepare' alias rkdsl='rake db:schema:load'
alias rdmtc='rake db:migrate db:test:clone' alias rkdtc='rake db:test:clone'
alias rdsl='rake db:schema:load' alias rkdtp='rake db:test:prepare'
alias rlc='rake log:clear' alias rklc='rake log:clear'
alias rn='rake notes' alias rkmd='rake middleware'
alias rt='rake test' alias rkn='rake notes'
alias rmd='rake middleware' alias rksts='rake stats'
alias rsts='rake stats' alias rkt='rake test'
# legacy stuff # legacy stuff
alias sstat='thin --stats "/thin/stats" start' alias sc='ruby script/console'
alias sg='ruby script/generate'
alias sd='ruby script/destroy' alias sd='ruby script/destroy'
alias sd='ruby script/server --debugger'
alias sg='ruby script/generate'
alias sp='ruby script/plugin' alias sp='ruby script/plugin'
alias sr='ruby script/runner' alias sr='ruby script/runner'
alias ssp='ruby script/spec' alias ssp='ruby script/spec'
alias sc='ruby script/console' alias sstat='thin --stats "/thin/stats" start'
alias sd='ruby script/server --debugger'
function remote_console() { function remote_console() {
/usr/bin/env ssh $1 "( cd $2 && ruby script/console production )" /usr/bin/env ssh $1 "( cd $2 && ruby script/console production )"

View File

@ -9,4 +9,14 @@ To use it, add `rbw` to the plugins array in your zshrc file:
plugins=(... rbw) plugins=(... rbw)
``` ```
## `rbwpw`
The `rbwpw` function is a wrapper around `rbw`. It copies the password in the
clipboard for the service you ask for and clears the clipboard 20s later.
The usage is as follows:
```zsh
rbwpw <service>
```
This plugin does not add any aliases. This plugin does not add any aliases.

View File

@ -2,12 +2,6 @@ if (( ! $+commands[rbw] )); then
return return
fi fi
# TODO: 2021-12-28: remove this bit of code as it exists in oh-my-zsh.sh
# Add completions folder in $ZSH_CACHE_DIR
command mkdir -p "$ZSH_CACHE_DIR/completions"
(( ${fpath[(Ie)"$ZSH_CACHE_DIR/completions"]} )) || fpath=("$ZSH_CACHE_DIR/completions" $fpath)
# If the completion file doesn't exist yet, we need to autoload it and # If the completion file doesn't exist yet, we need to autoload it and
# bind it to `rbw`. Otherwise, compinit will have already done that. # bind it to `rbw`. Otherwise, compinit will have already done that.
if [[ ! -f "$ZSH_CACHE_DIR/completions/_rbw" ]]; then if [[ ! -f "$ZSH_CACHE_DIR/completions/_rbw" ]]; then
@ -17,3 +11,33 @@ if [[ ! -f "$ZSH_CACHE_DIR/completions/_rbw" ]]; then
fi fi
rbw gen-completions zsh >| "$ZSH_CACHE_DIR/completions/_rbw" &| rbw gen-completions zsh >| "$ZSH_CACHE_DIR/completions/_rbw" &|
# rbwpw function copies the password of a service to the clipboard
# and clears it after 20 seconds
function rbwpw {
if [[ $# -ne 1 ]]; then
echo "usage: rbwpw <service>"
return 1
fi
local service=$1
if ! rbw unlock; then
echo "rbw is locked"
return 1
fi
local pw=$(rbw get $service 2>/dev/null)
if [[ -z $pw ]]; then
echo "$service not found"
return 1
fi
echo -n $pw | clipcopy
echo "password for $service copied!"
{sleep 20 && clipcopy </dev/null 2>/dev/null} &|
}
function _rbwpw {
local -a services
services=("${(@f)$(rbw ls 2>/dev/null)}")
[[ -n "$services" ]] && compadd -a -- services
}
compdef _rbwpw rbwpw

View File

@ -7,7 +7,3 @@ To use it, add `ripgrep` to the plugins array in your zshrc file:
```zsh ```zsh
plugins=(... ripgrep) plugins=(... ripgrep)
``` ```
Completion is taken from the ripgrep release [`12.1.1`](https://github.com/BurntSushi/ripgrep/releases/tag/12.1.1).
Updated on April 1st, 2021.

View File

@ -121,7 +121,7 @@ _rg() {
"(pretty-vimgrep)--no-heading[don't show matches grouped by file name]" "(pretty-vimgrep)--no-heading[don't show matches grouped by file name]"
+ '(hidden)' # Hidden-file options + '(hidden)' # Hidden-file options
'--hidden[search hidden files and directories]' {-.,--hidden}'[search hidden files and directories]'
$no"--no-hidden[don't search hidden files and directories]" $no"--no-hidden[don't search hidden files and directories]"
+ '(hybrid)' # hybrid regex options + '(hybrid)' # hybrid regex options
@ -303,6 +303,8 @@ _rg() {
'--context-separator=[specify string used to separate non-continuous context lines in output]:separator' '--context-separator=[specify string used to separate non-continuous context lines in output]:separator'
$no"--no-context-separator[don't print context separators]" $no"--no-context-separator[don't print context separators]"
'--debug[show debug messages]' '--debug[show debug messages]'
'--field-context-separator[set string to delimit fields in context lines]'
'--field-match-separator[set string to delimit fields in matching lines]'
'--trace[show more verbose debug messages]' '--trace[show more verbose debug messages]'
'--dfa-size-limit=[specify upper size limit of generated DFA]:DFA size (bytes)' '--dfa-size-limit=[specify upper size limit of generated DFA]:DFA size (bytes)'
"(1 stats)--files[show each file that would be searched (but don't search)]" "(1 stats)--files[show each file that would be searched (but don't search)]"

View File

@ -2,11 +2,6 @@ if ! (( $+commands[rustup] && $+commands[cargo] )); then
return return
fi fi
# Add completions folder in $ZSH_CACHE_DIR
# TODO: 2021-12-28: remove this bit of code as it exists in oh-my-zsh.sh
command mkdir -p "$ZSH_CACHE_DIR/completions"
(( ${fpath[(Ie)"$ZSH_CACHE_DIR/completions"]} )) || fpath=("$ZSH_CACHE_DIR/completions" $fpath)
# If the completion file doesn't exist yet, we need to autoload it and # If the completion file doesn't exist yet, we need to autoload it and
# bind it to `cargo`. Otherwise, compinit will have already done that # bind it to `cargo`. Otherwise, compinit will have already done that
if [[ ! -f "$ZSH_CACHE_DIR/completions/_cargo" ]]; then if [[ ! -f "$ZSH_CACHE_DIR/completions/_cargo" ]]; then

View File

@ -1,14 +1,6 @@
print ${(%):-'%F{yellow}The `rustup` plugin is deprecated and has been moved to the `rust` plugin.'} print ${(%):-'%F{yellow}The `rustup` plugin is deprecated and has been moved to the `rust` plugin.'}
print ${(%):-'Please update your .zshrc to use the `%Brust%b` plugin instead.%f'} print ${(%):-'Please update your .zshrc to use the `%Brust%b` plugin instead.%f'}
# TODO: 2021-12-28: remove this block
# Handle $0 according to the standard:
# https://zdharma-continuum.github.io/Zsh-100-Commits-Club/Zsh-Plugin-Standard.html
0="${${ZERO:-${0:#$ZSH_ARGZERO}}:-${(%):-%N}}"
0="${${(M)0:#/*}:-$PWD/$0}"
# Remove old generated completion file
command rm -f "${0:A:h}/_rustup" "$ZSH_CACHE_DIR/rustup_version"
(( ${fpath[(Ie)$ZSH/plugins/rust]} )) || { (( ${fpath[(Ie)$ZSH/plugins/rust]} )) || {
fpath=("$ZSH/plugins/rust" $fpath) fpath=("$ZSH/plugins/rust" $fpath)
source "$ZSH/plugins/rust/rust.plugin.zsh" source "$ZSH/plugins/rust/rust.plugin.zsh"

View File

@ -23,6 +23,7 @@ plugins=(... rvm)
| `rb26` | `rvm use ruby-2.6` | | `rb26` | `rvm use ruby-2.6` |
| `rb27` | `rvm use ruby-2.7` | | `rb27` | `rvm use ruby-2.7` |
| `rb30` | `rvm use ruby-3.0` | | `rb30` | `rvm use ruby-3.0` |
| `rb31` | `rvm use ruby-3.1` |
| `rvm-update` | `rvm get head` | | `rvm-update` | `rvm get head` |
| `gems` | `gem list` | | `gems` | `gem list` |
| `rvms` | `rvm gemset` | | `rvms` | `rvm gemset` |

View File

@ -26,6 +26,7 @@ rubies=(
26 'ruby-2.6' 26 'ruby-2.6'
27 'ruby-2.7' 27 'ruby-2.7'
30 'ruby-3.0' 30 'ruby-3.0'
31 'ruby-3.1'
) )
for v in ${(k)rubies}; do for v in ${(k)rubies}; do

View File

@ -0,0 +1,3 @@
[*.py]
indent_size = 4
indent_style = space

View File

@ -20,14 +20,17 @@ proxy_protocols = {
if parsed.scheme not in proxy_protocols: if parsed.scheme not in proxy_protocols:
raise TypeError('unsupported proxy protocol: "{}"'.format(parsed.scheme)) raise TypeError('unsupported proxy protocol: "{}"'.format(parsed.scheme))
argv = [ def make_argv():
"nc", yield "nc"
"-X", if sys.platform == 'linux':
proxy_protocols[parsed.scheme], # Supported protocols are 4 (SOCKS v4), 5 (SOCKS v5) and connect (HTTP proxy). Default SOCKS v5 is used. # caveats: macOS built-in netcat command not supported proxy-type
"-x", yield "-X" # --proxy-type
parsed.netloc, # proxy-host:proxy-port # Supported protocols are 4 (SOCKS v4), 5 (SOCKS v5) and connect (HTTP proxy).
sys.argv[1], # host # Default SOCKS v5 is used.
sys.argv[2], # port yield proxy_protocols[parsed.scheme]
] yield "-x" # --proxy
yield parsed.netloc # proxy-host:proxy-port
yield sys.argv[1] # host
yield sys.argv[2] # port
subprocess.call(argv) subprocess.call(make_argv())

View File

@ -18,7 +18,8 @@ plugins=(... sprunge)
| `echo data \| sprunge` | Any piped data will be uploaded | | `echo data \| sprunge` | Any piped data will be uploaded |
Once sprunge has processed the input it will give you a unique HTTP address: Once sprunge has processed the input it will give you a unique HTTP address:
```
```console
$ sprunge "hello" $ sprunge "hello"
http://sprunge.us/XxjnKz http://sprunge.us/XxjnKz
``` ```
@ -30,3 +31,8 @@ http://sprunge.us/XxjnKz
- Argument precedence goes as follows: stdin > piped input > text strings. - Argument precedence goes as follows: stdin > piped input > text strings.
- If a filename is misspelled 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. generate an error, but instead treat it as a text string.
## Credits
- Original code: [shellperson.net](https://web.archive.org/web/20190910065842/https://www.shellperson.net/sprunge-pastebin-script/).
- Adapted by: Matt Parnell (@ilikenwf).

View File

@ -1,7 +1,3 @@
# Contributed and SLIGHTLY modded by Matt Parnell/ilikenwf <parwok -at- gmail>
# Created by the blogger at the URL below...I don't know where to find his/her name
# Original found at https://www.shellperson.net/sprunge-pastebin-script/
sprunge() { sprunge() {
if [[ "$1" = --help ]]; then if [[ "$1" = --help ]]; then
fmt -s >&2 << EOF fmt -s >&2 << EOF

View File

@ -9,10 +9,10 @@ To use it, add `svn-fast-info` to the plugins array in your zshrc file:
plugins=(... svn-fast-info) plugins=(... svn-fast-info)
``` ```
It's faster because his efficient use of svn (single svn call) which saves a lot on a huge codebase It's faster because it has an efficient use of svn (single svn call) which saves a lot on a huge codebase.
It displays the current status of the local files (added, deleted, modified, replaced, or else...) It displays the current status of the local files (added, deleted, modified, replaced, or else...)
Use `svn_prompt_info` method to display the svn repository status in your theme. Use `svn_prompt_info` method to display the svn repository status in your theme.
## Functions ## Functions

View File

@ -34,109 +34,109 @@ alias pscpu10='ps -e -o pcpu,cpu,nice,state,cputime,args|sort -k1,1n -nr | head
alias hist10='print -l ${(o)history%% *} | uniq -c | sort -nr | head -n 10' alias hist10='print -l ${(o)history%% *} | uniq -c | sort -nr | head -n 10'
# directory LS # directory LS
dls () { function dls() {
print -l *(/) print -l *(/)
} }
psgrep() { function psgrep() {
ps aux | grep "${1:-.}" | grep -v grep ps aux | grep "${1:-.}" | grep -v grep
} }
# Kills any process that matches a regexp passed to it # Kills any process that matches a regexp passed to it
killit() { function killit() {
ps aux | grep -v "grep" | grep "$@" | awk '{print $2}' | xargs sudo kill ps aux | grep -v "grep" | grep "$@" | awk '{print $2}' | xargs sudo kill
} }
# list contents of directories in a tree-like format # list contents of directories in a tree-like format
if ! (( $+commands[tree] )); then if ! (( $+commands[tree] )); then
tree () { function tree() {
find $@ -print | sed -e 's;[^/]*/;|____;g;s;____|; |;g' find $@ -print | sed -e 's;[^/]*/;|____;g;s;____|; |;g'
} }
fi fi
# Sort connection state # Sort connection state
sortcons() { function sortcons() {
netstat -nat |awk '{print $6}'|sort|uniq -c|sort -rn netstat -nat |awk '{print $6}'|sort|uniq -c|sort -rn
} }
# View all 80 Port Connections # View all 80 Port Connections
con80() { function con80() {
netstat -nat|grep -i ":80"|wc -l netstat -nat|grep -i ":80"|wc -l
} }
# On the connected IP sorted by the number of connections # On the connected IP sorted by the number of connections
sortconip() { function sortconip() {
netstat -ntu | awk '{print $5}' | cut -d: -f1 | sort | uniq -c | sort -n netstat -ntu | awk '{print $5}' | cut -d: -f1 | sort | uniq -c | sort -n
} }
# top20 of Find the number of requests on 80 port # top20 of Find the number of requests on 80 port
req20() { function req20() {
netstat -anlp|grep 80|grep tcp|awk '{print $5}'|awk -F: '{print $1}'|sort|uniq -c|sort -nr|head -n20 netstat -anlp|grep 80|grep tcp|awk '{print $5}'|awk -F: '{print $1}'|sort|uniq -c|sort -nr|head -n20
} }
# top20 of Using tcpdump port 80 access to view # top20 of Using tcpdump port 80 access to view
http20() { function http20() {
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 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 # top20 of Find time_wait connection
timewait20() { function timewait20() {
netstat -n|grep TIME_WAIT|awk '{print $5}'|sort|uniq -c|sort -rn|head -n20 netstat -n|grep TIME_WAIT|awk '{print $5}'|sort|uniq -c|sort -rn|head -n20
} }
# top20 of Find SYN connection # top20 of Find SYN connection
syn20() { function syn20() {
netstat -an | grep SYN | awk '{print $5}' | awk -F: '{print $1}' | sort | uniq -c | sort -nr|head -n20 netstat -an | grep SYN | awk '{print $5}' | awk -F: '{print $1}' | sort | uniq -c | sort -nr|head -n20
} }
# Printing process according to the port number # Printing process according to the port number
port_pro() { function port_pro() {
netstat -ntlp | grep "${1:-.}" | awk '{print $7}' | cut -d/ -f1 netstat -ntlp | grep "${1:-.}" | awk '{print $7}' | cut -d/ -f1
} }
# top10 of gain access to the ip address # top10 of gain access to the ip address
accessip10() { function accessip10() {
awk '{counts[$(11)]+=1}; END {for(url in counts) print counts[url], url}' "$(retlog)" awk '{counts[$(11)]+=1}; END {for(url in counts) print counts[url], url}' "$(retlog)"
} }
# top20 of Most Visited file or page # top20 of Most Visited file or page
visitpage20() { function visitpage20() {
awk '{print $11}' "$(retlog)"|sort|uniq -c|sort -nr|head -n 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 # top100 of Page lists the most time-consuming (more than 60 seconds) as well as the corresponding page number of occurrences
consume100() { function consume100() {
awk '($NF > 60 && $7~/\.php/){print $7}' "$(retlog)" |sort -n|uniq -c|sort -nr|head -n 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 # if django website or other website make by no suffix language
# awk '{print $7}' "$(retlog)" |sort -n|uniq -c|sort -nr|head -n 100 # awk '{print $7}' "$(retlog)" |sort -n|uniq -c|sort -nr|head -n 100
} }
# Website traffic statistics (G) # Website traffic statistics (G)
webtraffic() { function webtraffic() {
awk "{sum+=$10} END {print sum/1024/1024/1024}" "$(retlog)" awk "{sum+=$10} END {print sum/1024/1024/1024}" "$(retlog)"
} }
# Statistical connections 404 # Statistical connections 404
c404() { function c404() {
awk '($9 ~/404/)' "$(retlog)" | awk '{print $9,$7}' | sort awk '($9 ~/404/)' "$(retlog)" | awk '{print $9,$7}' | sort
} }
# Statistical http status. # Statistical http status.
httpstatus() { function httpstatus() {
awk '{counts[$(9)]+=1}; END {for(code in counts) print code, counts[code]}' "$(retlog)" awk '{counts[$(9)]+=1}; END {for(code in counts) print code, counts[code]}' "$(retlog)"
} }
# Delete 0 byte file # Delete 0 byte file
d0() { function d0() {
find "${1:-.}" -type f -size 0 -exec rm -rf {} \; find "${1:-.}" -type f -size 0 -exec rm -rf {} \;
} }
# gather external ip address # gather external ip address
geteip() { function geteip() {
curl -s -S -4 https://icanhazip.com curl -s -S -4 https://icanhazip.com
curl -s -S -6 https://icanhazip.com curl -s -S -6 https://icanhazip.com
} }
# determine local IP address(es) # determine local IP address(es)
getip() { function getip() {
if (( ${+commands[ip]} )); then if (( ${+commands[ip]} )); then
ip addr | awk '/inet /{print $2}' | command grep -v 127.0.0.1 ip addr | awk '/inet /{print $2}' | command grep -v 127.0.0.1
else else
@ -145,11 +145,11 @@ getip() {
} }
# Clear zombie processes # Clear zombie processes
clrz() { function clrz() {
ps -eal | awk '{ if ($2 == "Z") {print $4}}' | kill -9 ps -eal | awk '{ if ($2 == "Z") {print $4}}' | kill -9
} }
# Second concurrent # Second concurrent
conssec() { function conssec() {
awk '{if($9~/200|30|404/)COUNT[$4]++}END{for( a in COUNT) print a,COUNT[a]}' "$(retlog)"|sort -k 2 -nr|head -n10 awk '{if($9~/200|30|404/)COUNT[$4]++}END{for( a in COUNT) print a,COUNT[a]}' "$(retlog)"|sort -k 2 -nr|head -n10
} }

View File

@ -22,6 +22,7 @@ plugins=(... terraform)
| `tfd` | `terraform destroy` | | `tfd` | `terraform destroy` |
| `tff` | `terraform fmt` | | `tff` | `terraform fmt` |
| `tfi` | `terraform init` | | `tfi` | `terraform init` |
| `tfo` | `terraform output` |
| `tfp` | `terraform plan` | | `tfp` | `terraform plan` |
| `tfv` | `terraform validate` | | `tfv` | `terraform validate` |

View File

@ -13,5 +13,6 @@ alias tfa='terraform apply'
alias tfd='terraform destroy' alias tfd='terraform destroy'
alias tff='terraform fmt' alias tff='terraform fmt'
alias tfi='terraform init' alias tfi='terraform init'
alias tfo='terraform output'
alias tfp='terraform plan' alias tfp='terraform plan'
alias tfv='terraform validate' alias tfv='terraform validate'

View File

@ -15,16 +15,16 @@ The plugin also supports the following:
## Aliases ## Aliases
| Alias | Command | Description | | Alias | Command | Description |
| ---------- | ---------------------- | -------------------------------------------------------- | | ---------- | -------------------------- | -------------------------------------------------------- |
| `ta` | tmux attach -t | Attach new tmux session to already running named session | | `ta` | tmux attach -t | Attach new tmux session to already running named session |
| `tad` | tmux attach -d -t | Detach named tmux session | | `tad` | tmux attach -d -t | Detach named tmux session |
| `ts` | tmux new-session -s | Create a new named tmux session | | `ts` | tmux new-session -s | Create a new named tmux session |
| `tl` | tmux list-sessions | Displays a list of running tmux sessions | | `tl` | tmux list-sessions | Displays a list of running tmux sessions |
| `tksv` | tmux kill-server | Terminate all running tmux sessions | | `tksv` | tmux kill-server | Terminate all running tmux sessions |
| `tkss` | tmux kill-session -t | Terminate named running tmux session | | `tkss` | tmux kill-session -t | Terminate named running tmux session |
| `tmux` | `_zsh_tmux_plugin_run` | Start a new tmux session | | `tmux` | `_zsh_tmux_plugin_run` | Start a new tmux session |
| `tmuxconf` | `$EDITOR ~/.tmux.conf` | Open .tmux.conf file with an editor | | `tmuxconf` | `$EDITOR $ZSH_TMUX_CONFIG` | Open .tmux.conf file with an editor |
## Configuration Variables ## Configuration Variables

View File

@ -3,16 +3,6 @@ if ! (( $+commands[tmux] )); then
return 1 return 1
fi fi
# ALIASES
alias ta='tmux attach -t'
alias tad='tmux attach -d -t'
alias ts='tmux new-session -s'
alias tl='tmux list-sessions'
alias tksv='tmux kill-server'
alias tkss='tmux kill-session -t'
alias tmuxconf='$EDITOR ~/.tmux.conf'
# CONFIGURATION VARIABLES # CONFIGURATION VARIABLES
# Automatically start tmux # Automatically start tmux
: ${ZSH_TMUX_AUTOSTART:=false} : ${ZSH_TMUX_AUTOSTART:=false}
@ -40,6 +30,16 @@ alias tmuxconf='$EDITOR ~/.tmux.conf'
# Set -u option to support unicode # Set -u option to support unicode
: ${ZSH_TMUX_UNICODE:=false} : ${ZSH_TMUX_UNICODE:=false}
# ALIASES
alias ta='tmux attach -t'
alias tad='tmux attach -d -t'
alias ts='tmux new-session -s'
alias tl='tmux list-sessions'
alias tksv='tmux kill-server'
alias tkss='tmux kill-session -t'
alias tmuxconf='$EDITOR $ZSH_TMUX_CONFIG'
# Determine if the terminal supports 256 colors # Determine if the terminal supports 256 colors
if [[ $terminfo[colors] == 256 ]]; then if [[ $terminfo[colors] == 256 ]]; then
export ZSH_TMUX_TERM=$ZSH_TMUX_FIXTERM_WITH_256COLOR export ZSH_TMUX_TERM=$ZSH_TMUX_FIXTERM_WITH_256COLOR

View File

@ -0,0 +1,19 @@
# toolbox plugin
Plugin for [toolbox](https://containertoolbx.org), a tool to use containerized CLI environments.
To use it, add `toolbox` to your plugins array in your `.zshrc` file:
```zsh
plugins=(... toolbox)
```
## Prompt function
This plugins adds `toolbox_prompt_info()` function. Using it in your prompt, it will show the toolbox indicator ⬢ (if you are running in a toolbox container), and nothing if not.
You can use it by adding `$(toolbox_prompt_info)` to your `PROMPT` or `RPROMPT` variable:
```zsh
RPROMPT='$(toolbox_prompt_info)'
```

View File

@ -0,0 +1,3 @@
function toolbox_prompt_info() {
[[ -f /run/.toolboxenv ]] && echo "⬢"
}

View File

@ -119,7 +119,7 @@ function wrap_clipboard_widgets() {
done done
} }
wrap_clipboard_widgets copy vi-yank vi-yank-eol vi-backward-kill-word vi-change-whole-line vi-delete wrap_clipboard_widgets copy vi-yank vi-yank-eol vi-backward-kill-word vi-change-whole-line vi-delete vi-delete-char
wrap_clipboard_widgets paste vi-put-{before,after} wrap_clipboard_widgets paste vi-put-{before,after}
unfunction wrap_clipboard_widgets unfunction wrap_clipboard_widgets

Some files were not shown because too many files have changed in this diff Show More