mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2026-01-30 02:44:42 +01:00
mychanges
This commit is contained in:
parent
6bcd61f44e
commit
a50fcdfb02
105 changed files with 27351 additions and 0 deletions
68
.github/ISSUE_TEMPLATE/bug_report.yml
vendored
Normal file
68
.github/ISSUE_TEMPLATE/bug_report.yml
vendored
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
name: Report a bug
|
||||
description: Report a bug that isn't caused by Oh My Zsh. If unsure, use this form
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
## Self Check
|
||||
- Look for similar errors in existing [GitHub Issues](https://github.com/ohmyzsh/ohmyzsh/issues?q=is%3Aissue) (open or closed).
|
||||
- Try reaching out on the [Discord server](https://discord.gg/ohmyzsh) for help.
|
||||
- type: textarea
|
||||
validations:
|
||||
required: true
|
||||
attributes:
|
||||
label: Describe the bug
|
||||
description: A clear description of what the bug is.
|
||||
- type: textarea
|
||||
validations:
|
||||
required: true
|
||||
attributes:
|
||||
label: Steps to reproduce
|
||||
description: |
|
||||
Steps to reproduce the problem.
|
||||
placeholder: |
|
||||
For example:
|
||||
1. Enable plugin '...'
|
||||
2. Run command '...' or try to complete command '...'
|
||||
3. See error
|
||||
- type: textarea
|
||||
validations:
|
||||
required: true
|
||||
attributes:
|
||||
label: Expected behavior
|
||||
description: A brief description of what should happen.
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: Screenshots and recordings
|
||||
description: |
|
||||
If applicable, add screenshots to help explain your problem. You can also record an asciinema session: https://asciinema.org/
|
||||
- type: input
|
||||
validations:
|
||||
required: true
|
||||
attributes:
|
||||
label: OS / Linux distribution
|
||||
placeholder: Windows 10, Ubuntu 20.04, Arch Linux, macOS 10.15...
|
||||
- type: input
|
||||
validations:
|
||||
required: true
|
||||
attributes:
|
||||
label: Zsh version
|
||||
description: Run `echo $ZSH_VERSION` to check.
|
||||
placeholder: "5.6"
|
||||
- type: input
|
||||
validations:
|
||||
required: true
|
||||
attributes:
|
||||
label: Terminal emulator
|
||||
placeholder: iTerm2, GNOME Terminal, Terminal.app...
|
||||
- type: dropdown
|
||||
attributes:
|
||||
label: If using WSL on Windows, which version of WSL
|
||||
description: Run `wsl -l -v` to check.
|
||||
options:
|
||||
- WSL1
|
||||
- WSL2
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: Additional context
|
||||
description: Add any other context about the problem here. This can be themes, plugins, custom settings...
|
||||
77
.github/ISSUE_TEMPLATE/bug_report_omz.yml
vendored
Normal file
77
.github/ISSUE_TEMPLATE/bug_report_omz.yml
vendored
Normal file
|
|
@ -0,0 +1,77 @@
|
|||
name: Report a bug in Oh My Zsh
|
||||
description: Create a report to help us improve Oh My Zsh
|
||||
labels: ['Bug']
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
## Self Check
|
||||
- **Make sure this bug only happens with Oh My Zsh enabled**.
|
||||
- Look for similar errors in existing [GitHub Issues](https://github.com/ohmyzsh/ohmyzsh/issues?q=is%3Aissue) (open or closed).
|
||||
- Try reaching out on the [Discord server](https://discord.gg/ohmyzsh) for help.
|
||||
- type: textarea
|
||||
validations:
|
||||
required: true
|
||||
attributes:
|
||||
label: Describe the bug
|
||||
description: A clear description of what the bug is.
|
||||
- type: textarea
|
||||
validations:
|
||||
required: true
|
||||
attributes:
|
||||
label: Steps to reproduce
|
||||
description: |
|
||||
Steps to reproduce the problem.
|
||||
placeholder: |
|
||||
For example:
|
||||
1. Enable plugin '...'
|
||||
2. Run command '...' or try to complete command '...'
|
||||
3. See error
|
||||
- type: textarea
|
||||
validations:
|
||||
required: true
|
||||
attributes:
|
||||
label: Expected behavior
|
||||
description: A brief description of what should happen.
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: Screenshots and recordings
|
||||
description: |
|
||||
If applicable, add screenshots to help explain your problem. You can also record an asciinema session: https://asciinema.org/
|
||||
- type: input
|
||||
validations:
|
||||
required: true
|
||||
attributes:
|
||||
label: OS / Linux distribution
|
||||
placeholder: Windows 10, Ubuntu 20.04, Arch Linux, macOS 10.15...
|
||||
- type: input
|
||||
validations:
|
||||
required: true
|
||||
attributes:
|
||||
label: Zsh version
|
||||
description: Run `echo $ZSH_VERSION` to check.
|
||||
placeholder: "5.6"
|
||||
- type: input
|
||||
validations:
|
||||
required: true
|
||||
attributes:
|
||||
label: Oh My Zsh version
|
||||
description: Run `omz version` to check.
|
||||
placeholder: master (bf303965)
|
||||
- type: input
|
||||
validations:
|
||||
required: true
|
||||
attributes:
|
||||
label: Terminal emulator
|
||||
placeholder: iTerm2, GNOME Terminal, Terminal.app...
|
||||
- type: dropdown
|
||||
attributes:
|
||||
label: If using WSL on Windows, which version of WSL
|
||||
description: Run `wsl -l -v` to check.
|
||||
options:
|
||||
- WSL1
|
||||
- WSL2
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: Additional context
|
||||
description: Add any other context about the problem here. This can be themes, plugins, custom settings...
|
||||
37
.github/ISSUE_TEMPLATE/feature_request.yml
vendored
Normal file
37
.github/ISSUE_TEMPLATE/feature_request.yml
vendored
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
name: Feature request
|
||||
description: Suggest a feature for Oh My Zsh
|
||||
labels: ["Feature"]
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
## Self Check
|
||||
- Look for similar features in existing [GitHub Issues](https://github.com/ohmyzsh/ohmyzsh/issues?q=is%3Aissue) (open or closed).
|
||||
- type: input
|
||||
attributes:
|
||||
label: If the feature request is for a plugin or theme, specify it here.
|
||||
description: The name of the plugin or theme that you would like us to improve.
|
||||
placeholder: e.g. Git plugin, Agnoster theme
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: If the feature solves a problem you have, specify it here.
|
||||
description: A description of what the problem is.
|
||||
placeholder: Ex. I'm always frustrated when...
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: Describe the proposed feature.
|
||||
description: A description of what you want to happen. Be as specific as possible.
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: Describe alternatives you've considered
|
||||
description: A description of any alternative solutions or features you've considered. This can also include other plugins or themes.
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: Additional context
|
||||
description: Add any other context, screenshots or Discord conversations about the feature request here. Also if you have any PRs related to this issue that are already open that you would like us to look at.
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: Related Issues
|
||||
description: Is there any open or closed issues that is related to this feature request? If so please link them below!
|
||||
140
.github/workflows/project.yml
vendored
Normal file
140
.github/workflows/project.yml
vendored
Normal file
|
|
@ -0,0 +1,140 @@
|
|||
name: Project tracking
|
||||
on:
|
||||
issues:
|
||||
types: [opened, reopened]
|
||||
pull_request_target:
|
||||
types: [opened, reopened, synchronize]
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
|
||||
cancel-in-progress: true
|
||||
|
||||
permissions: {}
|
||||
jobs:
|
||||
add-to-project:
|
||||
name: Add to project
|
||||
runs-on: ubuntu-latest
|
||||
if: github.repository == 'ohmyzsh/ohmyzsh'
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.PROJECT_TOKEN }}
|
||||
steps:
|
||||
- name: Read project data
|
||||
env:
|
||||
ORGANIZATION: ohmyzsh
|
||||
PROJECT_NUMBER: "1"
|
||||
run: |
|
||||
# Get Project data
|
||||
gh api graphql -f query='
|
||||
query($org: String!, $number: Int!) {
|
||||
organization(login: $org){
|
||||
projectV2(number: $number) {
|
||||
id
|
||||
fields(first:20) {
|
||||
nodes {
|
||||
... on ProjectV2Field {
|
||||
id
|
||||
name
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}' -f org=$ORGANIZATION -F number=$PROJECT_NUMBER > project_data.json
|
||||
|
||||
# Parse project data
|
||||
cat >> $GITHUB_ENV <<EOF
|
||||
PROJECT_ID=$(jq '.data.organization.projectV2.id' project_data.json)
|
||||
PLUGIN_FIELD_ID=$(jq '.data.organization.projectV2.fields.nodes[] | select(.name == "Plugin") | .id' project_data.json)
|
||||
THEME_FIELD_ID=$(jq '.data.organization.projectV2.fields.nodes[] | select(.name == "Theme") | .id' project_data.json)
|
||||
EOF
|
||||
|
||||
- name: Add to project
|
||||
env:
|
||||
ISSUE_OR_PR_ID: ${{ github.event.issue.node_id || github.event.pull_request.node_id }}
|
||||
run: |
|
||||
item_id="$(gh api graphql -f query='
|
||||
mutation($project: ID!, $content: ID!) {
|
||||
addProjectV2ItemById(input: {projectId: $project, contentId: $content}) {
|
||||
item {
|
||||
id
|
||||
}
|
||||
}
|
||||
}
|
||||
' -f project=$PROJECT_ID -f content=$ISSUE_OR_PR_ID --jq '.data.addProjectV2ItemById.item.id')"
|
||||
|
||||
echo "ITEM_ID=$item_id" >> $GITHUB_ENV
|
||||
|
||||
- name: Classify Pull Request
|
||||
if: github.event_name == 'pull_request_target'
|
||||
run: |
|
||||
touch plugins.list themes.list
|
||||
|
||||
gh pr view ${{ github.event.pull_request.number }} \
|
||||
--repo ${{ github.repository }} \
|
||||
--json files --jq '.files.[].path' | awk -F/ '
|
||||
/^plugins\// {
|
||||
plugins[$2] = 1
|
||||
}
|
||||
/^themes\// {
|
||||
gsub(/\.zsh-theme$/, "", $2)
|
||||
themes[$2] = 1
|
||||
}
|
||||
END {
|
||||
for (plugin in plugins) {
|
||||
print plugin >> "plugins.list"
|
||||
}
|
||||
for (theme in themes) {
|
||||
print theme >> "themes.list"
|
||||
}
|
||||
}
|
||||
'
|
||||
# If only one plugin is modified, add it to the plugin field
|
||||
if [[ $(wc -l < plugins.list) = 1 ]]; then
|
||||
echo "PLUGIN=$(cat plugins.list)" >> $GITHUB_ENV
|
||||
fi
|
||||
# If only one theme is modified, add it to the theme field
|
||||
if [[ $(wc -l < themes.list) = 1 ]]; then
|
||||
echo "THEME=$(cat themes.list)" >> $GITHUB_ENV
|
||||
fi
|
||||
|
||||
- name: Fill Pull Request fields in project
|
||||
if: github.event_name == 'pull_request_target'
|
||||
run: |
|
||||
gh api graphql -f query='
|
||||
mutation (
|
||||
$project: ID!
|
||||
$item: ID!
|
||||
$plugin_field: ID!
|
||||
$plugin_value: String!
|
||||
$theme_field: ID!
|
||||
$theme_value: String!
|
||||
) {
|
||||
set_plugin: updateProjectV2ItemFieldValue(input: {
|
||||
projectId: $project
|
||||
itemId: $item
|
||||
fieldId: $plugin_field
|
||||
value: {
|
||||
text: $plugin_value
|
||||
}
|
||||
}) {
|
||||
projectV2Item {
|
||||
id
|
||||
}
|
||||
}
|
||||
set_theme: updateProjectV2ItemFieldValue(input: {
|
||||
projectId: $project
|
||||
itemId: $item
|
||||
fieldId: $theme_field
|
||||
value: {
|
||||
text: $theme_value
|
||||
}
|
||||
}) {
|
||||
projectV2Item {
|
||||
id
|
||||
}
|
||||
}
|
||||
}
|
||||
' -f project=$PROJECT_ID -f item=$ITEM_ID \
|
||||
-f plugin_field=$PLUGIN_FIELD_ID -f plugin_value=$PLUGIN \
|
||||
-f theme_field=$THEME_FIELD_ID -f theme_value=$THEME \
|
||||
--silent
|
||||
24
SECURITY.md
Normal file
24
SECURITY.md
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
# Security Policy
|
||||
|
||||
## Supported Versions
|
||||
|
||||
At the moment Oh My Zsh only considers the very latest commit to be supported.
|
||||
We combine that with our fast response to incidents and the automated updates
|
||||
to minimize the time between vulnerability publication and patch release.
|
||||
|
||||
| Version | Supported |
|
||||
|:-------------- |:------------------ |
|
||||
| master | :white_check_mark: |
|
||||
| other commits | :x: |
|
||||
|
||||
In the near future we will introduce versioning, so expect this section to change.
|
||||
|
||||
## Reporting a Vulnerability
|
||||
|
||||
**Do not submit an issue or pull request**: this might reveal the vulnerability.
|
||||
|
||||
Instead, you should email the maintainers directly at: [**security@ohmyz.sh**](mailto:security@ohmyz.sh).
|
||||
|
||||
We will deal with the vulnerability privately and submit a patch as soon as possible.
|
||||
|
||||
You can also submit your vulnerability report to [huntr.dev](https://huntr.dev/bounties/disclose/?utm_campaign=ohmyzsh%2Fohmyzsh&utm_medium=social&utm_source=github&target=https%3A%2F%2Fgithub.com%2Fohmyzsh%2Fohmyzsh) and see if you can get a bounty reward.
|
||||
53
lib/vcs_info.zsh
Normal file
53
lib/vcs_info.zsh
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
# Don't skip this file until a Zsh release does the necessary quoting.
|
||||
# This is because even though 5.8.1 undid recursive prompt_subst inside
|
||||
# prompt sequences, % characters in relevant fields will still be rendered
|
||||
# incorrectly in vcs_info, on all Zsh releases up to writing this.
|
||||
#
|
||||
# There is no release yet that does this right, since it requires changing
|
||||
# how what vcs_info hooks expect to receive. Even so, I'd rather be correct
|
||||
# and break custom vcs_info hooks than have a broken prompt.
|
||||
|
||||
# Quote necessary $hook_com[<field>] items just before they are used
|
||||
# in the line "VCS_INFO_hook 'post-backend'" of the VCS_INFO_formats
|
||||
# function, where <field> is:
|
||||
#
|
||||
# base: the full path of the repository's root directory.
|
||||
# base-name: the name of the repository's root directory.
|
||||
# branch: the name of the currently checked out branch.
|
||||
# misc: a string that may contain anything the vcs_info backend wants.
|
||||
# revision: an identifier of the currently checked out revision.
|
||||
# subdir: the path of the current directory relative to the
|
||||
# repository's root directory.
|
||||
#
|
||||
# This patch %-quotes these fields previous to their use in vcs_info hooks and
|
||||
# the zformat call and, eventually, when they get expanded in the prompt.
|
||||
# It's important to quote these here, and not later after hooks have modified the
|
||||
# fields, because then we could be quoting % characters from valid prompt sequences,
|
||||
# like %F{color}, %B, etc.
|
||||
#
|
||||
# 32 │ hook_com[subdir]="$(VCS_INFO_reposub ${hook_com[base]})"
|
||||
# 33 │ hook_com[subdir_orig]="${hook_com[subdir]}"
|
||||
# 34 │
|
||||
# 35 + │ for tmp in base base-name branch misc revision subdir; do
|
||||
# 36 + │ hook_com[$tmp]="${hook_com[$tmp]//\%/%%}"
|
||||
# 37 + │ done
|
||||
# 38 + │
|
||||
# 39 │ VCS_INFO_hook 'post-backend'
|
||||
#
|
||||
# This is especially important so that no command substitution is performed
|
||||
# due to malicious input as a consequence of CVE-2021-45444, which affects
|
||||
# zsh versions from 5.0.3 to 5.8.
|
||||
#
|
||||
autoload -Uz +X regexp-replace VCS_INFO_formats 2>/dev/null || return
|
||||
|
||||
# We use $tmp here because it's already a local variable in VCS_INFO_formats
|
||||
typeset PATCH='for tmp (base base-name branch misc revision subdir) hook_com[$tmp]="${hook_com[$tmp]//\%/%%}"'
|
||||
# Unique string to avoid reapplying the patch if this code gets called twice
|
||||
typeset PATCH_ID=vcs_info-patch-9b9840f2-91e5-4471-af84-9e9a0dc68c1b
|
||||
# Only patch the VCS_INFO_formats function if not already patched
|
||||
if [[ "$functions[VCS_INFO_formats]" != *$PATCH_ID* ]]; then
|
||||
regexp-replace 'functions[VCS_INFO_formats]' \
|
||||
"VCS_INFO_hook 'post-backend'" \
|
||||
': ${PATCH_ID}; ${PATCH}; ${MATCH}'
|
||||
fi
|
||||
unset PATCH PATCH_ID
|
||||
9
plugins/1password/1password.plugin.zsh
Normal file
9
plugins/1password/1password.plugin.zsh
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
# Do nothing if op is not installed
|
||||
(( ${+commands[op]} )) || return
|
||||
|
||||
# Load op completion
|
||||
eval "$(op completion zsh)"
|
||||
compdef _op op
|
||||
|
||||
# Load opswd function
|
||||
autoload -Uz opswd
|
||||
40
plugins/1password/README.md
Normal file
40
plugins/1password/README.md
Normal 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).
|
||||
19
plugins/1password/_opswd
Normal file
19
plugins/1password/_opswd
Normal 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 "$@"
|
||||
90
plugins/1password/opswd
Normal file
90
plugins/1password/opswd
Normal 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" --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 "$@"
|
||||
13
plugins/ag/README.md
Normal file
13
plugins/ag/README.md
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
# The Silver Searcher
|
||||
|
||||
This plugin provides completion support for [`ag`](https://github.com/ggreer/the_silver_searcher).
|
||||
|
||||
To use it, add ag to the plugins array in your zshrc file.
|
||||
|
||||
```zsh
|
||||
plugins=(... ag)
|
||||
```
|
||||
|
||||
## INSTALLATION NOTES
|
||||
|
||||
Besides oh-my-zsh, `ag` needs to be installed by following these steps: https://github.com/ggreer/the_silver_searcher#installing.
|
||||
66
plugins/ag/_ag
Normal file
66
plugins/ag/_ag
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
#compdef ag
|
||||
#autoload
|
||||
|
||||
typeset -A opt_args
|
||||
|
||||
# Took the liberty of not listing every option… specially aliases and -D
|
||||
_ag () {
|
||||
local -a _1st_arguments
|
||||
_1st_arguments=(
|
||||
'--ackmate:Print results in AckMate-parseable format'
|
||||
{'-A','--after'}':[LINES] Print lines after match (Default: 2)'
|
||||
{'-B','--before'}':[LINES] Print lines before match (Default: 2)'
|
||||
'--break:Print newlines between matches in different files'
|
||||
'--nobreak:Do not print newlines between matches in different files'
|
||||
{'-c','--count'}':Only print the number of matches in each file'
|
||||
'--color:Print color codes in results (Default: On)'
|
||||
'--nocolor:Do not print color codes in results'
|
||||
'--color-line-number:Color codes for line numbers (Default: 1;33)'
|
||||
'--color-match:Color codes for result match numbers (Default: 30;43)'
|
||||
'--color-path:Color codes for path names (Default: 1;32)'
|
||||
'--column:Print column numbers in results'
|
||||
{'-H','--heading'}':Print file names (On unless searching a single file)'
|
||||
'--noheading:Do not print file names (On unless searching a single file)'
|
||||
'--line-numbers:Print line numbers even for streams'
|
||||
{'-C','--context'}':[LINES] Print lines before and after matches (Default: 2)'
|
||||
'-g:[PATTERN] Print filenames matching PATTERN'
|
||||
{'-l','--files-with-matches'}':Only print filenames that contain matches'
|
||||
{'-L','--files-without-matches'}':Only print filenames that do not contain matches'
|
||||
'--no-numbers:Do not print line numbers'
|
||||
{'-o','--only-matching'}':Prints only the matching part of the lines'
|
||||
'--print-long-lines:Print matches on very long lines (Default: 2k characters)'
|
||||
'--passthrough:When searching a stream, print all lines even if they do not match'
|
||||
'--silent:Suppress all log messages, including errors'
|
||||
'--stats:Print stats (files scanned, time taken, etc.)'
|
||||
'--vimgrep:Print results like vim :vimgrep /pattern/g would'
|
||||
{'-0','--null'}':Separate filenames with null (for "xargs -0")'
|
||||
|
||||
{'-a','--all-types'}':Search all files (does not include hidden files / .gitignore)'
|
||||
'--depth:[NUM] Search up to NUM directories deep (Default: 25)'
|
||||
{'-f','--follow'}':Follow symlinks'
|
||||
{'-G','--file-search-regex'}':[PATTERN] Limit search to filenames matching PATTERN'
|
||||
'--hidden:Search hidden files (obeys .*ignore files)'
|
||||
{'-i','--ignore-case'}':Match case insensitively'
|
||||
'--ignore:[PATTERN] Ignore files/directories matching PATTERN'
|
||||
{'-m','--max-count'}':[NUM] Skip the rest of a file after NUM matches (Default: 10k)'
|
||||
{'-p','--path-to-agignore'}':[PATH] Use .agignore file at PATH'
|
||||
{'-Q','--literal'}':Do not parse PATTERN as a regular expression'
|
||||
{'-s','--case-sensitive'}':Match case'
|
||||
{'-S','--smart-case'}':Insensitive match unless PATTERN has uppercase (Default: On)'
|
||||
'--search-binary:Search binary files for matches'
|
||||
{'-t','--all-text'}':Search all text files (Hidden files not included)'
|
||||
{'-u','--unrestricted'}':Search all files (ignore .agignore and _all_)'
|
||||
{'-U','--skip-vcs-ignores'}':Ignore VCS files (stil obey .agignore)'
|
||||
{'-v','--invert-match'}':Invert match'
|
||||
{'-w','--word-regexp'}':Only match whole words'
|
||||
{'-z','--search-zip'}':Search contents of compressed (e.g., gzip) files'
|
||||
|
||||
'--list-file-types:list of supported file types'
|
||||
)
|
||||
|
||||
if [[ $words[-1] =~ "^-" ]]; then
|
||||
_describe -t commands "ag options" _1st_arguments && ret=0
|
||||
else
|
||||
_files && ret=0
|
||||
fi
|
||||
}
|
||||
1
plugins/aliases/.gitignore
vendored
Normal file
1
plugins/aliases/.gitignore
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
__pycache__
|
||||
28
plugins/aliases/README.md
Normal file
28
plugins/aliases/README.md
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
# Aliases cheatsheet
|
||||
|
||||
**Maintainer:** [@hqingyi](https://github.com/hqingyi)
|
||||
|
||||
With lots of 3rd-party amazing aliases installed, this plugin helps list the shortcuts
|
||||
that are currently available based on the plugins you have enabled.
|
||||
|
||||
To use it, add `aliases` to the plugins array in your zshrc file:
|
||||
|
||||
```zsh
|
||||
plugins=(aliases)
|
||||
```
|
||||
|
||||
Requirements: Python needs to be installed.
|
||||
|
||||
## Usage
|
||||
|
||||
- `acs`: show all aliases by group
|
||||
|
||||
- `acs -h/--help`: print help mesage
|
||||
|
||||
- `acs <keyword>`: filter aliases by `<keyword>` and highlight
|
||||
|
||||
- `acs -g <group>/--group <group>`: show only aliases for group `<group>`. Multiple uses of the flag show all groups
|
||||
|
||||
- `acs --groups`: show only group names
|
||||
|
||||

|
||||
14
plugins/aliases/aliases.plugin.zsh
Normal file
14
plugins/aliases/aliases.plugin.zsh
Normal 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 acs(){
|
||||
(( $+commands[python3] )) || {
|
||||
echo "[error] No python executable detected"
|
||||
return
|
||||
}
|
||||
alias | python3 "'"${0:h}"'/cheatsheet.py" "$@"
|
||||
}
|
||||
'
|
||||
68
plugins/aliases/cheatsheet.py
Normal file
68
plugins/aliases/cheatsheet.py
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
#!/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 ]
|
||||
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.")
|
||||
parser.add_argument('filter', nargs="*", help="search aliases matching string")
|
||||
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)
|
||||
168
plugins/aliases/termcolor.py
Normal file
168
plugins/aliases/termcolor.py
Normal 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'])
|
||||
|
||||
22
plugins/ant/_ant
Normal file
22
plugins/ant/_ant
Normal 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 "$@"
|
||||
5
plugins/bedtools/README.md
Normal file
5
plugins/bedtools/README.md
Normal 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.
|
||||
64
plugins/bedtools/_bedtools
Normal file
64
plugins/bedtools/_bedtools
Normal 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 redistrubute intervals in a genome.]" \
|
||||
"slop[Adjust the size of intervals.]" \
|
||||
"sort[Order the intervals in a file.]" \
|
||||
"subtract[Remove intervals based on overlaps b/w two files.]" \
|
||||
"tag[Tag BAM alignments based on overlaps with interval files.]" \
|
||||
"unionbedg[Combines coverage intervals from multiple BEDGRAPH files.]" \
|
||||
"window[Find overlapping intervals within a window around an interval.]" \
|
||||
ret=0
|
||||
;;
|
||||
*)
|
||||
_files
|
||||
;;
|
||||
esac
|
||||
|
||||
return ret
|
||||
9
plugins/charm/README.md
Normal file
9
plugins/charm/README.md
Normal 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)
|
||||
```
|
||||
14
plugins/charm/charm.plugin.zsh
Normal file
14
plugins/charm/charm.plugin.zsh
Normal 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" &|
|
||||
1
plugins/colemak/.gitignore
vendored
Normal file
1
plugins/colemak/.gitignore
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
.less
|
||||
15
plugins/copypath/README.md
Normal file
15
plugins/copypath/README.md
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
# copypath plugin
|
||||
|
||||
Copies the path of given directory or file to the system clipboard.
|
||||
|
||||
To use it, add `copypath` to the plugins array in your zshrc file:
|
||||
|
||||
```zsh
|
||||
plugins=(... copypath)
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
- `copypath`: copies the absolute path of the current directory.
|
||||
|
||||
- `copypath <file_or_directory>`: copies the absolute path of the given file.
|
||||
15
plugins/copypath/copypath.plugin.zsh
Normal file
15
plugins/copypath/copypath.plugin.zsh
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
# Copies the path of given directory or file to the system or X Windows clipboard.
|
||||
# Copy current directory if no parameter.
|
||||
function copypath {
|
||||
# If no argument passed, use current directory
|
||||
local file="${1:-.}"
|
||||
|
||||
# If argument is not an absolute path, prepend $PWD
|
||||
[[ $file = /* ]] || file="$PWD/$file"
|
||||
|
||||
# Copy the absolute path without resolving symlinks
|
||||
# If clipcopy fails, exit the function with an error
|
||||
print -n "${file:a}" | clipcopy || return 1
|
||||
|
||||
echo ${(%):-"%B${file:a}%b copied to clipboard."}
|
||||
}
|
||||
32
plugins/docker/docker.plugin.zsh
Normal file
32
plugins/docker/docker.plugin.zsh
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
alias dbl='docker build'
|
||||
alias dcin='docker container inspect'
|
||||
alias dcls='docker container ls'
|
||||
alias dclsa='docker container ls -a'
|
||||
alias dib='docker image build'
|
||||
alias dii='docker image inspect'
|
||||
alias dils='docker image ls'
|
||||
alias dipu='docker image push'
|
||||
alias dirm='docker image rm'
|
||||
alias dit='docker image tag'
|
||||
alias dlo='docker container logs'
|
||||
alias dnc='docker network create'
|
||||
alias dncn='docker network connect'
|
||||
alias dndcn='docker network disconnect'
|
||||
alias dni='docker network inspect'
|
||||
alias dnls='docker network ls'
|
||||
alias dnrm='docker network rm'
|
||||
alias dpo='docker container port'
|
||||
alias dpu='docker pull'
|
||||
alias dr='docker container run'
|
||||
alias drit='docker container run -it'
|
||||
alias drm='docker container rm'
|
||||
alias 'drm!'='docker container rm -f'
|
||||
alias dst='docker container start'
|
||||
alias dsta='docker stop $(docker ps -q)'
|
||||
alias dstp='docker container stop'
|
||||
alias dtop='docker top'
|
||||
alias dvi='docker volume inspect'
|
||||
alias dvls='docker volume ls'
|
||||
alias dvprune='docker volume prune'
|
||||
alias dxc='docker container exec'
|
||||
alias dxcit='docker container exec -it'
|
||||
189
plugins/ember-cli/_ember-cli
Normal file
189
plugins/ember-cli/_ember-cli
Normal file
|
|
@ -0,0 +1,189 @@
|
|||
#compdef ember
|
||||
|
||||
local curcontext="$curcontext" state line ret=1
|
||||
|
||||
_arguments -C -A "--version" -A "--help" \
|
||||
'(- 1 *)--help' \
|
||||
'(- 1 *)--version' \
|
||||
'1: :->cmds' \
|
||||
'*:: :->args' && ret=0
|
||||
|
||||
case $state in
|
||||
cmds)
|
||||
_values "ember command" \
|
||||
"addon[Generates a new folder structure for building an addon, complete with test harness]" \
|
||||
"asset-sizes[Shows the sizes of your asset files]" \
|
||||
"build[Builds your app and places it into the output path (dist/ by default)]" \
|
||||
"destroy[Destroys code generated by generate command]" \
|
||||
"generate[Generates new code from blueprints]" \
|
||||
"help[Outputs the usage instructions for all commands or the provided command]" \
|
||||
"init[Creates a new ember-cli project in the current folder]" \
|
||||
"install[Installs an ember-cli addon from npm]" \
|
||||
"new[Creates a new directory and runs ember init in it]" \
|
||||
"serve[Builds and serves your app, rebuilding on file changes]" \
|
||||
"test[Runs your app's test suite]" \
|
||||
"version[outputs ember-cli version]"
|
||||
ret=0
|
||||
;;
|
||||
args)
|
||||
case $line[1] in
|
||||
help)
|
||||
_values 'commands' \
|
||||
'addon' \
|
||||
'asset-sizes' \
|
||||
'build' \
|
||||
'destroy' \
|
||||
'generate' \
|
||||
'help' \
|
||||
'init' \
|
||||
'install' \
|
||||
'new' \
|
||||
'serve' \
|
||||
'test' \
|
||||
'vesion' && ret=0
|
||||
;;
|
||||
addon)
|
||||
_arguments \
|
||||
'(--blueprint)--blueprint=-' \
|
||||
'(--directory)--directory=-' \
|
||||
'(--dry-run)--dry-run' \
|
||||
'(--skip-bower)--skip-bower' \
|
||||
'(--skip-git)--skip-git' \
|
||||
'(--skip-npm)--skip-npm' \
|
||||
'(--verbose)--verbose'
|
||||
;;
|
||||
asset-sizes)
|
||||
_arguments \
|
||||
'(--output-path)--output-path=-'
|
||||
;;
|
||||
build)
|
||||
_arguments \
|
||||
'(--environment)--environment=-' \
|
||||
'(--output-path)--output-path=-' \
|
||||
'(--output-path)--suppress-sizes' \
|
||||
'(--watch)--watch' \
|
||||
'(--watcher)--watcher=-' \
|
||||
'(-dev)-dev' \
|
||||
'(-prod)-prod'
|
||||
;;
|
||||
destroy|generate)
|
||||
_values 'arguments' \
|
||||
'(--classic)--classic' \
|
||||
'(--dry-run)--dry-run' \
|
||||
'(--dummy)--dummy' \
|
||||
'(--in-repo-addon)--in-repo-addon-=' \
|
||||
'(--pod)--pod' \
|
||||
'(--verbose)--verbose' && ret=0
|
||||
_values 'blueprints' \
|
||||
'acceptance-test' \
|
||||
'adapter' \
|
||||
'adapter-test' \
|
||||
'component' \
|
||||
'component-addon' \
|
||||
'component-test' \
|
||||
'controller' \
|
||||
'controller-test' \
|
||||
'helper' \
|
||||
'helper-addon' \
|
||||
'helper-test' \
|
||||
'initializer' \
|
||||
'initializer-addon' \
|
||||
'initializer-test' \
|
||||
'instance-initializer' \
|
||||
'instance-initializer-addon' \
|
||||
'instance-initializer-test' \
|
||||
'mixin' \
|
||||
'mixin-test' \
|
||||
'model' \
|
||||
'model-test' \
|
||||
'resource' \
|
||||
'route' \
|
||||
'route-addon' \
|
||||
'route-test' \
|
||||
'serializer' \
|
||||
'serializer-test' \
|
||||
'service' \
|
||||
'service-test' \
|
||||
'template' \
|
||||
'test-helper' \
|
||||
'transform' \
|
||||
'transform-test' \
|
||||
'util' \
|
||||
'util-test' \
|
||||
'view' \
|
||||
'view-test' \
|
||||
'addon' \
|
||||
'addon-import' \
|
||||
'app' \
|
||||
'blueprint' \
|
||||
'http-mock' \
|
||||
'http-proxy' \
|
||||
'in-repo-addon' \
|
||||
'lib' \
|
||||
'server' \
|
||||
'vendor-shim' && ret=0
|
||||
;;
|
||||
init)
|
||||
_arguments \
|
||||
'(--blueprint)--blueprint=-' \
|
||||
'(--name)--name=-' \
|
||||
'(--dry-run)--dry-run' \
|
||||
'(--skip-bower)--skip-bower' \
|
||||
'(--skip-npm)--skip-npm' \
|
||||
'(--verbose)--verbose'
|
||||
;;
|
||||
install)
|
||||
_arguments \
|
||||
'(--save-dev)--save-dev' \
|
||||
'(--save)--save'
|
||||
;;
|
||||
new)
|
||||
_arguments \
|
||||
'(--blueprint)--blueprint=-' \
|
||||
'(--directory)--directory=-' \
|
||||
'(--dry-run)--dry-run' \
|
||||
'(--skip-bower)--skip-bower' \
|
||||
'(--skip-git)--skip-git' \
|
||||
'(--skip-npm)--skip-npm' \
|
||||
'(--verbose)--verbose'
|
||||
;;
|
||||
serve)
|
||||
_arguments \
|
||||
'(--port)--port=-[To use a port different than 4200. Pass 0 to automatically pick an available port.]' \
|
||||
'(--host)--host=-[Listens on all interfaces by default]' \
|
||||
'(--proxy)--proxy=-' \
|
||||
'(--secure-proxy)--secure-proxy[Set to false to proxy self-signed SSL certificates]' \
|
||||
'(--transparent-proxy)--transparent-proxy[Set to false to omit x-forwarded-* headers when proxying]' \
|
||||
'(--watcher)--watcher=-' \
|
||||
'(--live-reload)--live-reload' \
|
||||
'(--live-reload-host)--live-reload-host=-[Defaults to host]' \
|
||||
'(--live-reload-base-url)--live-reload-base-url=-[Defaults to baseURL]' \
|
||||
'(--live-reload-port)--live-reload-port=-[Defaults to port number within \[49152...65535\]]' \
|
||||
'(--environment)--environment=-' \
|
||||
'(--output-path)--output-path=-' \
|
||||
'(--ssl)--ssl' \
|
||||
'(--ssl-key)--ssl-key=-' \
|
||||
'(--ssl-cert)--ssl-cert=-'
|
||||
;;
|
||||
test)
|
||||
_arguments \
|
||||
'(--environment)--environment=-' \
|
||||
'(--config-file)--config-file=-' \
|
||||
'(--server)--server' \
|
||||
'(--host)--host=-' \
|
||||
'(--test-port)--test-port=-[The test port to use when running with --server.]' \
|
||||
'(--filter)--filter=-[A string to filter tests to run]' \
|
||||
'(--module)--module=-[The name of a test module to run]' \
|
||||
'(--watcher)--watcher=-' \
|
||||
'(--launch)--launch=-[A comma separated list of browsers to launch for tests.]' \
|
||||
'(--reporter)--reporter=-[Test reporter to use \[tap|dot|xunit\] (default: tap)]' \
|
||||
'(--silent)--silent[Suppress any output except for the test report]' \
|
||||
'(--test-page)--test-page=-[Test page to invoke]' \
|
||||
'(--path)--path=-[Reuse an existing build at given path.]' \
|
||||
'(--query)--query=-[A query string to append to the test page URL.]'
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
|
||||
return ret
|
||||
21538
plugins/emoji/gemoji_db.json
Normal file
21538
plugins/emoji/gemoji_db.json
Normal file
File diff suppressed because it is too large
Load diff
213
plugins/emoji/update_emoji.py
Normal file
213
plugins/emoji/update_emoji.py
Normal file
|
|
@ -0,0 +1,213 @@
|
|||
"""
|
||||
Update Emoji.py
|
||||
Refeshes OMZ emoji database based on the latest Unicode spec
|
||||
"""
|
||||
import re
|
||||
import json
|
||||
|
||||
spec = open("emoji-data.txt", "r")
|
||||
|
||||
# Regexes
|
||||
# regex_emoji will return, respectively:
|
||||
# the code points, its type (status), the actual emoji, and its official name
|
||||
regex_emoji = r"^([\w ].*?\S)\s*;\s*([\w-]+)\s*#\s*(.*?)\s(\S.*).*$"
|
||||
# regex_group returns the group of subgroup that a line opens
|
||||
regex_group = r"^#\s*(group|subgroup):\s*(.*)$"
|
||||
|
||||
headers = """
|
||||
# emoji-char-definitions.zsh - Emoji definitions for oh-my-zsh emoji plugin
|
||||
#
|
||||
# This file is auto-generated by update_emoji.py. Do not edit it manually.
|
||||
#
|
||||
# This contains the definition for:
|
||||
# $emoji - which maps character names to Unicode characters
|
||||
# $emoji_flags - maps country names to Unicode flag characters using region
|
||||
# indicators
|
||||
# $emoji_mod - maps modifier components to Unicode characters
|
||||
# $emoji_groups - a single associative array to avoid cluttering up the
|
||||
# global namespace, and to allow adding additional group
|
||||
# definitions at run time. The keys are the group names, and
|
||||
# the values are whitespace-separated lists of emoji
|
||||
# character names.
|
||||
|
||||
# Main emoji
|
||||
typeset -gAH emoji
|
||||
# National flags
|
||||
typeset -gAH emoji_flags
|
||||
# Combining modifiers
|
||||
typeset -gAH emoji_mod
|
||||
# Emoji groups
|
||||
typeset -gAH emoji_groups
|
||||
"""
|
||||
|
||||
#######
|
||||
# Adding country codes
|
||||
#######
|
||||
# This is the only part of this script that relies on an external library
|
||||
# (country_converter), and is hence commented out by default.
|
||||
# You can uncomment it to have country codes added as aliases for flag
|
||||
# emojis. (By default, when you install this extension, country codes are
|
||||
# included as aliases, but not if you re-run this script without uncommenting.)
|
||||
# Warning: country_converter is very verbose, and will print warnings all over
|
||||
# your terminal.
|
||||
|
||||
# import country_converter as coco # pylint: disable=wrong-import-position
|
||||
# cc = coco.CountryConverter()
|
||||
|
||||
# def country_iso(_all_names, _omz_name):
|
||||
# """ Using the external library country_converter,
|
||||
# this function can detect the ISO2 and ISO3 codes
|
||||
# of the country. It takes as argument the array
|
||||
# with all the names of the emoji, and returns that array."""
|
||||
# omz_no_underscore = re.sub(r'_', r' ', _omz_name)
|
||||
# iso2 = cc.convert(names=[omz_no_underscore], to='ISO2')
|
||||
# if iso2 != 'not found':
|
||||
# _all_names.append(iso2)
|
||||
# iso3 = cc.convert(names=[omz_no_underscore], to='ISO3')
|
||||
# _all_names.append(iso3)
|
||||
# return _all_names
|
||||
|
||||
|
||||
#######
|
||||
# Helper functions
|
||||
#######
|
||||
|
||||
def code_to_omz(_code_points):
|
||||
""" Returns a ZSH-compatible Unicode string from the code point(s) """
|
||||
return r'\U' + r'\U'.join(_code_points.split(' '))
|
||||
|
||||
def name_to_omz(_name, _group, _subgroup, _status):
|
||||
""" Returns a reasonable snake_case name for the emoji. """
|
||||
def snake_case(_string):
|
||||
""" Does the regex work of snake_case """
|
||||
remove_dots = re.sub(r'\.\(\)', r'', _string)
|
||||
replace_ands = re.sub(r'\&', r'and', remove_dots)
|
||||
remove_whitespace = re.sub(r'[^\#\*\w]', r'_', replace_ands)
|
||||
return re.sub(r'__', r'_', remove_whitespace)
|
||||
|
||||
shortname = ""
|
||||
split_at_colon = lambda s: s.split(": ")
|
||||
# Special treatment by group and subgroup
|
||||
# If the emoji is a flag, we strip "flag" from its name
|
||||
if _group == "Flags" and len(split_at_colon(_name)) > 1:
|
||||
shortname = snake_case(split_at_colon(_name)[1])
|
||||
else:
|
||||
shortname = snake_case(_name)
|
||||
# Special treatment by status
|
||||
# Enables us to have every emoji combination,
|
||||
# even the one that are not officially sanctionned
|
||||
# and are implemented by, say, only one vendor
|
||||
if _status == "unqualified":
|
||||
shortname += "_unqualified"
|
||||
elif _status == "minimally-qualified":
|
||||
shortname += "_minimally"
|
||||
return shortname
|
||||
|
||||
def increment_name(_shortname):
|
||||
""" Increment the short name by 1. If you get, say,
|
||||
'woman_detective_unqualified', it returns
|
||||
'woman_detective_unqualified_1', and then
|
||||
'woman_detective_unqualified_2', etc. """
|
||||
last_char = _shortname[-1]
|
||||
if last_char.isdigit():
|
||||
num = int(last_char)
|
||||
return _shortname[:-1] + str(num + 1)
|
||||
return _shortname + "_1"
|
||||
|
||||
########
|
||||
# Going through every line
|
||||
########
|
||||
|
||||
group, subgroup, short_name_buffer = "", "", ""
|
||||
emoji_database = []
|
||||
for line in spec:
|
||||
# First, test if this line opens a group or subgroup
|
||||
group_match = re.findall(regex_group, line)
|
||||
if group_match != []:
|
||||
gr_or_sub, name = group_match[0]
|
||||
if gr_or_sub == "group":
|
||||
group = name
|
||||
elif gr_or_sub == "subgroup":
|
||||
subgroup = name
|
||||
continue # Moving on...
|
||||
# Second, test if this line references one emoji
|
||||
emoji_match = re.findall(regex_emoji, line)
|
||||
if emoji_match != []:
|
||||
code_points, status, emoji, name = emoji_match[0]
|
||||
omz_codes = code_to_omz(code_points)
|
||||
omz_name = name_to_omz(name, group, subgroup, status)
|
||||
# If this emoji has the same shortname as the preceding one
|
||||
if omz_name in short_name_buffer:
|
||||
omz_name = increment_name(short_name_buffer)
|
||||
short_name_buffer = omz_name
|
||||
emoji_database.append(
|
||||
[omz_codes, status, emoji, omz_name, group, subgroup])
|
||||
spec.close()
|
||||
|
||||
########
|
||||
# Write to emoji-char-definitions.zsh
|
||||
########
|
||||
|
||||
# Aliases for emojis are retrieved through the DB of Gemoji
|
||||
# Retrieved on Aug 9 2019 from the following URL:
|
||||
# https://raw.githubusercontent.com/github/gemoji/master/db/emoji.json
|
||||
|
||||
gemoji_db = open("gemoji_db.json")
|
||||
j = json.load(gemoji_db)
|
||||
aliases_map = {entry['emoji']: entry['aliases'] for entry in j}
|
||||
all_omz_names = [emoji_data[3] for emoji_data in emoji_database]
|
||||
|
||||
# Let's begin writing to this file
|
||||
output = open("emoji-char-definitions.zsh", "w")
|
||||
output.write(headers)
|
||||
|
||||
emoji_groups = {"fruits": "\n", "vehicles": "\n", "hands": "\n",
|
||||
"people": "\n", "animals": "\n", "faces": "\n",
|
||||
"flags": "\n"}
|
||||
|
||||
# First, write every emoji down
|
||||
for _omz_codes, _status, _emoji, _omz_name, _group, _subgroup in emoji_database:
|
||||
|
||||
# One emoji can be mapped to multiple names (aliases or country codes)
|
||||
names_for_this_emoji = [_omz_name]
|
||||
|
||||
# Variable that indicates in which map the emoji will be located
|
||||
emoji_map = "emoji"
|
||||
if _status == "component":
|
||||
emoji_map = "emoji_mod"
|
||||
if _group == "Flags":
|
||||
emoji_map = "emoji_flags"
|
||||
# Adding country codes (Optional, see above)
|
||||
# names_for_this_emoji = country_iso(names_for_this_emoji, _omz_name)
|
||||
|
||||
# Check if there is an alias available in the Gemoji DB
|
||||
if _emoji in aliases_map.keys():
|
||||
for alias in aliases_map[_emoji]:
|
||||
if alias not in all_omz_names:
|
||||
names_for_this_emoji.append(alias)
|
||||
|
||||
# And now we write to the definitions file
|
||||
for one_name in names_for_this_emoji:
|
||||
output.write(f"{emoji_map}[{one_name}]=$'{_omz_codes}'\n")
|
||||
|
||||
# Storing the emoji in defined subgroups for the next step
|
||||
if _status == "fully-qualified":
|
||||
if _subgroup == "food-fruit":
|
||||
emoji_groups["fruits"] += f" {_omz_name}\n"
|
||||
elif "transport-" in _subgroup:
|
||||
emoji_groups["vehicles"] += f" {_omz_name}\n"
|
||||
elif "hand-" in _subgroup:
|
||||
emoji_groups["hands"] += f" {_omz_name}\n"
|
||||
elif "person-" in _subgroup or _subgroup == "family":
|
||||
emoji_groups["people"] += f" {_omz_name}\n"
|
||||
elif "animal-" in _subgroup:
|
||||
emoji_groups["animals"] += f" {_omz_name}\n"
|
||||
elif "face-" in _subgroup:
|
||||
emoji_groups["faces"] += f" {_omz_name}\n"
|
||||
elif _group == "Flags":
|
||||
emoji_groups["flags"] += f" {_omz_name}\n"
|
||||
|
||||
# Second, write the subgroups to the end of the file
|
||||
for name, string in emoji_groups.items():
|
||||
output.write(f'\nemoji_groups[{name}]="{string}"\n')
|
||||
output.close()
|
||||
9
plugins/fig/README.md
Normal file
9
plugins/fig/README.md
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
# Fig plugin
|
||||
|
||||
This plugin sets up completion for [Fig](https://fig.io/).
|
||||
|
||||
To use it, add `fig` to the plugins array in your zshrc file:
|
||||
|
||||
```zsh
|
||||
plugins=(... fig)
|
||||
```
|
||||
13
plugins/fig/fig.plugin.zsh
Normal file
13
plugins/fig/fig.plugin.zsh
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
if ! (( $+commands[fig] )); then
|
||||
return
|
||||
fi
|
||||
|
||||
# If the completion file doesn't exist yet, we need to autoload it and
|
||||
# bind it to `fig`. Otherwise, compinit will have already done that
|
||||
if [[ ! -f "$ZSH_CACHE_DIR/completions/_fig" ]]; then
|
||||
autoload -Uz _fig
|
||||
typeset -g -A _comps
|
||||
_comps[fig]=_fig
|
||||
fi
|
||||
|
||||
fig completion zsh >| "$ZSH_CACHE_DIR/completions/_fig" &|
|
||||
9
plugins/fluxcd/README.md
Normal file
9
plugins/fluxcd/README.md
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
# FluxCD plugin
|
||||
|
||||
This plugin adds completion for [FluxCD](https://fluxcd.io), an open and extensible continuous delivery solution for Kubernetes. Powered by GitOps Toolkit.
|
||||
|
||||
To use it, add `fluxcd` to the plugins array in your zshrc file:
|
||||
|
||||
```zsh
|
||||
plugins=(... fluxcd)
|
||||
```
|
||||
14
plugins/fluxcd/fluxcd.plugin.zsh
Normal file
14
plugins/fluxcd/fluxcd.plugin.zsh
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
# Autocompletion for the FluxCD CLI (flux).
|
||||
if (( ! $+commands[flux] )); then
|
||||
return
|
||||
fi
|
||||
|
||||
# If the completion file doesn't exist yet, we need to autoload it and
|
||||
# bind it to `flux`. Otherwise, compinit will have already done that.
|
||||
if [[ ! -f "$ZSH_CACHE_DIR/completions/_flux" ]]; then
|
||||
typeset -g -A _comps
|
||||
autoload -Uz _flux
|
||||
_comps[flux]=_flux
|
||||
fi
|
||||
|
||||
flux completion zsh >| "$ZSH_CACHE_DIR/completions/_flux" &|
|
||||
9
plugins/fnm/README.md
Normal file
9
plugins/fnm/README.md
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
# fnm plugin
|
||||
|
||||
This plugin adds autocompletion for [fnm](https://github.com/Schniz/fnm) - a Node.js version manager.
|
||||
|
||||
To use it, add `fnm` to the plugins array in your zshrc file:
|
||||
|
||||
```zsh
|
||||
plugins=(... fnm)
|
||||
```
|
||||
13
plugins/fnm/fnm.plugin.zsh
Normal file
13
plugins/fnm/fnm.plugin.zsh
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
if (( ! $+commands[fnm] )); then
|
||||
return
|
||||
fi
|
||||
|
||||
# If the completion file doesn't exist yet, we need to autoload it and
|
||||
# bind it to `fnm`. Otherwise, compinit will have already done that.
|
||||
if [[ ! -f "$ZSH_CACHE_DIR/completions/_fnm" ]]; then
|
||||
typeset -g -A _comps
|
||||
autoload -Uz _fnm
|
||||
_comps[fnm]=_fnm
|
||||
fi
|
||||
|
||||
fnm completions --shell=zsh >| "$ZSH_CACHE_DIR/completions/_fnm" &|
|
||||
32
plugins/fossil/_fossil
Normal file
32
plugins/fossil/_fossil
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
#compdef fossil
|
||||
|
||||
function _fossil_get_command_list () {
|
||||
fossil help -a | grep -v "Usage|Common|This is"
|
||||
}
|
||||
|
||||
function _fossil () {
|
||||
local context state state_descr line
|
||||
typeset -A opt_args
|
||||
|
||||
_arguments \
|
||||
'1: :->command'\
|
||||
'2: :->subcommand'
|
||||
|
||||
case $state in
|
||||
command)
|
||||
local _OUTPUT=$(fossil branch 2>&1 | grep "use --repo")
|
||||
if [[ -z "$_OUTPUT" ]]; then
|
||||
compadd "$(_fossil_get_command_list)"
|
||||
else
|
||||
compadd clone init import help version
|
||||
fi ;;
|
||||
subcommand)
|
||||
case "$words[2]" in
|
||||
help) compadd "$(_fossil_get_command_list)" ;;
|
||||
add) compadd "$(fossil extra)" ;;
|
||||
*) compcall -D ;;
|
||||
esac ;;
|
||||
esac
|
||||
}
|
||||
|
||||
_fossil "$@"
|
||||
161
plugins/frontend-search/_frontend
Normal file
161
plugins/frontend-search/_frontend
Normal file
|
|
@ -0,0 +1,161 @@
|
|||
#compdef frontend
|
||||
|
||||
zstyle ':completion:*:descriptions' format '%B%d%b'
|
||||
zstyle ':completion::complete:frontend:*:commands' group-name commands
|
||||
zstyle ':completion::complete:frontend:*:frontend_points' group-name frontend_points
|
||||
zstyle ':completion::complete:frontend::' list-grouped
|
||||
|
||||
zmodload zsh/mapfile
|
||||
|
||||
function _frontend() {
|
||||
local CONFIG=$HOME/.frontend-search
|
||||
local ret=1
|
||||
|
||||
local -a commands
|
||||
local -a frontend_points
|
||||
|
||||
frontend_points=( "${(f)mapfile[$CONFIG]//$HOME/~}" )
|
||||
|
||||
commands=(
|
||||
'angular: Search in Angular.io website'
|
||||
'angularjs: Search in docs.angularjs.org website'
|
||||
'bem: Search in BEM website'
|
||||
'bootsnipp: Search in bootsnipp website'
|
||||
'bundlephobia: Search in Bundlephobia website'
|
||||
'caniuse: Search in Can I Use website'
|
||||
'codepen: Search in codepen website'
|
||||
'compassdoc: Search in COMPASS website'
|
||||
'cssflow: Search in cssflow website'
|
||||
'dartlang: Search in Dart website'
|
||||
'emberjs: Search in Ember website'
|
||||
'flowtype: Search in Flowtype website'
|
||||
'fontello: Search in fontello website'
|
||||
'github: Search in GitHub website'
|
||||
'html5please: Search in HTML5 Please website'
|
||||
'jestjs: Search in Jest website'
|
||||
'jquery: Search in jQuery website'
|
||||
'lodash: Search in Lo-Dash website'
|
||||
'mdn: Search in MDN website'
|
||||
'nodejs: Search in NodeJS website'
|
||||
'npmjs: Search in npmjs website'
|
||||
'packagephobia: Search in Packagephobia website'
|
||||
'qunit: Search in Qunit website'
|
||||
'reactjs: Search in React website'
|
||||
'smacss: Search in SMACSS website'
|
||||
'stackoverflow: Search in StackOverflow website'
|
||||
'typescript: Search in TypeScript website'
|
||||
'unheap: Search in unheap website'
|
||||
'vuejs: Search in VueJS website'
|
||||
)
|
||||
|
||||
_arguments -C \
|
||||
'1: :->first_arg' \
|
||||
'2: :->second_arg' && ret=0
|
||||
|
||||
case $state in
|
||||
first_arg)
|
||||
_describe -t frontend_points "Warp points" frontend_points && ret=0
|
||||
_describe -t commands "Commands" commands && ret=0
|
||||
;;
|
||||
second_arg)
|
||||
case $words[2] in
|
||||
jquery)
|
||||
_describe -t points "Warp points" frontend_points && ret=0
|
||||
;;
|
||||
mdn)
|
||||
_describe -t points "Warp points" frontend_points && ret=0
|
||||
;;
|
||||
compassdoc)
|
||||
_describe -t points "Warp points" frontend_points && ret=0
|
||||
;;
|
||||
html5please)
|
||||
_describe -t points "Warp points" frontend_points && ret=0
|
||||
;;
|
||||
caniuse)
|
||||
_describe -t points "Warp points" frontend_points && ret=0
|
||||
;;
|
||||
dartlang)
|
||||
_describe -t points "Warp points" frontend_points && ret=0
|
||||
;;
|
||||
lodash)
|
||||
_describe -t points "Warp points" frontend_points && ret=0
|
||||
;;
|
||||
qunit)
|
||||
_describe -t points "Warp points" frontend_points && ret=0
|
||||
;;
|
||||
fontello)
|
||||
_describe -t points "Warp points" frontend_points && ret=0
|
||||
;;
|
||||
github)
|
||||
_describe -t points "Warp points" frontend_points && ret=0
|
||||
;;
|
||||
bootsnipp)
|
||||
_describe -t points "Warp points" frontend_points && ret=0
|
||||
;;
|
||||
cssflow)
|
||||
_describe -t points "Warp points" frontend_points && ret=0
|
||||
;;
|
||||
codepen)
|
||||
_describe -t points "Warp points" frontend_points && ret=0
|
||||
;;
|
||||
unheap)
|
||||
_describe -t points "Warp points" frontend_points && ret=0
|
||||
;;
|
||||
bem)
|
||||
_describe -t points "Warp points" frontend_points && ret=0
|
||||
;;
|
||||
smacss)
|
||||
_describe -t points "Warp points" frontend_points && ret=0
|
||||
;;
|
||||
angularjs)
|
||||
_describe -t points "Warp points" frontend_points && ret=0
|
||||
;;
|
||||
reactjs)
|
||||
_describe -t points "Warp points" frontend_points && ret=0
|
||||
;;
|
||||
emberjs)
|
||||
_describe -t points "Warp points" frontend_points && ret=0
|
||||
;;
|
||||
stackoverflow)
|
||||
_describe -t points "Warp points" frontend_points && ret=0
|
||||
;;
|
||||
npmjs)
|
||||
_describe -t points "Warp points" frontend_points && ret=0
|
||||
;;
|
||||
bundlephobia)
|
||||
_describe -t points "Warp points" frontend_points && ret=0
|
||||
;;
|
||||
packagephobia)
|
||||
_describe -t points "Warp points" frontend_points && ret=0
|
||||
;;
|
||||
flowtype)
|
||||
_describe -t points "Warp points" frontend_points && ret=0
|
||||
;;
|
||||
typescript)
|
||||
_describe -t points "Warp points" frontend_points && ret=0
|
||||
;;
|
||||
vuejs)
|
||||
_describe -t points "Warp points" frontend_points && ret=0
|
||||
;;
|
||||
nodejs)
|
||||
_describe -t points "Warp points" frontend_points && ret=0
|
||||
;;
|
||||
jestjs)
|
||||
_describe -t points "Warp points" frontend_points && ret=0
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
|
||||
return $ret
|
||||
}
|
||||
|
||||
_frontend "$@"
|
||||
|
||||
# Local Variables:
|
||||
# mode: Shell-Script
|
||||
# sh-indentation: 2
|
||||
# indent-tabs-mode: nil
|
||||
# sh-basic-offset: 2
|
||||
# End:
|
||||
# vim: ft=zsh sw=2 ts=2 et
|
||||
327
plugins/git-flow/_git-flow
Normal file
327
plugins/git-flow/_git-flow
Normal file
|
|
@ -0,0 +1,327 @@
|
|||
#compdef git-flow
|
||||
|
||||
_git-flow () {
|
||||
local curcontext="$curcontext" state line
|
||||
typeset -A opt_args
|
||||
|
||||
_arguments -C \
|
||||
':command:->command' \
|
||||
'*::options:->options'
|
||||
|
||||
case $state in
|
||||
(command)
|
||||
|
||||
local -a subcommands
|
||||
subcommands=(
|
||||
'init:Initialize a new git repo with support for the branching model.'
|
||||
'feature:Manage your feature branches.'
|
||||
'release:Manage your release branches.'
|
||||
'hotfix:Manage your hotfix branches.'
|
||||
'support:Manage your support branches.'
|
||||
'version:Shows version information.'
|
||||
)
|
||||
_describe -t commands 'git flow' subcommands
|
||||
;;
|
||||
|
||||
(options)
|
||||
case $line[1] in
|
||||
|
||||
(init)
|
||||
_arguments \
|
||||
-f'[Force setting of gitflow branches, even if already configured]'
|
||||
;;
|
||||
|
||||
(version)
|
||||
;;
|
||||
|
||||
(hotfix)
|
||||
__git-flow-hotfix
|
||||
;;
|
||||
|
||||
(release)
|
||||
__git-flow-release
|
||||
;;
|
||||
|
||||
(feature)
|
||||
__git-flow-feature
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
__git-flow-release () {
|
||||
local curcontext="$curcontext" state line
|
||||
typeset -A opt_args
|
||||
|
||||
_arguments -C \
|
||||
':command:->command' \
|
||||
'*::options:->options'
|
||||
|
||||
case $state in
|
||||
(command)
|
||||
|
||||
local -a subcommands
|
||||
subcommands=(
|
||||
'start:Start a new release branch.'
|
||||
'finish:Finish a release branch.'
|
||||
'list:List all your release branches. (Alias to `git flow release`)'
|
||||
'publish: public'
|
||||
'track: track'
|
||||
)
|
||||
_describe -t commands 'git flow release' subcommands
|
||||
_arguments \
|
||||
-v'[Verbose (more) output]'
|
||||
;;
|
||||
|
||||
(options)
|
||||
case $line[1] in
|
||||
|
||||
(start)
|
||||
_arguments \
|
||||
-F'[Fetch from origin before performing finish]'\
|
||||
':version:__git_flow_version_list'
|
||||
;;
|
||||
|
||||
(finish)
|
||||
_arguments \
|
||||
-F'[Fetch from origin before performing finish]' \
|
||||
-s'[Sign the release tag cryptographically]'\
|
||||
-u'[Use the given GPG-key for the digital signature (implies -s)]'\
|
||||
-m'[Use the given tag message]'\
|
||||
-p'[Push to $ORIGIN after performing finish]'\
|
||||
-k'[Keep branch after performing finish]'\
|
||||
-n"[Don't tag this release]"\
|
||||
':version:__git_flow_version_list'
|
||||
;;
|
||||
|
||||
(publish)
|
||||
_arguments \
|
||||
':version:__git_flow_version_list'\
|
||||
;;
|
||||
|
||||
(track)
|
||||
_arguments \
|
||||
':version:__git_flow_version_list'\
|
||||
;;
|
||||
|
||||
*)
|
||||
_arguments \
|
||||
-v'[Verbose (more) output]'
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
__git-flow-hotfix () {
|
||||
local curcontext="$curcontext" state line
|
||||
typeset -A opt_args
|
||||
|
||||
_arguments -C \
|
||||
':command:->command' \
|
||||
'*::options:->options'
|
||||
|
||||
case $state in
|
||||
(command)
|
||||
|
||||
local -a subcommands
|
||||
subcommands=(
|
||||
'start:Start a new hotfix branch.'
|
||||
'finish:Finish a hotfix branch.'
|
||||
'list:List all your hotfix branches. (Alias to `git flow hotfix`)'
|
||||
)
|
||||
_describe -t commands 'git flow hotfix' subcommands
|
||||
_arguments \
|
||||
-v'[Verbose (more) output]'
|
||||
;;
|
||||
|
||||
(options)
|
||||
case $line[1] in
|
||||
|
||||
(start)
|
||||
_arguments \
|
||||
-F'[Fetch from origin before performing finish]'\
|
||||
':hotfix:__git_flow_version_list'\
|
||||
':branch-name:__git_branch_names'
|
||||
;;
|
||||
|
||||
(finish)
|
||||
_arguments \
|
||||
-F'[Fetch from origin before performing finish]' \
|
||||
-s'[Sign the release tag cryptographically]'\
|
||||
-u'[Use the given GPG-key for the digital signature (implies -s)]'\
|
||||
-m'[Use the given tag message]'\
|
||||
-p'[Push to $ORIGIN after performing finish]'\
|
||||
-k'[Keep branch after performing finish]'\
|
||||
-n"[Don't tag this release]"\
|
||||
':hotfix:__git_flow_hotfix_list'
|
||||
;;
|
||||
|
||||
*)
|
||||
_arguments \
|
||||
-v'[Verbose (more) output]'
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
__git-flow-feature () {
|
||||
local curcontext="$curcontext" state line
|
||||
typeset -A opt_args
|
||||
|
||||
_arguments -C \
|
||||
':command:->command' \
|
||||
'*::options:->options'
|
||||
|
||||
case $state in
|
||||
(command)
|
||||
|
||||
local -a subcommands
|
||||
subcommands=(
|
||||
'start:Start a new feature branch.'
|
||||
'finish:Finish a feature branch.'
|
||||
'list:List all your feature branches. (Alias to `git flow feature`)'
|
||||
'publish: publish'
|
||||
'track: track'
|
||||
'diff: diff'
|
||||
'rebase: rebase'
|
||||
'checkout: checkout'
|
||||
'pull: pull'
|
||||
)
|
||||
_describe -t commands 'git flow feature' subcommands
|
||||
_arguments \
|
||||
-v'[Verbose (more) output]'
|
||||
;;
|
||||
|
||||
(options)
|
||||
case $line[1] in
|
||||
|
||||
(start)
|
||||
_arguments \
|
||||
-F'[Fetch from origin before performing finish]'\
|
||||
':feature:__git_flow_feature_list'\
|
||||
':branch-name:__git_branch_names'
|
||||
;;
|
||||
|
||||
(finish)
|
||||
_arguments \
|
||||
-F'[Fetch from origin before performing finish]' \
|
||||
-r'[Rebase instead of merge]'\
|
||||
-k'[Keep branch after performing finish]'\
|
||||
':feature:__git_flow_feature_list'
|
||||
;;
|
||||
|
||||
(publish)
|
||||
_arguments \
|
||||
':feature:__git_flow_feature_list'\
|
||||
;;
|
||||
|
||||
(track)
|
||||
_arguments \
|
||||
':feature:__git_flow_feature_list'\
|
||||
;;
|
||||
|
||||
(diff)
|
||||
_arguments \
|
||||
':branch:__git_flow_feature_list'\
|
||||
;;
|
||||
|
||||
(rebase)
|
||||
_arguments \
|
||||
-i'[Do an interactive rebase]' \
|
||||
':branch:__git_flow_feature_list'
|
||||
;;
|
||||
|
||||
(checkout)
|
||||
_arguments \
|
||||
':branch:__git_flow_feature_list'\
|
||||
;;
|
||||
|
||||
(pull)
|
||||
_arguments \
|
||||
':remote:__git_remotes'\
|
||||
':branch:__git_flow_feature_list'
|
||||
;;
|
||||
|
||||
*)
|
||||
_arguments \
|
||||
-v'[Verbose (more) output]'
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
__git_flow_version_list () {
|
||||
local expl
|
||||
declare -a versions
|
||||
|
||||
versions=(${${(f)"$(_call_program versions git flow release list 2> /dev/null | tr -d ' |*')"}})
|
||||
__git_command_successful || return
|
||||
|
||||
_wanted versions expl 'version' compadd $versions
|
||||
}
|
||||
|
||||
__git_flow_feature_list () {
|
||||
local expl
|
||||
declare -a features
|
||||
|
||||
features=(${${(f)"$(_call_program features git flow feature list 2> /dev/null | tr -d ' |*')"}})
|
||||
__git_command_successful || return
|
||||
|
||||
_wanted features expl 'feature' compadd $features
|
||||
}
|
||||
|
||||
__git_remotes () {
|
||||
local expl gitdir remotes
|
||||
|
||||
gitdir=$(_call_program gitdir git rev-parse --git-dir 2>/dev/null)
|
||||
__git_command_successful || return
|
||||
|
||||
remotes=(${${(f)"$(_call_program remotes git config --get-regexp '"^remote\..*\.url$"')"}//#(#b)remote.(*).url */$match[1]})
|
||||
__git_command_successful || return
|
||||
|
||||
# TODO: Should combine the two instead of either or.
|
||||
if (( $#remotes > 0 )); then
|
||||
_wanted remotes expl remote compadd $* - $remotes
|
||||
else
|
||||
_wanted remotes expl remote _files $* - -W "($gitdir/remotes)" -g "$gitdir/remotes/*"
|
||||
fi
|
||||
}
|
||||
|
||||
__git_flow_hotfix_list () {
|
||||
local expl
|
||||
declare -a hotfixes
|
||||
|
||||
hotfixes=(${${(f)"$(_call_program hotfixes git flow hotfix list 2> /dev/null | tr -d ' |*')"}})
|
||||
__git_command_successful || return
|
||||
|
||||
_wanted hotfixes expl 'hotfix' compadd $hotfixes
|
||||
}
|
||||
|
||||
__git_branch_names () {
|
||||
local expl
|
||||
declare -a branch_names
|
||||
|
||||
branch_names=(${${(f)"$(_call_program branchrefs git for-each-ref --format='"%(refname)"' refs/heads 2>/dev/null)"}#refs/heads/})
|
||||
__git_command_successful || return
|
||||
|
||||
_wanted branch-names expl branch-name compadd $* - $branch_names
|
||||
}
|
||||
|
||||
__git_command_successful () {
|
||||
if (( ${#pipestatus:#0} > 0 )); then
|
||||
_message 'not a git repository'
|
||||
return 1
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
zstyle ':completion:*:*:git:*' user-commands flow:'description for foo'
|
||||
|
||||
# Detect if script is sourced or called via autoload
|
||||
[[ "$ZSH_EVAL_CONTEXT" != *:file ]] || return
|
||||
|
||||
_git-flow "$@"
|
||||
249
plugins/golang/_golang
Normal file
249
plugins/golang/_golang
Normal file
|
|
@ -0,0 +1,249 @@
|
|||
#compdef go
|
||||
|
||||
__go_packages() {
|
||||
local gopaths
|
||||
declare -a gopaths
|
||||
gopaths=("${(s/:/)$(go env GOPATH)}")
|
||||
gopaths+=("$(go env GOROOT)")
|
||||
for p in $gopaths; do
|
||||
_path_files -W "$p/src" -/
|
||||
done
|
||||
}
|
||||
|
||||
__go_identifiers() {
|
||||
local tmpl_path="${functions_source[$0]:h}/templates"
|
||||
compadd $(godoc -templates "$tmpl_path" ${words[-2]} 2> /dev/null)
|
||||
}
|
||||
|
||||
_go() {
|
||||
typeset -a commands build_flags
|
||||
commands+=(
|
||||
'build[compile packages and dependencies]'
|
||||
'clean[remove object files]'
|
||||
'doc[run godoc on package sources]'
|
||||
'env[print Go environment information]'
|
||||
'fix[run go tool fix on packages]'
|
||||
'fmt[run gofmt on package sources]'
|
||||
'generate[generate Go files by processing source]'
|
||||
'get[download and install packages and dependencies]'
|
||||
'help[display help]'
|
||||
'install[compile and install packages and dependencies]'
|
||||
'list[list packages]'
|
||||
'mod[modules maintenance]'
|
||||
'run[compile and run Go program]'
|
||||
'test[test packages]'
|
||||
'tool[run specified go tool]'
|
||||
'version[print Go version]'
|
||||
'vet[run go tool vet on packages]'
|
||||
)
|
||||
if (( CURRENT == 2 )); then
|
||||
# explain go commands
|
||||
_values 'go tool commands' ${commands[@]}
|
||||
return
|
||||
fi
|
||||
build_flags=(
|
||||
'-a[force reinstallation of packages that are already up to date]'
|
||||
'-n[print the commands but do not run them]'
|
||||
'-p[number of parallel builds]:number'
|
||||
'-race[enable data race detection]'
|
||||
'-x[print the commands]'
|
||||
'-work[print temporary directory name and keep it]'
|
||||
'-ccflags[flags for 5c/6c/8c]:flags'
|
||||
'-gcflags[flags for 5g/6g/8g]:flags'
|
||||
'-ldflags[flags for 5l/6l/8l]:flags'
|
||||
'-gccgoflags[flags for gccgo]:flags'
|
||||
'-compiler[name of compiler to use]:name'
|
||||
'-installsuffix[suffix to add to package directory]:suffix'
|
||||
'-tags[list of build tags to consider satisfied]:tags'
|
||||
)
|
||||
|
||||
case ${words[2]} in
|
||||
doc)
|
||||
_arguments -s -w \
|
||||
"-c[symbol matching honors case (paths not affected)]" \
|
||||
"-cmd[show symbols with package docs even if package is a command]" \
|
||||
"-u[show unexported symbols as well as exported]" \
|
||||
"2:importpaths:__go_packages" \
|
||||
":next identifiers:__go_identifiers"
|
||||
;;
|
||||
clean)
|
||||
_arguments -s -w \
|
||||
"-i[remove the corresponding installed archive or binary (what 'go install' would create)]" \
|
||||
"-n[print the remove commands it would execute, but not run them]" \
|
||||
"-r[apply recursively to all the dependencies of the packages named by the import paths]" \
|
||||
"-x[print remove commands as it executes them]" \
|
||||
"*:importpaths:__go_packages"
|
||||
;;
|
||||
fix|fmt|vet)
|
||||
_alternative ':importpaths:__go_packages' ':files:_path_files -g "*.go"'
|
||||
;;
|
||||
install)
|
||||
_arguments -s -w : ${build_flags[@]} \
|
||||
"-v[show package names]" \
|
||||
'*:importpaths:__go_packages'
|
||||
;;
|
||||
get)
|
||||
_arguments -s -w : \
|
||||
${build_flags[@]}
|
||||
;;
|
||||
build)
|
||||
_arguments -s -w : \
|
||||
${build_flags[@]} \
|
||||
"-v[show package names]" \
|
||||
"-o[output file]:file:_files" \
|
||||
"*:args:{ _alternative ':importpaths:__go_packages' ':files:_path_files -g \"*.go\"' }"
|
||||
;;
|
||||
test)
|
||||
_arguments -s -w : \
|
||||
${build_flags[@]} \
|
||||
"-c[do not run, compile the test binary]" \
|
||||
"-i[do not run, install dependencies]" \
|
||||
"-v[print test output]" \
|
||||
"-x[print the commands]" \
|
||||
"-short[use short mode]" \
|
||||
"-parallel[number of parallel tests]:number" \
|
||||
"-cpu[values of GOMAXPROCS to use]:number list" \
|
||||
"-run[run tests and examples matching regexp]:regexp" \
|
||||
"-bench[run benchmarks matching regexp]:regexp" \
|
||||
"-benchmem[print memory allocation stats]" \
|
||||
"-benchtime[run each benchmark until taking this long]:duration" \
|
||||
"-blockprofile[write goroutine blocking profile to file]:file" \
|
||||
"-blockprofilerate[set sampling rate of goroutine blocking profile]:number" \
|
||||
"-timeout[kill test after that duration]:duration" \
|
||||
"-cpuprofile[write CPU profile to file]:file:_files" \
|
||||
"-memprofile[write heap profile to file]:file:_files" \
|
||||
"-memprofilerate[set heap profiling rate]:number" \
|
||||
"*:args:{ _alternative ':importpaths:__go_packages' ':files:_path_files -g \"*.go\"' }"
|
||||
;;
|
||||
list)
|
||||
_arguments -s -w : \
|
||||
"-f[alternative format for the list]:format" \
|
||||
"-json[print data in json format]" \
|
||||
"-compiled[set CompiledGoFiles to the Go source files presented to the compiler]" \
|
||||
"-deps[iterate over not just the named packages but also all their dependencies]" \
|
||||
"-e[change the handling of erroneous packages]" \
|
||||
"-export[set the Export field to the name of a file containing up-to-date export information for the given package]" \
|
||||
"-find[identify the named packages but not resolve their dependencies]" \
|
||||
"-test[report not only the named packages but also their test binaries]" \
|
||||
"-m[list modules instead of packages]" \
|
||||
"-u[adds information about available upgrades]" \
|
||||
"-versions[set the Module's Versions field to a list of all known versions of that module]:number" \
|
||||
"*:importpaths:__go_packages"
|
||||
;;
|
||||
mod)
|
||||
local -a mod_commands
|
||||
mod_commands+=(
|
||||
'download[download modules to local cache]'
|
||||
'edit[edit go.mod from tools or scripts]'
|
||||
'graph[print module requirement graph]'
|
||||
'init[initialize new module in current directory]'
|
||||
'tidy[add missing and remove unused modules]'
|
||||
'vendor[make vendored copy of dependencies]'
|
||||
'verify[verify dependencies have expected content]'
|
||||
'why[explain why packages or modules are needed]'
|
||||
)
|
||||
|
||||
if (( CURRENT == 3 )); then
|
||||
_values 'go mod commands' ${mod_commands[@]} "help[display help]"
|
||||
return
|
||||
fi
|
||||
|
||||
case ${words[3]} in
|
||||
help)
|
||||
_values 'go mod commands' ${mod_commands[@]}
|
||||
;;
|
||||
download)
|
||||
_arguments -s -w : \
|
||||
"-json[print a sequence of JSON objects standard output]" \
|
||||
"*:flags"
|
||||
;;
|
||||
edit)
|
||||
_arguments -s -w : \
|
||||
"-fmt[reformat the go.mod file]" \
|
||||
"-module[change the module's path]" \
|
||||
"-replace[=old{@v}=new{@v} add a replacement of the given module path and version pair]:name" \
|
||||
"-dropreplace[=old{@v}=new{@v} drop a replacement of the given module path and version pair]:name" \
|
||||
"-go[={version} set the expected Go language version]:number" \
|
||||
"-print[print the final go.mod in its text format]" \
|
||||
"-json[print the final go.mod file in JSON format]" \
|
||||
"*:flags"
|
||||
;;
|
||||
graph)
|
||||
;;
|
||||
init)
|
||||
;;
|
||||
tidy)
|
||||
_arguments -s -w : \
|
||||
"-v[print information about removed modules]" \
|
||||
"*:flags"
|
||||
;;
|
||||
vendor)
|
||||
_arguments -s -w : \
|
||||
"-v[print the names of vendored]" \
|
||||
"*:flags"
|
||||
;;
|
||||
verify)
|
||||
;;
|
||||
why)
|
||||
_arguments -s -w : \
|
||||
"-m[treats the arguments as a list of modules and finds a path to any package in each of the modules]" \
|
||||
"-vendor[exclude tests of dependencies]" \
|
||||
"*:importpaths:__go_packages"
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
help)
|
||||
_values "${commands[@]}" \
|
||||
'environment[show Go environment variables available]' \
|
||||
'gopath[GOPATH environment variable]' \
|
||||
'packages[description of package lists]' \
|
||||
'remote[remote import path syntax]' \
|
||||
'testflag[description of testing flags]' \
|
||||
'testfunc[description of testing functions]'
|
||||
;;
|
||||
run)
|
||||
_arguments -s -w : \
|
||||
${build_flags[@]} \
|
||||
'*:file:_files -g "*.go"'
|
||||
;;
|
||||
tool)
|
||||
if (( CURRENT == 3 )); then
|
||||
_values "go tool" $(go tool)
|
||||
return
|
||||
fi
|
||||
case ${words[3]} in
|
||||
[568]g)
|
||||
_arguments -s -w : \
|
||||
'-I[search for packages in DIR]:includes:_path_files -/' \
|
||||
'-L[show full path in file:line prints]' \
|
||||
'-S[print the assembly language]' \
|
||||
'-V[print the compiler version]' \
|
||||
'-e[no limit on number of errors printed]' \
|
||||
'-h[panic on an error]' \
|
||||
'-l[disable inlining]' \
|
||||
'-m[print optimization decisions]' \
|
||||
'-o[file specify output file]:file' \
|
||||
'-p[assumed import path for this code]:importpath' \
|
||||
'-u[disable package unsafe]' \
|
||||
"*:file:_files -g '*.go'"
|
||||
;;
|
||||
[568]l)
|
||||
local O=${words[3]%l}
|
||||
_arguments -s -w : \
|
||||
'-o[file specify output file]:file' \
|
||||
'-L[search for packages in DIR]:includes:_path_files -/' \
|
||||
"*:file:_files -g '*.[ao$O]'"
|
||||
;;
|
||||
dist)
|
||||
_values "dist tool" banner bootstrap clean env install version
|
||||
;;
|
||||
*)
|
||||
# use files by default
|
||||
_files
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
_go "$@"
|
||||
9
plugins/hasura/README.md
Normal file
9
plugins/hasura/README.md
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
# Hasura plugin
|
||||
|
||||
This plugin adds completion for [the Hasura CLI](https://hasura.io/docs/latest/hasura-cli/index/).
|
||||
|
||||
To use it, add `hasura` to the plugins array in your zshrc file:
|
||||
|
||||
```zsh
|
||||
plugins=(... hasura)
|
||||
```
|
||||
13
plugins/hasura/hasura.plugin.zsh
Normal file
13
plugins/hasura/hasura.plugin.zsh
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
if (( ! $+commands[hasura] )); then
|
||||
return
|
||||
fi
|
||||
|
||||
# If the completion file does not exist, generate it and then source it
|
||||
# Otherwise, source it and regenerate in the background
|
||||
if [[ ! -f "$ZSH_CACHE_DIR/completions/_hasura" ]]; then
|
||||
hasura completion zsh --file "$ZSH_CACHE_DIR/completions/_hasura" >/dev/null
|
||||
source "$ZSH_CACHE_DIR/completions/_hasura"
|
||||
else
|
||||
source "$ZSH_CACHE_DIR/completions/_hasura"
|
||||
hasura completion zsh --file "$ZSH_CACHE_DIR/completions/_hasura" >/dev/null &|
|
||||
fi
|
||||
10
plugins/invoke/README.md
Normal file
10
plugins/invoke/README.md
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
# Invoke plugin
|
||||
|
||||
This plugin adds completion for [invoke](https://github.com/pyinvoke/invoke).
|
||||
|
||||
To use it, add `invoke` to the plugins array in your `~/.zshrc` file:
|
||||
|
||||
```zsh
|
||||
plugins=(... invoke)
|
||||
```
|
||||
|
||||
5
plugins/invoke/invoke.plugin.zsh
Normal file
5
plugins/invoke/invoke.plugin.zsh
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
# Autocompletion for invoke.
|
||||
#
|
||||
if [ $commands[invoke] ]; then
|
||||
source <(invoke --print-completion-script=zsh)
|
||||
fi
|
||||
22
plugins/isodate/README.md
Normal file
22
plugins/isodate/README.md
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
# Isodate plugin
|
||||
|
||||
**Maintainer:** [@Frani](https://github.com/frani)
|
||||
|
||||
This plugin adds completion for the [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601),
|
||||
as well as some aliases for common Date commands.
|
||||
|
||||
To use it, add `isodate` to the plugins array in your zshrc file:
|
||||
|
||||
```zsh
|
||||
plugins=(... isodate)
|
||||
```
|
||||
|
||||
## Aliases
|
||||
|
||||
| Alias | Command | Description |
|
||||
|---------------|--------------------------------------|----------------------------------------------------------------------------|
|
||||
| isodate | `date +%Y-%m-%dT%H:%M:%S%z` | Display the current date with UTC offset and ISO 8601-2 extended format |
|
||||
| isodate_utc | `date -u +%Y-%m-%dT%H:%M:%SZ` | Display the current date in UTC and ISO 8601-2 extended format |
|
||||
| isodate_basic | `date -u +%Y%m%dT%H%M%SZ` | Display the current date in UTC and ISO 8601 basic format |
|
||||
| unixstamp | `date +%s` | Display the current date as a Unix timestamp (seconds since the Unix epoch)|
|
||||
| date_locale | `date +"%c"` | Display the current date using the default locale's format |
|
||||
7
plugins/isodate/isodate.plugin.zsh
Normal file
7
plugins/isodate/isodate.plugin.zsh
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
# work with date ISO 8601 easy
|
||||
|
||||
alias isodate="date +%Y-%m-%dT%H:%M:%S%z"
|
||||
alias isodate_utc="date -u +%Y-%m-%dT%H:%M:%SZ"
|
||||
alias isodate_basic="date -u +%Y%m%dT%H%M%SZ"
|
||||
alias unixstamp="date +%s"
|
||||
alias date_locale="date +"%c""
|
||||
9
plugins/istioctl/README.md
Normal file
9
plugins/istioctl/README.md
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
# Istioctl - Istio Command-line Tool
|
||||
|
||||
The [istioctl](https://istio.io/latest/docs/ops/diagnostic-tools/istioctl/) tool is a configuration command line utility that allows service operators to debug and diagnose their Istio service mesh deployments.
|
||||
|
||||
To use it, add `istioctl` to the plugins array of your zshrc file:
|
||||
|
||||
```sh
|
||||
plugins=(... istioctl)
|
||||
```
|
||||
4
plugins/istioctl/istioctl.plugin.zsh
Normal file
4
plugins/istioctl/istioctl.plugin.zsh
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
if [ $commands[istioctl] ]; then
|
||||
source <(istioctl completion zsh)
|
||||
compdef _istioctl istioctl
|
||||
fi
|
||||
130
plugins/juju/README.md
Normal file
130
plugins/juju/README.md
Normal file
|
|
@ -0,0 +1,130 @@
|
|||
# juju plugin
|
||||
|
||||
This plugin provides useful aliases and functions for [juju](https://juju.is/) (for TAB completion,
|
||||
refer to the [official repo](https://github.com/juju/juju/blob/develop/etc/bash_completion.d/juju)).
|
||||
|
||||
To use this plugin, add `juju` to the plugins array in your zshrc file.
|
||||
|
||||
```zsh
|
||||
plugins=(... juju)
|
||||
```
|
||||
|
||||
## Aliases
|
||||
|
||||
Naming convention:
|
||||
|
||||
- `!` suffix: `--force --no-wait -y`.
|
||||
- `ds` suffix: `--destroy-storage`.
|
||||
- `jsh` prefix means `juju show-*`.
|
||||
|
||||
### General
|
||||
|
||||
| Alias | Command | Description |
|
||||
|---------|---------------------------------------------|--------------------------------------------------------|
|
||||
| `j` | `juju` | The juju command |
|
||||
| `jcld` | `juju clouds` | Lists all clouds with registered credentials |
|
||||
| `jclda` | `juju clouds --all` | Lists all clouds available to Juju |
|
||||
| `jdl` | `juju debug-log --ms` | Display log, with millisecond resolution |
|
||||
| `jdlr` | `juju debug-log --ms --replay` | Replay entire log |
|
||||
| `jh` | `juju help` | Show help on a command or other topic |
|
||||
| `jshsl` | `juju show-status-log` | Output past statuses for the specified entity |
|
||||
| `jstj` | `juju status --format=json` | Show status in json format (more detailed) |
|
||||
| `jst` | `juju status --relations --color` | Show status, including relations, in color |
|
||||
| `jsts` | `juju status --relations --storage --color` | Show status, including relations and storage, in color |
|
||||
|
||||
### Bootstrap
|
||||
|
||||
| Alias | Command | Description |
|
||||
|---------|-------------------------------------|-------------------------------------------------------|
|
||||
| `jb` | `juju bootstrap` | Initializing a Juju cloud environment |
|
||||
| `jbng` | `juju bootstrap --no-gui` | Initializing a Juju cloud environment without GUI |
|
||||
| `jbl` | `juju bootstrap localhost` | Initializing an lxd cloud environment |
|
||||
| `jblng` | `juju bootstrap --no-gui localhost` | Initializing an lxd cloud environment without GUI |
|
||||
| `jbm` | `juju bootstrap microk8s` | Initializing a MicroK8s cloud environment |
|
||||
| `jbmng` | `juju bootstrap --no-gui microk8s` | Initializing a MicroK8s cloud environment without GUI |
|
||||
|
||||
### Controller
|
||||
|
||||
| Alias | Command | Description |
|
||||
|----------|---------------------------------------------------------------------------------------|-------------------------------------------------------------------|
|
||||
| `jctl` | `juju controllers` | List all controllers |
|
||||
| `jctlr` | `juju controllers --refresh` | List all controllers (download latest details) |
|
||||
| `jdc` | `juju destroy-controller --destroy-all-models` | Destroy a controller |
|
||||
| `jdc!` | `juju destroy-controller --destroy-all-models --force --no-wait -y` | Destroy a controller |
|
||||
| `jdcds` | `juju destroy-controller --destroy-all-models --destroy-storage` | Destroy a controller and associated storage |
|
||||
| `jdcds!` | `juju destroy-controller --destroy-all-models --destroy-storage --force --no-wait -y` | Destroy a controller and associated storage |
|
||||
| `jkc` | `juju kill-controller -y -t 0` | Forcibly terminate all associated resources for a Juju controller |
|
||||
| `jshc` | `juju show-controller` | Shows detailed information of a controller |
|
||||
| `jsw` | `juju switch` | Select or identify the current controller and model |
|
||||
|
||||
### Model
|
||||
|
||||
| Alias | Command | Description |
|
||||
|----------|-------------------------------------------------------------|-------------------------------------------------------|
|
||||
| `jam` | `juju add-model` | Add a hosted model |
|
||||
| `jdm` | `juju destroy-model` | Non-recoverable, complete removal of a model |
|
||||
| `jdm!` | `juju destroy-model --force --no-wait -y` | Non-recoverable, complete removal of a model |
|
||||
| `jdmds` | `juju destroy-model --destroy-storage` | Non-recoverable, complete removal of a model |
|
||||
| `jdmds!` | `juju destroy-model --destroy-storage --force --no-wait -y` | Non-recoverable, complete removal of a model |
|
||||
| `jmc` | `juju model-config` | Display or set configuration values on a model |
|
||||
| `jm` | `juju models` | List models a user can access on a controller |
|
||||
| `jshm` | `juju show-model` | Show information about the current or specified model |
|
||||
| `jsw` | `juju switch` | Select or identify the current controller and model |
|
||||
|
||||
### Application / unit
|
||||
|
||||
| Alias | Command | Description |
|
||||
|----------|---------------------------------------------------------------|---------------------------------------------------------------------------|
|
||||
| `jc` | `juju config` | Get, set, or reset configuration for a deployed application |
|
||||
| `jde` | `juju deploy --channel=edge` | Deploy a new application or bundle from the edge channel |
|
||||
| `jd` | `juju deploy` | Deploy a new application or bundle |
|
||||
| `jra` | `juju run-action` | Queue an action for execution |
|
||||
| `jraw` | `juju run-action --wait` | Queue an action for execution and wait for results, with optional timeout |
|
||||
| `jrm` | `juju remove-application` | Remove application |
|
||||
| `jrm!` | `juju remove-application --force --no-wait` | Remove application forcefully |
|
||||
| `jrmds` | `juju remove-application --destroy-storage` | Remove application and destroy attached storage |
|
||||
| `jrmds!` | `juju remove-application --destroy-storage --force --no-wait` | Remove application forcefully, destroying attached storage |
|
||||
| `jrp` | `juju refresh --path` | Upgrade charm from local charm file |
|
||||
| `jsa` | `juju scale-application` | Set the desired number of application units |
|
||||
| `jssh` | `juju ssh` | Initiate an SSH session or execute a command on a Juju target |
|
||||
| `jsshc` | `juju ssh --container` | Initiate an SSH session or execute a command on a given container |
|
||||
| `jshu` | `juju show-unit` | Displays information about a unit |
|
||||
|
||||
### Storage
|
||||
|
||||
| Alias | Command | Description |
|
||||
|---------|-------------------------------|-------------------------------------------------|
|
||||
| `jrs` | `juju remove-storage` | Remove storage |
|
||||
| `jrs!` | `juju remove-storage --force` | Remove storage even if it is currently attached |
|
||||
|
||||
### Relation
|
||||
|
||||
| Alias | Command | Description |
|
||||
|-----------|--------------------------------|-------------------------------------------------------------------|
|
||||
| `jrel` | `juju relate` | Relate two applications |
|
||||
| `jrmrel` | `juju remove-relation` | Remove an existing relation between two applications. |
|
||||
| `jrmrel!` | `juju remove-relation --force` | Remove an existing relation between two applications, forcefully. |
|
||||
|
||||
### Cross-model relation (CMR)
|
||||
|
||||
| Alias | Command | Description |
|
||||
|----------|--------------------|----------------------------------------------------------------|
|
||||
| `jex` | `juju expose` | Make an application publicly available over the network |
|
||||
| `jof` | `juju offer` | Offer application endpoints for use in other models |
|
||||
| `jcon` | `juju consume` | Add a remote offer to the model |
|
||||
| `jrmsas` | `juju remove-saas` | Remove consumed applications (SAAS) from the model |
|
||||
| `junex` | `juju unexpose` | Remove public availability over the network for an application |
|
||||
|
||||
### Bundle
|
||||
|
||||
| Alias | Command | Description |
|
||||
|-------|----------------------|-------------------------------------------------------------|
|
||||
| `jeb` | `juju export-bundle` | Export the current model configuration as a reusable bundle |
|
||||
|
||||
## Functions
|
||||
|
||||
- `jaddr <app_name> [unit_num]`: display app or unit IP address.
|
||||
- `jreld <relation_name> <app_name> <unit_num>`: display app and unit relation data.
|
||||
- `jclean`: destroy all controllers
|
||||
- `wjst [interval_secs] [args_for_watch]`: watch juju status, with optional interval
|
||||
(default: 5s); you may pass additional arguments to `watch`.
|
||||
172
plugins/juju/juju.plugin.zsh
Normal file
172
plugins/juju/juju.plugin.zsh
Normal file
|
|
@ -0,0 +1,172 @@
|
|||
# ---------------------------------------------------------- #
|
||||
# Aliases and functions for juju (https://juju.is) #
|
||||
# ---------------------------------------------------------- #
|
||||
|
||||
# Load TAB completions
|
||||
# You need juju's bash completion script installed. By default bash-completion's
|
||||
# location will be used (i.e. pkg-config --variable=completionsdir bash-completion).
|
||||
completion_file="$(pkg-config --variable=completionsdir bash-completion 2>/dev/null)/juju" || \
|
||||
completion_file="/usr/share/bash-completion/completions/juju"
|
||||
[[ -f "$completion_file" ]] && source "$completion_file"
|
||||
unset completion_file
|
||||
|
||||
# ---------------------------------------------------------- #
|
||||
# Aliases (in alphabetic order) #
|
||||
# #
|
||||
# Generally, #
|
||||
# - `!` means --force --no-wait -y #
|
||||
# - `ds` suffix means --destroy-storage #
|
||||
# - `jsh` prefix means juju show-* #
|
||||
# ---------------------------------------------------------- #
|
||||
alias j="juju"
|
||||
alias jam="juju add-model --config logging-config=\"<root>=WARNING; unit=DEBUG\"\
|
||||
--config update-status-hook-interval=\"60m\""
|
||||
alias jb='juju bootstrap'
|
||||
alias jbng='juju bootstrap --no-gui'
|
||||
alias jbl='juju bootstrap localhost'
|
||||
alias jblng='juju bootstrap --no-gui localhost'
|
||||
alias jbm='juju bootstrap microk8s'
|
||||
alias jbmng='juju bootstrap --no-gui microk8s'
|
||||
alias jc='juju config'
|
||||
alias jcld='juju clouds'
|
||||
alias jclda='juju clouds --all'
|
||||
alias jctl='juju controllers'
|
||||
alias jctlr='juju controllers --refresh'
|
||||
alias jdc='juju destroy-controller --destroy-all-models'
|
||||
alias 'jdc!'='juju destroy-controller --destroy-all-models --force --no-wait -y'
|
||||
alias jdcds='juju destroy-controller --destroy-all-models --destroy-storage'
|
||||
alias 'jdcds!'='juju destroy-controller --destroy-all-models --destroy-storage --force --no-wait -y'
|
||||
alias jdm='juju destroy-model'
|
||||
alias 'jdm!'='juju destroy-model --force --no-wait -y'
|
||||
alias jdmds='juju destroy-model --destroy-storage'
|
||||
alias 'jdmds!'='juju destroy-model --destroy-storage --force --no-wait -y'
|
||||
alias jde='juju deploy --channel=edge'
|
||||
alias jd='juju deploy'
|
||||
alias jdl='juju debug-log --ms'
|
||||
alias jdlr='juju debug-log --ms --replay'
|
||||
alias jcon='juju consume'
|
||||
alias jeb='juju export-bundle'
|
||||
alias jex='juju expose'
|
||||
alias jh='juju help'
|
||||
alias jkc='juju kill-controller -y -t 0'
|
||||
alias jm='juju models'
|
||||
alias jmc='juju model-config'
|
||||
alias jof='juju offer'
|
||||
alias jra='juju run-action'
|
||||
alias jraw='juju run-action --wait'
|
||||
alias jrel='juju relate'
|
||||
alias jrm='juju remove-application'
|
||||
alias 'jrm!'='juju remove-application --force --no-wait'
|
||||
alias jrmds='juju remove-application --destroy-storage'
|
||||
alias 'jrmds!'='juju remove-application --destroy-storage --force --no-wait'
|
||||
alias jrmrel='juju remove-relation'
|
||||
alias 'jrmrel!'='juju remove-relation --force'
|
||||
alias jrmsas='juju remove-saas'
|
||||
alias jrp='juju refresh --path'
|
||||
alias jrs='juju remove-storage'
|
||||
alias 'jrs!'='juju remove-storage --force'
|
||||
alias jsa='juju scale-application'
|
||||
alias jsha='juju show-application'
|
||||
alias jshc='juju show-controller'
|
||||
alias jshm='juju show-model'
|
||||
alias jshsl='juju show-status-log'
|
||||
alias jshu='juju show-unit'
|
||||
alias jssh='juju ssh'
|
||||
alias jsshc='juju ssh --container'
|
||||
alias jstj='juju status --format=json'
|
||||
alias jst='juju status --relations --color'
|
||||
alias jsts='juju status --relations --storage --color'
|
||||
alias jsw='juju switch'
|
||||
|
||||
# ---------------------------------------------------------- #
|
||||
# Functions (in alphabetic order) #
|
||||
# ---------------------------------------------------------- #
|
||||
|
||||
# Get app or unit address
|
||||
jaddr() {
|
||||
# $1 = app name
|
||||
# $2 = unit number (optional)
|
||||
if (( ! ${+commands[jq]} )); then
|
||||
echo "jq is required but could not be found." >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
if [[ $# -eq 1 ]]; then
|
||||
# Get app address
|
||||
juju status "$1" --format=json \
|
||||
| jq -r ".applications.\"$1\".address"
|
||||
elif [[ $# -eq 2 ]]; then
|
||||
# Get unit address
|
||||
juju status "$1/$2" --format=json \
|
||||
| jq -r ".applications.\"$1\".units.\"$1/$2\".address"
|
||||
else
|
||||
echo "Invalid number of arguments."
|
||||
echo "Usage: jaddr <app-name> [<unit-number>]"
|
||||
echo "Example: jaddr karma"
|
||||
echo "Example: jaddr karma 0"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Destroy all controllers
|
||||
jclean() {
|
||||
if (( ! ${+commands[jq]} )); then
|
||||
echo "jq is required but could not be found." >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
local controllers=$(juju controllers --format=json | jq -r '.controllers | keys[]' 2>/dev/null)
|
||||
if [[ -z "$controllers" ]]; then
|
||||
echo "No controllers registered"
|
||||
return 0
|
||||
fi
|
||||
|
||||
echo "This will forcefully destroy all storages, models and controllers."
|
||||
echo "Controllers to be destroyed:"
|
||||
echo "$controllers"
|
||||
|
||||
if ! read -q '?Are you sure (y/n)? '; then
|
||||
echo
|
||||
echo "Aborted."
|
||||
return 0
|
||||
fi
|
||||
|
||||
echo
|
||||
for controller in ${=controllers}; do
|
||||
timeout 2m juju destroy-controller --destroy-all-models --destroy-storage --force --no-wait -y $controller
|
||||
timeout 2m juju kill-controller -y -t 0 $controller 2>/dev/null
|
||||
timeout 10s juju unregister $controller 2>/dev/null
|
||||
done
|
||||
}
|
||||
|
||||
# Display app and unit relation data
|
||||
jreld() {
|
||||
# $1 = relation name
|
||||
# $2 = app name
|
||||
# $3 = unit number
|
||||
if [[ $# -ne 3 ]]; then
|
||||
echo "Invalid number of arguments."
|
||||
echo "Usage: jreld <relation-name> <app-name> <unit-number>"
|
||||
echo "Example: jreld karma-dashboard alertmanager 0"
|
||||
return 1
|
||||
fi
|
||||
|
||||
local relid="$(juju run "relation-ids $1" --unit $2/$3)"
|
||||
if [[ -z "$relid" ]]; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
echo "App data:"
|
||||
juju run "relation-get -r $relid --app - $2" --unit $2/$3
|
||||
echo
|
||||
echo "Unit data:"
|
||||
juju run "relation-get -r $relid - $2" --unit $2/$3
|
||||
}
|
||||
|
||||
# Watch juju status, with optional interval (default: 5 sec)
|
||||
wjst() {
|
||||
local interval="${1:-5}"
|
||||
shift $(( $# > 0 ))
|
||||
watch -n "$interval" --color juju status --relations --color "$@"
|
||||
}
|
||||
|
||||
17
plugins/kn/README.md
Normal file
17
plugins/kn/README.md
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
# kn - Knative CLI
|
||||
|
||||
This plugin provides autocompletion for [kn](https://knative.dev/docs/install/client/install-kn/) operations.
|
||||
|
||||
To use it, add `kn` to the plugins array of your zshrc file:
|
||||
|
||||
```zsh
|
||||
plugins=(... kn)
|
||||
```
|
||||
|
||||
## See Also
|
||||
|
||||
+ [kn/client](https://github.com/knative/client)
|
||||
|
||||
## Contributors
|
||||
|
||||
+ [btannous](https://github.com/btannous) - Plugin Author
|
||||
8
plugins/kn/kn.plugin.zsh
Normal file
8
plugins/kn/kn.plugin.zsh
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
# Autocompletion for kn, the command line interface for knative
|
||||
#
|
||||
# Author: https://github.com/btannous
|
||||
|
||||
if [ $commands[kn] ]; then
|
||||
source <(kn completion zsh)
|
||||
compdef _kn kn
|
||||
fi
|
||||
26
plugins/kubectx/README.md
Normal file
26
plugins/kubectx/README.md
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
# kubectx - show active kubectl context
|
||||
|
||||
This plugins adds ```kubectx_prompt_info()``` function. It shows name of the
|
||||
active kubectl context (```kubectl config current-context```).
|
||||
|
||||
You can use it to customize prompt and know if You are on prod cluster ;)
|
||||
|
||||
_Example_. Add to **.zshrc**:
|
||||
|
||||
```
|
||||
RPS1='$(kubectx_prompt_info)'
|
||||
```
|
||||
|
||||
### custom ctx names
|
||||
|
||||
One can rename default context name for better readability.
|
||||
|
||||
_Example_. Add to **.zshrc**:
|
||||
```
|
||||
kubectx_mapping[minikube]="mini"
|
||||
kubectx_mapping[context_name_from_kubeconfig]="$emoji[wolf_face]"
|
||||
kubectx_mapping[production_cluster]="%{$fg[yellow]%}prod!%{$reset_color%}"
|
||||
```
|
||||
|
||||

|
||||

|
||||
13
plugins/kubectx/kubectx.plugin.zsh
Normal file
13
plugins/kubectx/kubectx.plugin.zsh
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
typeset -g -A kubectx_mapping
|
||||
|
||||
function kubectx_prompt_info() {
|
||||
(( $+commands[kubectl] )) || return
|
||||
|
||||
local current_ctx=$(kubectl config current-context 2> /dev/null)
|
||||
|
||||
[[ -n "$current_ctx" ]] || return
|
||||
|
||||
# use value in associative array if it exists
|
||||
# otherwise fall back to the context name
|
||||
echo "${kubectx_mapping[$current_ctx]:-${current_ctx:gs/%/%%}}"
|
||||
}
|
||||
BIN
plugins/kubectx/prod.png
Normal file
BIN
plugins/kubectx/prod.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.7 KiB |
BIN
plugins/kubectx/stage.png
Normal file
BIN
plugins/kubectx/stage.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.7 KiB |
13
plugins/lpass/README.md
Normal file
13
plugins/lpass/README.md
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
# lpass (LastPass CLI)
|
||||
|
||||
This plugin adds completion for LastPass CLI [`lpass`](https://github.com/lastpass/lastpass-cli).
|
||||
|
||||
To use it, add `lpass` to the plugins array in your zshrc file:
|
||||
|
||||
```zsh
|
||||
plugins=(... lpass)
|
||||
```
|
||||
|
||||
Completion is taken from the `lpass` release [`1.3.3`](https://github.com/lastpass/lastpass-cli/releases/tag/v1.3.3).
|
||||
|
||||
Updated on October 9th, 2020.
|
||||
169
plugins/lpass/_lpass
Normal file
169
plugins/lpass/_lpass
Normal file
|
|
@ -0,0 +1,169 @@
|
|||
#compdef lpass
|
||||
|
||||
_lpass() {
|
||||
local cmd has_color has_sync has_interactive
|
||||
if (( CURRENT > 2)); then
|
||||
cmd=${words[2]}
|
||||
# Set the context for the subcommand.
|
||||
curcontext="${curcontext%:*:*}:lpass-$cmd"
|
||||
# Narrow the range of words we are looking at to exclude `lpass'
|
||||
(( CURRENT-- ))
|
||||
shift words
|
||||
# Run the completion for the subcommand
|
||||
case "${cmd}" in
|
||||
login)
|
||||
_arguments : \
|
||||
'--trust[Cause subsequent logins to not require multifactor authentication.]' \
|
||||
'--plaintext-key[Save plaintext decryption key to the hard disk]' \
|
||||
'--force[Do not ask on saving plaintext key]'
|
||||
has_color=1
|
||||
;;
|
||||
|
||||
logout)
|
||||
_arguments : '--force[Force confirmation]'
|
||||
has_color=1
|
||||
;;
|
||||
show)
|
||||
_arguments : \
|
||||
'(-c --clip)'{-c,--clip}'[Copy output to clipboard]' \
|
||||
'(-x --expand-multi)'{-x,---expand-multi}'[Show the requested information from all of the matching sites]' \
|
||||
'(--all --username --password --url --notes --field= --id --name --attach=)'{--all,--username,--password,--url,--notes,--field=,--id,--name,--attach=}'[Output the specific field]' \
|
||||
'(--basic-regexp,--fixed-string)'{-G,--basic-regexp}'[Find a site by substring or regular expression]' \
|
||||
'--format=[Format output with printf-style placeholders]'
|
||||
_lpass_complete_uniqenames
|
||||
has_color=1
|
||||
has_sync=1
|
||||
;;
|
||||
|
||||
ls)
|
||||
_arguments : \
|
||||
'(-l --long)'{-l,--long}'[Also list the last modification time and username]' \
|
||||
'-u[List username]' \
|
||||
'-m[List modification time]' \
|
||||
'--format=[Format output with printf-style placeholders]'
|
||||
_lpass_complete_groups
|
||||
has_color=1
|
||||
has_sync=1
|
||||
;;
|
||||
mv)
|
||||
_lpass_complete_uniqenames
|
||||
_lpass_complete_groups
|
||||
has_color=1
|
||||
;;
|
||||
duplicate|rm)
|
||||
_lpass_complete_uniqenames
|
||||
has_color=1
|
||||
has_sync=1
|
||||
;;
|
||||
add)
|
||||
_arguments : '(--username --password --url --notes --field=)'{--username,--password,--url,--notes,--field=}'[Add field]'
|
||||
_lpass_complete_uniqenames
|
||||
has_color=1
|
||||
has_sync=1
|
||||
has_interactive=1
|
||||
;;
|
||||
edit)
|
||||
_arguments : '(--name --username --password --url --notes --field=)'{--name,--username,--password,--url,--notes,--field=}'[Update field]'
|
||||
_lpass_complete_uniqenames
|
||||
has_color=1
|
||||
has_sync=1
|
||||
has_interactive=1
|
||||
;;
|
||||
generate)
|
||||
_arguments : \
|
||||
'(-c --clip)'{-c,--clip}'[Copy output to clipboard]' \
|
||||
'--username=[USERNAME]' \
|
||||
'--url=[URL]' \
|
||||
'--no-symbols[Do not use symbols]'
|
||||
has_sync=1
|
||||
;;
|
||||
status)
|
||||
_arguments : '(-q --quiet)'{-q,--quiet}'[Supress output to stdout]'
|
||||
has_color=1
|
||||
;;
|
||||
sync)
|
||||
_arguments : '(-b --background)'{-b,--background}'[Run sync in background]'
|
||||
has_color=1
|
||||
;;
|
||||
export)
|
||||
_arguments : '--fields=[Field list]'
|
||||
has_color=1
|
||||
has_sync=1
|
||||
;;
|
||||
import)
|
||||
if ((CURRENT < 3)); then
|
||||
_files
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ -n "$has_sync" ] || [ -n "$has_color" ] || [ -n "$has_interactive" ]; then
|
||||
local -a generic_options
|
||||
if [ "$has_sync" -eq 1 ]; then
|
||||
generic_options+=('--sync=[Synchronize local cache with server: auto | now | no]')
|
||||
fi
|
||||
if [ "$has_color" -eq 1 ]; then
|
||||
generic_options+=('--color=[Color: auto | never | always]')
|
||||
fi
|
||||
if [ "$has_interactive" -eq 1 ]; then
|
||||
generic_options+=("--non-interactive[Use standard input instead of $EDITOR]")
|
||||
fi
|
||||
_arguments $generic_options
|
||||
fi
|
||||
else
|
||||
local -a subcommands
|
||||
subcommands=(
|
||||
"login:Authenticate with the LastPass server and initialize a local cache"
|
||||
"logout:Remove the local cache and stored encryption keys"
|
||||
"passwd:Change your LastPass password"
|
||||
"show:Display a password or selected field"
|
||||
"ls:List names in groups in a tree structure"
|
||||
"mv:Move the specified entry to a new group"
|
||||
"add:Add a new entry"
|
||||
"edit:Edit the selected field"
|
||||
"generate:Create a randomly generated password"
|
||||
"duplicate:Create a duplicate entry of the one specified"
|
||||
"rm:Remove the specified entry"
|
||||
"status:Show current login status"
|
||||
"sync:Synchronize local cache with server"
|
||||
"export:Dump all account information including passwords as unencrypted csv to stdout"
|
||||
"import:Upload accounts from an unencrypted CSV file to the server"
|
||||
"share:Manipulate shared folders (only enterprise or premium user)"
|
||||
)
|
||||
_describe -t commands 'lpass' subcommands
|
||||
_arguments : \
|
||||
'(-h --help)'{-h,--help}'[show help]' \
|
||||
'(-v --version)'{-v,--version}'[show version]'
|
||||
|
||||
fi
|
||||
}
|
||||
|
||||
_lpass_complete_uniqenames(){
|
||||
local -a entries
|
||||
while read i; do
|
||||
if [ -n "$i" ]; then
|
||||
entries+=("$i")
|
||||
fi
|
||||
done < <(lpass ls --sync auto --format "%an" --color=never)
|
||||
compadd -a entries
|
||||
}
|
||||
|
||||
|
||||
_lpass_complete_groups() {
|
||||
local -a entries
|
||||
while read i; do
|
||||
if [ -n "$i" ]; then
|
||||
entries+=("$i")
|
||||
fi
|
||||
done < <(lpass ls --sync auto --format "%aN" --color=never | grep -E "\/$")
|
||||
compadd -a entries
|
||||
}
|
||||
|
||||
_lpass
|
||||
# Local Variables:
|
||||
# mode: Shell-Script
|
||||
# sh-indentation: 2
|
||||
# indent-tabs-mode: nil
|
||||
# sh-basic-offset: 2
|
||||
# End:
|
||||
# vim: ft=zsh sw=2 ts=2 et
|
||||
63
plugins/macos/README.md
Normal file
63
plugins/macos/README.md
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
# MacOS plugin
|
||||
|
||||
This plugin provides a few utilities to make it more enjoyable on macOS (previously named OSX).
|
||||
|
||||
To start using it, add the `macos` plugin to your plugins array in `~/.zshrc`:
|
||||
|
||||
```zsh
|
||||
plugins=(... macos)
|
||||
```
|
||||
|
||||
Original author: [Sorin Ionescu](https://github.com/sorin-ionescu)
|
||||
|
||||
## Commands
|
||||
|
||||
| Command | Description |
|
||||
| :------------ | :------------------------------------------------------- |
|
||||
| `tab` | Open the current directory in a new tab |
|
||||
| `split_tab` | Split the current terminal tab horizontally |
|
||||
| `vsplit_tab` | Split the current terminal tab vertically |
|
||||
| `ofd` | Open the current directory in a Finder window |
|
||||
| `pfd` | Return the path of the frontmost Finder window |
|
||||
| `pfs` | Return the current Finder selection |
|
||||
| `cdf` | `cd` to the current Finder directory |
|
||||
| `pushdf` | `pushd` to the current Finder directory |
|
||||
| `pxd` | Return the current Xcode project directory |
|
||||
| `cdx` | `cd` to the current Xcode project directory |
|
||||
| `quick-look` | Quick-Look a specified file |
|
||||
| `man-preview` | Open a specified man page in Preview app |
|
||||
| `showfiles` | Show hidden files in Finder |
|
||||
| `hidefiles` | Hide the hidden files in Finder |
|
||||
| `itunes` | _DEPRECATED_. Use `music` from macOS Catalina on |
|
||||
| `music` | Control Apple Music. Use `music -h` for usage details |
|
||||
| `spotify` | Control Spotify and search by artist, album, track… |
|
||||
| `rmdsstore` | Remove .DS_Store files recursively in a directory |
|
||||
| `btrestart` | Restart the Bluetooth daemon |
|
||||
| `freespace` | Erases purgeable disk space with 0s on the selected disk |
|
||||
|
||||
## Acknowledgements
|
||||
|
||||
This application makes use of the following third party scripts:
|
||||
|
||||
[shpotify](https://github.com/hnarayanan/shpotify)
|
||||
|
||||
Copyright (c) 2012–2019 [Harish Narayanan](https://harishnarayanan.org/).
|
||||
|
||||
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.
|
||||
90
plugins/macos/_security
Normal file
90
plugins/macos/_security
Normal file
|
|
@ -0,0 +1,90 @@
|
|||
#compdef security
|
||||
|
||||
local -a _1st_arguments
|
||||
_1st_arguments=(
|
||||
'help:Show all commands, or show usage for a command'
|
||||
'list-keychains:Display or manipulate the keychain search list'
|
||||
'default-keychain:Display or set the default keychain'
|
||||
'login-keychain:Display or set the login keychain'
|
||||
'create-keychain:Create keychains and add them to the search list'
|
||||
'delete-keychain:Delete keychains and remove them from the search list'
|
||||
'lock-keychain:Lock the specified keychain'
|
||||
'lock-keychain:Unlock the specified keychain'
|
||||
'set-keychain-settings:Set settings for a keychain'
|
||||
'set-keychain-password:Set password for a keychain'
|
||||
'show-keychain-info:Show the settings for keychain'
|
||||
'dump-keychain:Dump the contents of one or more keychains'
|
||||
'create-keypair:Create an asymmetric key pair'
|
||||
'add-generic-password:Add a generic password item'
|
||||
'add-internet-password:Add an internet password item'
|
||||
'add-certificates:Add certificates to a keychain'
|
||||
'find-generic-password:Find a generic password item'
|
||||
'delete-generic-password:Delete a generic password item'
|
||||
'find-internet-password:Find an internet password item'
|
||||
'delete-internet-password:Delete an internet password item'
|
||||
'find-certificate:Find a certificate item'
|
||||
'find-identity:Find an identity certificate + private key'
|
||||
'delete-certificate:Delete a certificate from a keychain'
|
||||
'set-identity-preference:Set the preferred identity to use for a service'
|
||||
'get-identity-preference:Get the preferred identity to use for a service'
|
||||
'create-db:Create a db using the DL'
|
||||
'export:Export items from a keychain'
|
||||
'import:Import items into a keychain'
|
||||
'cms:Encode or decode CMS messages'
|
||||
'install-mds:MDS database'
|
||||
'add-trusted-cert:Add trusted certificates:'
|
||||
'remove-trusted-cert:Remove trusted certificates:'
|
||||
'dump-trust-settings:Display contents of trust settings'
|
||||
'user-trust-settings-enable:Display or manipulate user-level trust settings'
|
||||
'trust-settings-export:Export trust settings'
|
||||
'trust-settings-import:Import trust settings'
|
||||
'verify-cert:Verify certificates:'
|
||||
'authorize:Perform authorization operations'
|
||||
'authorizationdb:Make changes to the authorization policy database'
|
||||
'execute-with-privileges:Execute tool with privileges'
|
||||
'leaks:Run /usr/bin/leaks on this process'
|
||||
'error:Display a descriptive message for the given error codes:'
|
||||
'create-filevaultmaster-keychain:"Create a keychain containing a key pair for FileVault recovery use'
|
||||
)
|
||||
_arguments '*:: :->command'
|
||||
|
||||
if (( CURRENT == 1 )); then
|
||||
_describe -t commands "security command" _1st_arguments
|
||||
return
|
||||
fi
|
||||
|
||||
case "$words[1]" in
|
||||
find-(generic|internet)-password)
|
||||
_values \
|
||||
'Usage: find-[internet/generic]-password [-a account] [-s server] [options...] [-g] [keychain...]' \
|
||||
'-a[Match "account" string]' \
|
||||
'-c[Match "creator" (four-character code)]' \
|
||||
'-C[Match "type" (four-character code)]' \
|
||||
'-D[Match "kind" string]' \
|
||||
'-G[Match "value" string (generic attribute)]' \
|
||||
'-j[Match "comment" string]' \
|
||||
'-l[Match "label" string]' \
|
||||
'-s[Match "service" string]' \
|
||||
'-g[Display the password for the item found]' \
|
||||
'-w[Display only the password on stdout]' ;;
|
||||
add-(generic|internet)-password)
|
||||
_values \
|
||||
'Usage: add-[internet/generic]-password [-a account] [-s server] [-w password] [options...] [-A|-T appPath] [keychain]]' \
|
||||
'-a[Specify account name (required)]' \
|
||||
'-c[Specify item creator (optional four-character code)]' \
|
||||
'-C[Specify item type (optional four-character code)]' \
|
||||
'-d[Specify security domain string (optional)]' \
|
||||
'-D[Specify kind (default is "Internet password")]' \
|
||||
'-j[Specify comment string (optional)]' \
|
||||
'-l[Specify label (if omitted, server name is used as default label)]' \
|
||||
'-p[Specify path string (optional)]' \
|
||||
'-P[Specify port number (optional)]' \
|
||||
'-r[Specify protocol (optional four-character SecProtocolType, e.g. "http", "ftp ")]' \
|
||||
'-s[Specify server name (required)]' \
|
||||
'-t[Specify authentication type (as a four-character SecAuthenticationType, default is "dflt")]' \
|
||||
'-w[Specify password to be added]' \
|
||||
'-A[Allow any application to access this item without warning (insecure, not recommended!)]' \
|
||||
'-T[Specify an application which may access this item (multiple -T options are allowed)]' \
|
||||
'-U[Update item if it already exists (if omitted, the item cannot already exist) ]' \
|
||||
'utils)]' ;;
|
||||
esac
|
||||
268
plugins/macos/macos.plugin.zsh
Normal file
268
plugins/macos/macos.plugin.zsh
Normal file
|
|
@ -0,0 +1,268 @@
|
|||
# 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}"
|
||||
|
||||
# Open the current directory in a Finder window
|
||||
alias ofd='open_command $PWD'
|
||||
|
||||
# Show/hide hidden files in the Finder
|
||||
alias showfiles="defaults write com.apple.finder AppleShowAllFiles -bool true && killall Finder"
|
||||
alias hidefiles="defaults write com.apple.finder AppleShowAllFiles -bool false && killall Finder"
|
||||
|
||||
# Bluetooth restart
|
||||
function btrestart() {
|
||||
sudo kextunload -b com.apple.iokit.BroadcomBluetoothHostControllerUSBTransport
|
||||
sudo kextload -b com.apple.iokit.BroadcomBluetoothHostControllerUSBTransport
|
||||
}
|
||||
|
||||
function _omz_macos_get_frontmost_app() {
|
||||
osascript 2>/dev/null <<EOF
|
||||
tell application "System Events"
|
||||
name of first item of (every process whose frontmost is true)
|
||||
end tell
|
||||
EOF
|
||||
}
|
||||
|
||||
function tab() {
|
||||
# Must not have trailing semicolon, for iTerm compatibility
|
||||
local command="cd \\\"$PWD\\\"; clear"
|
||||
(( $# > 0 )) && command="${command}; $*"
|
||||
|
||||
local the_app=$(_omz_macos_get_frontmost_app)
|
||||
|
||||
if [[ "$the_app" == 'Terminal' ]]; then
|
||||
# Discarding stdout to quash "tab N of window id XXX" output
|
||||
osascript >/dev/null <<EOF
|
||||
tell application "System Events"
|
||||
tell process "Terminal" to keystroke "t" using command down
|
||||
end tell
|
||||
tell application "Terminal" to do script "${command}" in front window
|
||||
EOF
|
||||
elif [[ "$the_app" == 'iTerm' ]]; then
|
||||
osascript <<EOF
|
||||
tell application "iTerm"
|
||||
set current_terminal to current terminal
|
||||
tell current_terminal
|
||||
launch session "Default Session"
|
||||
set current_session to current session
|
||||
tell current_session
|
||||
write text "${command}"
|
||||
end tell
|
||||
end tell
|
||||
end tell
|
||||
EOF
|
||||
elif [[ "$the_app" == 'iTerm2' ]]; then
|
||||
osascript <<EOF
|
||||
tell application "iTerm2"
|
||||
tell current window
|
||||
create tab with default profile
|
||||
tell current session to write text "${command}"
|
||||
end tell
|
||||
end tell
|
||||
EOF
|
||||
elif [[ "$the_app" == 'Hyper' ]]; then
|
||||
osascript >/dev/null <<EOF
|
||||
tell application "System Events"
|
||||
tell process "Hyper" to keystroke "t" using command down
|
||||
end tell
|
||||
delay 1
|
||||
tell application "System Events"
|
||||
keystroke "${command}"
|
||||
key code 36 #(presses enter)
|
||||
end tell
|
||||
EOF
|
||||
else
|
||||
echo "$0: unsupported terminal app: $the_app" >&2
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
function vsplit_tab() {
|
||||
local command="cd \\\"$PWD\\\"; clear"
|
||||
(( $# > 0 )) && command="${command}; $*"
|
||||
|
||||
local the_app=$(_omz_macos_get_frontmost_app)
|
||||
|
||||
if [[ "$the_app" == 'iTerm' ]]; then
|
||||
osascript <<EOF
|
||||
-- tell application "iTerm" to activate
|
||||
tell application "System Events"
|
||||
tell process "iTerm"
|
||||
tell menu item "Split Vertically With Current Profile" of menu "Shell" of menu bar item "Shell" of menu bar 1
|
||||
click
|
||||
end tell
|
||||
end tell
|
||||
keystroke "${command} \n"
|
||||
end tell
|
||||
EOF
|
||||
elif [[ "$the_app" == 'iTerm2' ]]; then
|
||||
osascript <<EOF
|
||||
tell application "iTerm2"
|
||||
tell current session of first window
|
||||
set newSession to (split vertically with same profile)
|
||||
tell newSession
|
||||
write text "${command}"
|
||||
select
|
||||
end tell
|
||||
end tell
|
||||
end tell
|
||||
EOF
|
||||
elif [[ "$the_app" == 'Hyper' ]]; then
|
||||
osascript >/dev/null <<EOF
|
||||
tell application "System Events"
|
||||
tell process "Hyper"
|
||||
tell menu item "Split Vertically" of menu "Shell" of menu bar 1
|
||||
click
|
||||
end tell
|
||||
end tell
|
||||
delay 1
|
||||
keystroke "${command} \n"
|
||||
end tell
|
||||
EOF
|
||||
else
|
||||
echo "$0: unsupported terminal app: $the_app" >&2
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
function split_tab() {
|
||||
local command="cd \\\"$PWD\\\"; clear"
|
||||
(( $# > 0 )) && command="${command}; $*"
|
||||
|
||||
local the_app=$(_omz_macos_get_frontmost_app)
|
||||
|
||||
if [[ "$the_app" == 'iTerm' ]]; then
|
||||
osascript 2>/dev/null <<EOF
|
||||
tell application "iTerm" to activate
|
||||
|
||||
tell application "System Events"
|
||||
tell process "iTerm"
|
||||
tell menu item "Split Horizontally With Current Profile" of menu "Shell" of menu bar item "Shell" of menu bar 1
|
||||
click
|
||||
end tell
|
||||
end tell
|
||||
keystroke "${command} \n"
|
||||
end tell
|
||||
EOF
|
||||
elif [[ "$the_app" == 'iTerm2' ]]; then
|
||||
osascript <<EOF
|
||||
tell application "iTerm2"
|
||||
tell current session of first window
|
||||
set newSession to (split horizontally with same profile)
|
||||
tell newSession
|
||||
write text "${command}"
|
||||
select
|
||||
end tell
|
||||
end tell
|
||||
end tell
|
||||
EOF
|
||||
elif [[ "$the_app" == 'Hyper' ]]; then
|
||||
osascript >/dev/null <<EOF
|
||||
tell application "System Events"
|
||||
tell process "Hyper"
|
||||
tell menu item "Split Horizontally" of menu "Shell" of menu bar 1
|
||||
click
|
||||
end tell
|
||||
end tell
|
||||
delay 1
|
||||
keystroke "${command} \n"
|
||||
end tell
|
||||
EOF
|
||||
else
|
||||
echo "$0: unsupported terminal app: $the_app" >&2
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
function pfd() {
|
||||
osascript 2>/dev/null <<EOF
|
||||
tell application "Finder"
|
||||
return POSIX path of (insertion location as alias)
|
||||
end tell
|
||||
EOF
|
||||
}
|
||||
|
||||
function pfs() {
|
||||
osascript 2>/dev/null <<EOF
|
||||
set output to ""
|
||||
tell application "Finder" to set the_selection to selection
|
||||
set item_count to count the_selection
|
||||
repeat with item_index from 1 to count the_selection
|
||||
if item_index is less than item_count then set the_delimiter to "\n"
|
||||
if item_index is item_count then set the_delimiter to ""
|
||||
set output to output & ((item item_index of the_selection as alias)'s POSIX path) & the_delimiter
|
||||
end repeat
|
||||
EOF
|
||||
}
|
||||
|
||||
function cdf() {
|
||||
cd "$(pfd)"
|
||||
}
|
||||
|
||||
function pushdf() {
|
||||
pushd "$(pfd)"
|
||||
}
|
||||
|
||||
function pxd() {
|
||||
dirname $(osascript 2>/dev/null <<EOF
|
||||
if application "Xcode" is running then
|
||||
tell application "Xcode"
|
||||
return path of active workspace document
|
||||
end tell
|
||||
end if
|
||||
EOF
|
||||
)
|
||||
}
|
||||
|
||||
function cdx() {
|
||||
cd "$(pxd)"
|
||||
}
|
||||
|
||||
function quick-look() {
|
||||
(( $# > 0 )) && qlmanage -p $* &>/dev/null &
|
||||
}
|
||||
|
||||
function man-preview() {
|
||||
# Don't let Preview.app steal focus if the man page doesn't exist
|
||||
man -w "$@" &>/dev/null && man -t "$@" | open -f -a Preview || man "$@"
|
||||
}
|
||||
compdef _man man-preview
|
||||
|
||||
function vncviewer() {
|
||||
open vnc://$@
|
||||
}
|
||||
|
||||
# Remove .DS_Store files recursively in a directory, default .
|
||||
function rmdsstore() {
|
||||
find "${@:-.}" -type f -name .DS_Store -delete
|
||||
}
|
||||
|
||||
# Erases purgeable disk space with 0s on the selected disk
|
||||
function freespace(){
|
||||
if [[ -z "$1" ]]; then
|
||||
echo "Usage: $0 <disk>"
|
||||
echo "Example: $0 /dev/disk1s1"
|
||||
echo
|
||||
echo "Possible disks:"
|
||||
df -h | awk 'NR == 1 || /^\/dev\/disk/'
|
||||
return 1
|
||||
fi
|
||||
|
||||
echo "Cleaning purgeable files from disk: $1 ...."
|
||||
diskutil secureErase freespace 0 $1
|
||||
}
|
||||
|
||||
_freespace() {
|
||||
local -a disks
|
||||
disks=("${(@f)"$(df | awk '/^\/dev\/disk/{ printf $1 ":"; for (i=9; i<=NF; i++) printf $i FS; print "" }')"}")
|
||||
_describe disks disks
|
||||
}
|
||||
|
||||
compdef _freespace freespace
|
||||
|
||||
# Music / iTunes control function
|
||||
source "${0:h:A}/music"
|
||||
|
||||
# Spotify control function
|
||||
source "${0:h:A}/spotify"
|
||||
170
plugins/macos/music
Normal file
170
plugins/macos/music
Normal file
|
|
@ -0,0 +1,170 @@
|
|||
#!/usr/bin/env zsh
|
||||
|
||||
function music itunes() {
|
||||
local APP_NAME=Music sw_vers=$(sw_vers -productVersion 2>/dev/null)
|
||||
|
||||
autoload is-at-least
|
||||
if [[ -z "$sw_vers" ]] || is-at-least 10.15 $sw_vers; then
|
||||
if [[ $0 = itunes ]]; then
|
||||
echo >&2 The itunes function name is deprecated. Use \'music\' instead.
|
||||
return 1
|
||||
fi
|
||||
else
|
||||
APP_NAME=iTunes
|
||||
fi
|
||||
|
||||
local opt=$1 playlist=$2
|
||||
(( $# > 0 )) && shift
|
||||
case "$opt" in
|
||||
launch|play|pause|stop|rewind|resume|quit)
|
||||
;;
|
||||
mute)
|
||||
opt="set mute to true"
|
||||
;;
|
||||
unmute)
|
||||
opt="set mute to false"
|
||||
;;
|
||||
next|previous)
|
||||
opt="$opt track"
|
||||
;;
|
||||
vol)
|
||||
local new_volume volume=$(osascript -e "tell application \"$APP_NAME\" to get sound volume")
|
||||
if [[ $# -eq 0 ]]; then
|
||||
echo "Current volume is ${volume}."
|
||||
return 0
|
||||
fi
|
||||
case $1 in
|
||||
up) new_volume=$((volume + 10 < 100 ? volume + 10 : 100)) ;;
|
||||
down) new_volume=$((volume - 10 > 0 ? volume - 10 : 0)) ;;
|
||||
<0-100>) new_volume=$1 ;;
|
||||
*) echo "'$1' is not valid. Expected <0-100>, up or down."
|
||||
return 1 ;;
|
||||
esac
|
||||
opt="set sound volume to ${new_volume}"
|
||||
;;
|
||||
playlist)
|
||||
# Inspired by: https://gist.github.com/nakajijapan/ac8b45371064ae98ea7f
|
||||
if [[ -n "$playlist" ]]; then
|
||||
osascript 2>/dev/null <<EOF
|
||||
tell application "$APP_NAME"
|
||||
set new_playlist to "$playlist" as string
|
||||
play playlist new_playlist
|
||||
end tell
|
||||
EOF
|
||||
if [[ $? -eq 0 ]]; then
|
||||
opt="play"
|
||||
else
|
||||
opt="stop"
|
||||
fi
|
||||
else
|
||||
opt="set allPlaylists to (get name of every playlist)"
|
||||
fi
|
||||
;;
|
||||
playing|status)
|
||||
local currenttrack currentartist state=$(osascript -e "tell application \"$APP_NAME\" to player state as string")
|
||||
if [[ "$state" = "playing" ]]; then
|
||||
currenttrack=$(osascript -e "tell application \"$APP_NAME\" to name of current track as string")
|
||||
currentartist=$(osascript -e "tell application \"$APP_NAME\" to artist of current track as string")
|
||||
echo -E "Listening to ${fg[yellow]}${currenttrack}${reset_color} by ${fg[yellow]}${currentartist}${reset_color}"
|
||||
else
|
||||
echo "$APP_NAME is $state"
|
||||
fi
|
||||
return 0
|
||||
;;
|
||||
shuf|shuff|shuffle)
|
||||
# The shuffle property of current playlist can't be changed in iTunes 12,
|
||||
# so this workaround uses AppleScript to simulate user input instead.
|
||||
# Defaults to toggling when no options are given.
|
||||
# The toggle option depends on the shuffle button being visible in the Now playing area.
|
||||
# On and off use the menu bar items.
|
||||
local state=$1
|
||||
|
||||
if [[ -n "$state" && "$state" != (on|off|toggle) ]]; then
|
||||
print "Usage: $0 shuffle [on|off|toggle]. Invalid option."
|
||||
return 1
|
||||
fi
|
||||
|
||||
case "$state" in
|
||||
on|off)
|
||||
# Inspired by: https://stackoverflow.com/a/14675583
|
||||
osascript >/dev/null 2>&1 <<EOF
|
||||
tell application "System Events" to perform action "AXPress" of (menu item "${state}" of menu "Shuffle" of menu item "Shuffle" of menu "Controls" of menu bar item "Controls" of menu bar 1 of application process "iTunes" )
|
||||
EOF
|
||||
return 0
|
||||
;;
|
||||
toggle|*)
|
||||
osascript >/dev/null 2>&1 <<EOF
|
||||
tell application "System Events" to perform action "AXPress" of (button 2 of process "iTunes"'s window "iTunes"'s scroll area 1)
|
||||
EOF
|
||||
return 0
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
""|-h|--help)
|
||||
echo "Usage: $0 <option>"
|
||||
echo "option:"
|
||||
echo "\t-h|--help\tShow this message and exit"
|
||||
echo "\tlaunch|play|pause|stop|rewind|resume|quit"
|
||||
echo "\tmute|unmute\tMute or unmute $APP_NAME"
|
||||
echo "\tnext|previous\tPlay next or previous track"
|
||||
echo "\tshuf|shuffle [on|off|toggle]\tSet shuffled playback. Default: toggle. Note: toggle doesn't support the MiniPlayer."
|
||||
echo "\tvol [0-100|up|down]\tGet or set the volume. 0 to 100 sets the volume. 'up' / 'down' increases / decreases by 10 points. No argument displays current volume."
|
||||
echo "\tplaying|status\tShow what song is currently playing in Music."
|
||||
echo "\tplaylist [playlist name]\t Play specific playlist"
|
||||
return 0
|
||||
;;
|
||||
*)
|
||||
print "Unknown option: $opt"
|
||||
return 1
|
||||
;;
|
||||
esac
|
||||
osascript -e "tell application \"$APP_NAME\" to $opt"
|
||||
}
|
||||
|
||||
function _music() {
|
||||
local app_name
|
||||
case "$words[1]" in
|
||||
itunes) app_name="iTunes" ;;
|
||||
music|*) app_name="Music" ;;
|
||||
esac
|
||||
|
||||
local -a cmds subcmds
|
||||
cmds=(
|
||||
"launch:Launch the ${app_name} app"
|
||||
"play:Play ${app_name}"
|
||||
"pause:Pause ${app_name}"
|
||||
"stop:Stop ${app_name}"
|
||||
"rewind:Rewind ${app_name}"
|
||||
"resume:Resume ${app_name}"
|
||||
"quit:Quit ${app_name}"
|
||||
"mute:Mute the ${app_name} app"
|
||||
"unmute:Unmute the ${app_name} app"
|
||||
"next:Skip to the next song"
|
||||
"previous:Skip to the previous song"
|
||||
"vol:Change the volume"
|
||||
"playlist:Play a specific playlist"
|
||||
{playing,status}":Show what song is currently playing"
|
||||
{shuf,shuff,shuffle}":Set shuffle mode"
|
||||
{-h,--help}":Show usage"
|
||||
)
|
||||
|
||||
if (( CURRENT == 2 )); then
|
||||
_describe 'command' cmds
|
||||
elif (( CURRENT == 3 )); then
|
||||
case "$words[2]" in
|
||||
vol) subcmds=( 'up:Raise the volume' 'down:Lower the volume' )
|
||||
_describe 'command' subcmds ;;
|
||||
shuf|shuff|shuffle) subcmds=('on:Switch on shuffle mode' 'off:Switch off shuffle mode' 'toggle:Toggle shuffle mode (default)')
|
||||
_describe 'command' subcmds ;;
|
||||
esac
|
||||
elif (( CURRENT == 4 )); then
|
||||
case "$words[2]" in
|
||||
playlist) subcmds=('play:Play the playlist (default)' 'stop:Stop the playlist')
|
||||
_describe 'command' subcmds ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
compdef _music music itunes
|
||||
478
plugins/macos/spotify
Normal file
478
plugins/macos/spotify
Normal file
|
|
@ -0,0 +1,478 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
function spotify() {
|
||||
# Copyright (c) 2012--2019 Harish Narayanan <mail@harishnarayanan.org>
|
||||
#
|
||||
# Contains numerous helpful contributions from Jorge Colindres, Thomas
|
||||
# Pritchard, iLan Epstein, Gabriele Bonetti, Sean Heller, Eric Martin
|
||||
# and Peter Fonseca.
|
||||
|
||||
# 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.
|
||||
|
||||
USER_CONFIG_DEFAULTS="CLIENT_ID=\"\"\nCLIENT_SECRET=\"\"";
|
||||
USER_CONFIG_FILE="${HOME}/.shpotify.cfg";
|
||||
if ! [[ -f "${USER_CONFIG_FILE}" ]]; then
|
||||
touch "${USER_CONFIG_FILE}";
|
||||
echo -e "${USER_CONFIG_DEFAULTS}" > "${USER_CONFIG_FILE}";
|
||||
fi
|
||||
source "${USER_CONFIG_FILE}";
|
||||
|
||||
showAPIHelp() {
|
||||
echo;
|
||||
echo "Connecting to Spotify's API:";
|
||||
echo;
|
||||
echo " This command line application needs to connect to Spotify's API in order to";
|
||||
echo " find music by name. It is very likely you want this feature!";
|
||||
echo;
|
||||
echo " To get this to work, you need to sign up (or in) and create an 'Application' at:";
|
||||
echo " https://developer.spotify.com/my-applications/#!/applications/create";
|
||||
echo;
|
||||
echo " Once you've created an application, find the 'Client ID' and 'Client Secret'";
|
||||
echo " values, and enter them into your shpotify config file at '${USER_CONFIG_FILE}'";
|
||||
echo;
|
||||
echo " Be sure to quote your values and don't add any extra spaces!";
|
||||
echo " When done, it should look like this (but with your own values):";
|
||||
echo ' CLIENT_ID="abc01de2fghijk345lmnop"';
|
||||
echo ' CLIENT_SECRET="qr6stu789vwxyz"';
|
||||
}
|
||||
|
||||
showHelp () {
|
||||
echo "Usage:";
|
||||
echo;
|
||||
echo " `basename $0` <command>";
|
||||
echo;
|
||||
echo "Commands:";
|
||||
echo;
|
||||
echo " play # Resumes playback where Spotify last left off.";
|
||||
echo " play <song name> # Finds a song by name and plays it.";
|
||||
echo " play album <album name> # Finds an album by name and plays it.";
|
||||
echo " play artist <artist name> # Finds an artist by name and plays it.";
|
||||
echo " play list <playlist name> # Finds a playlist by name and plays it.";
|
||||
echo " play uri <uri> # Play songs from specific uri.";
|
||||
echo;
|
||||
echo " next # Skips to the next song in a playlist.";
|
||||
echo " prev # Returns to the previous song in a playlist.";
|
||||
echo " replay # Replays the current track from the beginning.";
|
||||
echo " pos <time> # Jumps to a time (in secs) in the current song.";
|
||||
echo " pause # Pauses (or resumes) Spotify playback.";
|
||||
echo " stop # Stops playback.";
|
||||
echo " quit # Stops playback and quits Spotify.";
|
||||
echo;
|
||||
echo " vol up # Increases the volume by 10%.";
|
||||
echo " vol down # Decreases the volume by 10%.";
|
||||
echo " vol <amount> # Sets the volume to an amount between 0 and 100.";
|
||||
echo " vol [show] # Shows the current Spotify volume.";
|
||||
echo;
|
||||
echo " status # Shows the current player status.";
|
||||
echo " status artist # Shows the currently playing artist.";
|
||||
echo " status album # Shows the currently playing album.";
|
||||
echo " status track # Shows the currently playing track.";
|
||||
echo;
|
||||
echo " share # Displays the current song's Spotify URL and URI."
|
||||
echo " share url # Displays the current song's Spotify URL and copies it to the clipboard."
|
||||
echo " share uri # Displays the current song's Spotify URI and copies it to the clipboard."
|
||||
echo;
|
||||
echo " toggle shuffle # Toggles shuffle playback mode.";
|
||||
echo " toggle repeat # Toggles repeat playback mode.";
|
||||
showAPIHelp
|
||||
}
|
||||
|
||||
cecho(){
|
||||
bold=$(tput bold);
|
||||
green=$(tput setaf 2);
|
||||
reset=$(tput sgr0);
|
||||
echo $bold$green"$1"$reset;
|
||||
}
|
||||
|
||||
showArtist() {
|
||||
echo `osascript -e 'tell application "Spotify" to artist of current track as string'`;
|
||||
}
|
||||
|
||||
showAlbum() {
|
||||
echo `osascript -e 'tell application "Spotify" to album of current track as string'`;
|
||||
}
|
||||
|
||||
showTrack() {
|
||||
echo `osascript -e 'tell application "Spotify" to name of current track as string'`;
|
||||
}
|
||||
|
||||
showStatus () {
|
||||
state=`osascript -e 'tell application "Spotify" to player state as string'`;
|
||||
cecho "Spotify is currently $state.";
|
||||
duration=`osascript -e 'tell application "Spotify"
|
||||
set durSec to (duration of current track / 1000) as text
|
||||
set tM to (round (durSec / 60) rounding down) as text
|
||||
if length of ((durSec mod 60 div 1) as text) is greater than 1 then
|
||||
set tS to (durSec mod 60 div 1) as text
|
||||
else
|
||||
set tS to ("0" & (durSec mod 60 div 1)) as text
|
||||
end if
|
||||
set myTime to tM as text & ":" & tS as text
|
||||
end tell
|
||||
return myTime'`;
|
||||
position=`osascript -e 'tell application "Spotify"
|
||||
set pos to player position
|
||||
set nM to (round (pos / 60) rounding down) as text
|
||||
if length of ((round (pos mod 60) rounding down) as text) is greater than 1 then
|
||||
set nS to (round (pos mod 60) rounding down) as text
|
||||
else
|
||||
set nS to ("0" & (round (pos mod 60) rounding down)) as text
|
||||
end if
|
||||
set nowAt to nM as text & ":" & nS as text
|
||||
end tell
|
||||
return nowAt'`;
|
||||
|
||||
echo -e $reset"Artist: $(showArtist)\nAlbum: $(showAlbum)\nTrack: $(showTrack) \nPosition: $position / $duration";
|
||||
}
|
||||
|
||||
if [ $# = 0 ]; then
|
||||
showHelp;
|
||||
else
|
||||
if [ ! -d /Applications/Spotify.app ] && [ ! -d $HOME/Applications/Spotify.app ]; then
|
||||
echo "The Spotify application must be installed."
|
||||
return 1
|
||||
fi
|
||||
|
||||
if [ $(osascript -e 'application "Spotify" is running') = "false" ]; then
|
||||
osascript -e 'tell application "Spotify" to activate' || return 1
|
||||
sleep 2
|
||||
fi
|
||||
fi
|
||||
while [ $# -gt 0 ]; do
|
||||
arg=$1;
|
||||
|
||||
case $arg in
|
||||
"play" )
|
||||
if [ $# != 1 ]; then
|
||||
# There are additional arguments, so find out how many
|
||||
array=( $@ );
|
||||
len=${#array[@]};
|
||||
SPOTIFY_SEARCH_API="https://api.spotify.com/v1/search";
|
||||
SPOTIFY_TOKEN_URI="https://accounts.spotify.com/api/token";
|
||||
if [ -z "${CLIENT_ID}" ]; then
|
||||
cecho "Invalid Client ID, please update ${USER_CONFIG_FILE}";
|
||||
showAPIHelp;
|
||||
return 1
|
||||
fi
|
||||
if [ -z "${CLIENT_SECRET}" ]; then
|
||||
cecho "Invalid Client Secret, please update ${USER_CONFIG_FILE}";
|
||||
showAPIHelp;
|
||||
return 1
|
||||
fi
|
||||
SHPOTIFY_CREDENTIALS=$(printf "${CLIENT_ID}:${CLIENT_SECRET}" | base64 | tr -d "\n"|tr -d '\r');
|
||||
SPOTIFY_PLAY_URI="";
|
||||
|
||||
getAccessToken() {
|
||||
cecho "Connecting to Spotify's API";
|
||||
|
||||
SPOTIFY_TOKEN_RESPONSE_DATA=$( \
|
||||
curl "${SPOTIFY_TOKEN_URI}" \
|
||||
--silent \
|
||||
-X "POST" \
|
||||
-H "Authorization: Basic ${SHPOTIFY_CREDENTIALS}" \
|
||||
-d "grant_type=client_credentials" \
|
||||
)
|
||||
if ! [[ "${SPOTIFY_TOKEN_RESPONSE_DATA}" =~ "access_token" ]]; then
|
||||
cecho "Authorization failed, please check ${USER_CONFG_FILE}"
|
||||
cecho "${SPOTIFY_TOKEN_RESPONSE_DATA}"
|
||||
showAPIHelp
|
||||
return 1
|
||||
fi
|
||||
SPOTIFY_ACCESS_TOKEN=$( \
|
||||
printf "${SPOTIFY_TOKEN_RESPONSE_DATA}" \
|
||||
| grep -E -o '"access_token":".*",' \
|
||||
| sed 's/"access_token"://g' \
|
||||
| sed 's/"//g' \
|
||||
| sed 's/,.*//g' \
|
||||
)
|
||||
}
|
||||
|
||||
searchAndPlay() {
|
||||
type="$1"
|
||||
Q="$2"
|
||||
|
||||
getAccessToken;
|
||||
|
||||
cecho "Searching ${type}s for: $Q";
|
||||
|
||||
SPOTIFY_PLAY_URI=$( \
|
||||
curl -s -G $SPOTIFY_SEARCH_API \
|
||||
-H "Authorization: Bearer ${SPOTIFY_ACCESS_TOKEN}" \
|
||||
-H "Accept: application/json" \
|
||||
--data-urlencode "q=$Q" \
|
||||
-d "type=$type&limit=1&offset=0" \
|
||||
| grep -E -o "spotify:$type:[a-zA-Z0-9]+" -m 1
|
||||
)
|
||||
echo "play uri: ${SPOTIFY_PLAY_URI}"
|
||||
}
|
||||
|
||||
case $2 in
|
||||
"list" )
|
||||
_args=${array[@]:2:$len};
|
||||
Q=$_args;
|
||||
|
||||
getAccessToken;
|
||||
|
||||
cecho "Searching playlists for: $Q";
|
||||
|
||||
results=$( \
|
||||
curl -s -G $SPOTIFY_SEARCH_API --data-urlencode "q=$Q" -d "type=playlist&limit=10&offset=0" -H "Accept: application/json" -H "Authorization: Bearer ${SPOTIFY_ACCESS_TOKEN}" \
|
||||
| grep -E -o "spotify:playlist:[a-zA-Z0-9]+" -m 10 \
|
||||
)
|
||||
|
||||
count=$( \
|
||||
echo "$results" | grep -c "spotify:playlist" \
|
||||
)
|
||||
|
||||
if [ "$count" -gt 0 ]; then
|
||||
random=$(( $RANDOM % $count));
|
||||
|
||||
SPOTIFY_PLAY_URI=$( \
|
||||
echo "$results" | awk -v random="$random" '/spotify:playlist:[a-zA-Z0-9]+/{i++}i==random{print; exit}' \
|
||||
)
|
||||
fi;;
|
||||
|
||||
"album" | "artist" | "track" )
|
||||
_args=${array[@]:2:$len};
|
||||
searchAndPlay $2 "$_args";;
|
||||
|
||||
"uri" )
|
||||
SPOTIFY_PLAY_URI=${array[@]:2:$len};;
|
||||
|
||||
* )
|
||||
_args=${array[@]:1:$len};
|
||||
searchAndPlay track "$_args";;
|
||||
esac
|
||||
|
||||
if [ "$SPOTIFY_PLAY_URI" != "" ]; then
|
||||
if [ "$2" = "uri" ]; then
|
||||
cecho "Playing Spotify URI: $SPOTIFY_PLAY_URI";
|
||||
else
|
||||
cecho "Playing ($Q Search) -> Spotify URI: $SPOTIFY_PLAY_URI";
|
||||
fi
|
||||
|
||||
osascript -e "tell application \"Spotify\" to play track \"$SPOTIFY_PLAY_URI\"";
|
||||
|
||||
else
|
||||
cecho "No results when searching for $Q";
|
||||
fi
|
||||
|
||||
else
|
||||
|
||||
# play is the only param
|
||||
cecho "Playing Spotify.";
|
||||
osascript -e 'tell application "Spotify" to play';
|
||||
fi
|
||||
break ;;
|
||||
|
||||
"pause" )
|
||||
state=`osascript -e 'tell application "Spotify" to player state as string'`;
|
||||
if [ $state = "playing" ]; then
|
||||
cecho "Pausing Spotify.";
|
||||
else
|
||||
cecho "Playing Spotify.";
|
||||
fi
|
||||
|
||||
osascript -e 'tell application "Spotify" to playpause';
|
||||
break ;;
|
||||
|
||||
"stop" )
|
||||
state=`osascript -e 'tell application "Spotify" to player state as string'`;
|
||||
if [ $state = "playing" ]; then
|
||||
cecho "Pausing Spotify.";
|
||||
osascript -e 'tell application "Spotify" to playpause';
|
||||
else
|
||||
cecho "Spotify is already stopped."
|
||||
fi
|
||||
|
||||
break ;;
|
||||
|
||||
"quit" ) cecho "Quitting Spotify.";
|
||||
osascript -e 'tell application "Spotify" to quit';
|
||||
break ;;
|
||||
|
||||
"next" ) cecho "Going to next track." ;
|
||||
osascript -e 'tell application "Spotify" to next track';
|
||||
showStatus;
|
||||
break ;;
|
||||
|
||||
"prev" ) cecho "Going to previous track.";
|
||||
osascript -e '
|
||||
tell application "Spotify"
|
||||
set player position to 0
|
||||
previous track
|
||||
end tell';
|
||||
showStatus;
|
||||
break ;;
|
||||
|
||||
"replay" ) cecho "Replaying current track.";
|
||||
osascript -e 'tell application "Spotify" to set player position to 0'
|
||||
break ;;
|
||||
|
||||
"vol" )
|
||||
vol=`osascript -e 'tell application "Spotify" to sound volume as integer'`;
|
||||
if [[ $2 = "" || $2 = "show" ]]; then
|
||||
cecho "Current Spotify volume level is $vol.";
|
||||
break ;
|
||||
elif [ "$2" = "up" ]; then
|
||||
if [ $vol -le 90 ]; then
|
||||
newvol=$(( vol+10 ));
|
||||
cecho "Increasing Spotify volume to $newvol.";
|
||||
else
|
||||
newvol=100;
|
||||
cecho "Spotify volume level is at max.";
|
||||
fi
|
||||
elif [ "$2" = "down" ]; then
|
||||
if [ $vol -ge 10 ]; then
|
||||
newvol=$(( vol-10 ));
|
||||
cecho "Reducing Spotify volume to $newvol.";
|
||||
else
|
||||
newvol=0;
|
||||
cecho "Spotify volume level is at min.";
|
||||
fi
|
||||
elif [[ $2 =~ ^[0-9]+$ ]] && [[ $2 -ge 0 && $2 -le 100 ]]; then
|
||||
newvol=$2;
|
||||
cecho "Setting Spotify volume level to $newvol";
|
||||
else
|
||||
echo "Improper use of 'vol' command"
|
||||
echo "The 'vol' command should be used as follows:"
|
||||
echo " vol up # Increases the volume by 10%.";
|
||||
echo " vol down # Decreases the volume by 10%.";
|
||||
echo " vol [amount] # Sets the volume to an amount between 0 and 100.";
|
||||
echo " vol # Shows the current Spotify volume.";
|
||||
return 1
|
||||
fi
|
||||
|
||||
osascript -e "tell application \"Spotify\" to set sound volume to $newvol";
|
||||
break ;;
|
||||
|
||||
"toggle" )
|
||||
if [ "$2" = "shuffle" ]; then
|
||||
osascript -e 'tell application "Spotify" to set shuffling to not shuffling';
|
||||
curr=`osascript -e 'tell application "Spotify" to shuffling'`;
|
||||
cecho "Spotify shuffling set to $curr";
|
||||
elif [ "$2" = "repeat" ]; then
|
||||
osascript -e 'tell application "Spotify" to set repeating to not repeating';
|
||||
curr=`osascript -e 'tell application "Spotify" to repeating'`;
|
||||
cecho "Spotify repeating set to $curr";
|
||||
fi
|
||||
break ;;
|
||||
|
||||
"status" )
|
||||
if [ $# != 1 ]; then
|
||||
# There are additional arguments, a status subcommand
|
||||
case $2 in
|
||||
"artist" )
|
||||
showArtist;
|
||||
break ;;
|
||||
|
||||
"album" )
|
||||
showAlbum;
|
||||
break ;;
|
||||
|
||||
"track" )
|
||||
showTrack;
|
||||
break ;;
|
||||
esac
|
||||
else
|
||||
# status is the only param
|
||||
showStatus;
|
||||
fi
|
||||
break ;;
|
||||
|
||||
"info" )
|
||||
info=`osascript -e 'tell application "Spotify"
|
||||
set durSec to (duration of current track / 1000)
|
||||
set tM to (round (durSec / 60) rounding down) as text
|
||||
if length of ((durSec mod 60 div 1) as text) is greater than 1 then
|
||||
set tS to (durSec mod 60 div 1) as text
|
||||
else
|
||||
set tS to ("0" & (durSec mod 60 div 1)) as text
|
||||
end if
|
||||
set myTime to tM as text & "min " & tS as text & "s"
|
||||
set pos to player position
|
||||
set nM to (round (pos / 60) rounding down) as text
|
||||
if length of ((round (pos mod 60) rounding down) as text) is greater than 1 then
|
||||
set nS to (round (pos mod 60) rounding down) as text
|
||||
else
|
||||
set nS to ("0" & (round (pos mod 60) rounding down)) as text
|
||||
end if
|
||||
set nowAt to nM as text & "min " & nS as text & "s"
|
||||
set info to "" & "\nArtist: " & artist of current track
|
||||
set info to info & "\nTrack: " & name of current track
|
||||
set info to info & "\nAlbum Artist: " & album artist of current track
|
||||
set info to info & "\nAlbum: " & album of current track
|
||||
set info to info & "\nSeconds: " & durSec
|
||||
set info to info & "\nSeconds played: " & pos
|
||||
set info to info & "\nDuration: " & mytime
|
||||
set info to info & "\nNow at: " & nowAt
|
||||
set info to info & "\nPlayed Count: " & played count of current track
|
||||
set info to info & "\nTrack Number: " & track number of current track
|
||||
set info to info & "\nPopularity: " & popularity of current track
|
||||
set info to info & "\nId: " & id of current track
|
||||
set info to info & "\nSpotify URL: " & spotify url of current track
|
||||
set info to info & "\nArtwork: " & artwork url of current track
|
||||
set info to info & "\nPlayer: " & player state
|
||||
set info to info & "\nVolume: " & sound volume
|
||||
set info to info & "\nShuffle: " & shuffling
|
||||
set info to info & "\nRepeating: " & repeating
|
||||
end tell
|
||||
return info'`
|
||||
cecho "$info";
|
||||
break ;;
|
||||
|
||||
"share" )
|
||||
uri=`osascript -e 'tell application "Spotify" to spotify url of current track'`;
|
||||
remove='spotify:track:'
|
||||
url=${uri#$remove}
|
||||
url="https://open.spotify.com/track/$url"
|
||||
|
||||
if [ "$2" = "" ]; then
|
||||
cecho "Spotify URL: $url"
|
||||
cecho "Spotify URI: $uri"
|
||||
echo "To copy the URL or URI to your clipboard, use:"
|
||||
echo "\`spotify share url\` or"
|
||||
echo "\`spotify share uri\` respectively."
|
||||
elif [ "$2" = "url" ]; then
|
||||
cecho "Spotify URL: $url";
|
||||
echo -n $url | pbcopy
|
||||
elif [ "$2" = "uri" ]; then
|
||||
cecho "Spotify URI: $uri";
|
||||
echo -n $uri | pbcopy
|
||||
fi
|
||||
break ;;
|
||||
|
||||
"pos" )
|
||||
cecho "Adjusting Spotify play position."
|
||||
osascript -e "tell application \"Spotify\" to set player position to $2";
|
||||
break ;;
|
||||
|
||||
"help" )
|
||||
showHelp;
|
||||
break ;;
|
||||
|
||||
* )
|
||||
showHelp;
|
||||
return 1 ;;
|
||||
|
||||
esac
|
||||
done
|
||||
}
|
||||
10
plugins/mongo-atlas/README.md
Normal file
10
plugins/mongo-atlas/README.md
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
# MongoDB Atlas plugin
|
||||
|
||||
This plugin adds completion for [Atlas](https://www.mongodb.com/docs/atlas/cli/stable/) a command line interface built specifically for
|
||||
MongoDB Atlas.
|
||||
|
||||
To use it, add `mongo-atlas` to the plugins array in your zshrc file:
|
||||
|
||||
```zsh
|
||||
plugins=(... mongo-atlas)
|
||||
```
|
||||
14
plugins/mongo-atlas/mongo-atlas.plugin.zsh
Normal file
14
plugins/mongo-atlas/mongo-atlas.plugin.zsh
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
# Autocompletion for the Mongo Atlas CLI (atlas).
|
||||
if (( ! $+commands[atlas] )); then
|
||||
return
|
||||
fi
|
||||
|
||||
# If the completion file doesn't exist yet, we need to autoload it and
|
||||
# bind it to `atlas`. Otherwise, compinit will have already done that.
|
||||
if [[ ! -f "$ZSH_CACHE_DIR/completions/_atlas" ]]; then
|
||||
typeset -g -A _comps
|
||||
autoload -Uz _atlas
|
||||
_comps[atlas]=_atlas
|
||||
fi
|
||||
|
||||
atlas completion zsh >| "$ZSH_CACHE_DIR/completions/atlas" &|
|
||||
22
plugins/multipass/README.md
Normal file
22
plugins/multipass/README.md
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
# multipass
|
||||
|
||||
This plugin provides completion for [multipass](https://multipass.run), as well as aliases
|
||||
for multipass commands.
|
||||
|
||||
To use it, add `multipass` to the plugins array in your zshrc file:
|
||||
|
||||
```zsh
|
||||
plugins=(... multipass)
|
||||
```
|
||||
|
||||
## Aliases
|
||||
|
||||
| Alias | Command |
|
||||
| ------ | ------------------------------------------------------------------- |
|
||||
| `mp` | `multipass` |
|
||||
| `mpl` | `multipass list` |
|
||||
| `mpla` | `multipass launch` |
|
||||
| `mpln` | `multipass launch --network en0 --network name=bridge0,mode=manual` |
|
||||
| `mps` | `multipass shell` |
|
||||
| `mpsp` | `multipass stop` |
|
||||
| `mpst` | `multipass start` |
|
||||
73
plugins/multipass/_multipass
Normal file
73
plugins/multipass/_multipass
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
#compdef multipass
|
||||
|
||||
_multipass_get_command_list () {
|
||||
# Sample output:
|
||||
# $ multipass --help
|
||||
# ...
|
||||
# Options:
|
||||
# -h, --help Display this help
|
||||
# -v, --verbose Increase logging verbosity. Repeat the 'v' in the short option
|
||||
# for more detail. Maximum verbosity is obtained with 4 (or more)
|
||||
# v's, i.e. -vvvv.
|
||||
# ...
|
||||
# Available commands:
|
||||
# alias Create an alias
|
||||
# aliases List available aliases
|
||||
# ...
|
||||
#
|
||||
$_comp_command1 --help | sed '1,/Available commands/d' | awk '/^[ \t]*[a-z]+/ { print $1 }'
|
||||
}
|
||||
|
||||
_multipass_get_args_list () {
|
||||
# Sample output:
|
||||
# $ multpass help stop
|
||||
# ...
|
||||
# Options:
|
||||
# -h, --help Display this help
|
||||
# -v, --verbose Increase logging verbosity. Repeat the 'v' in the short
|
||||
# option for more detail. Maximum verbosity is obtained with
|
||||
# 4 (or more) v's, i.e. -vvvv.
|
||||
# --all Stop all instances
|
||||
# -t, --time <time> Time from now, in minutes, to delay shutdown of the
|
||||
# instance
|
||||
# -c, --cancel Cancel a pending delayed shutdown
|
||||
#
|
||||
# Arguments:
|
||||
# name Names of instances to stop. If omitted, and without the
|
||||
# --all option, 'primary' will be assumed.
|
||||
#
|
||||
local arg_name=$($_comp_command1 help ${words[2]} | sed '1,/Arguments/d' | awk '/^[ \t]*[a-z]+/ { print $1; exit }')
|
||||
|
||||
case $arg_name in
|
||||
name)
|
||||
# Sample output:
|
||||
# $ multipass list
|
||||
# Name State IPv4 Image
|
||||
# workable-poacher Running 10.2.0.28 Ubuntu openHAB Home Appliance
|
||||
#
|
||||
$_comp_command1 list | sed '1d' | awk '/^[ \t]*[^ ]+/ { print $1 }'
|
||||
;;
|
||||
command)
|
||||
_multipass_get_command_list
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
_multipass () {
|
||||
typeset -A opt_args
|
||||
|
||||
_arguments \
|
||||
'1: :->command'\
|
||||
'*: :->args'
|
||||
|
||||
case $state in
|
||||
command)
|
||||
compadd $(_multipass_get_command_list)
|
||||
;;
|
||||
*)
|
||||
compadd $(_multipass_get_args_list)
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
_multipass "$@"
|
||||
7
plugins/multipass/multipass.plugin.zsh
Normal file
7
plugins/multipass/multipass.plugin.zsh
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
alias mp="multipass"
|
||||
alias mpl="multipass list"
|
||||
alias mpla="multipass launch"
|
||||
alias mpln="multipass launch --network en0 --network name=bridge0,mode=manual"
|
||||
alias mps="multipass shell"
|
||||
alias mpsp="multipass stop"
|
||||
alias mpst="multipass start"
|
||||
56
plugins/ng/_ng
Normal file
56
plugins/ng/_ng
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
#compdef ng
|
||||
|
||||
setopt localoptions extendedglob
|
||||
|
||||
if (( CURRENT == 2 )); then
|
||||
local -a cmds alias
|
||||
# Sample output (ng help):
|
||||
# Available Commands:
|
||||
# add Adds support for an external library to your project.
|
||||
for line in ${(@f)"$(ng help 2>/dev/null | sed -n '/^ /p')"}; do
|
||||
if [[ "$line" =~ '^ ([^ ]+) \(([^)]+)\) (.*)$' ]]; then
|
||||
alias=(${match[1]} ${(s:, :)match[2]})
|
||||
cmds+=(${^alias}:"${match[3]//:/}")
|
||||
elif [[ "$line" =~ '^ ([^ ]+) (.*)$' ]]; then
|
||||
cmds+=("${match[1]}:${match[2]//:/}")
|
||||
fi
|
||||
done
|
||||
_describe commands cmds && return 0
|
||||
elif (( CURRENT == 3 )); then
|
||||
local -a flags args
|
||||
local section description
|
||||
# Sample output (ng build --help):
|
||||
# --configuration (-c)
|
||||
# One or more named builder configurations as a comma-separated list as specified in the "configurations" section of angular.json.
|
||||
# The builder uses the named configurations to run the given target.
|
||||
# For more information, see https://angular.io/guide/workspace-config#alternate-build-configurations.
|
||||
# Prefix --flags with literal \0, and split on that to get each flag section
|
||||
for section in ${(s:\0:)"$(ng ${words[2]} --help 2>/dev/null | sed -e '1,/^options/ d;s/^ --/\\0--/')"}; do
|
||||
# Split by newline and discard extra description lines (lines > 2)
|
||||
for args description in ${${(@f)section}[1,2]}; do
|
||||
args=(${(s: :)${${args%% #}## #}//[(),]/})
|
||||
description=${${description%% #}## #}
|
||||
flags+=(${^args}":$description")
|
||||
done
|
||||
done
|
||||
_describe flags flags
|
||||
|
||||
case "$words[2]" in
|
||||
b|build|l|lint|t|test)
|
||||
# Sample output (ng config projects):
|
||||
# {
|
||||
# "angular-project-1": {
|
||||
# ...
|
||||
# },
|
||||
# "angular-project-2": {
|
||||
# ...
|
||||
# }
|
||||
# }
|
||||
# In absence of a proper JSON parser, just grab the lines with
|
||||
# a 2-space indentation and only the stuff inside quotes
|
||||
local -a projects
|
||||
projects=(${(@f)"$(ng config projects 2>/dev/null | sed -n 's/^ "\([^"]\+\)".*$/\1/p')"})
|
||||
_describe projects projects
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
12
plugins/octozen/README.md
Normal file
12
plugins/octozen/README.md
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
# Octozen plugin
|
||||
|
||||
Displays a zen quote from GitHub's Octocat on start up.
|
||||
|
||||
To use it, add `octozen` to the plugins array in your zshrc file:
|
||||
|
||||
```zsh
|
||||
plugins=(... octozen)
|
||||
```
|
||||
|
||||
It defines a `display_octozen` function that fetches a GitHub Octocat zen quote.
|
||||
NOTE: Internet connection is required (will time out if not fetched in 2 seconds).
|
||||
11
plugins/octozen/octozen.plugin.zsh
Normal file
11
plugins/octozen/octozen.plugin.zsh
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
# octozen plugin
|
||||
|
||||
# Displays a zen quote from octocat
|
||||
function display_octozen() {
|
||||
curl -m 2 -fsL "https://api.github.com/octocat"
|
||||
add-zsh-hook -d precmd display_octozen
|
||||
}
|
||||
|
||||
# Display the octocat on the first precmd, after the whole starting process has finished
|
||||
autoload -Uz add-zsh-hook
|
||||
add-zsh-hook precmd display_octozen
|
||||
11
plugins/operator-sdk/README.md
Normal file
11
plugins/operator-sdk/README.md
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
# Operator SDK
|
||||
|
||||
[Operator SDK](https://sdk.operatorframework.io/) is a component of the Operator Framework, an open source toolkit to manage Kubernetes native applications, called Operators, in an effective, automated, and scalable way.
|
||||
|
||||
To use it, add `operator-sdk` to the plugins array of your zshrc file:
|
||||
|
||||
```sh
|
||||
plugins=(... operator-sdk)
|
||||
```
|
||||
|
||||
|
||||
4
plugins/operator-sdk/operator-sdk.plugin.zsh
Normal file
4
plugins/operator-sdk/operator-sdk.plugin.zsh
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
if [ $commands[operator-sdk] ]; then
|
||||
source <(operator-sdk completion zsh)
|
||||
compdef _operator-sdk operator-sdk
|
||||
fi
|
||||
19
plugins/pm2/README.md
Normal file
19
plugins/pm2/README.md
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
# pm2 plugin
|
||||
|
||||
The plugin adds several aliases and completions for common [pm2](http://pm2.keymetrics.io/) commands.
|
||||
|
||||
To use it, add `pm2` to the plugins array of your zshrc file:
|
||||
```
|
||||
plugins=(... pm2)
|
||||
```
|
||||
|
||||
## Aliases
|
||||
|
||||
| Alias | Command |
|
||||
|--------|----------------------|
|
||||
| p2s | `pm2 start` |
|
||||
| p2o | `pm2 stop` |
|
||||
| p2d | `pm2 delete` |
|
||||
| p2r | `pm2 restart` |
|
||||
| p2i | `pm2 list` |
|
||||
| p2l | `pm2 logs` |
|
||||
168
plugins/pm2/_pm2
Normal file
168
plugins/pm2/_pm2
Normal file
|
|
@ -0,0 +1,168 @@
|
|||
#!/bin/zsh -f
|
||||
#compdef pm2
|
||||
#autoload
|
||||
|
||||
local -a _1st_arguments
|
||||
|
||||
_1st_arguments=(
|
||||
"start:start and daemonize an app"
|
||||
"trigger:trigger process action"
|
||||
"deploy:deploy your json"
|
||||
"startOrRestart:start or restart JSON file"
|
||||
"startOrReload:start or gracefully reload JSON file"
|
||||
"pid:return pid of [app_name] or all"
|
||||
"stop:stop a process"
|
||||
"restart:restart a process"
|
||||
"scale:scale up/down a process in cluster mode depending on total_number param"
|
||||
"profile\:mem:Sample PM2 heap memory"
|
||||
"profile\:cpu:Profile PM2 cpu"
|
||||
"reload:reload processes (note that its for app using HTTP/HTTPS)"
|
||||
"id:get process id by name"
|
||||
"inspect:inspect a process"
|
||||
"delete:stop and delete a process from pm2 process list"
|
||||
"sendSignal:send a system signal to the target process"
|
||||
"ping:ping pm2 daemon - if not up it will launch it"
|
||||
"updatePM2:update in-memory PM2 with local PM2"
|
||||
"install:install or update a module and run it forever"
|
||||
"module\:update:update a module and run it forever"
|
||||
"module\:generate:Generate a sample module in current folder"
|
||||
"uninstall:stop and uninstall a module"
|
||||
"package:Check & Package TAR type module"
|
||||
"publish:Publish the module you are currently on"
|
||||
"set:sets the specified config <key> <value>"
|
||||
"multiset:multiset eg \"key1 val1 key2 val2\""
|
||||
"get:get value for <key>"
|
||||
"config:get / set module config values"
|
||||
"unset:clears the specified config <key>"
|
||||
"report:give a full pm2 report for https\://github.com/Unitech/pm2/issues"
|
||||
"link:link with the pm2 monitoring dashboard"
|
||||
"unlink:unlink with the pm2 monitoring dashboard"
|
||||
"monitor:monitor target process"
|
||||
"unmonitor:unmonitor target process"
|
||||
"open:open the pm2 monitoring dashboard"
|
||||
"plus:enable pm2 plus"
|
||||
"login:Login to pm2 plus"
|
||||
"logout:Logout from pm2 plus"
|
||||
"web:launch a health API on 0.0.0.0\:9615"
|
||||
"dump:dump all processes for resurrecting them later"
|
||||
"cleardump:Create empty dump file"
|
||||
"send:send stdin to <pm_id>"
|
||||
"attach:attach stdin/stdout to application identified by <pm_id>"
|
||||
"resurrect:resurrect previously dumped processes"
|
||||
"unstartup:disable the pm2 startup hook"
|
||||
"startup:enable the pm2 startup hook"
|
||||
"logrotate:copy default logrotate configuration"
|
||||
"ecosystem:generate a process conf file. (mode = null or simple)"
|
||||
"reset:reset counters for process"
|
||||
"describe:describe all parameters of a process id"
|
||||
"list:list all processes"
|
||||
"jlist:list all processes in JSON format"
|
||||
"prettylist:print json in a prettified JSON"
|
||||
"monit:launch termcaps monitoring"
|
||||
"imonit:launch legacy termcaps monitoring"
|
||||
"dashboard:launch dashboard with monitoring and logs"
|
||||
"flush:flush logs"
|
||||
"reloadLogs:reload all logs"
|
||||
"logs:stream logs file. Default stream all logs"
|
||||
"kill:kill daemon"
|
||||
"pull:updates repository for a given app"
|
||||
"forward:updates repository to the next commit for a given app"
|
||||
"backward:downgrades repository to the previous commit for a given app"
|
||||
"deepUpdate:performs a deep update of PM2"
|
||||
"serve:serve a directory over http via port"
|
||||
"examples:display pm2 usage examples"
|
||||
)
|
||||
|
||||
local -a id_names
|
||||
|
||||
_id_names() {
|
||||
local app_list
|
||||
app_list=`pm2 list -m`
|
||||
|
||||
local -a names ids
|
||||
names=(`echo $app_list | grep '+---' | awk '{print $2}'`)
|
||||
ids=(`echo $app_list | grep 'pm2 id' | awk '{print $4}'`)
|
||||
|
||||
if (( ${#ids} > 0 )); then
|
||||
for i in {1..${#ids}}; do
|
||||
id_names+=( "${ids[i]}:${names[i]}" )
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
_arguments \
|
||||
'(-v --version)'{-v,--version}'[output version]' \
|
||||
'(-h --help)'{-h,--help}'[output usage information]' \
|
||||
'*:: :->subcmds' && return 0
|
||||
|
||||
if (( CURRENT == 1 )); then
|
||||
_describe "command" _1st_arguments
|
||||
return
|
||||
fi
|
||||
|
||||
local -a id_comp id_all_comp id_all_files_comp start_options logs_options
|
||||
id_comp=('1: :->id_comp')
|
||||
id_all_comp=('1: :->id_all_comp')
|
||||
id_all_files_comp=('1: :->id_all_files_comp')
|
||||
start_options=(
|
||||
'--watch[Watch folder for changes]'
|
||||
'--fresh[Rebuild Dockerfile]'
|
||||
'--daemon[Run container in Daemon mode (debug purposes)]'
|
||||
'--container[Start application in container mode]'
|
||||
'--dist[with --container; change local Dockerfile to containerize all files in current directory]'
|
||||
'--image-name[with --dist; set the exported image name]'
|
||||
'--node-version[with --container, set a specific major Node.js version]'
|
||||
'--dockerdaemon[for debugging purpose]'
|
||||
'(-h --help)'{-h,--help}'[output usage information]'
|
||||
$id_all_files_comp
|
||||
)
|
||||
logs_options=(
|
||||
'--json[json log output]'
|
||||
'--format[formatted log output]'
|
||||
'--raw[raw output]'
|
||||
'--err[only shows error output]'
|
||||
'--out[only shows standard output]'
|
||||
'--lines[output the last N lines, instead of the last 15 by default]'
|
||||
'--timestamp[add timestamps (default format YYYY-MM-DD-HH:mm:ss)]'
|
||||
'--nostream[print logs without launching the log stream]'
|
||||
'(-h --help)'{-h,--help}'[output usage information]'
|
||||
$id_all_comp
|
||||
)
|
||||
|
||||
case "$words[1]" in
|
||||
start)
|
||||
_arguments $start_options && return 0
|
||||
;;
|
||||
logs)
|
||||
_arguments $logs_options && return 0
|
||||
;;
|
||||
stop|restart|delete|reload|reset)
|
||||
_arguments $id_all_comp && return 0
|
||||
;;
|
||||
env|inspect|monitor|unmonitor|describe)
|
||||
_arguments $id_comp && return 0
|
||||
;;
|
||||
deploy|startOrRestart|startOrReload)
|
||||
_files ;;
|
||||
esac
|
||||
|
||||
case "$state" in
|
||||
id_comp)
|
||||
_id_names
|
||||
_alternative \
|
||||
'args:app args:(($id_names))'
|
||||
;;
|
||||
id_all_comp)
|
||||
_id_names
|
||||
id_names+=(all)
|
||||
_alternative \
|
||||
'args:app args:(($id_names))'
|
||||
;;
|
||||
id_all_files_comp)
|
||||
_id_names
|
||||
id_names+=(all)
|
||||
_alternative \
|
||||
'args:app args:(($id_names))' \
|
||||
'files:filename:_files'
|
||||
;;
|
||||
esac
|
||||
6
plugins/pm2/pm2.plugin.zsh
Normal file
6
plugins/pm2/pm2.plugin.zsh
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
alias p2s='pm2 start'
|
||||
alias p2o='pm2 stop'
|
||||
alias p2d='pm2 delete'
|
||||
alias p2r='pm2 restart'
|
||||
alias p2i='pm2 list'
|
||||
alias p2l='pm2 logs'
|
||||
9
plugins/poetry/README.md
Normal file
9
plugins/poetry/README.md
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
# Poetry Plugin
|
||||
|
||||
This plugin automatically installs [Poetry](https://python-poetry.org/)'s completions for you, and keeps them up to date as your Poetry version changes.
|
||||
|
||||
To use it, add `poetry` to the plugins array in your zshrc file:
|
||||
|
||||
```zsh
|
||||
plugins=(... poetry)
|
||||
```
|
||||
14
plugins/poetry/poetry.plugin.zsh
Normal file
14
plugins/poetry/poetry.plugin.zsh
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
# Return immediately if poetry is not found
|
||||
if (( ! $+commands[poetry] )); then
|
||||
return
|
||||
fi
|
||||
|
||||
# If the completion file doesn't exist yet, we need to autoload it and
|
||||
# bind it to `poetry`. Otherwise, compinit will have already done that.
|
||||
if [[ ! -f "$ZSH_CACHE_DIR/completions/_poetry" ]]; then
|
||||
typeset -g -A _comps
|
||||
autoload -Uz _poetry
|
||||
_comps[poetry]=_poetry
|
||||
fi
|
||||
|
||||
poetry completions zsh >| "$ZSH_CACHE_DIR/completions/_poetry" &|
|
||||
19
plugins/pre-commit/README.md
Normal file
19
plugins/pre-commit/README.md
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
# Pre-commit plugin
|
||||
|
||||
This plugin adds aliases for common commands of [pre-commit](https://pre-commit.com/).
|
||||
|
||||
To use this plugin, add it to the plugins array in your zshrc file:
|
||||
|
||||
```zsh
|
||||
plugins=(... pre-commit)
|
||||
```
|
||||
|
||||
## Aliases
|
||||
|
||||
| Alias | Command | Description |
|
||||
| ------- | -------------------------------------- | ------------------------------------------------------ |
|
||||
| prc | `pre-commit` | The `pre-commit` command |
|
||||
| prcau | `pre-commit autoupdate` | Update hooks automatically |
|
||||
| prcr | `pre-commit run` | The `pre-commit run` command |
|
||||
| prcra | `pre-commit run --all-files` | Run pre-commit hooks on all files |
|
||||
| prcrf | `pre-commit run --files` | Run pre-commit hooks on a given list of files |
|
||||
8
plugins/pre-commit/pre-commit.plugin.zsh
Normal file
8
plugins/pre-commit/pre-commit.plugin.zsh
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
# Aliases for pre-commit
|
||||
alias prc='pre-commit'
|
||||
|
||||
alias prcau='pre-commit autoupdate'
|
||||
|
||||
alias prcr='pre-commit run'
|
||||
alias prcra='pre-commit run --all-files'
|
||||
alias prcrf='pre-commit run --files'
|
||||
22
plugins/rbw/README.md
Normal file
22
plugins/rbw/README.md
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
# Bitwarden (unofficial) CLI plugin
|
||||
|
||||
This plugin adds completion for [rbw](https://github.com/doy/rbw), an unofficial
|
||||
CLI for [Bitwarden](https://bitwarden.com).
|
||||
|
||||
To use it, add `rbw` to the plugins array in your zshrc file:
|
||||
|
||||
```zsh
|
||||
plugins=(... rbw)
|
||||
```
|
||||
|
||||
## `rbwpw`
|
||||
|
||||
The `rbwpw` function is a wrapper around `rbw`. It copies the password in the
|
||||
clipboard for the service you ask for and clears the clipboard 20s later.
|
||||
The usage is as follows:
|
||||
|
||||
```zsh
|
||||
rbwpw <service>
|
||||
```
|
||||
|
||||
This plugin does not add any aliases.
|
||||
43
plugins/rbw/rbw.plugin.zsh
Normal file
43
plugins/rbw/rbw.plugin.zsh
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
if (( ! $+commands[rbw] )); then
|
||||
return
|
||||
fi
|
||||
|
||||
# If the completion file doesn't exist yet, we need to autoload it and
|
||||
# bind it to `rbw`. Otherwise, compinit will have already done that.
|
||||
if [[ ! -f "$ZSH_CACHE_DIR/completions/_rbw" ]]; then
|
||||
typeset -g -A _comps
|
||||
autoload -Uz _rbw
|
||||
_comps[rbw]=_rbw
|
||||
fi
|
||||
|
||||
rbw gen-completions zsh >| "$ZSH_CACHE_DIR/completions/_rbw" &|
|
||||
|
||||
# rbwpw function copies the password of a service to the clipboard
|
||||
# and clears it after 20 seconds
|
||||
function rbwpw {
|
||||
if [[ $# -ne 1 ]]; then
|
||||
echo "usage: rbwpw <service>"
|
||||
return 1
|
||||
fi
|
||||
local service=$1
|
||||
if ! rbw unlock; then
|
||||
echo "rbw is locked"
|
||||
return 1
|
||||
fi
|
||||
local pw=$(rbw get $service 2>/dev/null)
|
||||
if [[ -z $pw ]]; then
|
||||
echo "$service not found"
|
||||
return 1
|
||||
fi
|
||||
echo -n $pw | clipcopy
|
||||
echo "password for $service copied!"
|
||||
{sleep 20 && clipcopy </dev/null 2>/dev/null} &|
|
||||
}
|
||||
|
||||
function _rbwpw {
|
||||
local -a services
|
||||
services=("${(@f)$(rbw ls 2>/dev/null)}")
|
||||
[[ -n "$services" ]] && compadd -a -- services
|
||||
}
|
||||
|
||||
compdef _rbwpw rbwpw
|
||||
228
plugins/rust/_rustc
Normal file
228
plugins/rust/_rustc
Normal file
|
|
@ -0,0 +1,228 @@
|
|||
#compdef rustc
|
||||
|
||||
local -a _rustc_opts_switches _rustc_opts_lint _rustc_opts_debug
|
||||
|
||||
typeset -A opt_args
|
||||
|
||||
_rustc_debuginfo_levels=(
|
||||
"0[no debug info]"
|
||||
"1[line-tables only (for stacktraces and breakpoints)]"
|
||||
"2[full debug info with variable and type information (same as -g)]"
|
||||
)
|
||||
|
||||
_rustc_crate_types=(
|
||||
'bin'
|
||||
'lib'
|
||||
'rlib'
|
||||
'dylib'
|
||||
'cdylib'
|
||||
'staticlib'
|
||||
'proc-macro'
|
||||
)
|
||||
|
||||
_rustc_emit_types=(
|
||||
'asm'
|
||||
'llvm-bc'
|
||||
'llvm-ir'
|
||||
'obj'
|
||||
'metadata'
|
||||
'link'
|
||||
'dep-info'
|
||||
'mir'
|
||||
)
|
||||
_rustc_print_types=(
|
||||
'crate-name'
|
||||
'file-names'
|
||||
'sysroot'
|
||||
'cfg'
|
||||
'target-list'
|
||||
'target-cpus'
|
||||
'target-features'
|
||||
'relocation-models'
|
||||
'code-models'
|
||||
'target-spec-json'
|
||||
'native-static-libs'
|
||||
)
|
||||
_rustc_pretty_types=(
|
||||
'normal[un-annotated source]'
|
||||
'expanded[crates expanded]'
|
||||
'expanded,identified[fully parenthesized, AST nodes with IDs]'
|
||||
)
|
||||
_rustc_unpretty_types=(
|
||||
'normal[un-annotated source]'
|
||||
'expanded[crates expanded]'
|
||||
'expanded,identified[fully parenthesized, AST nodes with IDs]'
|
||||
'flowgraph=[graphviz formatted flowgraph for node]:NODEID:'
|
||||
'everybody_loops[all function bodies replaced with `loop {}`]'
|
||||
'hir[the HIR]'
|
||||
'hir,identified'
|
||||
'hir,typed[HIR with types for each node]'
|
||||
)
|
||||
_rustc_color_types=(
|
||||
'auto[colorize, if output goes to a tty (default)]'
|
||||
'always[always colorize output]'
|
||||
'never[never colorize output]'
|
||||
)
|
||||
_rustc_error_format=(
|
||||
'human'
|
||||
'json'
|
||||
)
|
||||
|
||||
_rustc_opts_vals=(
|
||||
--cfg='[Configure the compilation environment]:SPEC:'
|
||||
-L'[Add a directory to the library search path]:DIR:_files -/'
|
||||
--crate-name='[Specify the name of the crate being built]'
|
||||
--crate-type='[Comma separated list of types of crates for the compiler to emit]:TYPES:_values -s "," "Crate types" "$_rustc_crate_types[@]"'
|
||||
--emit='[Comma separated list of types of output for the compiler to emit]:TYPES:_values -s "," "Emit Targets" "$_rustc_emit_types[@]"'
|
||||
--print='[Comma separated list of compiler information to print on stdout]:TYPES:_values -s "," "Printable info" "$_rustc_print_types[@]"'
|
||||
-o'[Write output to <filename>. Ignored if more than one --emit is specified.]:FILENAME:_files'
|
||||
--out-dir='[Write output to compiler-chosen filename in <dir>. Ignored if -o is specified. (default the current directory)]:DIR:_files -/'
|
||||
--explain='[Provide a detailed explanation of an error message]:OPT:'
|
||||
--target='[Target triple cpu-manufacturer-kernel\[-os\] to compile]:TRIPLE:'
|
||||
--extern'[Specify where an external rust library is located]:ARG:'
|
||||
--sysroot='[Override the system root]:PATH:_files -/'
|
||||
--error-format='[How errors and other messages are produced]:TYPES:_values "$_rustc_error_format"'
|
||||
--debuginfo='[Emit DWARF debug info to the objects created]:LEVEL:_values "Debug Levels" "$_rustc_debuginfo_levels[@]"'
|
||||
--dep-info='[Output dependency info to <filename> after compiling]::FILE:_files -/'
|
||||
--opt-level='[Optimize with possible levels 0-3]:LEVEL:(0 1 2 3)'
|
||||
--pretty='[Pretty-print the input instead of compiling]::TYPE:_values "TYPES" "$_rustc_pretty_types[@]"'
|
||||
--unpretty='[Present the input source, unstable (and less-pretty)]::TYPE:_values "TYPES" "$_rustc_unpretty_types[@]"'
|
||||
--color='[Configure coloring of output]:CONF:_values "COLORS" "$_rustc_color_types[@]"'
|
||||
)
|
||||
|
||||
_rustc_opts_switches=(
|
||||
-g'[Equivalent to --debuginfo=2]'
|
||||
-O'[Equivalent to --opt-level=2]'
|
||||
--test'[Build a test harness]'
|
||||
{-v,--verbose}'[Use verbose output]'
|
||||
{-V,--version}'[Print version info and exit]'
|
||||
{-h,--help}'[Display this message]'
|
||||
--no-analysis'[Parse and expand the output, but run no analysis or produce output]'
|
||||
--no-trans'[Run all passes except translation; no output]'
|
||||
--parse-only'[Parse only; do not compile, assemble, or link]'
|
||||
--print-crate-name'[Output the crate name and exit]'
|
||||
--print-file-name'[Output the file(s) that would be written if compilation continued and exit]'
|
||||
)
|
||||
_rustc_opts_codegen=(
|
||||
'ar=[Path to the archive utility to use when assembling archives.]:BIN:_path_files'
|
||||
'linker=[Path to the linker utility to use when linking libraries, executables, and objects.]:BIN:_path_files'
|
||||
'link-args=[A space-separated list of extra arguments to pass to the linker when the linker is invoked.]:ARGS:'
|
||||
'target-cpu=[Selects a target processor. If the value is "help", then a list of available CPUs is printed.]:CPU:'
|
||||
'target-feature=[A space-separated list of features to enable or disable for the target. A preceding "+" enables a feature while a preceding "-" disables it. Available features can be discovered through target-cpu=help.]:FEATURE:'
|
||||
'passes=[A space-separated list of extra LLVM passes to run. A value of "list" will cause rustc to print all known passes and exit. The passes specified are appended at the end of the normal pass manager.]:LIST:'
|
||||
'llvm-args=[A space-separated list of arguments to pass through to LLVM.]:ARGS:'
|
||||
'save-temps[If specified, the compiler will save more files (.bc, .o, .no-opt.bc) generated throughout compilation in the output directory.]'
|
||||
'rpath[If specified, then the rpath value for dynamic libraries will be set in either dynamic library or executable outputs.]'
|
||||
'no-prepopulate-passes[Suppresses pre-population of the LLVM pass manager that is run over the module.]'
|
||||
'no-vectorize-loops[Suppresses running the loop vectorization LLVM pass, regardless of optimization level.]'
|
||||
'no-vectorize-slp[Suppresses running the LLVM SLP vectorization pass, regardless of optimization level.]'
|
||||
'soft-float[Generates software floating point library calls instead of hardware instructions.]'
|
||||
'prefer-dynamic[Prefers dynamic linking to static linking.]'
|
||||
"no-integrated-as[Force usage of an external assembler rather than LLVM's integrated one.]"
|
||||
'no-redzone[disable the use of the redzone]'
|
||||
'relocation-model=[The relocation model to use. (default: pic)]:MODEL:(pic static dynamic-no-pic)'
|
||||
'code-model=[choose the code model to use (llc -code-model for details)]:MODEL:'
|
||||
'metadata=[metadata to mangle symbol names with]:VAL:'
|
||||
'extra-filenames=[extra data to put in each output filename]:VAL:'
|
||||
'codegen-units=[divide crate into N units to optimize in parallel]:N:'
|
||||
'help[Show all codegen options]'
|
||||
)
|
||||
|
||||
_rustc_opts_lint=(
|
||||
'help[Show a list of all lints]'
|
||||
'experimental[detects use of #\[experimental\] items]'
|
||||
'heap-memory[use of any (Box type or @ type) heap memory]'
|
||||
'managed-heap-memory[use of managed (@ type) heap memory]'
|
||||
'missing-doc[detects missing documentation for public members]'
|
||||
'non-uppercase-statics[static constants should have uppercase identifiers]'
|
||||
'owned-heap-memory[use of owned (~ type) heap memory]'
|
||||
'unnecessary-qualification[detects unnecessarily qualified names]'
|
||||
'unsafe-block[usage of an `unsafe` block]'
|
||||
'unstable[detects use of #\[unstable\] items (incl. items with no stability attribute)]'
|
||||
'unused-result[unused result of an expression in a statement]'
|
||||
'variant-size-difference[detects enums with widely varying variant sizes]'
|
||||
'ctypes[proper use of libc types in foreign modules]'
|
||||
'dead-assignment[detect assignments that will never be read]'
|
||||
'dead-code[detect piece of code that will never be used]'
|
||||
'deprecated[detects use of #\[deprecated\] items]'
|
||||
'non-camel-case-types[types, variants and traits should have camel case names]'
|
||||
'non-snake-case[methods, functions, lifetime parameters and modules should have snake case names]'
|
||||
'path-statement[path statements with no effect]'
|
||||
'raw-pointer-deriving[uses of #\[deriving\] with raw pointers are rarely correct]'
|
||||
'type-limits[comparisons made useless by limits of the types involved]'
|
||||
'type-overflow[literal out of range for its type]'
|
||||
'unnecessary-allocation[detects unnecessary allocations that can be eliminated]'
|
||||
'unnecessary-parens[`if`, `match`, `while` and `return` do not need parentheses]'
|
||||
'unreachable-code[detects unreachable code]'
|
||||
'unrecognized-lint[unrecognized lint attribute]'
|
||||
'unsigned-negate[using an unary minus operator on unsigned type]'
|
||||
'unused-attribute[detects attributes that were not used by the compiler]'
|
||||
'unused-imports[imports that are never used]'
|
||||
'unused-must-use[unused result of a type flagged as #\[must_use\]]'
|
||||
"unused-mut[detect mut variables which don't need to be mutable]"
|
||||
'unused-unsafe[unnecessary use of an `unsafe` block]'
|
||||
'unused-variable[detect variables which are not used in any way]'
|
||||
'visible-private-types[detect use of private types in exported type signatures]'
|
||||
'warnings[mass-change the level for lints which produce warnings]'
|
||||
'while-true[suggest using `loop { }` instead of `while true { }`]'
|
||||
'unknown-crate-type[unknown crate type found in #\[crate_type\] directive]'
|
||||
'unknown-features[unknown features found in crate-level #\[feature\] directives]'
|
||||
'bad-style[group of non_camel_case_types, non_snake_case, non_uppercase_statics]'
|
||||
'unused[group of unused_imports, unused_variable, dead_assignment, dead_code, unused_mut, unreachable_code]'
|
||||
)
|
||||
|
||||
_rustc_opts_debug=(
|
||||
'verbose[in general, enable more debug printouts]'
|
||||
'span-free-formats[when debug-printing compiler state, do not include spans]'
|
||||
"identify-regions[make unnamed regions display as '# (where # is some non-ident unique id)]"
|
||||
'emit-end-regions[emit EndRegion as part of MIR; enable transforms that solely process EndRegion]'
|
||||
'time-passes[measure time of each rustc pass]'
|
||||
'count-llvm-insns[count where LLVM instrs originate]'
|
||||
'time-llvm-passes[measure time of each LLVM pass]'
|
||||
'trans-stats[gather trans statistics]'
|
||||
'asm-comments[generate comments into the assembly (may change behavior)]'
|
||||
'no-verify[skip LLVM verification]'
|
||||
'borrowck-stats[gather borrowck statistics]'
|
||||
'no-landing-pads[omit landing pads for unwinding]'
|
||||
'debug-llvm[enable debug output from LLVM]'
|
||||
'show-span[show spans for compiler debugging]'
|
||||
'count-type-sizes[count the sizes of aggregate types]'
|
||||
'meta-stats[gather metadata statistics]'
|
||||
'no-opt[do not optimize, even if -O is passed]'
|
||||
'print-link-args[Print the arguments passed to the linker]'
|
||||
'gc[Garbage collect shared data (experimental)]'
|
||||
'print-llvm-passes[Prints the llvm optimization passes being run]'
|
||||
'lto[Perform LLVM link-time optimizations]'
|
||||
'ast-json[Print the AST as JSON and halt]'
|
||||
'ast-json-noexpand[Print the pre-expansion AST as JSON and halt]'
|
||||
'ls[List the symbols defined by a library crate]'
|
||||
'save-analysis[Write syntax and type analysis information in addition to normal output]'
|
||||
'flowgraph-print-loans[Include loan analysis data in --pretty flowgraph output]'
|
||||
'flowgraph-print-moves[Include move analysis data in --pretty flowgraph output]'
|
||||
'flowgraph-print-assigns[Include assignment analysis data in --pretty flowgraph output]'
|
||||
'flowgraph-print-all[Include all dataflow analysis data in --pretty flowgraph output]'
|
||||
)
|
||||
|
||||
_rustc_opts_fun_lint(){
|
||||
_values -s , 'options' \
|
||||
"$_rustc_opts_lint[@]"
|
||||
}
|
||||
|
||||
_rustc_opts_fun_debug(){
|
||||
_values 'options' "$_rustc_opts_debug[@]"
|
||||
}
|
||||
|
||||
_rustc_opts_fun_codegen(){
|
||||
_values 'options' "$_rustc_opts_codegen[@]"
|
||||
}
|
||||
|
||||
_arguments -s : \
|
||||
'(-W --warn)'{-W,--warn=}'[Set lint warnings]:lint options:_rustc_opts_fun_lint' \
|
||||
'(-A --allow)'{-A,--allow=}'[Set lint allowed]:lint options:_rustc_opts_fun_lint' \
|
||||
'(-D --deny)'{-D,--deny=}'[Set lint denied]:lint options:_rustc_opts_fun_lint' \
|
||||
'(-F --forbid)'{-F,--forbid=}'[Set lint forbidden]:lint options:_rustc_opts_fun_lint' \
|
||||
'*-Z[Set internal debugging options]:debug options:_rustc_opts_fun_debug' \
|
||||
'*-C[Set internal Codegen options]:codegen options:_rustc_opts_fun_codegen' \
|
||||
"$_rustc_opts_switches[@]" \
|
||||
"$_rustc_opts_vals[@]" \
|
||||
'::files:_files -g "*.rs"'
|
||||
26
plugins/rust/rust.plugin.zsh
Normal file
26
plugins/rust/rust.plugin.zsh
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
if ! (( $+commands[rustup] && $+commands[cargo] )); then
|
||||
return
|
||||
fi
|
||||
|
||||
# If the completion file doesn't exist yet, we need to autoload it and
|
||||
# bind it to `cargo`. Otherwise, compinit will have already done that
|
||||
if [[ ! -f "$ZSH_CACHE_DIR/completions/_cargo" ]]; then
|
||||
autoload -Uz _cargo
|
||||
typeset -g -A _comps
|
||||
_comps[cargo]=_cargo
|
||||
fi
|
||||
|
||||
# If the completion file doesn't exist yet, we need to autoload it and
|
||||
# bind it to `rustup`. Otherwise, compinit will have already done that
|
||||
if [[ ! -f "$ZSH_CACHE_DIR/completions/_rustup" ]]; then
|
||||
autoload -Uz _rustup
|
||||
typeset -g -A _comps
|
||||
_comps[rustup]=_rustup
|
||||
fi
|
||||
|
||||
# Generate completion files in the background
|
||||
rustup completions zsh >| "$ZSH_CACHE_DIR/completions/_rustup" &|
|
||||
cat >| "$ZSH_CACHE_DIR/completions/_cargo" <<'EOF'
|
||||
#compdef cargo
|
||||
source "$(rustc +${${(z)$(rustup default)}[1]} --print sysroot)"/share/zsh/site-functions/_cargo
|
||||
EOF
|
||||
5
plugins/samtools/README.md
Normal file
5
plugins/samtools/README.md
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
# Samtools plugin
|
||||
|
||||
This plugin adds support for [samtools](http://www.htslib.org/):
|
||||
|
||||
* Adds autocomplete options for all samtools sub commands.
|
||||
40
plugins/samtools/_samtools
Normal file
40
plugins/samtools/_samtools
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
#compdef samtools
|
||||
#autoload
|
||||
|
||||
local curcontext="$curcontext" state line ret=1
|
||||
local -a _files
|
||||
|
||||
_arguments -C \
|
||||
'1: :->cmds' \
|
||||
'2:: :->args' && ret=0
|
||||
|
||||
case $state in
|
||||
cmds)
|
||||
_values "samtools command" \
|
||||
"view[SAM<->BAM conversion]" \
|
||||
"sort[sort alignment file]" \
|
||||
"mpileup[multi-way pileup]" \
|
||||
"depth[compute the depth]" \
|
||||
"faidx[index/extract FASTA]" \
|
||||
"tview[text alignment viewer]" \
|
||||
"index[index alignment]" \
|
||||
"idxstats[BAM index stats (r595 or later)]" \
|
||||
"fixmate[fix mate information]" \
|
||||
"flagstat[simple stats]" \
|
||||
"calmd[recalculate MD/NM tags and '=' bases]" \
|
||||
"merge[merge sorted alignments]" \
|
||||
"rmdup[remove PCR duplicates]" \
|
||||
"reheader[replace BAM header]" \
|
||||
"cat[concatenate BAMs]" \
|
||||
"bedcov[read depth per BED region]" \
|
||||
"targetcut[cut fosmid regions (for fosmid pool only)]" \
|
||||
"phase[phase heterozygotes]" \
|
||||
"bamshuf[shuffle and group alignments by name]"
|
||||
ret=0
|
||||
;;
|
||||
*)
|
||||
_files
|
||||
;;
|
||||
esac
|
||||
|
||||
return ret
|
||||
3
plugins/shell-proxy/.editorconfig
Normal file
3
plugins/shell-proxy/.editorconfig
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
[*.py]
|
||||
indent_size = 4
|
||||
indent_style = space
|
||||
13
plugins/sigstore/README.md
Normal file
13
plugins/sigstore/README.md
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
# Sigstore plugin
|
||||
|
||||
This plugin sets up completion for the following [Sigstore](https://sigstore.dev/) CLI tools.
|
||||
|
||||
- [Cosign](https://docs.sigstore.dev/cosign/overview)
|
||||
- [Sget](https://docs.sigstore.dev/cosign/installation#alpine-linux)
|
||||
- [Rekor](https://docs.sigstore.dev/rekor/overview)
|
||||
|
||||
To use it, add `sigstore` to the plugins array in your zshrc file:
|
||||
|
||||
```zsh
|
||||
plugins=(... sigstore)
|
||||
```
|
||||
22
plugins/sigstore/sigstore.plugin.zsh
Normal file
22
plugins/sigstore/sigstore.plugin.zsh
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
function install_autocompletion {
|
||||
if (( ! $+commands[$1] )); then
|
||||
return
|
||||
fi
|
||||
|
||||
# If the completion file doesn't exist yet, we need to autoload it and
|
||||
# bind it to `$1` (cosign, sget, rekor-cli). Otherwise, compinit will
|
||||
# have already done that
|
||||
if [[ ! -f "$ZSH_CACHE_DIR/completions/_$1" ]]; then
|
||||
autoload -Uz _$1
|
||||
typeset -g -A _comps
|
||||
_comps[$1]=_$1
|
||||
fi
|
||||
|
||||
$1 completion zsh >| "$ZSH_CACHE_DIR/completions/_$1" &|
|
||||
}
|
||||
|
||||
install_autocompletion cosign
|
||||
install_autocompletion sget
|
||||
install_autocompletion rekor-cli
|
||||
|
||||
unfunction install_autocompletion
|
||||
9
plugins/skaffold/README.md
Normal file
9
plugins/skaffold/README.md
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
# Skaffold plugin (Autocompletion)
|
||||
|
||||
This plugin adds completion for [Skaffold](https://skaffold.dev)
|
||||
|
||||
To use it, add `skaffold` to the plugins array in your zshrc file:
|
||||
|
||||
```zsh
|
||||
plugins=(... skaffold)
|
||||
```
|
||||
14
plugins/skaffold/skaffold.plugin.zsh
Normal file
14
plugins/skaffold/skaffold.plugin.zsh
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
# Autocompletion for skaffold
|
||||
if (( ! $+commands[skaffold] )); then
|
||||
return
|
||||
fi
|
||||
|
||||
# If the completion file doesn't exist yet, we need to autoload it and
|
||||
# bind it to `skaffold`. Otherwise, compinit will have already done that.
|
||||
if [[ ! -f "$ZSH_CACHE_DIR/completions/_skaffold" ]]; then
|
||||
typeset -g -A _comps
|
||||
autoload -Uz _skaffold
|
||||
_comps[skaffold]=_skaffold
|
||||
fi
|
||||
|
||||
skaffold completion zsh >| "$ZSH_CACHE_DIR/completions/_skaffold" &|
|
||||
25
plugins/toolbox/README.md
Normal file
25
plugins/toolbox/README.md
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
# toolbox plugin
|
||||
|
||||
Plugin for [toolbox](https://containertoolbx.org), a tool to use containerized CLI environments.
|
||||
|
||||
To use it, add `toolbox` to your plugins array in your `.zshrc` file:
|
||||
|
||||
```zsh
|
||||
plugins=(... toolbox)
|
||||
```
|
||||
|
||||
## Prompt function
|
||||
|
||||
This plugins adds `toolbox_prompt_info()` function. Using it in your prompt, it will show the toolbox indicator ⬢ (if you are running in a toolbox container), and nothing if not.
|
||||
|
||||
You can use it by adding `$(toolbox_prompt_info)` to your `PROMPT` or `RPROMPT` variable:
|
||||
|
||||
```zsh
|
||||
RPROMPT='$(toolbox_prompt_info)'
|
||||
```
|
||||
|
||||
## Aliases
|
||||
|
||||
| Alias | Command | Description |
|
||||
|-------|----------------------|----------------------------------------|
|
||||
| tb | `toolbox enter` | Enters the toolbox environment |
|
||||
5
plugins/toolbox/toolbox.plugin.zsh
Normal file
5
plugins/toolbox/toolbox.plugin.zsh
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
function toolbox_prompt_info() {
|
||||
[[ -f /run/.toolboxenv ]] && echo "⬢"
|
||||
}
|
||||
|
||||
alias tb="toolbox enter"
|
||||
11
plugins/volta/README.md
Normal file
11
plugins/volta/README.md
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
# Volta
|
||||
|
||||
This plugin provides completion for [Volta](https://volta.sh/).
|
||||
|
||||
To use it add volta to the plugins array in your zshrc file.
|
||||
|
||||
```bash
|
||||
plugins=(... volta)
|
||||
```
|
||||
|
||||
This plugin installs no aliases.
|
||||
14
plugins/volta/volta.plugin.zsh
Normal file
14
plugins/volta/volta.plugin.zsh
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
# COMPLETION FUNCTION
|
||||
if (( ! $+commands[volta] )); then
|
||||
return
|
||||
fi
|
||||
|
||||
# If the completion file doesn't exist yet, we need to autoload it and
|
||||
# bind it to `deno`. Otherwise, compinit will have already done that.
|
||||
if [[ ! -f "$ZSH_CACHE_DIR/completions/_volta" ]]; then
|
||||
typeset -g -A _comps
|
||||
autoload -Uz _volta
|
||||
_comps[volta]=_volta
|
||||
fi
|
||||
|
||||
volta completions zsh >| "$ZSH_CACHE_DIR/completions/_volta" &|
|
||||
21
plugins/z/LICENSE
Normal file
21
plugins/z/LICENSE
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2018-2022 Alexandros Kozak
|
||||
|
||||
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.
|
||||
343
plugins/z/MANUAL.md
Normal file
343
plugins/z/MANUAL.md
Normal file
|
|
@ -0,0 +1,343 @@
|
|||
# Zsh-z
|
||||
|
||||
Zsh-z is a command line tool that allows you to jump quickly to directories that you have visited frequently in the past, or recently -- but most often a combination of the two (a concept known as ["frecency"](https://en.wikipedia.org/wiki/Frecency)). It works by keeping track of when you go to directories and how much time you spend in them. It is then in the position to guess where you want to go when you type a partial string, e.g., `z src` might take you to `~/src/zsh`. `z zsh` might also get you there, and `z c/z` might prove to be even more specific -- it all depends on your habits and how much time you have been using Zsh-z to build up a database. After using Zsh-z for a little while, you will get to where you want to be by typing considerably less than you would need if you were using `cd`.
|
||||
|
||||
Zsh-z is a native Zsh port of [rupa/z](https://github.com/rupa/z), a tool written for `bash` and Zsh that uses embedded `awk` scripts to do the heavy lifting. It was quite possibly my most used command line tool for a couple of years. I decided to translate it, `awk` parts and all, into pure Zsh script, to see if by eliminating calls to external tools (`awk`, `sort`, `date`, `sed`, `mv`, `rm`, and `chown`) and reducing forking through subshells I could make it faster. The performance increase is impressive, particularly on systems where forking is slow, such as Cygwin, MSYS2, and WSL. I have found that, in those environments, switching directories using Zsh-z can be over 100% faster than it is using `rupa/z`.
|
||||
|
||||
There is a noteworthy stability increase as well. Race conditions have always been a problem with `rupa/z`, and users of that utility will occasionally lose their `.z` databases. By having Zsh-z only use Zsh (`rupa/z` uses a hybrid shell code that works on `bash` as well), I have been able to implement a `zsh/system`-based file-locking mechanism similar to [the one @mafredri once proposed for `rupa/z`](https://github.com/rupa/z/pull/199). It is now nearly impossible to crash the database, even through extreme testing.
|
||||
|
||||
There are other, smaller improvements which I try to document in [Improvements and Fixes](#improvements-and-fixes). These include the new default behavior of sorting your tab completions by frecency rather than just letting Zsh sort the raw results alphabetically (a behavior which can be restored if you like it -- [see below](#settings)).
|
||||
|
||||
Zsh-z is a drop-in replacement for `rupa/z` and will, by default, use the same database (`~/.z`), so you can go on using `rupa/z` when you launch `bash`.
|
||||
|
||||
## Table of Contents
|
||||
- [News](#news)
|
||||
- [Installation](#installation)
|
||||
- [Command Line Options](#command-line-options)
|
||||
- [Settings](#settings)
|
||||
- [Case Sensitivity](#case-sensitivity)
|
||||
- [`ZSHZ_UNCOMMON`](#zshz_uncommon)
|
||||
- [Making `--add` work for you](#making---add-work-for-you)
|
||||
- [Other Improvements and Fixes](#other-improvements-and-fixes)
|
||||
- [Migrating from Other Tools](#migrating-from-other-tools)
|
||||
- [`COMPLETE_ALIASES`](#complete_aliases)
|
||||
- [Known Bugs](#known-bugs)
|
||||
|
||||
## News
|
||||
|
||||
<details>
|
||||
<summary>Here are the latest features and updates.</summary>
|
||||
|
||||
- June 29, 2022
|
||||
+ Zsh-z is less likely to leave temporary files sitting around (props @mafredri).
|
||||
- June 27, 2022
|
||||
+ A bug was fixed which was preventing paths with spaces in them from being updated ([#61](https://github.com/agkozak/zsh-z/issues/61)).
|
||||
+ If writing to the temporary database file fails, the database will not be clobbered (props @mafredri).
|
||||
- December 19, 2021
|
||||
+ ZSH-z will now display tildes for `HOME` during completion when `ZSHZ_TILDE=1` has been set.
|
||||
- November 11, 2021
|
||||
+ A bug was fixed which was preventing ranks from being incremented.
|
||||
+ `--add` has been made to work with relative paths and has been documented for the user.
|
||||
- October 14, 2021
|
||||
+ Completions were being sorted alphabetically, rather than by rank; this error has been fixed.
|
||||
- September 25, 2021
|
||||
+ Orthographical change: "Zsh," not "ZSH."
|
||||
- September 23, 2021
|
||||
+ `z -xR` will now remove a directory *and its subdirectories* from the database.
|
||||
+ `z -x` and `z -xR` can now take an argument; without one, `PWD` is assumed.
|
||||
- September 7, 2021
|
||||
+ Fixed the unload function so that it removes the `$ZSHZ_CMD` alias (default: `z`).
|
||||
- August 27, 2021
|
||||
+ Using `print -v ... -f` instead of `print -v` to work around longstanding bug in Zsh involving `print -v` and multibyte strings.
|
||||
- August 13, 2021
|
||||
+ Fixed the explanation string printed during completion so that it may be formatted with `zstyle`.
|
||||
+ Zsh-z now declares `ZSHZ_EXCLUDE_DIRS` as an array with unique elements so that you do not have to.
|
||||
- July 29, 2021
|
||||
+ Temporarily disabling use of `print -v`, which seems to be mangling CJK multibyte strings.
|
||||
- July 27, 2021
|
||||
+ Internal escaping of path names now works with older versions of ZSH.
|
||||
+ Zsh-z now detects and discards any incomplete or incorrectly formattted database entries.
|
||||
- July 10, 2021
|
||||
+ Setting `ZSHZ_TRAILING_SLASH=1` makes it so that a search pattern ending in `/` can match the end of a path; e.g. `z foo/` can match `/path/to/foo`.
|
||||
- June 25, 2021
|
||||
+ Setting `ZSHZ_TILDE=1` displays the `HOME` directory as `~`.
|
||||
- May 7, 2021
|
||||
+ Setting `ZSHZ_ECHO=1` will cause Zsh-z to display the new path when you change directories.
|
||||
+ Better escaping of path names to deal paths containing the characters ``\`()[]``.
|
||||
- February 15, 2021
|
||||
+ Ranks are displayed the way `rupa/z` now displays them, i.e. as large integers. This should help Zsh-z to integrate with other tools.
|
||||
- January 31, 2021
|
||||
+ Zsh-z is now efficient enough that, on MSYS2 and Cygwin, it is faster to run it in the foreground than it is to fork a subshell for it.
|
||||
+ `_zshz_precmd` simply returns if `PWD` is `HOME` or in `ZSH_EXCLUDE_DIRS`, rather than waiting for `zshz` to do that.
|
||||
- January 17, 2021
|
||||
+ Made sure that the `PUSHD_IGNORE_DUPS` option is respected.
|
||||
- January 14, 2021
|
||||
+ The `z -h` help text now breaks at spaces.
|
||||
+ `z -l` was not working for Zsh version < 5.
|
||||
- January 11, 2021
|
||||
+ Major refactoring of the code.
|
||||
+ `z -lr` and `z -lt` work as expected.
|
||||
+ `EXTENDED_GLOB` has been disabled within the plugin to accomodate old-fashioned Windows directories with names such as `Progra~1`.
|
||||
+ Removed `zshelldoc` documentation.
|
||||
- January 6, 2021
|
||||
+ I have corrected the frecency routine so that it matches `rupa/z`'s math, but for the present, Zsh-z will continue to display ranks as 1/10000th of what they are in `rupa/z` -- [they had to multiply theirs by 10000](https://github.com/rupa/z/commit/f1f113d9bae9effaef6b1e15853b5eeb445e0712) to work around `bash`'s inadequacies at dealing with decimal fractions.
|
||||
- January 5, 2021
|
||||
+ If you try `z foo`, and `foo` is not in the database but `${PWD}/foo` is a valid directory, Zsh-z will `cd` to it.
|
||||
- December 22, 2020
|
||||
+ `ZSHZ_CASE`: when set to `ignore`, pattern matching is case-insensitive; when set to `smart`, patterns are matched case-insensitively when they are all lowercase and case-sensitively when they have uppercase characters in them (a behavior very much like Vim's `smartcase` setting).
|
||||
+ `ZSHZ_KEEP_DIRS` is an array of directory names that should not be removed from the database, even if they are not currently available (useful when a drive is not always mounted).
|
||||
+ Symlinked datafiles were having their symlinks overwritten; this bug has been fixed.
|
||||
|
||||
</details>
|
||||
|
||||
## Installation
|
||||
|
||||
### General observations
|
||||
|
||||
This script can be installed simply by downloading it and sourcing it from your `.zshrc`:
|
||||
|
||||
source /path/to/zsh-z.plugin.zsh
|
||||
|
||||
For tab completion to work, you will want to have loaded `compinit`. The frameworks handle this themselves. If you are not using a framework, put
|
||||
|
||||
autoload -U compinit && compinit
|
||||
|
||||
in your .zshrc somewhere below where you source `zsh-z.plugin.zsh`.
|
||||
|
||||
If you add
|
||||
|
||||
zstyle ':completion:*' menu select
|
||||
|
||||
to your `.zshrc`, your completion menus will look very nice. This `zstyle` invocation should work with any of the frameworks below as well.
|
||||
|
||||
### For [antigen](https://github.com/zsh-users/antigen) users
|
||||
|
||||
Add the line
|
||||
|
||||
antigen bundle agkozak/zsh-z
|
||||
|
||||
to your `.zshrc`, somewhere above the line that says `antigen apply`.
|
||||
|
||||
### For [oh-my-zsh](http://ohmyz.sh/) users
|
||||
|
||||
Execute the following command:
|
||||
|
||||
git clone https://github.com/agkozak/zsh-z ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-z
|
||||
|
||||
and add `zsh-z` to the line of your `.zshrc` that specifies `plugins=()`, e.g., `plugins=( git zsh-z )`.
|
||||
|
||||
### For [prezto](https://github.com/sorin-ionescu/prezto) users
|
||||
|
||||
Execute the following command:
|
||||
|
||||
git clone https://github.com/agkozak/zsh-z.git ~/.zprezto-contrib/zsh-z
|
||||
|
||||
Then edit your `~/.zpreztorc` file. Make sure the line that says
|
||||
|
||||
zstyle ':prezto:load' pmodule-dirs $HOME/.zprezto-contrib
|
||||
|
||||
is uncommented. Then find the section that specifies which modules are to be loaded; it should look something like this:
|
||||
|
||||
zstyle ':prezto:load' pmodule \
|
||||
'environment' \
|
||||
'terminal' \
|
||||
'editor' \
|
||||
'history' \
|
||||
'directory' \
|
||||
'spectrum' \
|
||||
'utility' \
|
||||
'completion' \
|
||||
'prompt'
|
||||
|
||||
Add a backslash to the end of the last line add `'zsh-z'` to the list, e.g.,
|
||||
|
||||
zstyle ':prezto:load' pmodule \
|
||||
'environment' \
|
||||
'terminal' \
|
||||
'editor' \
|
||||
'history' \
|
||||
'directory' \
|
||||
'spectrum' \
|
||||
'utility' \
|
||||
'completion' \
|
||||
'prompt' \
|
||||
'zsh-z'
|
||||
|
||||
Then relaunch `zsh`.
|
||||
|
||||
### For [zcomet](https://github.com/agkozak/zcomet) users
|
||||
|
||||
Simply add
|
||||
|
||||
zcomet load agkozak/zsh-z
|
||||
|
||||
to your `.zshrc` (below where you source `zcomet.zsh` and above where you run `zcomet compinit`).
|
||||
|
||||
### For [zgen](https://github.com/tarjoilija/zgen) users
|
||||
|
||||
Add the line
|
||||
|
||||
zgen load agkozak/zsh-z
|
||||
|
||||
somewhere above the line that says `zgen save`. Then run
|
||||
|
||||
zgen reset
|
||||
zsh
|
||||
|
||||
to refresh your init script.
|
||||
|
||||
### For [Zim](https://github.com/zimfw/zimfw)
|
||||
|
||||
Add the following line to your `.zimrc`:
|
||||
|
||||
zmodule https://github.com/agkozak/zsh-z
|
||||
|
||||
Then run
|
||||
|
||||
zimfw install
|
||||
|
||||
and restart your shell.
|
||||
|
||||
### For [Zinit](https://github.com/zdharma-continuum/zinit) users
|
||||
|
||||
Add the line
|
||||
|
||||
zinit load agkozak/zsh-z
|
||||
|
||||
to your `.zshrc`.
|
||||
|
||||
`zsh-z` supports `zinit`'s `unload` feature; just run `zinit unload agkozak/zshz` to restore the shell to its state before `zsh-z` was loaded.
|
||||
|
||||
### For [Znap](https://github.com/marlonrichert/zsh-snap) users
|
||||
|
||||
Add the line
|
||||
|
||||
znap source agkozak/zsh-z
|
||||
|
||||
somewhere below the line where you `source` Znap itself.
|
||||
|
||||
### For [zplug](https://github.com/zplug/zplug) users
|
||||
|
||||
Add the line
|
||||
|
||||
zplug "agkozak/zsh-z"
|
||||
|
||||
somewhere above the line that says `zplug load`. Then run
|
||||
|
||||
zplug install
|
||||
zplug load
|
||||
|
||||
to install `zsh-z`.
|
||||
|
||||
## Command Line Options
|
||||
|
||||
- `--add` Add a directory to the database
|
||||
- `-c` Only match subdirectories of the current directory
|
||||
- `-e` Echo the best match without going to it
|
||||
- `-h` Display help
|
||||
- `-l` List all matches without going to them
|
||||
- `-r` Match by rank (i.e. how much time you spend in directories)
|
||||
- `-t` Time -- match by how recently you have been to directories
|
||||
- `-x` Remove a directory (by default, the current directory) from the database
|
||||
- `-xR` Remove a directory (by default, the current directory) and its subdirectories from the database
|
||||
|
||||
# Settings
|
||||
|
||||
Zsh-z has environment variables (they all begin with `ZSHZ_`) that change its behavior if you set them; you can also keep your old ones if you have been using `rupa/z` (they begin with `_Z_`).
|
||||
|
||||
* `ZSHZ_CMD` changes the command name (default: `z`)
|
||||
* `ZSHZ_COMPLETION` can be `'frecent'` (default) or `'legacy'`, depending on whether you want your completion results sorted according to frecency or simply sorted alphabetically
|
||||
* `ZSHZ_DATA` changes the database file (default: `~/.z`)
|
||||
* `ZSHZ_ECHO` displays the new path name when changing directories (default: `0`)
|
||||
* `ZSHZ_EXCLUDE_DIRS` is an array of directories to keep out of the database (default: empty)
|
||||
* `ZSHZ_KEEP_DIRS` is an array of directories that should not be removed from the database, even if they are not currently available (useful when a drive is not always mounted) (default: empty)
|
||||
* `ZSHZ_MAX_SCORE` is the maximum combined score the database entries can have before they begin to age and potentially drop out of the database (default: 9000)
|
||||
* `ZSHZ_NO_RESOLVE_SYMLINKS` prevents symlink resolution (default: `0`)
|
||||
* `ZSHZ_OWNER` allows usage when in `sudo -s` mode (default: empty)
|
||||
* `ZSHZ_TILDE` displays the name of the `HOME` directory as a `~` (default: `0`)
|
||||
* `ZSHZ_TRAILING_SLASH` makes it so that a search pattern ending in `/` can match the final element in a path; e.g., `z foo/` can match `/path/to/foo` (default: `0`)
|
||||
* `ZSHZ_UNCOMMON` changes the logic used to calculate the directory jumped to; [see below](#zshz_uncommon`) (default: `0`)
|
||||
|
||||
## Case sensitivity
|
||||
|
||||
The default behavior of Zsh-z is to try to find a case-sensitive match. If there is none, then Zsh-z tries to find a case-insensitive match.
|
||||
|
||||
Some users prefer simple case-insensitivity; this behavior can be enabled by setting
|
||||
|
||||
ZSHZ_CASE=ignore
|
||||
|
||||
If you like Vim's `smartcase` setting, where lowercase patterns are case-insensitive while patterns with any uppercase characters are treated case-sensitively, try setting
|
||||
|
||||
ZSHZ_CASE=smart
|
||||
|
||||
## `ZSHZ_UNCOMMON`
|
||||
|
||||
A common complaint about the default behavior of `rupa/z` and Zsh-z involves "common prefixes." If you type `z code` and the best matches, in increasing order, are
|
||||
|
||||
/home/me/code/foo
|
||||
/home/me/code/bar
|
||||
/home/me/code/bat
|
||||
|
||||
Zsh-z will see that all possible matches share a common prefix and will send you to that directory -- `/home/me/code` -- which is often a desirable result. But if the possible matches are
|
||||
|
||||
/home/me/.vscode/foo
|
||||
/home/me/code/foo
|
||||
/home/me/code/bar
|
||||
/home/me/code/bat
|
||||
|
||||
then there is no common prefix. In this case, `z code` will simply send you to the highest-ranking match, `/home/me/code/bat`.
|
||||
|
||||
You may enable an alternate, experimental behavior by setting `ZSHZ_UNCOMMON=1`. If you do that, Zsh-z will not jump to a common prefix, even if one exists. Instead, it chooses the highest-ranking match -- but it drops any subdirectories that do not include the search term. So if you type `z bat` and `/home/me/code/bat` is the best match, that is exactly where you will end up. If, however, you had typed `z code` and the best match was also `/home/me/code/bat`, you would have ended up in `/home/me/code` (because `code` was what you had searched for). This feature is still in development, and feedback is welcome.
|
||||
|
||||
## Making `--add` Work for You
|
||||
|
||||
Zsh-z internally uses the `--add` option to add paths to its database. @zachriggle pointed out to me that users might want to use `--add` themselves, so I have altered it a little to make it more user-friendly.
|
||||
|
||||
A good example might involve a directory tree that has Git repositories within it. The working directories could be added to the Zsh-z database as a batch with
|
||||
|
||||
for i in $(find $PWD -maxdepth 3 -name .git -type d); do
|
||||
z --add ${i:h}
|
||||
done
|
||||
|
||||
(As a Zsh user, I tend to use `**` instead of `find`, but it is good to see how deep your directory trees go before doing that.)
|
||||
|
||||
|
||||
## Other Improvements and Fixes
|
||||
|
||||
* `z -x` works, with the help of `chpwd_functions`.
|
||||
* Zsh-z works on Solaris.
|
||||
* Zsh-z uses the "new" `zshcompsys` completion system instead of the old `compctl` one.
|
||||
* There is no error message when the database file has not yet been created.
|
||||
* There is support for special characters (e.g., `[`) in directory names.
|
||||
* If `z -l` only returns one match, a common root is not printed.
|
||||
* Exit status codes increasingly make sense.
|
||||
* Completions work with options `-c`, `-r`, and `-t`.
|
||||
* If `~/foo` and `~/foob` are matches, `~/foo` is *not* the common root. Only a common parent directory can be a common root.
|
||||
* `z -x` and the new, recursive `z -xR` can take an argument so that you can remove directories other than `PWD` from the database.
|
||||
|
||||
## Migrating from Other Tools
|
||||
|
||||
Zsh-z's database format is identical to that of `rupa/z`. You may switch freely between the two tools (I still use `rupa/z` for `bash`). `fasd` also uses that database format, but it stores it by default in `~/.fasd`, so you will have to `cp ~/.fasd ~/.z` if you want to use your old directory history.
|
||||
|
||||
If you are coming to Zsh-z (or even to the original `rupa/z`, for that matter) from `autojump`, try using my [`jumpstart-z`](https://github.com/agkozak/jumpstart-z/blob/master/jumpstart-z) tool to convert your old database to the Zsh-z format, or simply run
|
||||
|
||||
awk -F "\t" '{printf("%s|%0.f|%s\n", $2, $1, '"$(date +%s)"')}' < /path/to/autojump.txt > ~/.z
|
||||
|
||||
## `COMPLETE_ALIASES`
|
||||
|
||||
`z`, or any alternative you set up using `$ZSH_CMD` or `$_Z_CMD`, is an alias. `setopt COMPLETE_ALIASES` divorces the tab completion for aliases from the underlying commands they invoke, so if you enable `COMPLETE_ALIASES`, tab completion for Zsh-z will be broken. You can get it working again, however, by adding under
|
||||
|
||||
setopt COMPLETE_ALIASES
|
||||
|
||||
the line
|
||||
|
||||
compdef _zshz ${ZSHZ_CMD:-${_Z_CMD:-z}}
|
||||
|
||||
That will re-bind `z` or the command of your choice to the underlying Zsh-z function.
|
||||
|
||||
## Known Bugs
|
||||
It is possible to run a completion on a string with spaces in it, e.g., `z us bi<TAB>` might take you to `/usr/local/bin`. This works, but as things stand, after the completion the command line reads
|
||||
|
||||
z us /usr/local/bin.
|
||||
|
||||
You get where you want to go, but the detritus on the command line is annoying. This is also a problem in `rupa/z`, but I am keen on eventually eliminating this glitch. Advice is welcome.
|
||||
82
plugins/z/_z
Normal file
82
plugins/z/_z
Normal file
|
|
@ -0,0 +1,82 @@
|
|||
#compdef zshz ${ZSHZ_CMD:-${_Z_CMD:-z}}
|
||||
#
|
||||
# Zsh-z - jump around with Zsh - A native Zsh version of z without awk, sort,
|
||||
# date, or sed
|
||||
#
|
||||
# https://github.com/agkozak/zsh-z
|
||||
#
|
||||
# Copyright (c) 2018-2022 Alexandros Kozak
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
# z (https://github.com/rupa/z) is copyright (c) 2009 rupa deadwyler and
|
||||
# licensed under the WTFPL license, Version 2.a
|
||||
#
|
||||
# shellcheck shell=ksh
|
||||
|
||||
############################################################
|
||||
# Zsh-z COMPLETIONS
|
||||
############################################################
|
||||
emulate -L zsh
|
||||
(( ZSHZ_DEBUG )) &&
|
||||
setopt LOCAL_OPTIONS WARN_CREATE_GLOBAL NO_WARN_NESTED_VAR 2> /dev/null
|
||||
|
||||
# TODO: This routine currently reproduces z's feature of allowing spaces to be
|
||||
# used as wildcards in completions, so that
|
||||
#
|
||||
# z us lo bi
|
||||
#
|
||||
# can expand to
|
||||
#
|
||||
# z /usr/local/bin
|
||||
#
|
||||
# but it also reproduces z's buggy display on the commandline, viz.
|
||||
#
|
||||
# z us lo /usr/local/bin
|
||||
#
|
||||
# Address.
|
||||
|
||||
local completions expl completion
|
||||
local -a completion_list
|
||||
|
||||
completions=$(zshz --complete ${(@)words:1})
|
||||
[[ -z $completions ]] && return 1
|
||||
|
||||
for completion in ${(f)completions[@]}; do
|
||||
if (( ZSHZ_TILDE )) && [[ $completion == ${HOME}* ]]; then
|
||||
completion="~${(q)${completion#${HOME}}}"
|
||||
else
|
||||
completion="${(q)completion}"
|
||||
fi
|
||||
completion_list+=( $completion )
|
||||
done
|
||||
|
||||
_description -V completion_list expl 'directories'
|
||||
|
||||
if [[ $ZSHZ_COMPLETION == 'legacy' ]]; then
|
||||
compadd "${expl[@]}" -QU -- "${completion_list[@]}"
|
||||
else
|
||||
compadd "${expl[@]}" -QU -V zsh-z -- "${completion_list[@]}"
|
||||
fi
|
||||
|
||||
compstate[insert]=menu
|
||||
|
||||
return 0
|
||||
|
||||
# vim: ft=zsh:fdm=indent:ts=2:et:sts=2:sw=2:
|
||||
14
plugins/zoxide/README.md
Normal file
14
plugins/zoxide/README.md
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
# zoxide plugin
|
||||
|
||||
Initializes [zoxide](https://github.com/ajeetdsouza/zoxide), a smarter cd
|
||||
command for your terminal.
|
||||
|
||||

|
||||
|
||||
To use it, add `zoxide` to the plugins array in your `.zshrc` file:
|
||||
|
||||
```zsh
|
||||
plugins=(... zoxide)
|
||||
```
|
||||
|
||||
**Note:** you have to [install zoxide](https://github.com/ajeetdsouza/zoxide#step-1-install-zoxide) first.
|
||||
5
plugins/zoxide/zoxide.plugin.zsh
Normal file
5
plugins/zoxide/zoxide.plugin.zsh
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
if (( $+commands[zoxide] )); then
|
||||
eval "$(zoxide init zsh)"
|
||||
else
|
||||
echo '[oh-my-zsh] zoxide not found, please install it from https://github.com/ajeetdsouza/zoxide'
|
||||
fi
|
||||
35
plugins/zsh-navigation-tools/doc/generate_single_file
Executable file
35
plugins/zsh-navigation-tools/doc/generate_single_file
Executable file
|
|
@ -0,0 +1,35 @@
|
|||
#!/bin/zsh
|
||||
|
||||
local PLUGIN_FILE="doc/zshnavigationtools.plugin.zsh"
|
||||
|
||||
[ -d doc ] || cd ..
|
||||
|
||||
rm -vf "$PLUGIN_FILE"
|
||||
echo "# The preamble comments apply when using ZNT as autoload functions" >>"$PLUGIN_FILE"
|
||||
echo "# https://github.com/psprint/zsh-navigation-tools" >>"$PLUGIN_FILE"
|
||||
echo "# License is GPLv3 and MIT" >>"$PLUGIN_FILE"
|
||||
echo -n "# " >>"$PLUGIN_FILE"
|
||||
git show-ref master | head -1 >>"$PLUGIN_FILE"
|
||||
echo >>"$PLUGIN_FILE"
|
||||
|
||||
for i in n-*(on); do
|
||||
echo "$i() {" >>"$PLUGIN_FILE"
|
||||
cat "$i" >>"$PLUGIN_FILE"
|
||||
echo "}" >>"$PLUGIN_FILE"
|
||||
echo "alias n${i#n-}=$i" >>"$PLUGIN_FILE"
|
||||
echo >>"$PLUGIN_FILE"
|
||||
done
|
||||
|
||||
# Append znt-* files
|
||||
for i in znt-*(on); do
|
||||
echo "$i() {" >>"$PLUGIN_FILE"
|
||||
cat "$i" >>"$PLUGIN_FILE"
|
||||
echo "}" >>"$PLUGIN_FILE"
|
||||
echo >>"$PLUGIN_FILE"
|
||||
done
|
||||
|
||||
# Append ^R bind
|
||||
echo "zle -N znt-history-widget" >>"$PLUGIN_FILE"
|
||||
echo "bindkey '^R' znt-history-widget" >>"$PLUGIN_FILE"
|
||||
echo "setopt AUTO_PUSHD HIST_IGNORE_DUPS PUSHD_IGNORE_DUPS" >>"$PLUGIN_FILE"
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue