chezmoi init

This commit is contained in:
Cy Pokhrel 2024-10-22 11:11:45 -04:00
commit 530d6d7195
No known key found for this signature in database
GPG key ID: 1200FBE36C2ADE2E
1176 changed files with 111325 additions and 0 deletions

View file

@ -0,0 +1,15 @@
# Do nothing if op is not installed
(( ${+commands[op]} )) || return
# If the completion file doesn't exist yet, we need to autoload it and
# bind it to `op`. Otherwise, compinit will have already done that.
if [[ ! -f "$ZSH_CACHE_DIR/completions/_op" ]]; then
typeset -g -A _comps
autoload -Uz _op
_comps[op]=_op
fi
op completion zsh >| "$ZSH_CACHE_DIR/completions/_op" &|
# Load opswd function
autoload -Uz opswd

View file

@ -0,0 +1,40 @@
# 1Password
This plugin adds 1Password functionality to oh-my-zsh.
To use, add `1password` to the list of plugins in your `.zshrc` file:
```zsh
plugins=(... 1password)
```
Then, you can use the command `opswd` to copy passwords for services into your
clipboard.
## `opswd`
The `opswd` command is a wrapper around the `op` command. It takes a service
name as an argument and copies the username, then the password for that service
to the clipboard, after confirmation on the user part.
If the service also contains a TOTP, it is copied to the clipboard after confirmation
on the user part. Finally, after 20 seconds, the clipboard is cleared.
For example, `opswd github.com` will put your GitHub username into your clipboard. Then,
it will ask for confirmation to continue, and copy the password to your clipboard. Finally,
if a TOTP is available, it will be copied to the clipboard after your confirmation.
This function has completion support, so you can use tab completion to select which
service you want to get.
> 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:
>
> - [Get started with 1Password CLI 2: Sign in](https://developer.1password.com/docs/cli/get-started#sign-in)
> - [Sign in to your 1Password account manually](https://developer.1password.com/docs/cli/sign-in-manually)
## Requirements
- [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,90 @@
#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 username
# Copy the username to the clipboard
if ! username=$(op item get "$service" --fields username 2>/dev/null); then
echo "error: could not obtain username for $service"
return 1
fi
echo -n "$username" | clipcopy
echo "✔ username for service $service copied to the clipboard. Press Enter to continue"
read
local password
# Copy the password to the clipboard
if ! password=$(op item get "$service" --reveal --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. Press Enter to continue"
read
# If there's a one time password, copy it to the clipboard
local totp
if totp=$(op item get --otp "$service" 2>/dev/null) && [[ -n "$totp" ]]; then
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

@ -0,0 +1,68 @@
# alias-finder plugin
This plugin searches the defined aliases and outputs any that match the command inputted. This makes learning new aliases easier.
## Setup
To use it, add `alias-finder` to the `plugins` array of your zshrc file:
```
plugins=(... alias-finder)
```
To enable it for every single command, set zstyle in your `~/.zshrc`.
```zsh
# ~/.zshrc
zstyle ':omz:plugins:alias-finder' autoload yes # disabled by default
zstyle ':omz:plugins:alias-finder' longer yes # disabled by default
zstyle ':omz:plugins:alias-finder' exact yes # disabled by default
zstyle ':omz:plugins:alias-finder' cheaper yes # disabled by default
```
As you can see, options are also available with zstyle.
## Usage
When you execute a command alias finder will look at your defined aliases and suggest shorter aliases you could have used, for example:
Running the un-aliased `git status` command:
```sh
╭─tim@fox ~/repo/gitopolis ‹main›
╰─$ git status
gst='git status' # <=== shorter suggestion from alias-finder
On branch main
Your branch is up-to-date with 'origin/main'.
nothing to commit, working tree clean
```
Running a shorter `git st` alias from `.gitconfig` that it suggested :
```sh
╭─tim@fox ~/repo/gitopolis ‹main›
╰─$ git st
gs='git st' # <=== shorter suggestion from alias-finder
## main...origin/main
```
Running the shortest `gs` shell alias that it found:
```sh
╭─tim@fox ~/repo/gitopolis ‹main›
╰─$ gs
# <=== no suggestions alias-finder because this is the shortest
## main...origin/main
```
![image](https://github.com/ohmyzsh/ohmyzsh/assets/19378/39642750-fb10-4f1a-b7f9-f36789eeb01b)
### Options
> In order to clarify, let's say `alias a=abc` has source 'abc' and destination 'a'.
- Use `--longer` or `-l` to include aliases where the source is longer than the input (in other words, the source could contain the whole input).
- Use `--exact` or `-e` to avoid aliases where the source is shorter than the input (in other words, the source must be the same with the input).
- Use `--cheaper` or `-c` to avoid aliases where the destination is longer than the input (in other words, the destination must be the shorter than the input).

View file

@ -0,0 +1,62 @@
alias-finder() {
local cmd=" " exact="" longer="" cheaper="" wordEnd="'{0,1}$" finder="" filter=""
# build command and options
for c in "$@"; do
case $c in
# TODO: Remove backward compatibility (other than zstyle form)
# set options if exist
-e|--exact) exact=true;;
-l|--longer) longer=true;;
-c|--cheaper) cheaper=true;;
# concatenate cmd
*) cmd="$cmd$c " ;;
esac
done
zstyle -t ':omz:plugins:alias-finder' longer && longer=true
zstyle -t ':omz:plugins:alias-finder' exact && exact=true
zstyle -t ':omz:plugins:alias-finder' cheaper && cheaper=true
# format cmd for grep
## - replace newlines with spaces
## - trim both ends
## - replace multiple spaces with one space
## - add escaping character to special characters
cmd=$(echo -n "$cmd" | tr '\n' ' ' | xargs | tr -s '[:space:]' | sed 's/[].\|$(){}?+*^[]/\\&/g')
if [[ $longer == true ]]; then
wordEnd="" # remove wordEnd to find longer aliases
fi
# find with alias and grep, removing last word each time until no more words
while [[ $cmd != "" ]]; do
finder="'{0,1}$cmd$wordEnd"
# make filter to find only shorter results than current cmd
if [[ $cheaper == true ]]; then
cmdLen=$(echo -n "$cmd" | wc -c)
filter="^'{0,1}.{0,$((cmdLen - 1))}="
fi
alias | grep -E "$filter" | grep -E "=$finder"
if [[ $exact == true ]]; then
break # because exact case is only one
elif [[ $longer = true ]]; then
break # because above grep command already found every longer aliases during first cycle
fi
cmd=$(sed -E 's/ {0,}[^ ]*$//' <<< "$cmd") # remove last word
done
}
preexec_alias-finder() {
# TODO: Remove backward compatibility (other than zstyle form)
zstyle -t ':omz:plugins:alias-finder' autoload && alias-finder $1 || if [[ $ZSH_ALIAS_FINDER_AUTOMATIC = true ]]; then
alias-finder $1
fi
}
autoload -U add-zsh-hook
add-zsh-hook preexec preexec_alias-finder

View file

@ -0,0 +1,9 @@
tap: false
directories:
tests: tests
output: tests/_output
support: tests/_support
time_limit: 0
fail_fast: false
allow_risky: false
verbose: true

View file

@ -0,0 +1,2 @@
#!/usr/bin/env zsh
# Write your bootstrap code here

View file

@ -0,0 +1,107 @@
#!/usr/bin/env zunit
@setup {
load ../alias-finder.plugin.zsh
set_git_aliases() {
unalias -a # all
alias g="git"
alias gc="git commit"
alias gcv="git commit -v"
alias gcvs="git commit -v -S"
}
}
@test 'find aliases that contain input' {
set_git_aliases
run alias-finder "git"
assert "${#lines[@]}" equals 1
assert "${lines[1]}" same_as "g=git"
}
@test 'find aliases that contain input with whitespaces at ends' {
set_git_aliases
run alias-finder " git "
assert "${#lines[@]}" equals 1
assert "${lines[1]}" same_as "g=git"
}
@test 'find aliases that contain multiple words' {
set_git_aliases
run alias-finder "git commit -v"
assert "${#lines[@]}" equals 3
assert "${lines[1]}" same_as "gcv='git commit -v'"
assert "${lines[2]}" same_as "gc='git commit'"
assert "${lines[3]}" same_as "g=git"
}
@test 'find alias that is the same with input when --exact option is set' {
set_git_aliases
run alias-finder -e "git"
assert "${#lines[@]}" equals 1
assert "${lines[1]}" same_as "g=git"
}
@test 'find alias that is the same with multiple words input when --exact option is set' {
set_git_aliases
run alias-finder -e "git commit -v"
assert "${#lines[@]}" equals 1
assert "${lines[1]}" same_as "gcv='git commit -v'"
}
@test 'find alias that is the same with or longer than input when --longer option is set' {
set_git_aliases
run alias-finder -l "git"
assert "${#lines[@]}" equals 4
assert "${lines[1]}" same_as "g=git"
assert "${lines[2]}" same_as "gc='git commit'"
assert "${lines[3]}" same_as "gcv='git commit -v'"
assert "${lines[4]}" same_as "gcvs='git commit -v -S'"
}
@test 'find alias that is the same with or longer than multiple words input when --longer option is set' {
set_git_aliases
run alias-finder -l "git commit -v"
assert "${#lines[@]}" equals 2
assert "${lines[1]}" same_as "gcv='git commit -v'"
assert "${lines[2]}" same_as "gcvs='git commit -v -S'"
}
@test 'find aliases including expensive (longer) than input' {
set_git_aliases
alias expensiveCommands="git commit"
run alias-finder "git commit -v"
assert "${#lines[@]}" equals 4
assert "${lines[1]}" same_as "gcv='git commit -v'"
assert "${lines[2]}" same_as "expensiveCommands='git commit'"
assert "${lines[3]}" same_as "gc='git commit'"
assert "${lines[4]}" same_as "g=git"
}
@test 'find aliases excluding expensive (longer) than input when --cheap option is set' {
set_git_aliases
alias expensiveCommands="git commit"
run alias-finder -c "git commit -v"
assert "${#lines[@]}" equals 3
assert "${lines[1]}" same_as "gcv='git commit -v'"
assert "${lines[2]}" same_as "gc='git commit'"
assert "${lines[3]}" same_as "g=git"
}

View file

@ -0,0 +1,28 @@
# Aliases cheatsheet
With lots of 3rd-party amazing aliases installed, this plugin helps list the shortcuts
that are currently available based on the plugins you have enabled.
To use it, add `aliases` to the plugins array in your zshrc file:
```zsh
plugins=(aliases)
```
Requirements: Python needs to be installed.
**Maintainer:** [@hqingyi](https://github.com/hqingyi)
## Usage
- `als`: show all aliases by group
- `als -h/--help`: print help message
- `als <keyword(s)>`: filter and highlight aliases by `<keyword>`
- `als -g <group>/--group <group>`: show only aliases for group `<group>`. Multiple uses of the flag show all groups
- `als --groups`: show only group names
![screenshot](https://github.com/ohmyzsh/ohmyzsh/assets/66907184/5bfa00ea-5fc3-4e97-8b22-2f74f6b948c7)

View file

@ -0,0 +1,14 @@
# 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}"
eval '
function als(){
(( $+commands[python3] )) || {
echo "[error] No python executable detected"
return
}
alias | python3 "'"${0:h}"'/cheatsheet.py" "$@"
}
'

View file

@ -0,0 +1,69 @@
#!/usr/bin/env python3
import sys
import itertools
import termcolor
import argparse
def parse(line):
left = line[0:line.find('=')].strip()
right = line[line.find('=')+1:].strip('\'"\n ')
try:
cmd = next(part for part in right.split() if len([char for char in '=<>' if char in part])==0)
except StopIteration:
cmd = right
return (left, right, cmd)
def cheatsheet(lines):
exps = [ parse(line) for line in lines ]
exps.sort(key=lambda exp:exp[2])
cheatsheet = {'_default': []}
for key, group in itertools.groupby(exps, lambda exp:exp[2]):
group_list = [ item for item in group ]
if len(group_list)==1:
target_aliases = cheatsheet['_default']
else:
if key not in cheatsheet:
cheatsheet[key] = []
target_aliases = cheatsheet[key]
target_aliases.extend(group_list)
return cheatsheet
def pretty_print_group(key, aliases, highlight=None, only_groupname=False):
if len(aliases) == 0:
return
group_hl_formatter = lambda g, hl: termcolor.colored(hl, 'yellow').join([termcolor.colored(part, 'red') for part in ('[%s]' % g).split(hl)])
alias_hl_formatter = lambda alias, hl: termcolor.colored(hl, 'yellow').join([termcolor.colored(part, 'green') for part in ('\t%s = %s' % alias[0:2]).split(hl)])
group_formatter = lambda g: termcolor.colored('[%s]' % g, 'red')
alias_formatter = lambda alias: termcolor.colored('\t%s = %s' % alias[0:2], 'green')
if highlight and len(highlight)>0:
print (group_hl_formatter(key, highlight))
if not only_groupname:
print ('\n'.join([alias_hl_formatter(alias, highlight) for alias in aliases]))
else:
print (group_formatter(key))
if not only_groupname:
print ('\n'.join([alias_formatter(alias) for alias in aliases]))
print ('')
def pretty_print(cheatsheet, wfilter, group_list=None, groups_only=False):
sorted_key = sorted(cheatsheet.keys())
for key in sorted_key:
if group_list and key not in group_list:
continue
aliases = cheatsheet.get(key)
if not wfilter:
pretty_print_group(key, aliases, wfilter, groups_only)
else:
pretty_print_group(key, [ alias for alias in aliases if alias[0].find(wfilter)>-1 or alias[1].find(wfilter)>-1], wfilter)
if __name__ == '__main__':
parser = argparse.ArgumentParser(description="Pretty print aliases.", prog="als")
parser.add_argument('filter', nargs="*", metavar="<keyword>", help="search aliases matching keywords")
parser.add_argument('-g', '--group', dest="group_list", action='append', help="only print aliases in given groups")
parser.add_argument('--groups', dest='groups_only', action='store_true', help="only print alias groups")
args = parser.parse_args()
lines = sys.stdin.readlines()
group_list = args.group_list or None
wfilter = " ".join(args.filter) or None
pretty_print(cheatsheet(lines), wfilter, group_list, args.groups_only)

View file

@ -0,0 +1 @@
__pycache__

View file

@ -0,0 +1,168 @@
# coding: utf-8
# Copyright (c) 2008-2011 Volvox Development Team
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#
# Author: Konstantin Lepa <konstantin.lepa@gmail.com>
"""ANSI Color formatting for output in terminal."""
from __future__ import print_function
import os
__ALL__ = [ 'colored', 'cprint' ]
VERSION = (1, 1, 0)
ATTRIBUTES = dict(
list(zip([
'bold',
'dark',
'',
'underline',
'blink',
'',
'reverse',
'concealed'
],
list(range(1, 9))
))
)
del ATTRIBUTES['']
HIGHLIGHTS = dict(
list(zip([
'on_grey',
'on_red',
'on_green',
'on_yellow',
'on_blue',
'on_magenta',
'on_cyan',
'on_white'
],
list(range(40, 48))
))
)
COLORS = dict(
list(zip([
'grey',
'red',
'green',
'yellow',
'blue',
'magenta',
'cyan',
'white',
],
list(range(30, 38))
))
)
RESET = '\033[0m'
def colored(text, color=None, on_color=None, attrs=None):
"""Colorize text.
Available text colors:
red, green, yellow, blue, magenta, cyan, white.
Available text highlights:
on_red, on_green, on_yellow, on_blue, on_magenta, on_cyan, on_white.
Available attributes:
bold, dark, underline, blink, reverse, concealed.
Example:
colored('Hello, World!', 'red', 'on_grey', ['blue', 'blink'])
colored('Hello, World!', 'green')
"""
if os.getenv('ANSI_COLORS_DISABLED') is None:
fmt_str = '\033[%dm%s'
if color is not None:
text = fmt_str % (COLORS[color], text)
if on_color is not None:
text = fmt_str % (HIGHLIGHTS[on_color], text)
if attrs is not None:
for attr in attrs:
text = fmt_str % (ATTRIBUTES[attr], text)
text += RESET
return text
def cprint(text, color=None, on_color=None, attrs=None, **kwargs):
"""Print colorize text.
It accepts arguments of print function.
"""
print((colored(text, color, on_color, attrs)), **kwargs)
if __name__ == '__main__':
print('Current terminal type: %s' % os.getenv('TERM'))
print('Test basic colors:')
cprint('Grey color', 'grey')
cprint('Red color', 'red')
cprint('Green color', 'green')
cprint('Yellow color', 'yellow')
cprint('Blue color', 'blue')
cprint('Magenta color', 'magenta')
cprint('Cyan color', 'cyan')
cprint('White color', 'white')
print(('-' * 78))
print('Test highlights:')
cprint('On grey color', on_color='on_grey')
cprint('On red color', on_color='on_red')
cprint('On green color', on_color='on_green')
cprint('On yellow color', on_color='on_yellow')
cprint('On blue color', on_color='on_blue')
cprint('On magenta color', on_color='on_magenta')
cprint('On cyan color', on_color='on_cyan')
cprint('On white color', color='grey', on_color='on_white')
print('-' * 78)
print('Test attributes:')
cprint('Bold grey color', 'grey', attrs=['bold'])
cprint('Dark red color', 'red', attrs=['dark'])
cprint('Underline green color', 'green', attrs=['underline'])
cprint('Blink yellow color', 'yellow', attrs=['blink'])
cprint('Reversed blue color', 'blue', attrs=['reverse'])
cprint('Concealed Magenta color', 'magenta', attrs=['concealed'])
cprint('Bold underline reverse cyan color', 'cyan',
attrs=['bold', 'underline', 'reverse'])
cprint('Dark blink concealed white color', 'white',
attrs=['dark', 'blink', 'concealed'])
print(('-' * 78))
print('Test mixing:')
cprint('Underline red on grey color', 'red', 'on_grey',
['underline'])
cprint('Reversed green on red color', 'green', 'on_red', ['reverse'])

View file

@ -0,0 +1,31 @@
# ansible plugin
The `ansible plugin` adds several aliases for useful [ansible](https://docs.ansible.com/ansible/latest/index.html) commands and [aliases](#aliases).
To use it, add `ansible` to the plugins array of your zshrc file:
```
plugins=(... ansible)
```
## Aliases
| Command | Description |
|:-------------------------------------------|:--------------------------------------------------------------------|
| `ansible-version` / `aver` | Show the version on ansible installed in this host |
| `ansible-role-init <role name>` / `arinit` | Creates the Ansible Role as per Ansible Galaxy standard |
| `a` | command `ansible` |
| `aconf` | command `ansible-config` |
| `acon` | command `ansible-console` |
| `ainv` | command `ansible-inventory` |
| `aplaybook` | command `ansible-playbook` |
| `adoc` | command `ansible-doc` |
| `agal` | command `ansible-galaxy` |
| `apull` | command `ansible-pull` |
| `aval` | command `ansible-vault` |
## Maintainer
### [Deepankumar](https://github.com/deepan10)
[https://github.com/deepan10/oh-my-zsh/tree/features/ansible-plugin](https://github.com/deepan10/oh-my-zsh/tree/features/ansible-plugin)

View file

@ -0,0 +1,28 @@
# Functions
function ansible-version(){
ansible --version
}
function ansible-role-init(){
if ! [ -z $1 ] ; then
echo "Ansible Role : $1 Creating...."
ansible-galaxy init $1
tree $1
else
echo "Usage : ansible-role-init <role name>"
echo "Example : ansible-role-init role1"
fi
}
# Alias
alias a='ansible '
alias aconf='ansible-config '
alias acon='ansible-console '
alias aver='ansible-version'
alias arinit='ansible-role-init'
alias aplaybook='ansible-playbook '
alias ainv='ansible-inventory '
alias adoc='ansible-doc '
alias agal='ansible-galaxy '
alias apull='ansible-pull '
alias aval='ansible-vault'

View file

@ -0,0 +1,12 @@
# Ant
This plugin provides completion for [Ant](https://ant.apache.org/).
To use it, add `ant` to the plugins array in your zshrc file:
```zsh
plugins=(... ant)
```
It caches ant targets in a file named `.ant_targets`, you might want to add that to
your `.gitignore` file.

View file

@ -0,0 +1,22 @@
#compdef ant
_ant_does_target_list_need_generating () {
[[ ! -f .ant_targets ]] && return 0
[[ build.xml -nt .ant_targets ]] && return 0
return 1
}
_ant () {
if [[ ! -f build.xml ]]; then
return
fi
if ! _ant_does_target_list_need_generating; then
return
fi
ant -p | awk -F " " 'NR > 5 { print lastTarget } { lastTarget = $1 }' >| .ant_targets
compadd -- "$(cat .ant_targets)"
}
_ant "$@"

View file

@ -0,0 +1,2 @@
# Default to colored output
export ANT_ARGS='-logger org.apache.tools.ant.listener.AnsiColorLogger'

View file

@ -0,0 +1,21 @@
# apache2-macports plugin
Enables aliases to control a local Apache2 installed via [MacPorts](https://www.macports.org/).
To use it, add `apache2-macports` to the plugins array in your zshrc file:
```zsh
plugins=(... apache2-macports)
```
## Aliases
| Alias | Function | Description |
|----------------|-----------------------------------------|-----------------------|
| apache2restart | `sudo /path/to/apache2.wrapper restart` | Restart apache daemon |
| apache2start | `sudo /path/to/apache2.wrapper start` | Start apache daemon |
| apache2stop | `sudo /path/to/apache2.wrapper stop` | Stop apache daemon |
## Contributors
- Alexander Rinass (alex@rinass.net)

View file

@ -0,0 +1,6 @@
# commands to control local apache2 server installation
# paths are for osx installation via macports
alias apache2start='sudo /opt/local/etc/LaunchDaemons/org.macports.apache2/apache2.wrapper start'
alias apache2stop='sudo /opt/local/etc/LaunchDaemons/org.macports.apache2/apache2.wrapper stop'
alias apache2restart='sudo /opt/local/etc/LaunchDaemons/org.macports.apache2/apache2.wrapper restart'

View file

@ -0,0 +1,43 @@
## arcanist
This plugin adds many useful aliases for [arcanist](https://github.com/phacility/arcanist).
To use it, add `arcanist` to the plugins array of your zshrc file:
```zsh
plugins=(... arcanist)
```
## Aliases
| Alias | Command |
| ------- | ---------------------------------- |
| ara | `arc amend` |
| arb | `arc branch` |
| arbl | `arc bland` |
| arco | `arc cover` |
| arci | `arc commit` |
| ard | `arc diff` |
| ardc | `arc diff --create` |
| ardp | `arc diff --preview` |
| ardnu | `arc diff --nounit` |
| ardnupc | `arc diff --nounit --plan-changes` |
| ardpc | `arc diff --plan-changes` |
| are | `arc export` |
| arh | `arc help` |
| arho | `arc hotfix` |
| arl | `arc land` |
| arli | `arc lint` |
| arls | `arc list` |
| arpa | `arc patch` |
## Functions
The following functions make copy pasting revision ids from the URL bar of your browser
easier, as they allow for copy pasting the whole URL. For example: `ardu` accepts
both `https://arcanist-url.com/<REVISION>` as well as `<REVISION>`.
| Function | Command |
| ------------------------- | --------------------------------- |
| ardu [URL or revision_id] | `arc diff --update` [revision_id] |
| arpa [URL or revision_id] | `arc patch` [revision_id] |

View file

@ -0,0 +1,39 @@
#
# Aliases
# (sorted alphabetically)
#
alias ara='arc amend'
alias arb='arc branch'
alias arbl='arc bland'
alias arco='arc cover'
alias arci='arc commit'
alias ard='arc diff'
alias ardc='arc diff --create'
alias ardnu='arc diff --nounit'
alias ardnupc='arc diff --nounit --plan-changes'
alias ardpc='arc diff --plan-changes'
alias ardp='arc diff --preview' # creates a new diff in the phab interface
alias are='arc export'
alias arh='arc help'
alias arho='arc hotfix'
alias arl='arc land'
alias arli='arc lint'
alias arls='arc list'
#
# Functions
# (sorted alphabetically)
#
ardu() {
# Both `ardu https://arcanist-url.com/<REVISION>`, and `ardu <REVISION>` work.
arc diff --update "${1:t}"
}
arpa() {
# Both `arpa https://arcanist-url.com/<REVISION>`, and `arpa <REVISION>` work.
arc patch "${1:t}"
}

View file

@ -0,0 +1,184 @@
# Arch Linux plugin
This plugin adds some aliases and functions to work with Arch Linux.
To use it, add `archlinux` to the plugins array in your zshrc file:
```zsh
plugins=(... archlinux)
```
## Features
### Pacman
| Alias | Command | Description |
|--------------|----------------------------------------|------------------------------------------------------------------|
| pacin | `sudo pacman -S` | Install packages from the repositories |
| pacins | `sudo pacman -U` | Install a package from a local file |
| pacinsd | `sudo pacman -S --asdeps` | Install packages as dependencies of another package |
| paclean | `sudo pacman -Sc` | Clean out old and unused caches and packages |
| pacloc | `pacman -Qi` | Display information about a package in the local database |
| paclocs | `pacman -Qs` | Search for packages in the local database |
| paclr | `sudo pacman -Scc` | Remove all files from the cache |
| paclsorphans | `sudo pacman -Qdt` | List all orphaned packages |
| pacmir | `sudo pacman -Syy` | Force refresh of all package lists after updating mirrorlist |
| pacre | `sudo pacman -R` | Remove packages, keeping its settings and dependencies |
| pacrem | `sudo pacman -Rns` | Remove packages, including its settings and dependencies |
| pacrep | `pacman -Si` | Display information about a package in the repositories |
| pacreps | `pacman -Ss` | Search for packages in the repositories |
| pacrmorphans | `sudo pacman -Rs $(pacman -Qtdq)` | Delete all orphaned packages |
| pacupd | `sudo pacman -Sy` | Update and refresh local package, ABS and AUR databases |
| pacupg | `sudo pacman -Syu` | Sync with repositories before upgrading packages |
| pacfileupg | `sudo pacman -Fy` | Download fresh package databases from the server |
| pacfiles | `pacman -F` | Search package file names for matching strings |
| pacls | `pacman -Ql` | List files in a package |
| pacown | `pacman -Qo` | Show which package owns a file |
| upgrade[¹](#f1) | `sudo pacman -Syu` | Sync with repositories before upgrading packages |
| Function | Description |
|----------------|-----------------------------------------------------------|
| pacdisowned | List all disowned files in your system |
| paclist | List all explicitly installed packages with a description |
| pacmanallkeys | Get all keys for developers and trusted users |
| pacmansignkeys | Locally trust all keys passed as parameters |
| pacweb | Open the website of an ArchLinux package |
Note: paclist used to print packages with a description which are (1) explicitly installed
and (2) available for upgrade. Due to flawed scripting, it also printed all packages if no
upgrades were available. Use `pacman -Que` instead.
### AUR helpers
#### Aura
| Alias | Command | Description |
|---------|-------------------------------------------------|-------------------------------------------------------------------------|
| auclean | `sudo aura -Sc` | Clean out old and unused caches and packages |
| auclr | `sudo aura -Scc` | Remove all files from the cache |
| auin | `sudo aura -S` | Install packages from the repositories |
| aurin | `sudo aura -A` | Install packages from the repositories |
| auins | `sudo aura -U` | Install a package from a local file |
| auinsd | `sudo aura -S --asdeps` | Install packages as dependencies of another package (repositories only) |
| aurinsd | `sudo aura -A --asdeps` | Install packages as dependencies of another package (AUR only) |
| auloc | `aura -Qi` | Display information about a package in the local database |
| aulocs | `aura -Qs` | Search for packages in the local database |
| auls | `aura -Qql` | List all files owned by a given package |
| aulst | `aura -Qe` | List installed packages including from AUR (tagged as "local") |
| aumir | `sudo aura -Syy` | Force refresh of all package lists after updating mirrorlist |
| aurph | `sudo aura -Oj` | Remove orphans using aura |
| auown | `aura -Qqo` | Search for packages that own the specified file(s) |
| aure | `sudo aura -R` | Remove packages, keeping its settings and dependencies |
| aurem | `sudo aura -Rns` | Remove packages, including its settings and unneeded dependencies |
| aurep | `aura -Si` | Display information about a package in the repositories |
| aurrep | `aura -Ai` | Display information about a package from AUR |
| aureps | `aura -As --both` | Search for packages in the repositories and AUR |
| auras | `aura -As --both` | Same as above |
| auupd | `sudo aura -Sy` | Update and refresh local package, ABS and AUR databases |
| auupg | `sudo sh -c "aura -Syu && aura -Au"` | Sync with repositories before upgrading all packages (from AUR too) |
| ausu | `sudo sh -c "aura -Syu --no-confirm && aura -Au --no-confirm"` | Same as `auupg`, but without confirmation |
| upgrade[¹](#f1) | `sudo aura -Syu` | Sync with repositories before upgrading packages |
| Function | Description |
|-----------------|---------------------------------------------------------------------|
| auownloc _file_ | Display information about a package that owns the specified file(s) |
| auownls _file_ | List all files owned by a package that owns the specified file(s) |
#### Pacaur
| Alias | Command | Description |
|---------|-----------------------------------|---------------------------------------------------------------------|
| pacclean| `pacaur -Sc` | Clean out old and unused caches and packages |
| pacclr | `pacaur -Scc` | Remove all files from the cache |
| pain | `pacaur -S` | Install packages from the repositories |
| pains | `pacaur -U` | Install a package from a local file |
| painsd | `pacaur -S --asdeps` | Install packages as dependencies of another package |
| paloc | `pacaur -Qi` | Display information about a package in the local database |
| palocs | `pacaur -Qs` | Search for packages in the local database |
| palst | `pacaur -Qe` | List installed packages including from AUR (tagged as "local") |
| pamir | `pacaur -Syy` | Force refresh of all package lists after updating mirrorlist |
| paorph | `pacaur -Qtd` | Remove orphans using pacaur |
| pare | `pacaur -R` | Remove packages, keeping its settings and dependencies |
| parem | `pacaur -Rns` | Remove packages, including its settings and unneeded dependencies |
| parep | `pacaur -Si` | Display information about a package in the repositories |
| pareps | `pacaur -Ss` | Search for packages in the repositories |
| paupd | `pacaur -Sy` | Update and refresh local package, ABS and AUR databases |
| paupg | `pacaur -Syua` | Sync with repositories before upgrading all packages (from AUR too) |
| pasu | `pacaur -Syua --no-confirm` | Same as `paupg`, but without confirmation |
| upgrade[¹](#f1) | `pacaur -Syu` | Sync with repositories before upgrading packages |
#### Trizen
| Alias | Command | Description |
|---------|-----------------------------------|---------------------------------------------------------------------|
| trconf | `trizen -C` | Fix all configuration files with vimdiff |
| trclean | `trizen -Sc` | Clean out old and unused caches and packages |
| trclr | `trizen -Scc` | Remove all files from the cache |
| trin | `trizen -S` | Install packages from the repositories |
| trins | `trizen -U` | Install a package from a local file |
| trinsd | `trizen -S --asdeps` | Install packages as dependencies of another package |
| trloc | `trizen -Qi` | Display information about a package in the local database |
| trlocs | `trizen -Qs` | Search for packages in the local database |
| trlst | `trizen -Qe` | List installed packages including from AUR (tagged as "local") |
| trmir | `trizen -Syy` | Force refresh of all package lists after updating mirrorlist |
| trorph | `trizen -Qtd` | Remove orphans using yaourt |
| trre | `trizen -R` | Remove packages, keeping its settings and dependencies |
| trrem | `trizen -Rns` | Remove packages, including its settings and unneeded dependencies |
| trrep | `trizen -Si` | Display information about a package in the repositories |
| trreps | `trizen -Ss` | Search for packages in the repositories |
| trupd | `trizen -Sy` | Update and refresh local package, ABS and AUR databases |
| trupg | `trizen -Syua` | Sync with repositories before upgrading all packages (from AUR too) |
| trsu | `trizen -Syua --no-confirm` | Same as `trupg`, but without confirmation |
| upgrade[¹](#f1) | `trizen -Syu` | Sync with repositories before upgrading packages |
#### Yay
| Alias | Command | Description |
|---------|--------------------------------|-------------------------------------------------------------------|
| yaconf | `yay -Pg` | Print current configuration |
| yaclean | `yay -Sc` | Clean out old and unused caches and packages |
| yaclr | `yay -Scc` | Remove all files from the cache |
| yain | `yay -S` | Install packages from the repositories |
| yains | `yay -U` | Install a package from a local file |
| yainsd | `yay -S --asdeps` | Install packages as dependencies of another package |
| yaloc | `yay -Qi` | Display information about a package in the local database |
| yalocs | `yay -Qs` | Search for packages in the local database |
| yalst | `yay -Qe` | List installed packages including from AUR (tagged as "local") |
| yamir | `yay -Syy` | Force refresh of all package lists after updating mirrorlist |
| yaorph | `yay -Qtd` | Remove orphans using yay |
| yare | `yay -R` | Remove packages, keeping its settings and dependencies |
| yarem | `yay -Rns` | Remove packages, including its settings and unneeded dependencies |
| yarep | `yay -Si` | Display information about a package in the repositories |
| yareps | `yay -Ss` | Search for packages in the repositories |
| yaupd | `yay -Sy` | Update and refresh local package, ABS and AUR databases |
| yaupg | `yay -Syu` | Sync with repositories before upgrading packages |
| yasu | `yay -Syu --no-confirm` | Same as `yaupg`, but without confirmation |
| upgrade[¹](#f1) | `yay -Syu` | Sync with repositories before upgrading packages |
---
<span id="f1">¹</span>
The `upgrade` alias is set for all package managers. Its value will depend on
whether the package manager is installed, checked in the following order:
1. `yay`
2. `trizen`
3. `pacaur`
4. `aura`
5. `pacman`
## Contributors
- Benjamin Boudreau - dreurmail@gmail.com
- Celso Miranda - contacto@celsomiranda.net
- ratijas (ivan tkachenko) - me@ratijas.tk
- Juraj Fiala - doctorjellyface@riseup.net
- KhasMek - Boushh@gmail.com
- Majora320 (Moses Miller) - Majora320@gmail.com
- Martin Putniorz - mputniorz@gmail.com
- MatthR3D - matthr3d@gmail.com
- ornicar - thibault.duplessis@gmail.com
- Ybalrid (Arthur Brainville) - ybalrid@ybalrid.info
- Jeff M. Hubbard - jeffmhubbard@gmail.com
- K. Harishankar(harishnkr) - hari2menon1234@gmail.com
- WH-2099 - wh2099@outlook.com

View file

@ -0,0 +1,203 @@
#######################################
# Pacman #
#######################################
# Pacman - https://wiki.archlinux.org/index.php/Pacman_Tips
alias pacupg='sudo pacman -Syu'
alias pacin='sudo pacman -S'
alias paclean='sudo pacman -Sc'
alias pacins='sudo pacman -U'
alias paclr='sudo pacman -Scc'
alias pacre='sudo pacman -R'
alias pacrem='sudo pacman -Rns'
alias pacrep='pacman -Si'
alias pacreps='pacman -Ss'
alias pacloc='pacman -Qi'
alias paclocs='pacman -Qs'
alias pacinsd='sudo pacman -S --asdeps'
alias pacmir='sudo pacman -Syy'
alias paclsorphans='sudo pacman -Qdt'
alias pacrmorphans='sudo pacman -Rs $(pacman -Qtdq)'
alias pacfileupg='sudo pacman -Fy'
alias pacfiles='pacman -F'
alias pacls='pacman -Ql'
alias pacown='pacman -Qo'
alias pacupd="sudo pacman -Sy"
function paclist() {
pacman -Qqe | xargs -I{} -P0 --no-run-if-empty pacman -Qs --color=auto "^{}\$"
}
function pacdisowned() {
local tmp_dir db fs
tmp_dir=$(mktemp --directory)
db=$tmp_dir/db
fs=$tmp_dir/fs
trap "rm -rf $tmp_dir" EXIT
pacman -Qlq | sort -u > "$db"
find /etc /usr ! -name lost+found \
\( -type d -printf '%p/\n' -o -print \) | sort > "$fs"
comm -23 "$fs" "$db"
rm -rf $tmp_dir
}
alias pacmanallkeys='sudo pacman-key --refresh-keys'
function pacmansignkeys() {
local key
for key in $@; do
sudo pacman-key --recv-keys $key
sudo pacman-key --lsign-key $key
printf 'trust\n3\n' | sudo gpg --homedir /etc/pacman.d/gnupg \
--no-permission-warning --command-fd 0 --edit-key $key
done
}
if (( $+commands[xdg-open] )); then
function pacweb() {
if [[ $# = 0 || "$1" =~ '--help|-h' ]]; then
local underline_color="\e[${color[underline]}m"
echo "$0 - open the website of an ArchLinux package"
echo
echo "Usage:"
echo " $bold_color$0$reset_color ${underline_color}target${reset_color}"
return 1
fi
local pkg="$1"
local infos="$(LANG=C pacman -Si "$pkg")"
if [[ -z "$infos" ]]; then
return
fi
local repo="$(grep -m 1 '^Repo' <<< "$infos" | grep -oP '[^ ]+$')"
local arch="$(grep -m 1 '^Arch' <<< "$infos" | grep -oP '[^ ]+$')"
xdg-open "https://www.archlinux.org/packages/$repo/$arch/$pkg/" &>/dev/null
}
fi
#######################################
# AUR helpers #
#######################################
if (( $+commands[aura] )); then
alias auin='sudo aura -S'
alias aurin='sudo aura -A'
alias auclean='sudo aura -Sc'
alias auclr='sudo aura -Scc'
alias auins='sudo aura -U'
alias auinsd='sudo aura -S --asdeps'
alias aurinsd='sudo aura -A --asdeps'
alias auloc='aura -Qi'
alias aulocs='aura -Qs'
alias aulst='aura -Qe'
alias aumir='sudo aura -Syy'
alias aurph='sudo aura -Oj'
alias aure='sudo aura -R'
alias aurem='sudo aura -Rns'
alias aurep='aura -Si'
alias aurrep='aura -Ai'
alias aureps='aura -As --both'
alias auras='aura -As --both'
alias auupd="sudo aura -Sy"
alias auupg='sudo sh -c "aura -Syu && aura -Au"'
alias ausu='sudo sh -c "aura -Syu --no-confirm && aura -Au --no-confirm"'
# extra bonus specially for aura
alias auown="aura -Qqo"
alias auls="aura -Qql"
function auownloc() { aura -Qi $(aura -Qqo $@); }
function auownls () { aura -Qql $(aura -Qqo $@); }
fi
if (( $+commands[pacaur] )); then
alias pacclean='pacaur -Sc'
alias pacclr='pacaur -Scc'
alias paupg='pacaur -Syu'
alias pasu='pacaur -Syu --noconfirm'
alias pain='pacaur -S'
alias pains='pacaur -U'
alias pare='pacaur -R'
alias parem='pacaur -Rns'
alias parep='pacaur -Si'
alias pareps='pacaur -Ss'
alias paloc='pacaur -Qi'
alias palocs='pacaur -Qs'
alias palst='pacaur -Qe'
alias paorph='pacaur -Qtd'
alias painsd='pacaur -S --asdeps'
alias pamir='pacaur -Syy'
alias paupd="pacaur -Sy"
fi
if (( $+commands[trizen] )); then
alias trconf='trizen -C'
alias trupg='trizen -Syua'
alias trsu='trizen -Syua --noconfirm'
alias trin='trizen -S'
alias trclean='trizen -Sc'
alias trclr='trizen -Scc'
alias trins='trizen -U'
alias trre='trizen -R'
alias trrem='trizen -Rns'
alias trrep='trizen -Si'
alias trreps='trizen -Ss'
alias trloc='trizen -Qi'
alias trlocs='trizen -Qs'
alias trlst='trizen -Qe'
alias trorph='trizen -Qtd'
alias trinsd='trizen -S --asdeps'
alias trmir='trizen -Syy'
alias trupd="trizen -Sy"
fi
if (( $+commands[yay] )); then
alias yaconf='yay -Pg'
alias yaclean='yay -Sc'
alias yaclr='yay -Scc'
alias yaupg='yay -Syu'
alias yasu='yay -Syu --noconfirm'
alias yain='yay -S'
alias yains='yay -U'
alias yare='yay -R'
alias yarem='yay -Rns'
alias yarep='yay -Si'
alias yareps='yay -Ss'
alias yaloc='yay -Qi'
alias yalocs='yay -Qs'
alias yalst='yay -Qe'
alias yaorph='yay -Qtd'
alias yainsd='yay -S --asdeps'
alias yamir='yay -Syy'
alias yaupd="yay -Sy"
fi
# Check Arch Linux PGP Keyring before System Upgrade to prevent failure.
function upgrade() {
echo ":: Checking Arch Linux PGP Keyring..."
local installedver="$(LANG= sudo pacman -Qi archlinux-keyring | grep -Po '(?<=Version : ).*')"
local currentver="$(LANG= sudo pacman -Si archlinux-keyring | grep -Po '(?<=Version : ).*')"
if [ $installedver != $currentver ]; then
echo " Arch Linux PGP Keyring is out of date."
echo " Updating before full system upgrade."
sudo pacman -Sy --needed --noconfirm archlinux-keyring
else
echo " Arch Linux PGP Keyring is up to date."
echo " Proceeding with full system upgrade."
fi
if (( $+commands[yay] )); then
yay -Syu
elif (( $+commands[trizen] )); then
trizen -Syu
elif (( $+commands[pacaur] )); then
pacaur -Syu
elif (( $+commands[aura] )); then
sudo aura -Syu
else
sudo pacman -Syu
fi
}

View file

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

View file

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

View file

@ -0,0 +1,20 @@
# Argo CD plugin
This plugin adds completion for the [Argo CD](https://argoproj.github.io/cd/) CLI.
To use it, add `argocd` to the plugins array in your zshrc file:
```zsh
plugins=(... argocd)
```
This plugin does not add any aliases.
## Cache
This plugin caches the completion script and is automatically updated asynchronously when the plugin is
loaded, which is usually when you start up a new terminal emulator.
The cache is stored at:
- `$ZSH_CACHE/completions/_argocd` completions script

View file

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

View file

@ -0,0 +1,32 @@
## asdf
Adds integration with [asdf](https://github.com/asdf-vm/asdf), the extendable version manager, with support for Ruby, Node.js, Elixir, Erlang and more.
### Installation
1. [Download asdf](https://asdf-vm.com/guide/getting-started.html#_2-download-asdf) by running the following:
```
git clone https://github.com/asdf-vm/asdf.git ~/.asdf
```
2. [Enable asdf](https://asdf-vm.com/guide/getting-started.html#_3-install-asdf) by adding it to your `plugins` definition in `~/.zshrc`.
```
plugins=(asdf)
```
### Usage
See the [asdf documentation](https://asdf-vm.com/guide/getting-started.html#_4-install-a-plugin) for information on how to use asdf:
```
asdf plugin add nodejs https://github.com/asdf-vm/asdf-nodejs.git
asdf install nodejs latest
asdf global nodejs latest
asdf local nodejs latest
```
### Maintainer
- [@RobLoach](https://github.com/RobLoach)

View file

@ -0,0 +1,30 @@
# Find where asdf should be installed
ASDF_DIR="${ASDF_DIR:-$HOME/.asdf}"
ASDF_COMPLETIONS="$ASDF_DIR/completions"
if [[ ! -f "$ASDF_DIR/asdf.sh" || ! -f "$ASDF_COMPLETIONS/_asdf" ]]; then
# If not found, check for archlinux/AUR package (/opt/asdf-vm/)
if [[ -f "/opt/asdf-vm/asdf.sh" ]]; then
ASDF_DIR="/opt/asdf-vm"
ASDF_COMPLETIONS="$ASDF_DIR"
# If not found, check for Homebrew package
elif (( $+commands[brew] )); then
_ASDF_PREFIX="$(brew --prefix asdf)"
ASDF_DIR="${_ASDF_PREFIX}/libexec"
ASDF_COMPLETIONS="${_ASDF_PREFIX}/share/zsh/site-functions"
unset _ASDF_PREFIX
else
return
fi
fi
# Load command
if [[ -f "$ASDF_DIR/asdf.sh" ]]; then
source "$ASDF_DIR/asdf.sh"
# Load completions
if [[ -f "$ASDF_COMPLETIONS/_asdf" ]]; then
fpath+=("$ASDF_COMPLETIONS")
autoload -Uz _asdf
compdef _asdf asdf # compdef is already loaded before loading plugins
fi
fi

View file

@ -0,0 +1,20 @@
# Autoenv plugin
This plugin loads the [Autoenv](https://github.com/inishchith/autoenv).
To use it, add `autoenv` to the plugins array in your zshrc file:
```zsh
plugins=(... autoenv)
```
## Functions
* `use_env()`: creates and/or activates a virtualenv. For use in `.env` files.
See the source code for details.
## Requirements
In order to make this work, you will need to have the autoenv installed.
More info on the usage and install at [the project's homepage](https://github.com/inishchith/autoenv).

View file

@ -0,0 +1,80 @@
# Initialization: activate autoenv or report its absence
() {
local d autoenv_dir install_locations
if ! type autoenv_init >/dev/null; then
# Check if activate.sh is in $PATH
if (( $+commands[activate.sh] )); then
autoenv_dir="${commands[activate.sh]:h}"
fi
# Locate autoenv installation
if [[ -z $autoenv_dir ]]; then
install_locations=(
~/.autoenv
~/.local/bin
/usr/local/opt/autoenv
/opt/homebrew/opt/autoenv
/usr/local/bin
/usr/share/autoenv-git
~/Library/Python/bin
.venv/bin
venv/bin
env/bin
.env/bin
)
for d ( $install_locations ); do
if [[ -e $d/activate || -e $d/activate.sh ]]; then
autoenv_dir=$d
break
fi
done
fi
# Look for Homebrew path as a last resort
if [[ -z "$autoenv_dir" ]] && (( $+commands[brew] )); then
d=$(brew --prefix)/opt/autoenv
if [[ -e $d/activate || -e $d/activate.sh ]]; then
autoenv_dir=$d
fi
fi
# Complain if autoenv is not installed
if [[ -z $autoenv_dir ]]; then
cat <<END >&2
-------- AUTOENV ---------
Could not locate autoenv installation.
Please check if autoenv is correctly installed.
In the meantime the autoenv plugin is DISABLED.
--------------------------
END
return 1
fi
# Load autoenv
if [[ -e $autoenv_dir/activate ]]; then
source $autoenv_dir/activate
else
source $autoenv_dir/activate.sh
fi
fi
}
[[ $? != 0 ]] && return $?
# The use_env call below is a reusable command to activate/create a new Python
# virtualenv, requiring only a single declarative line of code in your .env files.
# It only performs an action if the requested virtualenv is not the current one.
use_env() {
local venv
venv="$1"
if [[ "${VIRTUAL_ENV:t}" != "$venv" ]]; then
if workon | grep -q "$venv"; then
workon "$venv"
else
echo -n "Create virtualenv $venv now? (Yn) "
read answer
if [[ "$answer" == "Y" ]]; then
mkvirtualenv "$venv"
fi
fi
fi
}

View file

@ -0,0 +1,11 @@
# Autojump plugin
This plugin loads the [autojump navigation tool](https://github.com/wting/autojump).
To use it, add `autojump` to the plugins array in your zshrc file:
```zsh
plugins=(... autojump)
```
**Note:** you have to [install autojump](https://github.com/wting/autojump#installation) first.

View file

@ -0,0 +1,40 @@
declare -a autojump_paths
autojump_paths=(
$HOME/.autojump/etc/profile.d/autojump.zsh # manual installation
$HOME/.autojump/share/autojump/autojump.zsh # manual installation
$HOME/.nix-profile/etc/profile.d/autojump.sh # NixOS installation
/run/current-system/sw/share/autojump/autojump.zsh # NixOS installation
/etc/profiles/per-user/$USER/share/autojump/autojump.zsh # Home Manager, NixOS with user-scoped packages
/usr/share/autojump/autojump.zsh # Debian and Ubuntu package
/etc/profile.d/autojump.zsh # manual installation
/etc/profile.d/autojump.sh # Gentoo installation
/usr/local/share/autojump/autojump.zsh # FreeBSD installation
/usr/pkg/share/autojump/autojump.zsh # NetBSD installation
/opt/local/etc/profile.d/autojump.sh # macOS with MacPorts
/usr/local/etc/profile.d/autojump.sh # macOS with Homebrew (default)
/opt/homebrew/etc/profile.d/autojump.sh # macOS with Homebrew (default on M1 macs)
/opt/pkg/share/autojump/autojump.zsh # macOS with pkgsrc
/etc/profiles/per-user/$USER/etc/profile.d/autojump.sh # macOS Nix, Home Manager and flakes
/nix/var/nix/gcroots/current-system/sw/share/zsh/site-functions/autojump.zsh # macOS Nix, nix-darwin
)
for file in $autojump_paths; do
if [[ -f "$file" ]]; then
source "$file"
found=1
break
fi
done
# if no path found, try Homebrew
if (( ! found && $+commands[brew] )); then
file=$(brew --prefix)/etc/profile.d/autojump.sh
if [[ -f "$file" ]]; then
source "$file"
found=1
fi
fi
(( ! found )) && echo '[oh-my-zsh] autojump not found. Please install it first.'
unset autojump_paths file found

View file

@ -0,0 +1,8 @@
# autopep8 plugin
This plugin adds completion for [autopep8](https://pypi.org/project/autopep8/), a tool that automatically formats Python code to conform to the [PEP 8](http://www.python.org/dev/peps/pep-0008/) style guide.
To use it, add autopep8 to the plugins array of your zshrc file:
```
plugins=(... autopep8)
```

View file

@ -0,0 +1,32 @@
#compdef autopep8
#
# this is zsh completion function file.
# generated by genzshcomp(ver: 0.5.1)
#
typeset -A opt_args
local context state line
_arguments -s -S \
"--help[show this help message and exit]:" \
"-h[show this help message and exit]:" \
"--version[show program's version number and exit]:" \
"--verbose[print verbose messages; multiple -v result in more verbose messages]" \
"-v[print verbose messages; multiple -v result in more verbose messages]" \
"--diff[print the diff for the fixed source]" \
"-d[print the diff for the fixed source]" \
"--in-place[make changes to files in place]" \
"-i[make changes to files in place]" \
"--recursive[run recursively; must be used with --in-place or --diff]" \
"-r[run recursively; must be used with --in-place or --diff]" \
"--jobs[number of parallel jobs; match CPU count if value is less than 1]::n number of parallel jobs; match CPU count if value is:_files" \
"-j[number of parallel jobs; match CPU count if value is less than 1]::n number of parallel jobs; match CPU count if value is:_files" \
"--pep8-passes[maximum number of additional pep8 passes (default: 100)]::n:_files" \
"-p[maximum number of additional pep8 passes (default: 100)]::n:_files" \
"-a[-a result in more aggressive changes]::result:_files" \
"--exclude[exclude files/directories that match these comma- separated globs]::globs:_files" \
"--list-fixes[list codes for fixes; used by --ignore and --select]" \
"--ignore[do not fix these errors/warnings (default E226,E24)]::errors:_files" \
"--select[fix only these errors/warnings (e.g. E4,W)]::errors:_files" \
"--max-line-length[set maximum allowed line length (default: 79)]::n:_files" \
"*::args:_files"

View file

@ -0,0 +1,98 @@
# aws
This plugin provides completion support for [awscli v2](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/index.html)
and a few utilities to manage AWS profiles/regions and display them in the prompt.
[awscli v1](https://docs.aws.amazon.com/cli/latest/userguide/cliv2-migration.html) is no longer supported.
To use it, add `aws` to the plugins array in your zshrc file.
```zsh
plugins=(... aws)
```
## Plugin commands
* `asp [<profile>]`: sets `$AWS_PROFILE` and `$AWS_DEFAULT_PROFILE` (legacy) to `<profile>`.
It also sets `$AWS_EB_PROFILE` to `<profile>` for the Elastic Beanstalk CLI. It sets `$AWS_PROFILE_REGION` for display in `aws_prompt_info`.
Run `asp` without arguments to clear the profile.
* `asp [<profile>] login`: If AWS SSO has been configured in your aws profile, it will run the `aws sso login` command following profile selection.
* `asp [<profile>] login [<sso_session>]`: In addition to `asp [<profile>] login`, if SSO session has been configured in your aws profile, it will run the `aws sso login --sso-session <sso_session>` command following profile selection.
* `asp [<profile>] logout`: If AWS SSO has been configured in your aws profile, it will run the `aws sso logout` command following profile selection.
* `asr [<region>]`: sets `$AWS_REGION` and `$AWS_DEFAULT_REGION` (legacy) to `<region>`.
Run `asr` without arguments to clear the profile.
* `acp [<profile>] [<mfa_token>]`: in addition to `asp` functionality, it actually changes
the profile by assuming the role specified in the `<profile>` configuration. It supports
MFA and sets `$AWS_ACCESS_KEY_ID`, `$AWS_SECRET_ACCESS_KEY` and `$AWS_SESSION_TOKEN`, if
obtained. It requires the roles to be configured as per the
[official guide](https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-role.html).
Run `acp` without arguments to clear the profile.
* `agp`: gets the current value of `$AWS_PROFILE`.
* `agr`: gets the current value of `$AWS_REGION`.
* `aws_change_access_key`: changes the AWS access key of a profile.
* `aws_profiles`: lists the available profiles in the `$AWS_CONFIG_FILE` (default: `~/.aws/config`).
Used to provide completion for the `asp` function.
* `aws_regions`: lists the available regions.
Used to provide completion for the `asr` function.
## Plugin options
* Set `SHOW_AWS_PROMPT=false` in your zshrc file if you want to prevent the plugin from modifying your RPROMPT.
Some themes might overwrite the value of RPROMPT instead of appending to it, so they'll need to be fixed to
see the AWS profile/region prompt.
* Set `AWS_PROFILE_STATE_ENABLED=true` in your zshrc file if you want the aws profile to persist between shell sessions.
This option might slow down your shell startup time.
By default the state file path is `/tmp/.aws_current_profile`. This means that the state won't survive a reboot or otherwise GC.
You can control the state file path using the `AWS_STATE_FILE` environment variable.
## Theme
The plugin creates an `aws_prompt_info` function that you can use in your theme, which displays
the current `$AWS_PROFILE` and `$AWS_REGION`. It uses four variables to control how that is shown:
* ZSH_THEME_AWS_PROFILE_PREFIX: sets the prefix of the AWS_PROFILE. Defaults to `<aws:`.
* ZSH_THEME_AWS_PROFILE_SUFFIX: sets the suffix of the AWS_PROFILE. Defaults to `>`.
* ZSH_THEME_AWS_REGION_PREFIX: sets the prefix of the AWS_REGION. Defaults to `<region:`.
* ZSH_THEME_AWS_REGION_SUFFIX: sets the suffix of the AWS_REGION. Defaults to `>`.
* ZSH_THEME_AWS_DIVIDER: sets the divider between ZSH_THEME_AWS_PROFILE_SUFFIX and ZSH_THEME_AWS_REGION_PREFIX. Defaults to ` ` (single space).
## Configuration
[Configuration and credential file settings](https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-files.html) by AWS
### Scenario: IAM roles with a source profile and MFA authentication
Source profile credentials in `~/.aws/credentials`:
```ini
[source-profile-name]
aws_access_key_id = ...
aws_secret_access_key = ...
```
Role configuration in `~/.aws/config`:
```ini
[profile source-profile-name]
mfa_serial = arn:aws:iam::111111111111:mfa/myuser
region = us-east-1
output = json
[profile profile-with-role]
role_arn = arn:aws:iam::9999999999999:role/myrole
mfa_serial = arn:aws:iam::111111111111:mfa/myuser
source_profile = source-profile-name
region = us-east-1
output = json
```

View file

@ -0,0 +1,338 @@
function agp() {
echo $AWS_PROFILE
}
function agr() {
echo $AWS_REGION
}
# Update state file if enabled
function _aws_update_state() {
if [[ "$AWS_PROFILE_STATE_ENABLED" == true ]]; then
test -d $(dirname ${AWS_STATE_FILE}) || exit 1
echo "${AWS_PROFILE} ${AWS_REGION}" > "${AWS_STATE_FILE}"
fi
}
function _aws_clear_state() {
if [[ "$AWS_PROFILE_STATE_ENABLED" == true ]]; then
test -d $(dirname ${AWS_STATE_FILE}) || exit 1
echo -n > "${AWS_STATE_FILE}"
fi
}
# AWS profile selection
function asp() {
if [[ -z "$1" ]]; then
unset AWS_DEFAULT_PROFILE AWS_PROFILE AWS_EB_PROFILE AWS_PROFILE_REGION
_aws_clear_state
echo AWS profile cleared.
return
fi
local -a available_profiles
available_profiles=($(aws_profiles))
if [[ -z "${available_profiles[(r)$1]}" ]]; then
echo "${fg[red]}Profile '$1' not found in '${AWS_CONFIG_FILE:-$HOME/.aws/config}'" >&2
echo "Available profiles: ${(j:, :)available_profiles:-no profiles found}${reset_color}" >&2
return 1
fi
export AWS_DEFAULT_PROFILE=$1
export AWS_PROFILE=$1
export AWS_EB_PROFILE=$1
export AWS_PROFILE_REGION=$(aws configure get region)
_aws_update_state
if [[ "$2" == "login" ]]; then
if [[ -n "$3" ]]; then
aws sso login --sso-session $3
else
aws sso login
fi
elif [[ "$2" == "logout" ]]; then
aws sso logout
fi
}
# AWS region selection
function asr() {
if [[ -z "$1" ]]; then
unset AWS_DEFAULT_REGION AWS_REGION
_aws_update_state
echo AWS region cleared.
return
fi
local -a available_regions
available_regions=($(aws_regions))
if [[ -z "${available_regions[(r)$1]}" ]]; then
echo "${fg[red]}Available regions: \n$(aws_regions)"
return 1
fi
export AWS_REGION=$1
export AWS_DEFAULT_REGION=$1
_aws_update_state
}
# AWS profile switch
function acp() {
if [[ -z "$1" ]]; then
unset AWS_DEFAULT_PROFILE AWS_PROFILE AWS_EB_PROFILE
unset AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY AWS_SESSION_TOKEN
echo AWS profile cleared.
return
fi
local -a available_profiles
available_profiles=($(aws_profiles))
if [[ -z "${available_profiles[(r)$1]}" ]]; then
echo "${fg[red]}Profile '$1' not found in '${AWS_CONFIG_FILE:-$HOME/.aws/config}'" >&2
echo "Available profiles: ${(j:, :)available_profiles:-no profiles found}${reset_color}" >&2
return 1
fi
local profile="$1"
local mfa_token="$2"
# Get fallback credentials for if the aws command fails or no command is run
local aws_access_key_id="$(aws configure get aws_access_key_id --profile $profile)"
local aws_secret_access_key="$(aws configure get aws_secret_access_key --profile $profile)"
local aws_session_token="$(aws configure get aws_session_token --profile $profile)"
# First, if the profile has MFA configured, lets get the token and session duration
local mfa_serial="$(aws configure get mfa_serial --profile $profile)"
local sess_duration="$(aws configure get duration_seconds --profile $profile)"
if [[ -n "$mfa_serial" ]]; then
local -a mfa_opt
if [[ -z "$mfa_token" ]]; then
echo -n "Please enter your MFA token for $mfa_serial: "
read -r mfa_token
fi
if [[ -z "$sess_duration" ]]; then
echo -n "Please enter the session duration in seconds (900-43200; default: 3600, which is the default maximum for a role): "
read -r sess_duration
fi
mfa_opt=(--serial-number "$mfa_serial" --token-code "$mfa_token" --duration-seconds "${sess_duration:-3600}")
fi
# Now see whether we need to just MFA for the current role, or assume a different one
local role_arn="$(aws configure get role_arn --profile $profile)"
local sess_name="$(aws configure get role_session_name --profile $profile)"
if [[ -n "$role_arn" ]]; then
# Means we need to assume a specified role
aws_command=(aws sts assume-role --role-arn "$role_arn" "${mfa_opt[@]}")
# Check whether external_id is configured to use while assuming the role
local external_id="$(aws configure get external_id --profile $profile)"
if [[ -n "$external_id" ]]; then
aws_command+=(--external-id "$external_id")
fi
# Get source profile to use to assume role
local source_profile="$(aws configure get source_profile --profile $profile)"
if [[ -z "$sess_name" ]]; then
sess_name="${source_profile:-profile}"
fi
aws_command+=(--profile="${source_profile:-profile}" --role-session-name "${sess_name}")
echo "Assuming role $role_arn using profile ${source_profile:-profile}"
else
# Means we only need to do MFA
aws_command=(aws sts get-session-token --profile="$profile" "${mfa_opt[@]}")
echo "Obtaining session token for profile $profile"
fi
# Format output of aws command for easier processing
aws_command+=(--query '[Credentials.AccessKeyId,Credentials.SecretAccessKey,Credentials.SessionToken]' --output text)
# Run the aws command to obtain credentials
local -a credentials
credentials=(${(ps:\t:)"$(${aws_command[@]})"})
if [[ -n "$credentials" ]]; then
aws_access_key_id="${credentials[1]}"
aws_secret_access_key="${credentials[2]}"
aws_session_token="${credentials[3]}"
fi
# Switch to AWS profile
if [[ -n "${aws_access_key_id}" && -n "$aws_secret_access_key" ]]; then
export AWS_DEFAULT_PROFILE="$profile"
export AWS_PROFILE="$profile"
export AWS_EB_PROFILE="$profile"
export AWS_ACCESS_KEY_ID="$aws_access_key_id"
export AWS_SECRET_ACCESS_KEY="$aws_secret_access_key"
if [[ -n "$aws_session_token" ]]; then
export AWS_SESSION_TOKEN="$aws_session_token"
else
unset AWS_SESSION_TOKEN
fi
echo "Switched to AWS Profile: $profile"
fi
}
function aws_change_access_key() {
if [[ -z "$1" ]]; then
echo "usage: $0 <profile>"
return 1
fi
local profile="$1"
# Get current access key
local original_aws_access_key_id="$(aws configure get aws_access_key_id --profile $profile)"
asp "$profile" || return 1
echo "Generating a new access key pair for you now."
if aws --no-cli-pager iam create-access-key; then
echo "Insert the newly generated credentials when asked."
aws --no-cli-pager configure --profile $profile
else
echo "Current access keys:"
aws --no-cli-pager iam list-access-keys
echo "Profile \"${profile}\" is currently using the $original_aws_access_key_id key. You can delete an old access key by running \`aws --profile $profile iam delete-access-key --access-key-id AccessKeyId\`"
return 1
fi
read -q "yn?Would you like to disable your previous access key (${original_aws_access_key_id}) now? "
case $yn in
[Yy]*)
echo -n "\nDisabling access key ${original_aws_access_key_id}..."
if aws --no-cli-pager iam update-access-key --access-key-id ${original_aws_access_key_id} --status Inactive; then
echo "done."
else
echo "\nFailed to disable ${original_aws_access_key_id} key."
fi
;;
*)
echo ""
;;
esac
echo "You can now safely delete the old access key by running \`aws --profile $profile iam delete-access-key --access-key-id ${original_aws_access_key_id}\`"
echo "Your current keys are:"
aws --no-cli-pager iam list-access-keys
}
function aws_regions() {
local region
if [[ $AWS_DEFAULT_REGION ]];then
region="$AWS_DEFAULT_REGION"
elif [[ $AWS_REGION ]];then
region="$AWS_REGION"
else
region="us-west-1"
fi
if [[ $AWS_DEFAULT_PROFILE || $AWS_PROFILE ]];then
aws ec2 describe-regions --region $region |grep RegionName | awk -F ':' '{gsub(/"/, "", $2);gsub(/,/, "", $2);gsub(/ /, "", $2); print $2}'
else
echo "You must specify a AWS profile."
fi
}
function aws_profiles() {
aws --no-cli-pager configure list-profiles 2> /dev/null && return
[[ -r "${AWS_CONFIG_FILE:-$HOME/.aws/config}" ]] || return 1
grep --color=never -Eo '\[.*\]' "${AWS_CONFIG_FILE:-$HOME/.aws/config}" | sed -E 's/^[[:space:]]*\[(profile)?[[:space:]]*([^[:space:]]+)\][[:space:]]*$/\2/g'
}
function _aws_regions() {
reply=($(aws_regions))
}
compctl -K _aws_regions asr
function _aws_profiles() {
reply=($(aws_profiles))
}
compctl -K _aws_profiles asp acp aws_change_access_key
# AWS prompt
function aws_prompt_info() {
local _aws_to_show
local region="${AWS_REGION:-${AWS_DEFAULT_REGION:-$AWS_PROFILE_REGION}}"
if [[ -n "$AWS_PROFILE" ]];then
_aws_to_show+="${ZSH_THEME_AWS_PROFILE_PREFIX="<aws:"}${AWS_PROFILE}${ZSH_THEME_AWS_PROFILE_SUFFIX=">"}"
fi
if [[ -n "$region" ]]; then
[[ -n "$_aws_to_show" ]] && _aws_to_show+="${ZSH_THEME_AWS_DIVIDER=" "}"
_aws_to_show+="${ZSH_THEME_AWS_REGION_PREFIX="<region:"}${region}${ZSH_THEME_AWS_REGION_SUFFIX=">"}"
fi
echo "$_aws_to_show"
}
if [[ "$SHOW_AWS_PROMPT" != false && "$RPROMPT" != *'$(aws_prompt_info)'* ]]; then
RPROMPT='$(aws_prompt_info)'"$RPROMPT"
fi
if [[ "$AWS_PROFILE_STATE_ENABLED" == true ]]; then
AWS_STATE_FILE="${AWS_STATE_FILE:-/tmp/.aws_current_profile}"
test -s "${AWS_STATE_FILE}" || return
aws_state=($(cat $AWS_STATE_FILE))
export AWS_DEFAULT_PROFILE="${aws_state[1]}"
export AWS_PROFILE="$AWS_DEFAULT_PROFILE"
export AWS_EB_PROFILE="$AWS_DEFAULT_PROFILE"
test -z "${aws_state[2]}" && AWS_REGION=$(aws configure get region)
export AWS_REGION=${AWS_REGION:-$aws_state[2]}
export AWS_DEFAULT_REGION="$AWS_REGION"
fi
# Load awscli completions
# AWS CLI v2 comes with its own autocompletion. Check if that is there, otherwise fall back
if command -v aws_completer &> /dev/null; then
autoload -Uz bashcompinit && bashcompinit
complete -C aws_completer aws
else
function _awscli-homebrew-installed() {
# check if Homebrew is installed
(( $+commands[brew] )) || return 1
# speculatively check default brew prefix
if [ -h /usr/local/opt/awscli ]; then
_brew_prefix=/usr/local/opt/awscli
else
# ok, it is not in the default prefix
# this call to brew is expensive (about 400 ms), so at least let's make it only once
_brew_prefix=$(brew --prefix awscli)
fi
}
# get aws_zsh_completer.sh location from $PATH
_aws_zsh_completer_path="$commands[aws_zsh_completer.sh]"
# otherwise check common locations
if [[ -z $_aws_zsh_completer_path ]]; then
# Homebrew
if _awscli-homebrew-installed; then
_aws_zsh_completer_path=$_brew_prefix/libexec/bin/aws_zsh_completer.sh
# Ubuntu
elif [[ -e /usr/share/zsh/vendor-completions/_awscli ]]; then
_aws_zsh_completer_path=/usr/share/zsh/vendor-completions/_awscli
# NixOS
elif [[ -e "${commands[aws]:P:h:h}/share/zsh/site-functions/aws_zsh_completer.sh" ]]; then
_aws_zsh_completer_path="${commands[aws]:P:h:h}/share/zsh/site-functions/aws_zsh_completer.sh"
# RPM
else
_aws_zsh_completer_path=/usr/share/zsh/site-functions/aws_zsh_completer.sh
fi
fi
[[ -r $_aws_zsh_completer_path ]] && source $_aws_zsh_completer_path
unset _aws_zsh_completer_path _brew_prefix
fi

View file

@ -0,0 +1,49 @@
# azure
This plugin provides completion support for [azure cli](https://docs.microsoft.com/en-us/cli/azure/)
and a few utilities to manage azure subscriptions and display them in the prompt.
To use it, add `azure` to the plugins array in your zshrc file.
```zsh
plugins=(... azure)
```
## Plugin commands
* `az_subscriptions`: lists the available subscriptions in the `AZURE_CONFIG_DIR` (default: `~/.azure/`).
Used to provide completion for the `azss` function.
* `azgs`: gets the current value of `$azure_subscription`.
* `azss [<subscription>]`: sets the `$azure_subscription`.
NOTE : because azure keeps the state of active subscription in ${AZURE_CONFIG_DIR:-$HOME/.azure/azureProfile.json}, the prompt command requires `jq` to be enabled to parse the file. If jq is not in the path the prompt will show nothing
## Theme
The plugin creates an `azure_prompt_info` function that you can use in your theme, which displays
the current `$azure_subscription`. It uses two variables to control how that is shown:
- ZSH_THEME_AZURE_PREFIX: sets the prefix of the azure_subscription. Defaults to `<az:`.
- ZSH_THEME_azure_SUFFIX: sets the suffix of the azure_subscription. Defaults to `>`.
```
RPROMPT='$(azure_prompt_info)'
```
## Develop
On ubuntu get a working environment with :
` docker run -it -v $(pwd):/mnt -w /mnt ubuntu bash`
```
apt install -y curl jq zsh git vim
sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
curl -sL https://aka.ms/InstallAzureCLIDeb | bash
```

View file

@ -0,0 +1,60 @@
# AZ Get Subscriptions
function azgs() {
az account show --output tsv --query 'name' 2>/dev/null
}
# AZ Subscription Selection
alias azss="az account set --subscription"
function az_subscriptions() {
az account list --all --output tsv --query '[*].name' 2> /dev/null
}
function _az_subscriptions() {
reply=($(az_subscriptions))
}
compctl -K _az_subscriptions azss
# Azure prompt
function azure_prompt_info() {
[[ ! -f "${AZURE_CONFIG_DIR:-$HOME/.azure}/azureProfile.json" ]] && return
# azgs is too expensive, if we have jq, we enable the prompt
(( $+commands[jq] )) || return 1
azgs=$(jq -r '.subscriptions[] | select(.isDefault==true) .name' "${AZURE_CONFIG_DIR:-$HOME/.azure}/azureProfile.json")
echo "${ZSH_THEME_AZURE_PREFIX:=<az:}${azgs}${ZSH_THEME_AZURE_SUFFIX:=>}"
}
# Load az completions
function _az-homebrew-installed() {
# check if Homebrew is installed
(( $+commands[brew] )) || return 1
# if so, we assume it's default way to install brew
if [[ ${commands[brew]:t2} == bin/brew ]]; then
_brew_prefix="${commands[brew]:h:h}" # remove trailing /bin/brew
else
# ok, it is not in the default prefix
# this call to brew is expensive (about 400 ms), so at least let's make it only once
_brew_prefix=$(brew --prefix)
fi
}
# get az.completion.sh location from $PATH
_az_zsh_completer_path="$commands[az_zsh_completer.sh]"
# otherwise check common locations
if [[ -z $_az_zsh_completer_path ]]; then
# Homebrew
if _az-homebrew-installed; then
_az_zsh_completer_path=$_brew_prefix/etc/bash_completion.d/az
# Linux
else
_az_zsh_completer_path=/etc/bash_completion.d/azure-cli
fi
fi
[[ -r $_az_zsh_completer_path ]] && autoload -U +X bashcompinit && bashcompinit && source $_az_zsh_completer_path
unset _az_zsh_completer_path _brew_prefix

View file

@ -0,0 +1,36 @@
# Battery Plugin
This plugin adds some functions you can use to display battery information in your custom theme.
To use, add `battery` to the list of plugins in your `.zshrc` file:
`plugins=(... battery)`
Then, add the `battery_pct_prompt` function to your custom theme. For example:
```zsh
RPROMPT='$(battery_pct_prompt) ...'
```
Also, you set the `BATTERY_CHARGING` variable to your favor.
For example:
```zsh
BATTERY_CHARGING="⚡️"
```
## Requirements
- On Linux, you must have the `acpi` or `acpitool` commands installed on your operating system.
On Debian/Ubuntu, you can do that with `sudo apt install acpi` or `sudo apt install acpitool`.
- On Android (via [Termux](https://play.google.com/store/apps/details?id=com.termux)), you must have:
1. The `Termux:API` addon app installed:
[Google Play](https://play.google.com/store/apps/details?id=com.termux.api) | [F-Droid](https://f-droid.org/packages/com.termux.api/)
2. The `termux-api` package installed within termux:
```sh
pkg install termux-api
```

View file

@ -0,0 +1,306 @@
###########################################
# Battery plugin for oh-my-zsh #
# Original Author: Peter hoeg (peterhoeg) #
# Email: peter@speartail.com #
###########################################
# Author: Sean Jones (neuralsandwich) #
# Email: neuralsandwich@gmail.com #
# Modified to add support for Apple Mac #
###########################################
# Author: J (927589452) #
# Modified to add support for FreeBSD #
###########################################
# Author: Avneet Singh (kalsi-avneet) #
# Modified to add support for Android #
###########################################
# Author: Not Pua (im-notpua) #
# Modified to add support for OpenBSD #
###########################################
if [[ "$OSTYPE" = darwin* ]]; then
function battery_is_charging() {
ioreg -rc AppleSmartBattery | command grep -q '^.*"ExternalConnected"\ =\ Yes'
}
function battery_pct() {
pmset -g batt | grep -Eo "\d+%" | cut -d% -f1
}
function battery_pct_remaining() {
if battery_is_charging; then
echo "External Power"
else
battery_pct
fi
}
function battery_time_remaining() {
local smart_battery_status="$(ioreg -rc "AppleSmartBattery")"
if [[ $(echo $smart_battery_status | command grep -c '^.*"ExternalConnected"\ =\ No') -eq 1 ]]; then
timeremaining=$(echo $smart_battery_status | command grep '^.*"AvgTimeToEmpty"\ =\ ' | sed -e 's/^.*"AvgTimeToEmpty"\ =\ //')
if [ $timeremaining -gt 720 ]; then
echo "::"
else
echo "~$((timeremaining / 60)):$((timeremaining % 60))"
fi
else
echo "∞"
fi
}
function battery_pct_prompt () {
local battery_pct color
if ioreg -rc AppleSmartBattery | command grep -q '^.*"ExternalConnected"\ =\ No'; then
battery_pct=$(battery_pct_remaining)
if [[ $battery_pct -gt 50 ]]; then
color='green'
elif [[ $battery_pct -gt 20 ]]; then
color='yellow'
else
color='red'
fi
echo "%{$fg[$color]%}[${battery_pct}%%]%{$reset_color%}"
else
echo "${BATTERY_CHARGING-⚡️}"
fi
}
elif [[ "$OSTYPE" = freebsd* ]]; then
function battery_is_charging() {
[[ $(sysctl -n hw.acpi.battery.state) -eq 2 ]]
}
function battery_pct() {
if (( $+commands[sysctl] )); then
sysctl -n hw.acpi.battery.life
fi
}
function battery_pct_remaining() {
if ! battery_is_charging; then
battery_pct
else
echo "External Power"
fi
}
function battery_time_remaining() {
local remaining_time
remaining_time=$(sysctl -n hw.acpi.battery.time)
if [[ $remaining_time -ge 0 ]]; then
((hour = $remaining_time / 60 ))
((minute = $remaining_time % 60 ))
printf %02d:%02d $hour $minute
fi
}
function battery_pct_prompt() {
local battery_pct color
battery_pct=$(battery_pct_remaining)
if battery_is_charging; then
echo "∞"
else
if [[ $battery_pct -gt 50 ]]; then
color='green'
elif [[ $battery_pct -gt 20 ]]; then
color='yellow'
else
color='red'
fi
echo "%{$fg[$color]%}${battery_pct}%%%{$reset_color%}"
fi
}
elif [[ "$OSTYPE" = linux-android ]] && (( ${+commands[termux-battery-status]} )); then
function battery_is_charging() {
termux-battery-status 2>/dev/null | command awk '/status/ { exit ($0 ~ /DISCHARGING/) }'
}
function battery_pct() {
# Sample output:
# {
# "health": "GOOD",
# "percentage": 93,
# "plugged": "UNPLUGGED",
# "status": "DISCHARGING",
# "temperature": 29.0,
# "current": 361816
# }
termux-battery-status 2>/dev/null | command awk '/percentage/ { gsub(/[,]/,""); print $2}'
}
function battery_pct_remaining() {
if ! battery_is_charging; then
battery_pct
else
echo "External Power"
fi
}
function battery_time_remaining() { } # Not available on android
function battery_pct_prompt() {
local battery_pct color
battery_pct=$(battery_pct_remaining)
if battery_is_charging; then
echo "∞"
else
if [[ $battery_pct -gt 50 ]]; then
color='green'
elif [[ $battery_pct -gt 20 ]]; then
color='yellow'
else
color='red'
fi
echo "%{$fg[$color]%}${battery_pct}%%%{$reset_color%}"
fi
}
elif [[ "$OSTYPE" = openbsd* ]]; then
function battery_is_charging() {
[[ $(apm -b) -eq 3 ]]
}
function battery_pct() {
apm -l
}
function battery_pct_remaining() {
if ! battery_is_charging; then
battery_pct
else
echo "External Power"
fi
}
function battery_time_remaining() {
local remaining_time
remaining_time=$(apm -m)
if [[ $remaining_time -ge 0 ]]; then
((hour = $remaining_time / 60 ))
((minute = $remaining_time % 60 ))
printf %02d:%02d $hour $minute
fi
}
function battery_pct_prompt() {
local battery_pct color
battery_pct=$(battery_pct_remaining)
if battery_is_charging; then
echo "∞"
else
if [[ $battery_pct -gt 50 ]]; then
color='green'
elif [[ $battery_pct -gt 20 ]]; then
color='yellow'
else
color='red'
fi
echo "%{$fg[$color]%}${battery_pct}%%%{$reset_color%}"
fi
}
elif [[ "$OSTYPE" = linux* ]]; then
function battery_is_charging() {
if (( $+commands[acpitool] )); then
! acpitool 2>/dev/null | command grep -qE '^\s+Battery.*Discharging'
elif (( $+commands[acpi] )); then
! acpi 2>/dev/null | command grep -v "rate information unavailable" | command grep -q '^Battery.*Discharging'
fi
}
function battery_pct() {
if (( $+commands[acpitool] )); then
# Sample output:
# Battery #1 : Unknown, 99.55%
# Battery #2 : Discharging, 49.58%, 01:12:05
# All batteries : 62.60%, 02:03:03
local -i pct=$(acpitool 2>/dev/null | command awk -F, '
/^\s+All batteries/ {
gsub(/[^0-9.]/, "", $1)
pct=$1
exit
}
!pct && /^\s+Battery/ {
gsub(/[^0-9.]/, "", $2)
pct=$2
}
END { print pct }
')
echo $pct
elif (( $+commands[acpi] )); then
# Sample output:
# Battery 0: Discharging, 0%, rate information unavailable
# Battery 1: Full, 100%
acpi 2>/dev/null | command awk -F, '
/rate information unavailable/ { next }
/^Battery.*: /{ gsub(/[^0-9]/, "", $2); print $2; exit }
'
fi
}
function battery_pct_remaining() {
if ! battery_is_charging; then
battery_pct
else
echo "External Power"
fi
}
function battery_time_remaining() {
if ! battery_is_charging; then
acpi 2>/dev/null | command grep -v "rate information unavailable" | cut -f3 -d ','
fi
}
function battery_pct_prompt() {
local battery_pct color
battery_pct=$(battery_pct_remaining)
if battery_is_charging; then
echo "∞"
else
if [[ $battery_pct -gt 50 ]]; then
color='green'
elif [[ $battery_pct -gt 20 ]]; then
color='yellow'
else
color='red'
fi
echo "%{$fg[$color]%}${battery_pct}%%%{$reset_color%}"
fi
}
else
# Empty functions so we don't cause errors in prompts
function battery_is_charging { false }
function battery_pct \
battery_pct_remaining \
battery_time_remaining \
battery_pct_prompt { }
fi
function battery_level_gauge() {
local gauge_slots=${BATTERY_GAUGE_SLOTS:-10}
local green_threshold=${BATTERY_GREEN_THRESHOLD:-$(( gauge_slots * 0.6 ))}
local yellow_threshold=${BATTERY_YELLOW_THRESHOLD:-$(( gauge_slots * 0.4 ))}
local color_green=${BATTERY_COLOR_GREEN:-%F{green}}
local color_yellow=${BATTERY_COLOR_YELLOW:-%F{yellow}}
local color_red=${BATTERY_COLOR_RED:-%F{red}}
local color_reset=${BATTERY_COLOR_RESET:-%{%f%k%b%}}
local battery_prefix=${BATTERY_GAUGE_PREFIX:-'['}
local battery_suffix=${BATTERY_GAUGE_SUFFIX:-']'}
local filled_symbol=${BATTERY_GAUGE_FILLED_SYMBOL:-'▶'}
local empty_symbol=${BATTERY_GAUGE_EMPTY_SYMBOL:-'▷'}
local charging_color=${BATTERY_CHARGING_COLOR:-$color_yellow}
local charging_symbol=${BATTERY_CHARGING_SYMBOL:-'⚡'}
local -i battery_remaining_percentage=$(battery_pct)
local filled empty gauge_color
if [[ $battery_remaining_percentage =~ [0-9]+ ]]; then
filled=$(( ($battery_remaining_percentage * $gauge_slots) / 100 ))
empty=$(( $gauge_slots - $filled ))
if [[ $filled -gt $green_threshold ]]; then
gauge_color=$color_green
elif [[ $filled -gt $yellow_threshold ]]; then
gauge_color=$color_yellow
else
gauge_color=$color_red
fi
else
filled=$gauge_slots
empty=0
filled_symbol=${BATTERY_UNKNOWN_SYMBOL:-'.'}
fi
local charging=' '
battery_is_charging && charging=$charging_symbol
# Charging status and prefix
print -n ${charging_color}${charging}${color_reset}${battery_prefix}${gauge_color}
# Filled slots
[[ $filled -gt 0 ]] && printf ${filled_symbol//\%/\%\%}'%.0s' {1..$filled}
# Empty slots
[[ $filled -lt $gauge_slots ]] && printf ${empty_symbol//\%/\%\%}'%.0s' {1..$empty}
# Suffix
print -n ${color_reset}${battery_suffix}${color_reset}
}

View file

@ -0,0 +1,22 @@
# Bazel plugin
This plugin adds completion and aliases for [bazel](https://bazel.build), an open-source build and test tool that scalably supports multi-language and multi-platform projects.
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
## Aliases
| Alias | Command | Description |
| ------- | -------------------------------------- | ------------------------------------------------------ |
| bzb | `bazel build` | The `bazel build` command |
| bzt | `bazel test` | The `bazel test` command |
| bzr | `bazel run` | The `bazel run` command |
| bzq | `bazel query` | The `bazel query` command |

View file

@ -0,0 +1,341 @@
#compdef bazel bazelisk
# Copyright 2015 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Installation
# ------------
#
# 1. Add this script to a directory on your $fpath:
# fpath[1,0]=~/.zsh/completion/
# mkdir -p ~/.zsh/completion/
# cp scripts/zsh_completion/_bazel ~/.zsh/completion
#
# 2. Optionally, add the following to your .zshrc.
# zstyle ':completion:*' use-cache on
# zstyle ':completion:*' cache-path ~/.zsh/cache
#
# This way, the completion script does not have to parse Bazel's options
# repeatedly. The directory in cache-path must be created manually.
#
# 3. Restart the shell
#
# Options
# -------
# completion:init:bazel:* cache-lifetime
# Lifetime for the completion cache (if turned on, default: 1 week)
local curcontext="$curcontext" state line
: ${BAZEL_COMPLETION_PACKAGE_PATH:=%workspace%}
: ${BAZEL:=bazel}
_bazel_b() { ${BAZEL} --noblock_for_lock "$@" 2>/dev/null; }
# Default cache lifetime is 1 week
zstyle -s ":completion:${curcontext}:" cache-lifetime lifetime
if [[ -z "${lifetime}" ]]; then
lifetime=$((60*60*24*7))
fi
_bazel_cache_policy() {
local -a oldp
oldp=( "$1"(Nms+${lifetime}) )
(( $#oldp ))
}
_set_cache_policy() {
zstyle -s ":completion:*:$curcontext*" cache-policy update_policy
if [[ -z "$update_policy" ]]; then
zstyle ":completion:$curcontext*" cache-policy _bazel_cache_policy
fi
}
# Skips over all global arguments. After invocation, OFFSET contains the
# position of the bazel command in $words.
_adapt_subcommand_offset() {
OFFSET=2
for w in ${words[2,-1]}; do
if [[ $w == (#b)-* ]]; then
(( OFFSET++ ))
else
return
fi
done
}
# Retrieve the cache but also check that the value is not empty.
_bazel_safe_retrieve_cache() {
_retrieve_cache $1 && [[ ${(P)#2} -gt 0 ]]
}
# Puts the name of the variable that contains the options for the bazel
# subcommand handed in as the first argument into the global variable
# _bazel_cmd_options.
_bazel_get_options() {
local lcmd=$1
_bazel_cmd_options=_bazel_${lcmd}_options
_bazel_cmd_args=_bazel_${lcmd}_args
if [[ ${(P)#_bazel_cmd_options} != 0 ]]; then
return
fi
if _cache_invalid BAZEL_${lcmd}_options || _cache_invalid BAZEL_${lcmd}_args \
|| ! _bazel_safe_retrieve_cache BAZEL_${lcmd}_options ${_bazel_cmd_options} \
|| ! _retrieve_cache BAZEL_${lcmd}_args ${_bazel_cmd_args}; then
if ! eval "$(_bazel_b help completion)"; then
return
fi
local opts_var
if [[ $lcmd == "startup_options" ]]; then
opts_var="BAZEL_STARTUP_OPTIONS"
else
opts_var="BAZEL_COMMAND_${lcmd:u}_FLAGS"
fi
local -a raw_options
if ! eval "raw_options=(\${(@f)$opts_var})"; then
return
fi
local -a option_list
for opt in $raw_options; do
case $opt in
--*"={"*)
local lst="${${opt##*"={"}%"}"}"
local opt="${opt%%=*}="
option_list+=("${opt}:string:_values '' ${lst//,/ }") ;;
--*=path)
option_list+=("${opt%path}:path:_files") ;;
--*=label)
option_list+=("${opt%label}:target:_bazel_complete_target") ;;
--*=*)
option_list+=("${opt}:string:") ;;
*)
option_list+=("$opt") ;;
esac
done
local -a cmd_args
local cmd_type
if eval "cmd_type=\${BAZEL_COMMAND_${lcmd:u}_ARGUMENT}" && [[ -n $cmd_type ]]; then
case $cmd_type in
label|label-*)
cmd_args+=("*::${cmd_type}:_bazel_complete_target_${cmd_type//-/_}") ;;
info-key)
cmd_args+=('1::key:_bazel_info_key') ;;
path)
cmd_args+=('1::profile:_path_files') ;;
"command|{"*"}")
local lst=${${cmd_type#"command|{"}%"}"}
cmd_args+=("1::topic:_bazel_help_topic -- ${lst//,/ }") ;;
esac
fi
typeset -g "${_bazel_cmd_options}"="${(pj:|:)option_list[*]}"
_store_cache BAZEL_${lcmd}_options ${_bazel_cmd_options}
typeset -g "${_bazel_cmd_args}"="${(pj:|:)cmd_args[*]}"
_store_cache BAZEL_${lcmd}_args ${_bazel_cmd_args}
fi
}
_get_build_targets() {
local pkg=$1
local rule_re
typeset -a completions
case $target_type in
test)
rule_re=".*_test"
;;
build)
rule_re=".*"
;;
bin)
rule_re=".*_test|.*_binary"
;;
esac
completions=(${$(_bazel_b query "kind(\"${rule_re}\", ${pkg}:all)" 2>/dev/null)##*:})
if ( (( ${#completions} > 0 )) && [[ $target_type != bin ]] ); then
completions+=(all)
fi
echo ${completions[*]}
}
# Returns all packages that match $PREFIX. PREFIX may start with //, in which
# case the workspace roots are searched. Otherwise, they are completed based on
# PWD.
_get_build_packages() {
local workspace pfx
typeset -a package_roots paths final_paths
workspace=$PWD
package_roots=(${(ps.:.)BAZEL_COMPLETION_PACKAGE_PATH})
package_roots=(${^package_roots//\%workspace\%/$workspace})
if [[ "${(e)PREFIX}" == //* ]]; then
pfx=${(e)PREFIX[2,-1]}
else
pfx=${(e)PREFIX}
fi
paths=(${^package_roots}/${pfx}*(/))
for p in ${paths[*]}; do
if [[ -f ${p}/BUILD || -f ${p}/BUILD.bazel ]]; then
final_paths+=(${p##*/}:)
fi
final_paths+=(${p##*/}/)
done
echo ${final_paths[*]}
}
_package_remove_slash() {
if [[ $KEYS == ':' && $LBUFFER == */ ]]; then
LBUFFER=${LBUFFER[1,-2]}
fi
}
# Completion function for BUILD targets, called by the completion system.
_bazel_complete_target() {
local expl
typeset -a packages targets
if [[ "${(e)PREFIX}" != *:* ]]; then
# There is no : in the prefix, completion can be either
# a package or a target, if the cwd is a package itself.
if [[ -f $PWD/BUILD || -f $PWD/BUILD.bazel ]]; then
targets=($(_get_build_targets ""))
_description build_target expl "BUILD target"
compadd "${expl[@]}" -a targets
fi
packages=($(_get_build_packages))
_description build_package expl "BUILD package"
# Chop of the leading path segments from the prefix for display.
compset -P '*/'
compadd -R _package_remove_slash -S '' "${expl[@]}" -a packages
else
targets=($(_get_build_targets "${${(e)PREFIX}%:*}"))
_description build_target expl "BUILD target"
# Ignore the current prefix for the upcoming completion, since we only list
# the names of the targets, not the full path.
compset -P '*:'
compadd "${expl[@]}" -a targets
fi
}
_bazel_complete_target_label() {
typeset -g target_type=build
_bazel_complete_target
}
_bazel_complete_target_label_test() {
typeset -g target_type=test
_bazel_complete_target
}
_bazel_complete_target_label_bin() {
typeset -g target_type=bin
_bazel_complete_target
}
### Actual completion commands
_bazel() {
_adapt_subcommand_offset
if (( CURRENT - OFFSET > 0 )); then
# Remember the subcommand name, stored globally so we can access it
# from any subsequent function
cmd=${words[OFFSET]//-/_}
# Set the context for the subcommand.
curcontext="${curcontext%:*:*}:bazel-$cmd:"
_set_cache_policy
# Narrow the range of words we are looking at to exclude cmd
# name and any leading options
(( CURRENT = CURRENT - OFFSET + 1 ))
shift $((OFFSET - 1)) words
# Run the completion for the subcommand
_bazel_get_options $cmd
_arguments : \
${(Pps:|:)_bazel_cmd_options} \
${(Pps:|:)_bazel_cmd_args}
else
_set_cache_policy
# Start special handling for global options,
# which can be retrieved by calling
# $ bazel help startup_options
_bazel_get_options startup_options
_arguments : \
${(Pps:|:)_bazel_cmd_options} \
"*:commands:_bazel_commands"
fi
return
}
_get_commands() {
# bazel_cmd_list is a global (g) array (a)
typeset -ga _bazel_cmd_list
# Use `bazel help` instead of `bazel help completion` to get command
# descriptions.
if _bazel_cmd_list=("${(@f)$(_bazel_b help | awk '
/Available commands/ { command=1; }
/ [-a-z]+[ \t]+.+/ { if (command) { printf "%s:", $1; for (i=2; i<=NF; i++) printf "%s ", $i; print "" } }
/^$/ { command=0; }')}"); then
_store_cache BAZEL_commands _bazel_cmd_list
fi
}
# Completion function for bazel subcommands, called by the completion system.
_bazel_commands() {
if [[ ${#_bazel_cmd_list} == 0 ]]; then
if _cache_invalid BAZEL_commands \
|| ! _bazel_safe_retrieve_cache BAZEL_commands _bazel_cmd_list; then
_get_commands
fi
fi
_describe -t bazel-commands 'Bazel command' _bazel_cmd_list
}
# Completion function for bazel help options, called by the completion system.
_bazel_help_topic() {
if [[ ${#_bazel_cmd_list} == 0 ]]; then
if _cache_invalid BAZEL_commands \
|| ! _bazel_safe_retrieve_cache BAZEL_commands _bazel_cmd_list; then
_get_commands
fi
fi
while [[ $# -gt 0 ]]; do
if [[ $1 == -- ]]; then
shift
break
fi
shift
done
_bazel_help_list=($@)
_bazel_help_list+=($_bazel_cmd_list)
_describe -t bazel-help 'Help topic' _bazel_help_list
}
# Completion function for bazel info keys, called by the completion system.
_bazel_info_key() {
if [[ ${#_bazel_info_keys_list} == 0 ]]; then
if _cache_invalid BAZEL_info_keys \
|| ! _bazel_safe_retrieve_cache BAZEL_info_keys _bazel_info_keys_list; then
typeset -ga _bazel_info_keys_list
# Use `bazel help` instead of `bazel help completion` to get info-key
# descriptions.
if _bazel_info_keys_list=("${(@f)$(_bazel_b help info-keys | awk '
{ printf "%s:", $1; for (i=2; i<=NF; i++) printf "%s ", $i; print "" }')}"); then
_store_cache BAZEL_info_keys _bazel_info_keys_list
fi
fi
fi
_describe -t bazel-info 'Key' _bazel_info_keys_list
}

View file

@ -0,0 +1,5 @@
# Aliases for bazel
alias bzb='bazel build'
alias bzt='bazel test'
alias bzr='bazel run'
alias bzq='bazel query'

View file

@ -0,0 +1,20 @@
## bbedit
Plugin for BBEdit, an HTML and text editor for Mac OS X
### Requirements
* [BBEdit](https://www.barebones.com/products/bbedit/)
* [BBEdit Command-Line Tools](https://www.barebones.com/support/bbedit/cmd-line-tools.html)
### Usage
* If the `bb` command is called without an argument, launch BBEdit
* If `bb` is passed a directory, cd to it and open it in BBEdit
* If `bb` is passed a file, open it in BBEdit
* If `bbpb` create a new BBEdit document with the contents of the clipboard
* If `bbd` alias for BBEdit diff tool

View file

@ -0,0 +1,21 @@
alias bbpb='pbpaste | bbedit --clean --view-top'
alias bbd=bbdiff
#
# If the bb command is called without an argument, launch BBEdit
# If bb is passed a directory, cd to it and open it in BBEdit
# If bb is passed a file, open it in BBEdit
#
function bb() {
if [[ -z "$1" ]]
then
bbedit --launch
else
bbedit "$1"
if [[ -d "$1" ]]
then
cd "$1"
fi
fi
}

View file

@ -0,0 +1,5 @@
# Bedtools plugin
This plugin adds support for the [bedtools suite](http://bedtools.readthedocs.org/en/latest/):
* Adds autocomplete options for all bedtools sub commands.

View file

@ -0,0 +1,64 @@
#compdef bedtools
#autoload
local curcontext="$curcontext" state line ret=1
local -a _files
_arguments -C \
'1: :->cmds' \
'2:: :->args' && ret=0
case $state in
cmds)
_values "bedtools command" \
"--contact[Feature requests, bugs, mailing lists, etc.]" \
"--help[Print this help menu.]" \
"--version[What version of bedtools are you using?.]" \
"annotate[Annotate coverage of features from multiple files.]" \
"bamtobed[Convert BAM alignments to BED (& other) formats.]" \
"bamtofastq[Convert BAM records to FASTQ records.]" \
"bed12tobed6[Breaks BED12 intervals into discrete BED6 intervals.]" \
"bedpetobam[Convert BEDPE intervals to BAM records.]" \
"bedtobam[Convert intervals to BAM records.]" \
"closest[Find the closest, potentially non-overlapping interval.]" \
"cluster[Cluster (but don't merge) overlapping/nearby intervals.]" \
"complement[Extract intervals _not_ represented by an interval file.]" \
"coverage[Compute the coverage over defined intervals.]" \
"expand[Replicate lines based on lists of values in columns.]" \
"fisher[Calculate Fisher statistic b/w two feature files.]" \
"flank[Create new intervals from the flanks of existing intervals.]" \
"genomecov[Compute the coverage over an entire genome.]" \
"getfasta[Use intervals to extract sequences from a FASTA file.]" \
"groupby[Group by common cols. & summarize oth. cols. (~ SQL "groupBy")]" \
"igv[Create an IGV snapshot batch script.]" \
"intersect[Find overlapping intervals in various ways.]" \
"jaccard[Calculate the Jaccard statistic b/w two sets of intervals.]" \
"links[Create a HTML page of links to UCSC locations.]" \
"makewindows[Make interval "windows" across a genome.]" \
"map[Apply a function to a column for each overlapping interval.]" \
"maskfasta[Use intervals to mask sequences from a FASTA file.]" \
"merge[Combine overlapping/nearby intervals into a single interval.]" \
"multicov[Counts coverage from multiple BAMs at specific intervals.]" \
"multiinter[Identifies common intervals among multiple interval files.]" \
"nuc[Profile the nucleotide content of intervals in a FASTA file.]" \
"overlap[Computes the amount of overlap from two intervals.]" \
"pairtobed[Find pairs that overlap intervals in various ways.]" \
"pairtopair[Find pairs that overlap other pairs in various ways.]" \
"random[Generate random intervals in a genome.]" \
"reldist[Calculate the distribution of relative distances b/w two files.]" \
"sample[Sample random records from file using reservoir sampling.]" \
"shuffle[Randomly redistribute intervals in a genome.]" \
"slop[Adjust the size of intervals.]" \
"sort[Order the intervals in a file.]" \
"subtract[Remove intervals based on overlaps b/w two files.]" \
"tag[Tag BAM alignments based on overlaps with interval files.]" \
"unionbedg[Combines coverage intervals from multiple BEDGRAPH files.]" \
"window[Find overlapping intervals within a window around an interval.]" \
ret=0
;;
*)
_files
;;
esac
return ret

View file

@ -0,0 +1,64 @@
# bgnotify zsh plugin
cross-platform background notifications for long running commands! Supports OSX and Linux.
Standalone homepage: [t413/zsh-background-notify](https://github.com/t413/zsh-background-notify)
---
## How to use
Just add bgnotify to your plugins list in your `.zshrc`
- On OS X you'll need [terminal-notifier](https://github.com/alloy/terminal-notifier)
* `brew install terminal-notifier` (or `gem install terminal-notifier`)
- On Linux, make sure you have `notify-send` or `kdialog` installed. If you're using Ubuntu you should already be all set!
- On Windows you can use [notifu](https://www.paralint.com/projects/notifu/) or the Cygwin Ports libnotify package
## Screenshots
**Linux**
![screenshot from 2014-11-07 15 58 36](https://cloud.githubusercontent.com/assets/326829/4962187/256b465c-66da-11e4-927d-cc2fc105e31f.png)
**OS X**
![screenshot 2014-11-08 14 15 12](https://cloud.githubusercontent.com/assets/326829/4965780/19fa3eac-6795-11e4-8ed6-0355711123a9.png)
**Windows**
![screenshot from 2014-11-07 15 55 00](https://cloud.githubusercontent.com/assets/326829/4962159/a2625ca0-66d9-11e4-9e91-c5834913190e.png)
## Configuration
One can configure a few things:
- `bgnotify_bell` enabled or disables the terminal bell (default true)
- `bgnotify_threshold` sets the notification threshold time (default 6 seconds)
- `function bgnotify_formatted` lets you change the notification. You can for instance customize the message and pass in an icon.
- `bgnotify_extraargs` appends extra args to notifier (e.g. `-e` for notify-send to create a transient notification)
Use these by adding a function definition before the your call to source. Example:
```sh
bgnotify_bell=false ## disable terminal bell
bgnotify_threshold=4 ## set your own notification threshold
function bgnotify_formatted {
## $1=exit_status, $2=command, $3=elapsed_time
# Humanly readable elapsed time
local elapsed="$(( $3 % 60 ))s"
(( $3 < 60 )) || elapsed="$((( $3 % 3600) / 60 ))m $elapsed"
(( $3 < 3600 )) || elapsed="$(( $3 / 3600 ))h $elapsed"
[ $1 -eq 0 ] && title="Holy Smokes Batman" || title="Holy Graf Zeppelin"
[ $1 -eq 0 ] && icon="$HOME/icons/success.png" || icon="$HOME/icons/fail.png"
bgnotify "$title - took ${elapsed}" "$2" "$icon"
}
plugins=(git bgnotify) ## add to plugins list
source $ZSH/oh-my-zsh.sh ## existing source call
```

View file

@ -0,0 +1,141 @@
#!/usr/bin/env zsh
## Setup
[[ -o interactive ]] || return # don't load on non-interactive shells
[[ -z "$SSH_CLIENT" && -z "$SSH_TTY" ]] || return # don't load on a SSH connection
zmodload zsh/datetime # faster than `date`
## Zsh Hooks
function bgnotify_begin {
bgnotify_timestamp=$EPOCHSECONDS
bgnotify_lastcmd="${1:-$2}"
}
function bgnotify_end {
{
local exit_status=$?
local elapsed=$(( EPOCHSECONDS - bgnotify_timestamp ))
# check time elapsed
[[ $bgnotify_timestamp -gt 0 ]] || return 0
[[ $elapsed -ge $bgnotify_threshold ]] || return 0
# check if Terminal app is not active
[[ $(bgnotify_appid) != "$bgnotify_termid" ]] || return 0
bgnotify_formatted "$exit_status" "$bgnotify_lastcmd" "$elapsed"
} always {
bgnotify_timestamp=0
}
}
autoload -Uz add-zsh-hook
add-zsh-hook preexec bgnotify_begin
add-zsh-hook precmd bgnotify_end
## Functions
# allow custom function override
(( ${+functions[bgnotify_formatted]} )) || \
function bgnotify_formatted {
local exit_status=$1
local cmd="$2"
# humanly readable elapsed time
local elapsed="$(( $3 % 60 ))s"
(( $3 < 60 )) || elapsed="$((( $3 % 3600) / 60 ))m $elapsed"
(( $3 < 3600 )) || elapsed="$(( $3 / 3600 ))h $elapsed"
[[ $bgnotify_bell = true ]] && printf '\a' # beep sound
if [[ $exit_status -eq 0 ]]; then
bgnotify "#win (took $elapsed)" "$cmd"
else
bgnotify "#fail (took $elapsed)" "$cmd"
fi
}
function bgnotify_appid {
if (( ${+commands[osascript]} )); then
osascript -e "tell application id \"$(bgnotify_programid)\" to get the {id, frontmost, id of front window, visible of front window}" 2>/dev/null
elif [[ -n $WAYLAND_DISPLAY ]] && (( ${+commands[swaymsg]} )); then # wayland+sway
local app_id=$(bgnotify_find_sway_appid)
[[ -n "$app_id" ]] && echo "$app_id" || echo $EPOCHSECONDS
elif [[ -z $WAYLAND_DISPLAY ]] && [[ -n $DISPLAY ]] && (( ${+commands[xprop]} )); then
xprop -root _NET_ACTIVE_WINDOW 2>/dev/null | cut -d' ' -f5
else
echo $EPOCHSECONDS
fi
}
function bgnotify_find_sway_appid {
# output is "app_id,container_id", for example "Alacritty,1694"
# see example swaymsg output: https://github.com/ohmyzsh/ohmyzsh/files/13463939/output.json
if (( ${+commands[jq]} )); then
swaymsg -t get_tree | jq '.. | select(.type?) | select(.focused==true) | {app_id, id} | join(",")'
else
swaymsg -t get_tree | awk '
BEGIN { Id = ""; Appid = ""; FocusNesting = -1; Nesting = 0 }
{
# Enter a block
if ($0 ~ /.*{$/) Nesting++
# Exit a block. If Nesting is now less than FocusNesting, we have the data we are looking for
if ($0 ~ /^[[:blank:]]*}.*/) { Nesting--; if (FocusNesting > 0 && Nesting < FocusNesting) exit 0 }
# Save the Id, it is potentially what we are looking for
if ($0 ~ /^[[:blank:]]*"id": [0-9]*,?$/) { sub(/^[[:blank:]]*"id": /, ""); sub(/,$/, ""); Id = $0 }
# Save the Appid, it is potentially what we are looking for
if ($0 ~ /^[[:blank:]]*"app_id": ".*",?$/) { sub(/^[[:blank:]]*"app_id": "/, ""); sub(/",$/, ""); Appid = $0 }
# Window is focused, this nesting block contains the Id and Appid we want!
if ($0 ~ /^[[:blank:]]*"focused": true,?$/) { FocusNesting = Nesting }
}
END {
if (Appid != "" && Id != "" && FocusNesting != -1) print Appid "," Id
else print ""
}'
fi
}
function bgnotify_programid {
case "$TERM_PROGRAM" in
iTerm.app) echo 'com.googlecode.iterm2' ;;
Apple_Terminal) echo 'com.apple.terminal' ;;
esac
}
function bgnotify {
local title="$1"
local message="$2"
local icon="$3"
if (( ${+commands[terminal-notifier]} )); then # macOS
local term_id=$(bgnotify_programid)
terminal-notifier -message "$message" -title "$title" ${=icon:+-appIcon "$icon"} ${=term_id:+-activate "$term_id"} ${=bgnotify_extraargs:-} &>/dev/null
elif (( ${+commands[growlnotify]} )); then # macOS growl
growlnotify -m "$title" "$message" ${=bgnotify_extraargs:-}
elif (( ${+commands[notify-send]} )); then
notify-send "$title" "$message" ${=icon:+--icon "$icon"} ${=bgnotify_extraargs:-}
elif (( ${+commands[kdialog]} )); then # KDE
kdialog --title "$title" --passivepopup "$message" 5 ${=bgnotify_extraargs:-}
elif (( ${+commands[notifu]} )); then # cygwin
notifu /m "$message" /p "$title" ${=icon:+/i "$icon"} ${=bgnotify_extraargs:-}
fi
}
## Defaults
# enable terminal bell on notify by default
bgnotify_bell=${bgnotify_bell:-true}
# notify if command took longer than 5s by default
bgnotify_threshold=${bgnotify_threshold:-5}
# bgnotify_appid is slow in macOS and the terminal ID won't change, so cache it at startup
bgnotify_termid="$(bgnotify_appid)"

View file

@ -0,0 +1,17 @@
# Bower plugin
This plugin adds completion for [Bower](https://bower.io/) and a few useful aliases for common Bower commands.
To use it, add `bower` to the plugins array in your zshrc file:
```zsh
plugins=(... bower)
```
## Aliases
| Alias | Command | Description |
|-------|-----------------|--------------------------------------------------------|
| bi | `bower install` | Installs the project dependencies listed in bower.json |
| bl | `bower list` | List local packages and possible updates |
| bs | `bower search` | Finds all packages or a specific package. |

View file

@ -0,0 +1,58 @@
# Credits to npm's awesome completion utility.
#
# Bower completion script, based on npm completion script.
###-begin-bower-completion-###
#
# Installation: bower completion >> ~/.bashrc (or ~/.zshrc)
# Or, maybe: bower completion > /usr/local/etc/bash_completion.d/bower
#
COMP_WORDBREAKS=${COMP_WORDBREAKS/=/}
COMP_WORDBREAKS=${COMP_WORDBREAKS/@/}
export COMP_WORDBREAKS
if type complete &>/dev/null; then
_bower_completion () {
local si="$IFS"
IFS=$'\n' COMPREPLY=($(COMP_CWORD="$COMP_CWORD" \
COMP_LINE="$COMP_LINE" \
COMP_POINT="$COMP_POINT" \
bower completion -- "${COMP_WORDS[@]}" \
2>/dev/null)) || return $?
IFS="$si"
}
complete -F _bower_completion bower
elif type compdef &>/dev/null; then
_bower_completion() {
si=$IFS
compadd -- $(COMP_CWORD=$((CURRENT-1)) \
COMP_LINE=$BUFFER \
COMP_POINT=0 \
bower completion -- "${words[@]}" \
2>/dev/null)
IFS=$si
}
compdef _bower_completion bower
elif type compctl &>/dev/null; then
_bower_completion () {
local cword line point words si
read -Ac words
read -cn cword
let cword-=1
read -l line
read -ln point
si="$IFS"
IFS=$'\n' reply=($(COMP_CWORD="$cword" \
COMP_LINE="$line" \
COMP_POINT="$point" \
bower completion -- "${words[@]}" \
2>/dev/null)) || return $?
IFS="$si"
}
compctl -K _bower_completion bower
fi
###-end-bower-completion-###

View file

@ -0,0 +1,84 @@
alias bi="bower install"
alias bisd="bower install --save-dev"
alias bis="bower install --save"
alias bl="bower list"
alias bs="bower search"
_bower_installed_packages () {
bower_package_list=$(bower ls --no-color 2>/dev/null| awk 'NR>3{print p}{p=$0}'| cut -d ' ' -f 2|sed 's/#.*//')
}
_bower ()
{
local -a _1st_arguments _no_color _dopts _save_dev _force_latest _production
local expl
typeset -A opt_args
_no_color=('--no-color[Do not print colors (available in all commands)]')
_dopts=(
'(--save)--save[Save installed packages into the project"s bower.json dependencies]'
'(--force)--force[Force fetching remote resources even if a local copy exists on disk]'
)
_save_dev=('(--save-dev)--save-dev[Save installed packages into the project"s bower.json devDependencies]')
_force_latest=('(--force-latest)--force-latest[Force latest version on conflict]')
_production=('(--production)--production[Do not install project devDependencies]')
_1st_arguments=(
'cache-clean:Clean the Bower cache, or the specified package caches' \
'help:Display help information about Bower' \
'info:Version info and description of a particular package' \
'init:Interactively create a bower.json file' \
'install:Install a package locally' \
'link:Symlink a package folder' \
'lookup:Look up a package URL by name' \
'register:Register a package' \
'search:Search for a package by name' \
'uninstall:Remove a package' \
'update:Update a package' \
{ls,list}:'[List all installed packages]'
)
_arguments \
$_no_color \
'*:: :->subcmds' && return 0
if (( CURRENT == 1 )); then
_describe -t commands "bower subcommand" _1st_arguments
return
fi
case "$words[1]" in
install)
_arguments \
$_dopts \
$_save_dev \
$_force_latest \
$_no_color \
$_production
;;
update)
_arguments \
$_dopts \
$_no_color \
$_force_latest
_bower_installed_packages
compadd "$@" $(echo $bower_package_list)
;;
uninstall)
_arguments \
$_no_color \
$_dopts
_bower_installed_packages
compadd "$@" $(echo $bower_package_list)
;;
*)
_arguments \
$_no_color \
;;
esac
}
compdef _bower bower

View file

@ -0,0 +1,49 @@
# Branch plugin
This plugin displays the current Git or Mercurial branch, fast. If in a Mercurial repository,
also display the current bookmark, if present.
To use it, add `branch` to the plugins array in your zshrc file:
```zsh
plugins=(... branch)
```
## Speed test
- `hg branch`:
```console
$ time hg branch
0.11s user 0.14s system 70% cpu 0.355 total
```
- branch plugin:
```console
$ time zsh /tmp/branch_prompt_info_test.zsh
0.00s user 0.01s system 78% cpu 0.014 total
```
## Usage
Copy your theme to `$ZSH_CUSTOM/themes/` and modify it to add `$(branch_prompt_info)` in your prompt.
This example is for the `robbyrussell` theme:
```diff
diff --git a/themes/robbyrussell.zsh-theme b/themes/robbyrussell.zsh-theme
index 2fd5f2cd..9d89a464 100644
--- a/themes/robbyrussell.zsh-theme
+++ b/themes/robbyrussell.zsh-theme
@@ -1,5 +1,5 @@
PROMPT="%(?:%{$fg_bold[green]%}➜ :%{$fg_bold[red]%}➜ )"
-PROMPT+=' %{$fg[cyan]%}%c%{$reset_color%} $(git_prompt_info)'
+PROMPT+=' %{$fg[cyan]%}%c%{$reset_color%} $(branch_prompt_info)'
ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg_bold[blue]%}git:(%{$fg[red]%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%} "
```
## Maintainer
Victor Torres (<vpaivatorres@gmail.com>)

View file

@ -0,0 +1,35 @@
# Branch: displays the current Git or Mercurial branch fast.
# Victor Torres <vpaivatorres@gmail.com>
# Oct 2, 2015
function branch_prompt_info() {
# Start checking in current working directory
local branch="" dir="$PWD"
while [[ "$dir" != '/' ]]; do
# Found .git directory
if [[ -d "${dir}/.git" ]]; then
branch="${"$(<"${dir}/.git/HEAD")"##*/}"
echo '±' "${branch:gs/%/%%}"
return
fi
# Found .hg directory
if [[ -d "${dir}/.hg" ]]; then
if [[ -f "${dir}/.hg/branch" ]]; then
branch="$(<"${dir}/.hg/branch")"
else
branch="default"
fi
if [[ -f "${dir}/.hg/bookmarks.current" ]]; then
branch="${branch}/$(<"${dir}/.hg/bookmarks.current")"
fi
echo '☿' "${branch:gs/%/%%}"
return
fi
# Check parent directory
dir="${dir:h}"
done
}

View file

@ -0,0 +1,62 @@
# brew plugin
The plugin adds several aliases for common [brew](https://brew.sh) commands.
To use it, add `brew` to the plugins array of your zshrc file:
```zsh
plugins=(... brew)
```
## Shellenv
If `brew` is not found in the PATH, this plugin will attempt to find it in common locations, and execute
`brew shellenv` to set the environment appropriately. This plugin will also export
`HOMEBREW_PREFIX="$(brew --prefix)"` if not previously defined for convenience.
In case you installed `brew` in a non-common location, you can still set `BREW_LOCATION` variable pointing to
the `brew` binary before sourcing `oh-my-zsh.sh` and it'll set up the environment.
## Aliases
| Alias | Command | Description |
| -------- | --------------------------------------- | --------------------------------------------------------------------- |
| `ba` | `brew autoremove` | Uninstall unnecessary formulae. |
| `bci` | `brew info --cask` | Display information about the given cask. |
| `bcin` | `brew install --cask` | Install the given cask. |
| `bcl` | `brew list --cask` | List installed casks. |
| `bcn` | `brew cleanup` | Run cleanup. |
| `bco` | `brew outdated --cask` | Report all outdated casks. |
| `bcrin` | `brew reinstall --cask` | Reinstall the given cask. |
| `bcubc` | `brew upgrade --cask && brew cleanup` | Upgrade outdated casks, then run cleanup. |
| `bcubo` | `brew update && brew outdated --cask` | Update Homebrew data, then list outdated casks. |
| `bcup` | `brew upgrade --cask` | Upgrade all outdated casks. |
| `bfu` | `brew upgrade --formula` | Upgrade only formulae (not casks). |
| `bi` | `brew install` | Install a formula. |
| `bl` | `brew list` | List all installed formulae. |
| `bo` | `brew outdated` | List installed formulae that have an updated version available. |
| `brewp` | `brew pin` | Pin a specified formula so that it's not upgraded. |
| `brews` | `brew list -1` | List installed formulae or the installed files for a given formula. |
| `brewsp` | `brew list --pinned` | List pinned formulae, or show the version of a given formula. |
| `bsl` | `brew services list` | List all running services. |
| `bsoff` | `brew services stop` | Stop the service and unregister it from launching at login (or boot). |
| `bsoffa` | `bsoff --all` | Stop all started services. |
| `bson` | `brew services start` | Start the service and register it to launch at login (or boot). |
| `bsona` | `bson --all` | Start all stopped services. |
| `bsr` | `brew services run` | Run the service without registering to launch at login (or boot). |
| `bsra` | `bsr --all` | Run all stopped services. |
| `bu` | `brew update` | Update brew and all installed formulae. |
| `bubo` | `brew update && brew outdated` | Update Homebrew data, then list outdated formulae and casks. |
| `bubu` | `bubo && bup` | Do the last two operations above. |
| `bugbc` | `brew upgrade --greedy && brew cleanup` | Upgrade outdated formulae and casks (greedy), then run cleanup. |
| `bup` | `brew upgrade` | Upgrade outdated, unpinned brews. |
| `buz` | `brew uninstall --zap` | Remove all files associated with a cask. |
## Completion
This plugin configures paths with Homebrew's completion functions automatically, so you don't need to do it
manually. See: https://docs.brew.sh/Shell-Completion#configuring-completions-in-zsh.
With the release of Homebrew 1.0, they decided to bundle the zsh completion as part of the brew installation,
so we no longer ship it with the brew plugin; now it only has brew aliases. If you find that brew completion
no longer works, make sure you have your Homebrew installation fully up to date.

View file

@ -0,0 +1,79 @@
if (( ! $+commands[brew] )); then
if [[ -n "$BREW_LOCATION" ]]; then
if [[ ! -x "$BREW_LOCATION" ]]; then
echo "[oh-my-zsh] $BREW_LOCATION is not executable"
return
fi
elif [[ -x /opt/homebrew/bin/brew ]]; then
BREW_LOCATION="/opt/homebrew/bin/brew"
elif [[ -x /usr/local/bin/brew ]]; then
BREW_LOCATION="/usr/local/bin/brew"
elif [[ -x /home/linuxbrew/.linuxbrew/bin/brew ]]; then
BREW_LOCATION="/home/linuxbrew/.linuxbrew/bin/brew"
elif [[ -x "$HOME/.linuxbrew/bin/brew" ]]; then
BREW_LOCATION="$HOME/.linuxbrew/bin/brew"
else
return
fi
# Only add Homebrew installation to PATH, MANPATH, and INFOPATH if brew is
# not already on the path, to prevent duplicate entries. This aligns with
# the behavior of the brew installer.sh post-install steps.
eval "$("$BREW_LOCATION" shellenv)"
unset BREW_LOCATION
fi
if [[ -z "$HOMEBREW_PREFIX" ]]; then
# Maintain compatibility with potential custom user profiles, where we had
# previously relied on always sourcing shellenv. OMZ plugins should not rely
# on this to be defined due to out of order processing.
export HOMEBREW_PREFIX="$(brew --prefix)"
fi
if [[ -d "$HOMEBREW_PREFIX/share/zsh/site-functions" ]]; then
fpath+=("$HOMEBREW_PREFIX/share/zsh/site-functions")
fi
alias ba='brew autoremove'
alias bci='brew info --cask'
alias bcin='brew install --cask'
alias bcl='brew list --cask'
alias bcn='brew cleanup'
alias bco='brew outdated --cask'
alias bcrin='brew reinstall --cask'
alias bcubc='brew upgrade --cask && brew cleanup'
alias bcubo='brew update && brew outdated --cask'
alias bcup='brew upgrade --cask'
alias bfu='brew upgrade --formula'
alias bi='brew install'
alias bl='brew list'
alias bo='brew outdated'
alias brewp='brew pin'
alias brewsp='brew list --pinned'
alias bsl='brew services list'
alias bsoff='brew services stop'
alias bsoffa='bsoff --all'
alias bson='brew services start'
alias bsona='bson --all'
alias bsr='brew services run'
alias bsra='bsr --all'
alias bu='brew update'
alias bubo='brew update && brew outdated'
alias bubu='bubo && bup'
alias bubug='bubo && bugbc'
alias bugbc='brew upgrade --greedy && brew cleanup'
alias bup='brew upgrade'
alias buz='brew uninstall --zap'
function brews() {
local formulae="$(brew leaves | xargs brew deps --installed --for-each)"
local casks="$(brew list --cask 2>/dev/null)"
local blue="$(tput setaf 4)"
local bold="$(tput bold)"
local off="$(tput sgr0)"
echo "${blue}==>${off} ${bold}Formulae${off}"
echo "${formulae}" | sed "s/^\(.*\):\(.*\)$/\1${blue}\2${off}/"
echo "\n${blue}==>${off} ${bold}Casks${off}\n${casks}"
}

View file

@ -0,0 +1,26 @@
# Bridgetown plugin
This plugin adds some aliases and autocompletion for common [Bridgetown](https://bridgetownrb.com/) commands.
To use it, add `bridgetown` to the plugins array in your zshrc file:
```zsh
plugins=(... bridgetown)
```
## Aliases
| Alias | Command |
|-------|----------------------------|
| br | `bridgetown` |
| bra | `bin/bridgetown apply` |
| brb | `bin/bridgetown build` |
| brc | `bin/bridgetown console` |
| brclean | `bin/bridgetown clean` |
| brd | `bin/bridgetown deploy` |
| brdoc | `bin/bridgetown doctor` |
| brh | `bin/bridgetown help` |
| brn | `bridgetown new` |
| brp | `bridgetown plugins` |
| brpl | `bridgetown plugins list` |
| brs | `bin/bridgetown start` |

View file

@ -0,0 +1,12 @@
alias br='bridgetown'
alias bra='bin/bridgetown apply'
alias brb='bin/bridgetown build'
alias brc='bin/bridgetown console'
alias brclean='bin/bridgetown clean'
alias brd='bin/bridgetown deploy'
alias brdoc='bin/bridgetown doctor'
alias brh='bin/bridgetown help'
alias brn='bridgetown new'
alias brp='bridgetown plugins'
alias brpl='bridgetown plugins list'
alias brs='bin/bridgetown start'

View file

@ -0,0 +1,20 @@
# Bun Plugin
This plugin sets up completion for [Bun](https://bun.sh).
To use it, add `bun` to the plugins array in your zshrc file:
```zsh
plugins=(... bun)
```
This plugin does not add any aliases.
## Cache
This plugin caches the completion script and is automatically updated when the
plugin is loaded, which is usually when you start up a new terminal emulator.
The cache is stored at:
- `$ZSH_CACHE_DIR/completions/_bun_` completions script

View file

@ -0,0 +1,14 @@
# If Bun is not found, don't do the rest of the script
if (( ! $+commands[bun] )); then
return
fi
# If the completion file doesn't exist yet, we need to autoload it and
# bind it to `bun`. Otherwise, compinit will have already done that.
if [[ ! -f "$ZSH_CACHE_DIR/completions/_bun" ]]; then
typeset -g -A _comps
autoload -Uz _bun
_comps[bun]=_bun
fi
SHELL=zsh bun completions >| "$ZSH_CACHE_DIR/completions/_bun" &|

View file

@ -0,0 +1,74 @@
# Bundler
This plugin adds completion for basic bundler commands, as well as aliases and helper functions for
an easier experience with bundler.
To use it, add `bundler` to the plugins array in your zshrc file:
```zsh
plugins=(... bundler)
```
## Aliases
| Alias | Command | Description |
|--------|--------------------------------------|------------------------------------------------------------------------------------------|
| `ba` | `bundle add` | Add gem to the Gemfile and run bundle install |
| `bck` | `bundle check` | Verifies if dependencies are satisfied by installed gems |
| `bcn` | `bundle clean` | Cleans up unused gems in your bundler directory |
| `be` | `bundle exec` | Execute a command in the context of the bundle |
| `bi` | `bundle install --jobs=<core_count>` | Install the dependencies specified in your Gemfile (using all cores in bundler >= 1.4.0) |
| `bl` | `bundle list` | List all the gems in the bundle |
| `bo` | `bundle open` | Opens the source directory for a gem in your bundle |
| `bout` | `bundle outdated` | List installed gems with newer versions available |
| `bp` | `bundle package` | Package your needed .gem files into your application |
| `bu` | `bundle update` | Update your gems to the latest available versions |
## Gem wrapper
The plugin adds a wrapper for common gems, which:
- Looks for a binstub under `./bin/` and executes it if present.
- Calls `bundle exec <gem>` otherwise.
Common gems wrapped by default (by name of the executable):
`annotate`, `cap`, `capify`, `cucumber`, `foodcritic`, `guard`, `hanami`, `irb`, `jekyll`, `kitchen`, `knife`, `middleman`, `nanoc`, `pry`, `puma`, `rackup`, `rainbows`, `rake`, `rspec`, `rubocop`, `shotgun`, `sidekiq`, `spec`, `spork`, `spring`, `strainer`, `tailor`, `taps`, `thin`, `thor`, `unicorn` and `unicorn_rails`.
### Settings
You can add or remove gems from the list of wrapped commands.
Please **use the exact name of the executable** and not the gem name.
#### Include gems to be wrapped (`BUNDLED_COMMANDS`)
Add this before the plugin list in your `.zshrc`:
```sh
BUNDLED_COMMANDS=(rubocop)
plugins=(... bundler ...)
```
This will add the wrapper for the `rubocop` gem (i.e. the executable).
#### Exclude gems from being wrapped (`UNBUNDLED_COMMANDS`)
Add this before the plugin list in your `.zshrc`:
```sh
UNBUNDLED_COMMANDS=(foreman spin)
plugins=(... bundler ...)
```
This will exclude the `foreman` and `spin` gems (i.e. their executable) from being wrapped.
### Excluded gems
These gems should not be called with `bundle exec`. Please see [issue #2923](https://github.com/ohmyzsh/ohmyzsh/pull/2923) on GitHub for clarification:
- `berks`
- `foreman`
- `mailcatcher`
- `rails`
- `ruby`
- `spin`

View file

@ -0,0 +1,105 @@
#compdef bundle bundler
local curcontext="$curcontext" state line _gems _opts ret=1
_arguments -C -A "-v" -A "--version" \
'(- 1 *)'{-v,--version}'[display version information]' \
'1: :->cmds' \
'*:: :->args' && ret=0
case $state in
cmds)
_values "bundle command" \
"install[Install the gems specified by the Gemfile or Gemfile.lock]" \
"update[Update dependencies to their latest versions]" \
"package[Package the .gem files required by your application]" \
"exec[Execute a script in the context of the current bundle]" \
"config[Specify and read configuration options for bundler]" \
"check[Determine whether the requirements for your application are installed]" \
"list[Show all of the gems in the current bundle]" \
"show[Show the source location of a particular gem in the bundle]" \
"info[Show details of a particular gem in the bundle]" \
"outdated[Show all of the outdated gems in the current bundle]" \
"console[Start an IRB session in the context of the current bundle]" \
"open[Open an installed gem in the editor]" \
"viz[Generate a visual representation of your dependencies]" \
"init[Generate a simple Gemfile, placed in the current directory]" \
"gem[Create a simple gem, suitable for development with bundler]" \
"platform[Displays platform compatibility information]" \
"clean[Cleans up unused gems in your bundler directory]" \
"help[Describe available tasks or one specific task]"
ret=0
;;
args)
case $line[1] in
help)
_values 'commands' \
'install' \
'update' \
'package' \
'exec' \
'config' \
'check' \
'list' \
'show' \
'outdated' \
'console' \
'open' \
'viz' \
'init' \
'gem' \
'platform' \
'help' && ret=0
;;
install)
_arguments \
'(--no-color)--no-color[disable colorization in output]' \
'(--local)--local[do not attempt to connect to rubygems.org]' \
'(--quiet)--quiet[only output warnings and errors]' \
'(--gemfile)--gemfile=-[use the specified gemfile instead of Gemfile]:gemfile' \
'(--system)--system[install to the system location]' \
'(--deployment)--deployment[install using defaults tuned for deployment environments]' \
'(--frozen)--frozen[do not allow the Gemfile.lock to be updated after this install]' \
'(--path)--path=-[specify a different path than the system default]:path:_files' \
'(--binstubs)--binstubs=-[generate bin stubs for bundled gems to ./bin]:directory:_files' \
'(--without)--without=-[exclude gems that are part of the specified named group]:groups'
ret=0
;;
exec)
_normal && ret=0
;;
clean)
_arguments \
'(--force)--force[forces clean even if --path is not set]' \
'(--dry-run)--dry-run[only print out changes, do not actually clean gems]' \
'(--no-color)--no-color[Disable colorization in output]' \
'(--verbose)--verbose[Enable verbose output mode]'
ret=0
;;
outdated)
_arguments \
'(--pre)--pre[Check for newer pre-release gems]' \
'(--source)--source[Check against a specific source]' \
'(--local)--local[Do not attempt to fetch gems remotely and use the gem cache instead]' \
'(--no-color)--no-color[Disable colorization in output]' \
'(--verbose)--verbose[Enable verbose output mode]'
ret=0
;;
(open|show|info)
_gems=( $(bundle show 2> /dev/null | sed -e '/^ \*/!d; s/^ \* \([^ ]*\) .*/\1/') )
if [[ $_gems != "" ]]; then
_values 'gems' $_gems && ret=0
fi
;;
*)
_opts=( $(bundle help $line[1] | sed -e '/^ \[-/!d; s/^ \[\(-[^=]*\)=.*/\1/') )
_opts+=( $(bundle help $line[1] | sed -e '/^ -/!d; s/^ \(-.\), \[\(-[^=]*\)=.*/\1 \2/') )
if [[ $_opts != "" ]]; then
_values 'options' $_opts && ret=0
fi
;;
esac
;;
esac
return ret

View file

@ -0,0 +1,127 @@
## Aliases
alias ba="bundle add"
alias bck="bundle check"
alias bcn="bundle clean"
alias be="bundle exec"
alias bi="bundle_install"
alias bl="bundle list"
alias bo="bundle open"
alias bout="bundle outdated"
alias bp="bundle package"
alias bu="bundle update"
## Functions
bundle_install() {
# Bail out if bundler is not installed
if (( ! $+commands[bundle] )); then
echo "Bundler is not installed"
return 1
fi
# Bail out if not in a bundled project
if ! _within-bundled-project; then
echo "Can't 'bundle install' outside a bundled project"
return 1
fi
# Check the bundler version is at least 1.4.0
autoload -Uz is-at-least
local bundler_version=$(bundle version | cut -d' ' -f3)
if ! is-at-least 1.4.0 "$bundler_version"; then
bundle install "$@"
return $?
fi
# If bundler is at least 1.4.0, use all the CPU cores to bundle install
if [[ "$OSTYPE" = (darwin|freebsd)* ]]; then
local cores_num="$(sysctl -n hw.ncpu)"
else
local cores_num="$(nproc)"
fi
BUNDLE_JOBS="$cores_num" bundle install "$@"
}
## Gem wrapper
bundled_commands=(
annotate
cap
capify
cucumber
foodcritic
guard
hanami
irb
jekyll
kitchen
knife
middleman
nanoc
pry
puma
rackup
rainbows
rake
rspec
rubocop
shotgun
sidekiq
spec
spork
spring
strainer
tailor
taps
thin
thor
unicorn
unicorn_rails
)
# Remove $UNBUNDLED_COMMANDS from the bundled_commands list
bundled_commands=(${bundled_commands:|UNBUNDLED_COMMANDS})
unset UNBUNDLED_COMMANDS
# Add $BUNDLED_COMMANDS to the bundled_commands list
bundled_commands+=($BUNDLED_COMMANDS)
unset BUNDLED_COMMANDS
# Check if in the root or a subdirectory of a bundled project
_within-bundled-project() {
local check_dir="$PWD"
while [[ "$check_dir" != "/" ]]; do
if [[ -f "$check_dir/Gemfile" || -f "$check_dir/gems.rb" ]]; then
return 0
fi
check_dir="${check_dir:h}"
done
return 1
}
_run-with-bundler() {
if (( ! $+commands[bundle] )) || ! _within-bundled-project; then
"$@"
return $?
fi
if [[ -f "./bin/${1}" ]]; then
./bin/${^^@}
else
bundle exec "$@"
fi
}
for cmd in $bundled_commands; do
# Create wrappers for bundled and unbundled execution
eval "function unbundled_$cmd () { \"$cmd\" \"\$@\"; }"
eval "function bundled_$cmd () { _run-with-bundler \"$cmd\" \"\$@\"; }"
alias "$cmd"="bundled_$cmd"
# Bind completion function to wrapped gem if available
if (( $+functions[_$cmd] )); then
compdef "_$cmd" "bundled_$cmd"="$cmd"
fi
done
unset cmd bundled_commands

View file

@ -0,0 +1,9 @@
# Cabal
This plugin provides completion for [Cabal](https://www.haskell.org/cabal/), a build tool for Haskell. It
also provides a function `cabal_sandbox_info` that prints whether the current working directory is in a sandbox.
To use it, add cabal to the plugins array of your zshrc file:
```
plugins=(... cabal)
```

View file

@ -0,0 +1,93 @@
function cabal_sandbox_info() {
cabal_files=(*.cabal(N))
if [ $#cabal_files -gt 0 ]; then
if [ -f cabal.sandbox.config ]; then
echo "%{$fg[green]%}sandboxed%{$reset_color%}"
else
echo "%{$fg[red]%}not sandboxed%{$reset_color%}"
fi
fi
}
function _cabal_commands() {
local ret=1 state
_arguments ':subcommand:->subcommand' && ret=0
case $state in
subcommand)
subcommands=(
"bench:Run the benchmark, if any (configure with UserHooks)"
"build:Compile all targets or specific target."
"check:Check the package for common mistakes"
"clean:Clean up after a build"
"copy:Copy the files into the install locations"
"configure:Prepare to build the package"
"exec:Run a command with the cabal environment"
"fetch:Downloads packages for later installation"
"freeze:Freeze dependencies."
"get:Gets a package's source code"
"haddock:Generate Haddock HTML documentation"
"help:Help about commands"
"hscolour:Generate HsColour colourised code, in HTML format"
"info:Display detailed information about a particular package"
"init:Interactively create a .cabal file"
"install:Installs a list of packages"
"list:List packages matching a search string"
"register:Register this package with the compiler"
"repl:Open an interpreter session for the given target"
"report:Upload build reports to a remote server"
"run:Runs the compiled executable"
"sandbox:Create/modify/delete a sandbox"
"sdist:Generate a source distribution file (.tar.gz)"
"test:Run the test suite, if any (configure with UserHooks)"
"unpack:Unpacks packages for user inspection"
"update:Updates list of known packages"
"upload:Uploads source packages to Hackage"
)
_describe -t subcommands 'cabal subcommands' subcommands && ret=0
esac
return ret
}
compdef _cabal_commands cabal
function _cab_commands() {
local ret=1 state
_arguments ':subcommand:->subcommand' && ret=0
case $state in
subcommand)
subcommands=(
"sync:Fetch the latest package index"
"install:Install packages"
"uninstall:Uninstall packages"
"installed:List installed packages"
"configure:Configure a cabal package"
"build:Build a cabal package"
"clean:Clean up a build directory"
"outdated:Display outdated packages"
"info:Display information of a package"
"sdist:Make tar.gz for source distribution"
"upload:Uploading tar.gz to HackageDB"
"get:Untar a package in the current directory"
"deps:Show dependencies of this package"
"revdeps:Show reverse dependencies of this package"
"check:Check consistency of packages"
"genpaths:Generate Paths_<pkg>.hs"
"search:Search available packages by package name"
"add:Add a source directory"
"test:Run tests"
"bench:Run benchmarks"
"doc:Generate manuals"
"ghci:Run GHCi (with a sandbox)"
"init:Initialize a sandbox"
"help:Display the help message of the command"
)
_describe -t subcommands 'cab subcommands' subcommands && ret=0
esac
return ret
}
command -v cab >/dev/null 2>&1 && { compdef _cab_commands cab }

View file

@ -0,0 +1,15 @@
# Cake
This plugin provides completion for [CakePHP](https://cakephp.org/).
To use it add cake to the plugins array in your zshrc file.
```bash
plugins=(... cake)
```
## Note
This plugin generates a cache file of the cake tasks found, named `.cake_task_cache`, in the current working directory.
It is regenerated when the Cakefile is newer than the cache file. It is advised that you add the cake file to your
`.gitignore` files.

View file

@ -0,0 +1,33 @@
# Set this to 1 if you want to cache the tasks
_cake_cache_task_list=1
# Cache filename
_cake_task_cache_file='.cake_task_cache'
_cake_get_target_list () {
cake | grep '^cake ' | sed -e "s/cake \([^ ]*\) .*/\1/" | grep -v '^$'
}
_cake_does_target_list_need_generating () {
if [ ${_cake_cache_task_list} -eq 0 ]; then
return 1;
fi
[ ! -f ${_cake_task_cache_file} ] && return 0;
[ Cakefile -nt ${_cake_task_cache_file} ] && return 0;
return 1;
}
_cake () {
if [ -f Cakefile ]; then
if _cake_does_target_list_need_generating; then
_cake_get_target_list > ${_cake_task_cache_file}
compadd `cat ${_cake_task_cache_file}`
else
compadd `_cake_get_target_list`
fi
fi
}
compdef _cake cake

View file

@ -0,0 +1,16 @@
# cakephp3 plugin
The plugin adds aliases and autocompletion for [cakephp3](https://book.cakephp.org/3.0/en/index.html).
To use it, add `cakephp3` to the plugins array of your zshrc file:
```
plugins=(... cakephp3)
```
## Aliases
| Alias | Command |
|-----------|-------------------------------|
| c3 | `bin/cake` |
| c3cache | `bin/cake orm_cache clear` |
| c3migrate | `bin/cake migrations migrate` |

View file

@ -0,0 +1,38 @@
# CakePHP 3 basic command completion
_cakephp3_get_command_list () {
bin/cake completion commands
}
_cakephp3_get_sub_command_list () {
bin/cake completion subcommands ${words[2]}
}
_cakephp3_get_3rd_argument () {
bin/cake ${words[2]} ${words[3]} | \grep '\-\ '| \awk '{print $2}'
}
_cakephp3 () {
local -a has3rdargument
has3rdargument=("all" "controller" "fixture" "model" "template")
if [ -f bin/cake ]; then
if (( CURRENT == 2 )); then
compadd $(_cakephp3_get_command_list)
fi
if (( CURRENT == 3 )); then
compadd $(_cakephp3_get_sub_command_list)
fi
if (( CURRENT == 4 )); then
if [[ ${has3rdargument[(i)${words[3]}]} -le ${#has3rdargument} ]]; then
compadd $(_cakephp3_get_3rd_argument)
fi
fi
fi
}
compdef _cakephp3 bin/cake
compdef _cakephp3 cake
#Alias
alias c3='bin/cake'
alias c3cache='bin/cake schema_cache clear'
alias c3migrate='bin/cake migrations migrate'

View file

@ -0,0 +1,14 @@
# Capistrano
This plugin provides completion for [Capistrano](https://capistranorb.com/).
To use it add capistrano to the plugins array in your zshrc file.
```bash
plugins=(... capistrano)
```
For a working completion use the `capit` command instead of `cap`, because cap is a
[reserved word in zsh](http://zsh.sourceforge.net/Doc/Release/Zsh-Modules.html#The-zsh_002fcap-Module).
`capit` automatically runs cap with bundler if a Gemfile is found.

View file

@ -0,0 +1,49 @@
#compdef capit
#autoload
# Added `capit` because `cap` is a reserved word. `cap` completion doesn't work.
# http://zsh.sourceforge.net/Doc/Release/Zsh-Modules.html#The-zsh_002fcap-Module
local curcontext="$curcontext" state line ret=1
local -a _configs
_arguments -C \
'1: :->cmds' \
'2:: :->args' && ret=0
_cap_tasks() {
if [[ -f config/deploy.rb || -f Capfile ]]; then
if [[ ! -f .cap_tasks~ ]]; then
capit --tasks | sed 's/\(\[\)\(.*\)\(\]\)/\2:/' | awk '{command=$2; $1=$2=$3=""; gsub(/^[ \t\r\n]+/, "", $0); gsub(":", "\\:", command); print command"["$0"]"}' > .cap_tasks~
fi
OLD_IFS=$IFS
IFS=$'\n'
_values 'cap commands' $(< .cap_tasks~)
IFS=$OLD_IFS
# zmodload zsh/mapfile
# _values ${(f)mapfile[.cap_tasks~]}
fi
}
_cap_stages() {
compadd $(find config/deploy -name \*.rb | cut -d/ -f3 | sed s:.rb::g)
}
case $state in
cmds)
# check if it uses multistage
if [[ -d config/deploy ]]; then
_cap_stages
else
_cap_tasks
fi
ret=0
;;
args)
_cap_tasks
ret=0
;;
esac
return ret

View file

@ -0,0 +1,11 @@
# Added `capit` because `cap` is a reserved word. `cap` completion doesn't work.
# http://zsh.sourceforge.net/Doc/Release/Zsh-Modules.html#The-zsh_002fcap-Module
function capit() {
if [ -f Gemfile ]
then
bundle exec cap $*
else
cap $*
fi
}

View file

@ -0,0 +1,15 @@
# Cask plugin
[Cask](https://github.com/cask/cask) is a project management tool for Emacs that helps
automate the package development cycle; development, dependencies, testing, building,
packaging and more.
This plugin loads `cask` completion from non-standard locations, such as if installed
via Homebrew or others. To enable it, add `cask` to your plugins array:
```zsh
plugins=(... cask)
```
Make sure you have the `cask` directory in your `$PATH` before loading Oh My Zsh,
otherwise you'll get a "command not found" error.

View file

@ -0,0 +1,26 @@
() {
emulate -L zsh
if ! (( $+commands[cask] )); then
print "zsh cask plugin: cask command not found" >&2
return
fi
cask_base=${commands[cask]:h:h}
# Plain cask installation location (for Cask 0.7.2 and earlier)
comp_files=($cask_base/etc/cask_completion.zsh)
# Mac Homebrew installs the completion in a different location
if (( $+commands[brew] )); then
comp_files+=($(brew --prefix)/share/zsh/site-functions/cask_completion.zsh)
fi
# Load first found file
for f in $comp_files; do
if [[ -f "$f" ]]; then
source "$f"
break
fi
done
}

View file

@ -0,0 +1,24 @@
# catimg
Plugin for displaying images on the terminal using the `catimg.sh` script provided by
[posva](https://github.com/posva/catimg)
To use it, add `catimg` to the plugins array in your zshrc file:
```zsh
plugins=(... catimg)
```
## Requirements
- `magick convert` (ImageMagick)
## Functions
| Function | Description |
| -------- | ---------------------------------------- |
| `catimg` | Displays the given image on the terminal |
## Usage examples
[![asciicast](https://asciinema.org/a/204702.png)](https://asciinema.org/a/204702)

View file

@ -0,0 +1,19 @@
################################################################################
# catimg script by Eduardo San Martin Morote aka Posva #
# https://posva.net #
# #
# Output the content of an image to the stdout using the 256 colors of the #
# terminal. #
# GitHub: https://github.com/posva/catimg #
################################################################################
function catimg() {
if (( $+commands[magick] )); then
CONVERT_CMD="magick" zsh $ZSH/plugins/catimg/catimg.sh $@
elif (( $+commands[convert] )); then
CONVERT_CMD="convert" zsh $ZSH/plugins/catimg/catimg.sh $@
else
echo "catimg need magick/convert (ImageMagick) to work)"
fi
}

View file

@ -0,0 +1,92 @@
################################################################################
# catimg script by Eduardo San Martin Morote aka Posva #
# https://posva.net #
# #
# Output the content of an image to the stdout using the 256 colors of the #
# terminal. #
# GitHub: https://github.com/posva/catimg #
################################################################################
# this should come from outside, either `magick` or `convert`
# from imagemagick v7 and ahead `convert` is deprecated
: ${CONVERT_CMD:=convert}
function help() {
echo "Usage catimg [-h] [-w width] [-c char] img"
echo "By default char is \" \" and w is the terminal width"
}
# VARIABLES
COLOR_FILE=$(dirname $0)/colors.png
CHAR=" "
WIDTH=""
IMG=""
while getopts qw:c:h opt; do
case "$opt" in
w) WIDTH="$OPTARG" ;;
c) CHAR="$OPTARG" ;;
h) help; exit ;;
*) help ; exit 1;;
esac
done
while [ "$1" ]; do
IMG="$1"
shift
done
if [ "$IMG" = "" -o ! -f "$IMG" ]; then
help
exit 1
fi
if [ ! "$WIDTH" ]; then
COLS=$(expr $(tput cols) "/" $(echo -n "$CHAR" | wc -c))
else
COLS=$(expr $WIDTH "/" $(echo -n "$CHAR" | wc -c))
fi
WIDTH=$($CONVERT_CMD "$IMG" -print "%w\n" /dev/null)
if [ "$WIDTH" -gt "$COLS" ]; then
WIDTH=$COLS
fi
REMAP=""
if $CONVERT_CMD "$IMG" -resize $COLS\> +dither -remap $COLOR_FILE /dev/null ; then
REMAP="-remap $COLOR_FILE"
else
echo "The version of convert is too old, don't expect good results :(" >&2
# $CONVERT_CMD "$IMG" -colors 256 PNG8:tmp.png
# IMG="tmp.png"
fi
# Display the image
I=0
$CONVERT_CMD "$IMG" -resize $COLS\> +dither `echo $REMAP` txt:- 2>/dev/null |
sed -e 's/.*none.*/NO NO NO/g' -e '1d;s/^.*(\(.*\)[,)].*$/\1/g;y/,/ /' |
while read R G B f; do
if [ ! "$R" = "NO" ]; then
if [ "$R" -eq "$G" -a "$G" -eq "$B" ]; then
((
I++,
IDX = 232 + R * 23 / 255
))
else
((
I++,
IDX = 16
+ R * 5 / 255 * 36
+ G * 5 / 255 * 6
+ B * 5 / 255
))
fi
#echo "$R,$G,$B: $IDX"
echo -ne "\e[48;5;${IDX}m${CHAR}"
else
(( I++ ))
echo -ne "\e[0m${CHAR}"
fi
# New lines
(( $I % $WIDTH )) || echo -e "\e[0m"
done

Binary file not shown.

After

Width:  |  Height:  |  Size: 353 B

View file

@ -0,0 +1,9 @@
# Celery
This plugin provides completion for [Celery](http://www.celeryproject.org/).
To use it add celery to the plugins array in your zshrc file.
```bash
plugins=(... celery)
```

View file

@ -0,0 +1,129 @@
#compdef celery
#autoload
#celery zsh completion
_celery () {
local -a _1st_arguments ifargs dopts controlargs
typeset -A opt_args
_1st_arguments=('worker' 'events' 'beat' 'shell' 'multi' 'amqp' 'status' 'inspect' \
'control' 'purge' 'list' 'migrate' 'call' 'result' 'report')
ifargs=('--app=' '--broker=' '--loader=' '--config=' '--version')
dopts=('--detach' '--umask=' '--gid=' '--uid=' '--pidfile=' '--logfile=' '--loglevel=')
controlargs=('--timeout' '--destination')
_arguments \
'(-A --app=)'{-A,--app}'[app instance to use (e.g. module.attr_name):APP]' \
'(-b --broker=)'{-b,--broker}'[url to broker. default is "amqp://guest@localhost//":BROKER]' \
'(--loader)--loader[name of custom loader class to use.:LOADER]' \
'(--config)--config[Name of the configuration module:CONFIG]' \
'(--workdir)--workdir[Optional directory to change to after detaching.:WORKING_DIRECTORY]' \
'(-q --quiet)'{-q,--quiet}'[Don"t show as much output.]' \
'(-C --no-color)'{-C,--no-color}'[Don"t display colors.]' \
'(--version)--version[show program"s version number and exit]' \
'(- : *)'{-h,--help}'[show this help message and exit]' \
'*:: :->subcmds' && return 0
if (( CURRENT == 1 )); then
_describe -t commands "celery subcommand" _1st_arguments
return
fi
case "$words[1]" in
worker)
_arguments \
'(-C --concurrency=)'{-C,--concurrency=}'[Number of child processes processing the queue. The default is the number of CPUs.]' \
'(--pool)--pool=:::(processes eventlet gevent threads solo)' \
'(--purge --discard)'{--discard,--purge}'[Purges all waiting tasks before the daemon is started.]' \
'(-f --logfile=)'{-f,--logfile=}'[Path to log file. If no logfile is specified, stderr is used.]' \
'(--loglevel=)--loglevel=:::(critical error warning info debug)' \
'(-N --hostname=)'{-N,--hostname=}'[Set custom hostname, e.g. "foo.example.com".]' \
'(-B --beat)'{-B,--beat}'[Also run the celerybeat periodic task scheduler.]' \
'(-s --schedule=)'{-s,--schedule=}'[Path to the schedule database if running with the -B option. Defaults to celerybeat-schedule.]' \
'(-S --statedb=)'{-S,--statedb=}'[Path to the state database.Default: None]' \
'(-E --events)'{-E,--events}'[Send events that can be captured by monitors like celeryev, celerymon, and others.]' \
'(--time-limit=)--time-limit=[nables a hard time limit (in seconds int/float) for tasks]' \
'(--soft-time-limit=)--soft-time-limit=[Enables a soft time limit (in seconds int/float) for tasks]' \
'(--maxtasksperchild=)--maxtasksperchild=[Maximum number of tasks a pool worker can execute before it"s terminated and replaced by a new worker.]' \
'(-Q --queues=)'{-Q,--queues=}'[List of queues to enable for this worker, separated by comma. By default all configured queues are enabled.]' \
'(-I --include=)'{-I,--include=}'[Comma separated list of additional modules to import.]' \
'(--pidfile=)--pidfile=[Optional file used to store the process pid.]' \
'(--autoscale=)--autoscale=[Enable autoscaling by providing max_concurrency, min_concurrency.]' \
'(--autoreload)--autoreload[Enable autoreloading.]' \
'(--no-execv)--no-execv[Don"t do execv after multiprocessing child fork.]'
compadd -a ifargs
;;
inspect)
_values -s \
'active[dump active tasks (being processed)]' \
'active_queues[dump queues being consumed from]' \
'ping[ping worker(s)]' \
'registered[dump of registered tasks]' \
'report[get bugreport info]' \
'reserved[dump reserved tasks (waiting to be processed)]' \
'revoked[dump of revoked task ids]' \
'scheduled[dump scheduled tasks (eta/countdown/retry)]' \
'stats[dump worker statistics]'
compadd -a controlargs ifargs
;;
control)
_values -s \
'add_consumer[tell worker(s) to start consuming a queue]' \
'autoscale[change autoscale settings]' \
'cancel_consumer[tell worker(s) to stop consuming a queue]' \
'disable_events[tell worker(s) to disable events]' \
'enable_events[tell worker(s) to enable events]' \
'pool_grow[start more pool processes]' \
'pool_shrink[use less pool processes]' \
'rate_limit[tell worker(s) to modify the rate limit for a task type]' \
'time_limit[tell worker(s) to modify the time limit for a task type.]'
compadd -a controlargs ifargs
;;
multi)
_values -s \
'--nosplash[Don"t display program info.]' \
'--verbose[Show more output.]' \
'--no-color[Don"t display colors.]' \
'--quiet[Don"t show as much output.]' \
'start' 'restart' 'stopwait' 'stop' 'show' \
'names' 'expand' 'get' 'kill'
compadd -a ifargs
;;
amqp)
_values -s \
'queue.declare' 'queue.purge' 'exchange.delete' 'basic.publish' \
'exchange.declare' 'queue.delete' 'queue.bind' 'basic.get'
;;
list)
_values -s, 'bindings'
;;
shell)
_values -s \
'--ipython[force iPython.]' \
'--bpython[force bpython.]' \
'--python[force default Python shell.]' \
'--without-tasks[don"t add tasks to locals.]' \
'--eventlet[use eventlet.]' \
'--gevent[use gevent.]'
compadd -a ifargs
;;
beat)
_arguments \
'(-s --schedule=)'{-s,--schedule=}'[Path to the schedule database. Defaults to celerybeat-schedule.]' \
'(-S --scheduler=)'{-S,--scheduler=}'[Scheduler class to use. Default is celery.beat.PersistentScheduler.]' \
'(--max-interval)--max-interval[]'
compadd -a dopts fargs
;;
events)
_arguments \
'(-d --dump)'{-d,--dump}'[Dump events to stdout.]' \
'(-c --camera=)'{-c,--camera=}'[Take snapshots of events using this camera.]' \
'(-F --frequency=)'{-F,--frequency=}'[Camera: Shutter frequency. Default is every 1.0 seconds.]' \
'(-r --maxrate=)'{-r,--maxrate=}'[Camera: Optional shutter rate limit (e.g. 10/m).]'
compadd -a dopts fargs
;;
*)
;;
esac
}

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

@ -0,0 +1,11 @@
# chezmoi Plugin
## Introduction
This `chezmoi` plugin sets up completion for [chezmoi](https://chezmoi.io).
To use it, add `chezmoi` to the plugins array of your zshrc file:
```bash
plugins=(... chezmoi)
```

View file

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

View file

@ -0,0 +1,21 @@
# chruby plugin
This plugin loads [chruby](https://github.com/postmodern/chruby), a tool that changes the
current Ruby version, and completion and a prompt function to display the Ruby version.
Supports brew and manual installation of chruby.
To use it, add `chruby` to the plugins array in your zshrc file:
```zsh
plugins=(... chruby)
```
## Usage
If you'd prefer to specify an explicit path to load chruby from
you can set variables like so:
```zsh
zstyle :omz:plugins:chruby path /local/path/to/chruby.sh
zstyle :omz:plugins:chruby auto /local/path/to/auto.sh
```

View file

@ -0,0 +1,94 @@
## load chruby from different locations
_source-from-omz-settings() {
local _chruby_path _chruby_auto
zstyle -s :omz:plugins:chruby path _chruby_path || return 1
zstyle -s :omz:plugins:chruby auto _chruby_auto || return 1
if [[ -r ${_chruby_path} ]]; then
source ${_chruby_path}
fi
if [[ -r ${_chruby_auto} ]]; then
source ${_chruby_auto}
fi
}
_source-from-homebrew() {
(( $+commands[brew] )) || return 1
local _brew_prefix
# check default brew prefix
if [[ -h /usr/local/opt/chruby ]];then
_brew_prefix="/usr/local/opt/chruby"
else
# ok , it is not default prefix
# this call to brew is expensive ( about 400 ms ), so at least let's make it only once
_brew_prefix=$(brew --prefix chruby)
fi
[[ -r "$_brew_prefix" ]] || return 1
source $_brew_prefix/share/chruby/chruby.sh
source $_brew_prefix/share/chruby/auto.sh
}
_load-chruby-dirs() {
local dir
for dir in "$HOME/.rubies" "$PREFIX/opt/rubies"; do
if [[ -d "$dir" ]]; then
RUBIES+=("$dir")
fi
done
}
# Load chruby
if _source-from-omz-settings; then
_load-chruby-dirs
elif [[ -r "/usr/local/share/chruby/chruby.sh" ]] ; then
source /usr/local/share/chruby/chruby.sh
source /usr/local/share/chruby/auto.sh
_load-chruby-dirs
elif _source-from-homebrew; then
_load-chruby-dirs
fi
unfunction _source-from-homebrew _source-from-omz-settings _load-chruby-dirs
## chruby utility functions and aliases
# rvm and rbenv plugins also provide this alias
alias rubies='chruby'
function current_ruby() {
local ruby
ruby="$(chruby | grep \* | tr -d '* ')"
if [[ $(chruby | grep -c \*) -eq 1 ]]; then
echo ${ruby}
else
echo "system"
fi
}
function chruby_prompt_info() {
echo "${$(current_ruby):gs/%/%%}"
}
# Complete chruby command with installed rubies
_chruby() {
compadd $(chruby | tr -d '* ')
if PATH="/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin" command ruby &>/dev/null; then
compadd system
fi
}
compdef _chruby chruby
# Simple definition completer for ruby-build
if command ruby-build &> /dev/null; then
_ruby-build() { compadd $(ruby-build --definitions) }
compdef _ruby-build ruby-build
fi

View file

@ -0,0 +1,38 @@
# chucknorris
Fortunes plugin for Chuck Norris for Oh My Zsh. Perfectly suitable as MOTD.
To use it add `chucknorris` to the plugins array in you zshrc file.
```zsh
plugins=(... chucknorris)
```
## Usage
| Command | Description |
| ----------- | ------------------------------- |
| `chuck` | Print random Chuck Norris quote |
| `chuck_cow` | Print quote in cowthink |
Example: output of `chuck_cow`:
```
Last login: Fri Jan 30 23:12:26 on ttys001
______________________________________
( When Chuck Norris plays Monopoly, it )
( affects the actual world economy. )
--------------------------------------
o ^__^
o (oo)\_______
(__)\ )\/\
||----w |
|| ||
```
## Requirements
- `fortune`
- `cowsay` if using `chuck_cow`
Available via homebrew, apt, ...

View file

@ -0,0 +1,24 @@
() {
# %x: name of file containing code being executed
local fortunes_dir="${${(%):-%x}:h}/fortunes"
# Aliases
alias chuck="fortune -a $fortunes_dir"
alias chuck_cow="chuck | cowthink"
# Automatically generate or update Chuck's compiled fortune data file
if [[ "$fortunes_dir/chucknorris" -ot "$fortunes_dir/chucknorris.dat" ]]; then
return
fi
# For some reason, Cygwin puts strfile in /usr/sbin, which is not on the path by default
local strfile="${commands[strfile]:-/usr/sbin/strfile}"
if [[ ! -x "$strfile" ]]; then
echo "[oh-my-zsh] chucknorris depends on strfile, which is not installed" >&2
echo "[oh-my-zsh] strfile is often provided as part of the 'fortune' package" >&2
return
fi
# Generate the compiled fortune data file
$strfile "$fortunes_dir/chucknorris" "$fortunes_dir/chucknorris.dat" >/dev/null
}

View file

@ -0,0 +1 @@
fortunes/chucknorris.dat

View file

@ -0,0 +1,568 @@
King Kong climbed the Empire State building in fear of Chuck Norris who was downstairs at the time.
%
"2012" is code for, Chuck Norris when he is pissed.
%
"The Big Chuck Norris Roundhouse-Kick Theory"
%
"The wind cries Chuck Norris"
%
"Walker Texas Ranger: The Movie 3-D" was considered by Warner Brothers; however the technology to create the visual effects will never be possible.
%
A Handicapped parking sign does not signify that this spot is for handicapped people. It is actually in fact a warning, that the spot belongs to Chuck Norris and that you will be handicapped if you park there.
%
Abraham Lincoln didn't die because he was shot, Chuck Norris roundhouse-kicked so fast his foot went back in time and killed Abraham Lincoln.
%
Achievement Unlocked: Chuck Norris of Death
%
After Chuck counted to infinity the first time, he vowed to count to infinity a second time....by counting the bodies of those previously roundhoused.
%
Aliens fear that Chuck Norris might abduct them.
%
An angry glare from Chuck Norris is known to kill on the spot.
%
Behind every successful man is Chuck Norris.
%
Beware of dogs... Dogs, beware of Chuck Norris.
%
Bruce Lee didn't defeat Chuck Norris. Chuck hit Bruce with a Delayed roundhouse kick that was so fast that Lee only felt the impact a year later!
%
CNN was originally created as the "Chuck Norris Network" to update Americans with on-the-spot ass kicking in real-time.
%
Casinos pay Chuck Norris not to play at anything or wish anyone good luck.
%
Chuck Norris - the new standard.
%
Chuck Norris CAN balance the light-switch between ON and OFF.
%
Chuck Norris CAN believe it's not butter.
%
Chuck Norris CAN spell with an I before E even after C.
%
Chuck Norris can play the theme from the Twilight Zone with his beard.
%
Chuck Norris can power solar panels. At night.
%
Chuck Norris watches "the Nat.Geo. Specials" on Discovery Channel.
%
Chuck Norris bowled a 301 after constructing another pin out of his beard hair.
%
Chuck Norris burnt a fire proof vest, UNDERWATER!
%
Chuck Norris can French kiss his elbow.
%
Chuck Norris can bake in a freezer.
%
Chuck Norris can defuse a bomb by cutting the wrong wire.
%
Chuck Norris can dig a hole in air.
%
Chuck Norris can divide by zero.
%
Chuck Norris can do a regime change with a roundhouse kick.
%
Chuck Norris can fit 10 gallons of water in a 5 gallon bucket.
%
Chuck Norris can grill a popsicle.
%
Chuck Norris can lead a horse to water AND make it drink.
%
Chuck Norris can make his own megazord "The Chuck Norris Roundhouse Kickers Ultimate Super Awesome Megazord".
%
Chuck Norris can milk an alligator.
%
Chuck Norris can play the death waltz with his chin.
%
Chuck Norris can roundhouse kick someone through a window without breaking the glass.
%
Chuck Norris can roundhouse-kick round houses into squares.
%
Chuck Norris can rub two fires together and make a stick!
%
Chuck Norris can see in 3D with just one eye.
%
Chuck Norris can slam a revolving door.
%
Chuck Norris can terminate a repeating decimal.
%
Chuck Norris can turn toast back into bread.
%
Chuck Norris can win a game of Connect Four in only three moves.
%
Chuck Norris can win in a top spinning tournament with a cube.
%
Chuck Norris can't perform Hadoukens, he IS a Hadouken.
%
Chuck Norris checks under his bed for Fedor Emelianenko because he takes Fedor to the vet regularly.
%
Chuck Norris counted to infinity - twice.
%
Chuck Norris created Heavy Metal when he was upset.
%
Chuck Norris does not get frostbite. Chuck Norris bites frost.
%
Chuck Norris does not have a cell phone because he hears everything.
%
Chuck Norris does not sleep. He waits.
%
Chuck Norris doesn't bowl strikes, he just knocks down one pin and the other nine faint.
%
Chuck Norris doesn't call the wrong number, you just answer the wrong phone.
%
Chuck Norris doesn't cheat death, he beats it fair and square.
%
Chuck Norris doesn't churn butter. He roundhouse kicks the cows and the butter comes straight out.
%
Chuck Norris doesn't eat, he just sucks the energy out of food by staring at it.
%
Chuck Norris doesn't exhale. The air runs desperately scared out of his lungs.
%
Chuck Norris doesn't go hunting.... CHUCK NORRIS GOES KILLING.
%
Chuck Norris doesn't let it go.
%
Chuck Norris doesn't like Mudkipz.
%
Chuck Norris doesn't look for fun. The fun looks for Chuck Norris.
%
Chuck Norris doesn't need a bulletproof vest. He catches them with his bare hands.
%
Chuck Norris doesn't need air, he is air.
%
Chuck Norris doesn't need sunglasses, the sun needs Chuck Norris glasses.
%
Chuck Norris doesn't need to brush his teeth, his spit acts as a bleach.
%
Chuck Norris doesn't read books. He stares them down until he gets the information he wants.
%
Chuck Norris doesn't throw up if he drinks too much. Chuck Norris throws down!
%
Chuck Norris doesn't eat salad, he eats vegetarians.
%
Chuck Norris doesn't wash his clothes, he disembowels them.
%
Chuck Norris doesn't wear a watch. HE decides what time it is.
%
Chuck Norris doesn't carry a list. He always knows what to do.
%
Chuck Norris drives an ice cream truck covered in human skulls.
%
Chuck Norris drowned a man ON LAND.
%
Chuck Norris fed the Hunger Games.
%
Chuck Norris found the hay in the needle stack.
%
Chuck Norris found the last digit of pi.
%
Chuck Norris had a knife thrown at him. The knife didn't impale him; he impaled the knife.
%
Chuck Norris has a battle cruiser AND a car.
%
Chuck Norris has killed the Dead Sea.
%
Chuck Norris has made a 148 break at snooker.
%
Chuck Norris invented Kentucky Fried Chicken's famous secret recipe, with eleven herbs and spices. But nobody ever mentions the twelfth ingredient: Fear.
%
Chuck Norris is allowed two carry-ons.
%
Chuck Norris is currently suing NBC, claiming Law and Order are trademarked names for his left and right legs.
%
Chuck Norris is currently suing any broadway theater that plays "The Nutcracker". He claims its an infringement on his "other" roundhouse kick.
%
Chuck Norris is entitled to his own facts.
%
Chuck Norris is my Homeboy.
%
Chuck Norris is so fast, he can run around the world and punch himself in the back of the head.
%
Chuck Norris is so hard, he uses diamonds as stress balls.
%
Chuck Norris is so scary, he makes sharks swim backwards away from him.
%
Chuck Norris is ten feet tall, weighs two-tons, breathes fire, and could eat a hammer and take a shotgun blast standing.
%
Chuck Norris is the ghost in paranormal activity.
%
Chuck Norris is the life of parties he doesn't attend.
%
Chuck Norris is the meaning of life. Too bad he's also the meaning of death.
%
Chuck Norris is the only man to ever defeat a brick wall in a game of tennis.
%
Chuck Norris is the only one who can tear a facebook page!
%
Chuck Norris is the reason that the world will end in 2012. He was getting bored with the Earth.
%
Chuck Norris is the reason tumbleweeds tumble.
%
Chuck Norris is the reason why Waldo is hiding.
%
Chuck Norris is waiting for Mt. St. Helens to erupt again. He's hoping the lava is hot enough to soften his beard so he can shave for the first time.
%
Chuck Norris isn't allowed at the zoo, because when he's there the animals are too terrified to come out of their cages.
%
Chuck Norris made a statue bleed.
%
Chuck Norris made the big bang just by clicking his fingers.
%
Chuck Norris never trains, because he's Chuck Norris.
%
Chuck Norris once cried just to see what it was like. The end result was the creation of life.
%
Chuck Norris once cut a knife with a stick of butter.
%
Chuck Norris once got a 200 yard punt return.
%
Chuck Norris once had a pet monkey named KING KONG.
%
Chuck Norris once had a street named after him. The name removed at once, because nobody crosses Chuck Norris, and lives.
%
Chuck Norris once had a weak moment, just to know what it felt like.
%
Chuck Norris once played Duck Duck Goose with a group of Kindergarteners. Only one kid made it to first grade.
%
Chuck Norris once proved p^~p by induction on his beard hairs.
%
Chuck Norris once punched the ground to stop an earthquake. The resulting aftershock caused the BP oil spill.
%
Chuck Norris once round-house kicked a salesman. Over the phone.
%
Chuck Norris once roundhouse kicked a football. The astronomical society now considers it a planet.
%
Chuck Norris once thought he was wrong. He was, however, mistaken.
%
Chuck Norris once walked down a street with his fists in his pockets. He was then arrested for concealing two deadly weapons.
%
Chuck Norris once won the Tour de France riding a "big wheel".
%
Chuck Norris originally appeared in the "Street Fighter II" video game, but was removed by Beta Testers because every button caused him to do a roundhouse kick. When asked bout this "glitch," Norris replied, "That's no glitch."
%
Chuck Norris owns all number 1 pencils.
%
Chuck Norris pees Adamantium.
%
Chuck Norris plays Texas Hold'Em with Zeus, every second Wednesday of the month.
%
Chuck Norris played "Got your Nose" with Voldemort and won.
%
Chuck Norris played the game of thrones and won.
%
Chuck Norris protects his bodyguards.
%
Chuck Norris rolled a 20 on a 6 sided die.
%
Chuck Norris roundhouse kicks people in the face first and asks questions later.
%
Chuck Norris sent a BBM to an iPhone.
%
Chuck Norris shops at Sam's Club, but leaves without having his receipt checked.
%
Chuck Norris splattered tiger blood and Adonis' DNA on Charlie Sheen with 1 roundhouse kick!
%
Chuck Norris started Chuck Norris.
%
Chuck Norris starts his day with 6 live chickens, two cows, three pigs, and a boiling hot cup of pure fury.
%
Chuck Norris told me to put this here.
%
Chuck Norris uses a real mouse to move the cursor, type on the keyboard, write e-mails, code entire websites, and make coffee.
%
Chuck Norris uses pepper spray to spice up his steaks.
%
Chuck Norris was heard in a soundproof room!
%
Chuck Norris was once turned down for American Idol. When Simon was questioned about it, he replied "I'm retiring after this season". I wonder why?
%
Chuck Norris was originally in Mortal Kombat, but that version was deleted because no one can beat Chuck Norris in a fight.
%
Chuck Norris was the image used for Papa Smurf.
%
Chuck Norris was the reason why the Great Wall of China was constructed. It failed miserably.
%
Chuck Norris was what Willis was talking about.
%
Chuck Norris wasn't born on his birthday.
%
Chuck Norris watched the first steps on the moon... from his summer home on Mars.
%
Chuck Norris went up the creek without a paddle... or a canoe.
%
Chuck Norris will attain statehood in 2009. His state flower will be the Magnolia.
%
Chuck Norris wins NASCAR races with all right turns.
%
Chuck Norris won a stepdance contest by standing on his hands.
%
Chuck Norris yells at drill Sergeants.
%
Chuck Norris' dog picks up after him.
%
Chuck Norris' films are factual documentaries.
%
Chuck Norris' first job was as a paperboy. There were no survivors.
%
Chuck Norris' glass is never half full or half empty. It stays full even after he takes a drink.
%
Chuck Norris' hand is the only hand that can beat a Royal Flush.
%
Chuck Norris' personal airplane is called Air Force Chuck.
%
Chuck Norris. Enough said.
%
Chuck Norris: even Naruto can't believe it.
%
Chuck Norris can make sour milk turn fresh.
%
Contrary to popular belief, Rome WAS built in a day, by Chuck Norris.
%
Contrary to popular belief, America is not a democracy, it is a Chucktatorship.
%
Contrary to popular belief, Chuck Norris, not the box jellyfish of northern Australia, is the most venomous creature on Earth.
%
Cops don't need badges in their wallets, but only a picture of Chuck Norris.
%
Crop circles are Chuck Norris' way of telling the world that sometimes corn needs to lie down.
%
Did you hear about the boy who cried Chuck Norris?
%
Dog the Bounty Hunter can't track Chuck Norris down.
%
Don't get Chuck Norris angry. Last time somebody did that, Chuck Norris made the Grand Canyon.
%
Earth's rotation is purely governed by the direction that Chuck Norris is walking.
%
Ever wonder what really happened to the dinosaurs? They all dug their own graves when they heard Chuck Norris was coming.
%
Every line in a Chuck Norris haiku is "A roundhouse kick to the face." And they all have the correct number of syllables.
%
Every phobia known to man has a phobia of Chuck Norris.
%
Every time there's an earthquake, you know Chuck Norris is hungry. The earthquake is caused by his stomach growling.
%
Evolution's driving mechanism is nature's desperate attempt to escape Chuck Norris.
%
Fear of spiders is arachnophobia. Fear of tight spaces is claustrophobia. Fear of Chuck Norris is called Logic.
%
Fool me once, shame on you. Fool Chuck Norris once and he will roundhouse you in the face.
%
Ghosts can see Chuck Norris.
%
Guns don't kill people. Chuck Norris kills people.
%
How much wood could a woodchuck chuck if a woodchuck could chuck wood? No woodchuck could chuck Chuck's wood!
%
If Chuck Norris were a calendar, every month would be named Chucktober, and every day he'd kick your ass.
%
If Chuck Norris were to get into a fight with another Chuck Norris, Chuck Norris would win.
%
If God doesn't know, Chuck does.
%
If Goliath listened to Chuck Norris, he would have won.
%
If at first you don't succeed, you're not Chuck Norris.
%
If you ask Chuck Norris what time it is, he always says, "Two seconds 'til." After you ask, "Two seconds 'til what?" he roundhouse kicks you in the face.
%
If you put in the correct cheat code in Halo 2, you can have Master Chief play without his helmet, revealing himself to be Chuck Norris.
%
If you see a man in the street who looks like Chuck Norris, but isn't, run: you don't want to be caught in the resulting roundhouse kick to his face.
%
If you spell Chuck Norris in Scrabble, you win. Forever.
%
In 1945 The US army asked if they could clone Chuck Norris. Instead he said he could sort out the Japanese.
%
In Texas, there are five sizes for fountain drinks: small, medium, large, Texas sized, and Chuck Norris sized. It is a cup made of a human skull.
%
In a rain storm Chuck Norris stays dry. Rain drops are scared to hit him.
%
In the back of the book of world records, it says "All records are held by Chuck Norris. The ones listed are in second place."
%
James Bond has a license to kill. He got it from Chuck Norris.
%
Jedis are now taught to use the "Chuck".
%
MacGyver immediately tried to make a bomb out of some Q-Tips and Gatorade, but Chuck Norris roundhouse-kicked him in the solar plexus. MacGyver promptly threw up his own heart.
%
Machiavelli said it is better to be feared than loved because he was inspired by Chuck Norris.
%
May the Force be with Chuck Norris... for its own good.
%
Merlin was Chuck Norris' assistant.
%
Most people have 23 pairs of chromosomes. Chuck Norris has 72... and they're all poisonous.
%
Note to self: Don't be the cashier to tell Chuck Norris his coupons have expired.
%
Chuck Norris' keyboard has no control key. Chuck Norris is always in control.
%
Once upon a time, Chuck Norris found himself in a town called Shit Creek. He opened a Paddle Store.
%
One glance from Chuck Norris and snow turns itself yellow.
%
One time a test cheated on Chuck Norris.
%
Only Chuck Norris can win the mind game, 'cause he never minds.
%
Only Chuck Norris is stronger than an Altoid.
%
Outer space exists because it's afraid to be on the same planet with Chuck Norris.
%
Ozzy Osbourne once accidentally bit the head off a live bat - Chuck Norris once deliberately bit the head off a live pterodactyl.
%
Pluto is actually an orbiting group of British soldiers from the American Revolution who entered space after the Chuck gave them a roundhouse kick to the face.
%
Police label anyone attacking Chuck Norris as a Code 45-11.... a suicide.
%
Remember the Soviet Union? They decided to quit after watching a DeltaForce marathon on Satellite TV.
%
Simon doesn't say... Chuck Norris says.
%
Some boots were made for walking. Some boots may walk all over you, but Chuck Norris' boots walk THROUGH you.
%
Some kids pee their name in snow. Chuck Norris pees his name in concrete.
%
Some people ask for a Kleenex when they sneeze, Chuck Norris asks for a body bag.
%
Someone once videotaped Chuck Norris getting pissed off. It was called Walker: Texas Chain Saw Massacre.
%
Staring at Chuck Norris for extended periods of time without proper eye protection will cause blindness, and possibly foot sized bruises on the face.
%
Taking Karate Lessons = $100, Buying MMA DVD's = $150, Subscribing to a UFC event = $50, Getting a Roundhouse Kick from Chuck Norris = PRICELESS.
%
That's not an eclipse. That's the sun hiding from Chuck Norris.
%
The Beatles are on iTunes because Chuck Norris bought a Mac.
%
The Earth is made up of two-thirds water and one-third Chuck Norris.
%
The Earth was almost destroyed by a 50 km wide asteroid in 1984, but Chuck Norris roundhouse kicked it into the Sun.
%
The Great Wall of China was originally created to keep Chuck Norris out. It failed miserably.
%
The Joneses are trying to keep up with Chuck Norris.
%
The Matrix Trilogy would have ended on the first movie had Keanu Reeves said, “I know Chuck Norris.”
%
The answer to life, the universe and everything isn't 42. It's Chuck Norris.
%
The apple falls far from the tree, when Chuck's roundhouse kick is taken to the trunk.
%
The best part of waking up is not Folgers in your cup. it's knowing that Chuck Norris let you live.
%
The chief export of Chuck Norris is pain.
%
The dictionary references Chuck Norris several times, he is mentioned under Fear, Law, Order and Chucktatorship.
%
The leading causes of death in the United States are: 1. Heart Disease 2. Chuck Norris 3. Cancer.
%
The letters in Chuck Norris cannot be unscrambled.
%
The only place where the Starship Enterprise refuses to boldly go is Chuck Norris' planet... which is all of them.
%
The only reason that USA lost the 2011 world cup to Japan is because Chuck Norris wasn't there.
%
The only sure things are Death and Taxes, and when Chuck Norris goes to work for the IRS, they'll be the same thing.
%
The only way sharks will come near CN underwater is when CN is inside of a cage.
%
The only word that rhymes with orange is Chuck Norris.
%
The producers of the movie "The Last Airbender" are now in talks with Chuck Norris in Order to star him in their next sequel "The Last Skull Bender".
%
The quickest way to a man's heart is with Chuck Norris' fist.
%
The reason why Batman only comes out at night is because he's afraid he might encounter Chuck Norris in the morning and afternoon.
%
The red phone in the oval office rings directly to Chuck Norris' cell phone.
%
The show Survivor had the original premise of putting people on an island with Chuck Norris. There were no survivors, and nobody is brave enough to go to the island to retrieve the footage.
%
The square root of Chuck Norris is pain. Do not try to square Chuck Norris. The result is death.
%
The sun only rises every morning because Chuck Norris allows it to.
%
The truth hurts, doesn't it? Chuck Norris' truth kills.
%
There is no chin behind Chuck Norris' beard. There is only another fist.
%
There is no limbo, only a world that doesn't know of Chuck Norris.
%
There is no such thing as global warming. Chuck Norris was cold, so he turned the sun up.
%
There is no theory of evolution, just a list of creatures Chuck Norris has allowed to live.
%
This one time at band camp... BAM! Chuck Norris.
%
Those who ignore history, are doomed by Chuck Norris.
%
Trick me once, shame on you, trick Chuck Norris.. rest in peace.
%
Unlike Jack Bauer, Chuck Norris doesn't need bullets. A quick roundhouse to the face kills twice as fast.
%
Walker: Texas Ranger went into syndication before the first episode was shot.
%
What was going through the minds of all of Chuck Norris' victims before they died? His shoe.
%
Whatever Chuck Norris wants, it will instantly appear.
%
When Betty White gets angry, she turns into the Hulk. When Valerie Bertinelli gets mad, she turns into Chuck Norris.
%
When Chuck Norris creates a login, it tells him "password not strong enough." He types in his name and it tells him "password too strong."
%
When Chuck Norris does a pushup, he isn't lifting himself up, he's pushing the Earth down.
%
When Chuck Norris drinks water, the water automatically pasteurized.
%
When Chuck Norris goes to Vegas, he doesn't have to gamble. The casinos just give him stacks of money.
%
When Chuck Norris goes to rodeos, bulls ride him.
%
When Chuck Norris goes to the library, he looks for the Guinness book of records in the comedy section.
%
When Chuck Norris inhales helium, his voice doesn't change.
%
When Chuck Norris performs a roundhouse kick, he's actually measuring the circumference of the universe.
%
When Chuck Norris played the card game War with a friend, France surrendered.
%
When Chuck Norris pokes the Pillsbury Doughboy, it's not a laughing matter.
%
When Chuck Norris roundhouse-kicks you, he decides when you will feel the impact.
%
When Chuck Norris sends in his taxes, he sends blank forms and includes only a picture of himself, crouched and ready to attack. Chuck Norris has not had to pay taxes, ever.
%
When Chuck Norris tosses a coin, it lands on both heads and tails.
%
When God said "Let there be light!", Chuck Norris said "Only for half the day."
%
When Presidents speak, their nation listens. When Chuck Norris blinks, the whole world listens.
%
When Steven Seagal kills a ninja, he only takes its hide. When Chuck Norris kills a ninja, he uses every part.
%
When chuck Norris was in school, he made his PE teacher run laps.
%
When does Chuck Norris run out of shotgun bullets? whenever he wants to.
%
When taking the SAT, write "Chuck Norris" for every answer. You will score over 8000.
%
When the Boogeyman goes to sleep every night, he checks his closet for Chuck Norris.
%
When things go bump in the night, it's Chuck Norris
%
While visiting the Hexagon, Chuck Norris was asked to demonstrate his famous roundhouse kick. Henceforth, it has been known as the Pentagon.
%
Why didn't the chicken cross the road? Because Chuck Norris got to it first.
%
You know Chuck Norris' pet lizard, right? Last I heard, he was in the movie "Godzilla". Oh, and his pet turtle starred in "Gamera" as well.
%
http://chucknorrisfacts.com/ is built in Drupal because Chuck Norris knows a good CMS when he sees one.
%
Chuck Norris made the first Giraffe by uppercutting a horse.
%
Chuck Norris can hear sign language.
%
Chuck Norris make onions cry.
%
Chuck Norris doesn't shake hands, he makes them tremble.
%

View file

@ -0,0 +1,58 @@
# Cloudfoundry Plugin
This plugin is intended to offer a few simple aliases for regular users of the [Cloud Foundry Cli][1]. Most are just simple aliases that will save a bit of typing. Others include mini functions and or accept parameters. Take a look at the table below for details.
| Alias | Command | Description |
|----------|-----------------------------|--------------------------------------------------------------------------|
| cfl | `cf login` | Login to Cloud Foundry |
| cft | `cf target` | Target the cli at a specific Org/Space in Cloud Foundry |
| cfa | `cf apps` | List all applications in the current Org/Space |
| cfs | `cf services` | List all services in the current Org/Space |
| cfm | `cf marketplace` | List the services available in the Marketplace |
| cfp | `cf push` | Push your application code to Cloud Foundry |
| cfcs | `cf create-service` | Create a service based on a Marketplace offering |
| cfbs | `cf bind-service` | Bind an application to a service you created |
| cfus | `cf unbind-service` | Unbind a service from an application |
| cfds | `cf delete-service` | Delete a service you no longer have bound |
| cfup | `cf cups` | Create a "user-provided-service" |
| cflg | `cf logs` | Tail the logs of an application (requires <APP_NAME>) |
| cfr | `cf routes` | List all the routes in the current Space |
| cfe | `cf env` | Show the environment variables for an application (requires <APP_NAME>) |
| cfsh | `cf ssh` | Attach to a running container (requires an <APP_NAME> etc.) |
| cfsc | `cf scale` | Scale an application (requires an <APP_NAME> etc.) |
| cfev | `cf events` | Show the application events (requires <APP_NAME>) |
| cfdor | `cf delete-orphaned-routes` | Delete routes that are no longer bound to applications |
| cfbpk | `cf buildpacks` | List the available buildpacks |
| cfdm | `cf domains` | List the domains associates with this Cloud Foundry foundation |
| cfsp | `cf spaces` | List all the Spaces in the current Org |
| cfap | `cf app` | Show the details of a deployed application (requires <APP_NAME>) |
| cfh. | `export CF_HOME=$PWD/.cf` | Set the current directory as CF_HOME |
| cfh~ | `export CF_HOME=~/.cf` | Set the user's root directory as CF_HOME |
| cfhu | `unset CF_HOME` | Unsets CF_HOME |
| cfpm | `cf push -f` | Push an application using a manifest (requires <MANIFEST_FILE> location) |
| cflr | `cf logs --recent` | Show the recent logs (requires <APP_NAME>) |
| cfsrt | `cf start` | Start an application (requires <APP_NAME>) |
| cfstp | `cf stop` | Stop an application (requires <APP_NAME>) |
| cfstg | `cf restage` | Restage an application (requires <APP_NAME>) |
| cfdel | `cf delete` | Delete an application (requires <APP_NAME>) |
| cfsrtall | - | Start all apps that are currently in the "Stopped" state |
| cfstpall | - | Stop all apps that are currently in the "Started" state |
For help and advice on what any of the commands does, consult the built in `cf` help functions as follows:-
```bash
cf help # List the most popular and commonly used commands
cf help -a # Complete list of all possible commands
cf <COMMAND_NAME> --help # Help on a specific command including arguments and examples
```
Alternatively, seek out the [online documentation][3]. And don't forget, there are loads of great [community plugins for the cf-cli][4] command line tool that can greatly extend its power and usefulness.
## Contributors
Contributed to `oh_my_zsh` by [benwilcock][2].
[1]: https://docs.cloudfoundry.org/cf-cli/install-go-cli.html
[2]: https://github.com/benwilcock
[3]: https://docs.cloudfoundry.org/cf-cli/getting-started.html
[4]: https://plugins.cloudfoundry.org/

View file

@ -0,0 +1,34 @@
# Some Useful CloudFoundry Aliases & Functions
alias cfl="cf login"
alias cft="cf target"
alias cfa="cf apps"
alias cfs="cf services"
alias cfm="cf marketplace"
alias cfp="cf push"
alias cfcs="cf create-service"
alias cfbs="cf bind-service"
alias cfus="cf unbind-service"
alias cfds="cf delete-service"
alias cfup="cf cups"
alias cflg="cf logs"
alias cfr="cf routes"
alias cfe="cf env"
alias cfsh="cf ssh"
alias cfsc="cf scale"
alias cfev="cf events"
alias cfdor="cf delete-orphaned-routes"
alias cfbpk="cf buildpacks"
alias cfdm="cf domains"
alias cfsp="cf spaces"
function cfap() { cf app $1 }
function cfh.() { export CF_HOME=$PWD/.cf }
function cfh~() { export CF_HOME=~/.cf }
function cfhu() { unset CF_HOME }
function cfpm() { cf push -f $1 }
function cflr() { cf logs $1 --recent }
function cfsrt() { cf start $1 }
function cfstp() { cf stop $1 }
function cfstg() { cf restage $1 }
function cfdel() { cf delete $1 }
function cfsrtall() {cf apps | awk '/stopped/ { system("cf start " $1)}'}
function cfstpall() {cf apps | awk '/started/ { system("cf stop " $1)}'}

View file

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

View file

@ -0,0 +1,82 @@
#compdef codeclimate
_codeclimate_all_engines() {
engines_all=(`codeclimate engines:list | tail -n +2 | gawk '{ print $2 }' | gawk -F: '{ print $1 }'`)
}
_codeclimate_installed_engines() {
_codeclimate_all_engines
engines_installed=()
if [ -e .codeclimate.yml ]
then
for engine in $engines_all
do
if grep -q $engine ".codeclimate.yml"
then
engines_installed+=$engine
fi
done
fi
}
_codeclimate_not_installed_engines() {
_codeclimate_all_engines
engines_not_installed=()
if [ -e .codeclimate.yml ]
then
for engine in $engines_all
do
if ! grep -q $engine ".codeclimate.yml"
then
engines_not_installed+=$engine
fi
done
fi
}
local curcontext="$curcontext" state line ret=1
local expl
local -a engines_all engines_installed engines_not_installed
_arguments \
'1: :->cmds' \
'*:: :->args' && ret=0
case $state in
cmds)
_values "bundle command" \
"analyze[Analyze all relevant files in the current working directory]" \
"console[Start an interactive session providing access to the classes within the CLI]" \
"engines\:disable[Prevents the engine from being used in this project]" \
"engines\:enable[This engine will be run the next time your project is analyzed]" \
"engines\:install[Compares the list of engines in your .codeclimate.yml file to those that are currently installed, then installs any missing engines]" \
"engines\:list[Lists all available engines in the Code Climate Docker Hub]" \
"engines\:remove[Removes an engine from your .codeclimate.yml file]" \
"help[Displays a list of commands that can be passed to the Code Climate CLI]" \
"init[Generates a new .codeclimate.yml file in the current working directory]" \
"validate-config[Validates the .codeclimate.yml file in the current working directory]" \
"version[Displays the current version of the Code Climate CLI]"
ret=0
;;
args)
case $line[1] in
engines:enable)
_codeclimate_not_installed_engines
_wanted engines_not_installed expl 'not installed engines' compadd -a engines_not_installed ;;
engines:disable|engines:remove)
_codeclimate_installed_engines
_wanted engines_installed expl 'installed engines' compadd -a engines_installed ;;
analyze)
_arguments \
'-f:Output Format:(text json)'
ret=0
;;
esac
;;
esac
return ret

View file

@ -0,0 +1,31 @@
# Coffeescript Plugin
This plugin provides aliases for quickly compiling and previewing your
coffeescript code.
When writing Coffeescript it's very common to want to preview the output of a
certain snippet of code, either because you want to test the output or because
you'd like to execute it in a browser console which doesn't accept Coffeescript.
Preview the compiled result of your coffeescript with `cf "code"` as per the
following:
```zsh
$ cf 'if a then b else c'
if (a) {
b;
} else {
c;
}
```
Also provides the following aliases:
* **cfc:** Copies the compiled JS to your clipboard. Very useful when you want
to run the code in a JS console.
* **cfp:** Compiles from your currently copied clipboard. Useful when you want
to compile large/multi-line snippets
* **cfpc:** Paste coffeescript from clipboard, compile to JS, then copy the
the result back to clipboard.

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