mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2024-11-27 00:00:08 +00:00
Merge branch 'ohmyzsh:master' into master
This commit is contained in:
commit
1b5f65fadd
533 changed files with 50452 additions and 12577 deletions
6
.github/CODEOWNERS
vendored
6
.github/CODEOWNERS
vendored
|
@ -1,9 +1,13 @@
|
|||
# Plugin owners
|
||||
plugins/archlinux/ @ratijas
|
||||
plugins/aws/ @maksyms
|
||||
plugins/genpass/ @atoponce
|
||||
plugins/git-lfs/ @hellovietduc
|
||||
plugins/gitfast/ @felipec
|
||||
plugins/react-native @esthor
|
||||
plugins/sdk/ @rgoldberg
|
||||
plugins/shell-proxy/ @septs
|
||||
plugins/universalarchive/ @Konfekt
|
||||
plugins/wp-cli/ @joshmedeski
|
||||
plugins/zoxide/ @ajeetdsouza
|
||||
plugins/starship/ @axieax
|
||||
plugins/dbt/ @msempere
|
||||
|
|
2
.github/FUNDING.yml
vendored
2
.github/FUNDING.yml
vendored
|
@ -1,2 +1,2 @@
|
|||
github: [robbyrussell, mcornella, larson-carter]
|
||||
github: [ohmyzsh, robbyrussell, mcornella, larson-carter, carlosala]
|
||||
open_collective: ohmyzsh
|
||||
|
|
46
.github/ISSUE_TEMPLATE/bug_report.md
vendored
46
.github/ISSUE_TEMPLATE/bug_report.md
vendored
|
@ -1,46 +0,0 @@
|
|||
---
|
||||
name: Bug report
|
||||
about: Create a report to help us improve Oh My Zsh
|
||||
labels: 'Bug'
|
||||
|
||||
---
|
||||
|
||||
<!--
|
||||
Fill this out before posting. You can delete irrelevant sections, but
|
||||
an issue where no sections have been filled will be deleted without comment.
|
||||
-->
|
||||
|
||||
**Describe the bug**
|
||||
A clear description of what the bug is.
|
||||
|
||||
**To Reproduce**
|
||||
Steps to reproduce the behavior, for example:
|
||||
1. Enable this plugin '...'
|
||||
2. Run command '...' or try the autocomplete command '...'
|
||||
3. See error
|
||||
|
||||
**Expected behavior**
|
||||
A brief description of what should happen.
|
||||
|
||||
**Screenshots and/or Recordings**
|
||||
If applicable, add screenshots to help explain your problem.
|
||||
You can also record an asciinema session: https://asciinema.org/
|
||||
|
||||
**Self Check**
|
||||
|
||||
- Have you tried reaching out on the [Discord server](https://discord.gg/ohmyzsh)?
|
||||
This can help cut down on filling up issues. We always have a few people
|
||||
online that are in a variety of timezones that are willing to help you!
|
||||
|
||||
- Also searching existing [GitHub Issues](https://github.com/ohmyzsh/ohmyzsh/issues?q=) might help you get quicker support
|
||||
|
||||
**Desktop (please complete the following information):**
|
||||
|
||||
- OS / Distro: [e.g. Arch Linux, macOS]
|
||||
- If on Windows what version of WSL: [e.g. WSL1, WSL2]
|
||||
- Latest ohmyzsh update?: [e.g. Yes/No]
|
||||
- ZSH Version: [e.g. 5.6]
|
||||
- Terminal emulator: [e.g. iTerm2]
|
||||
|
||||
**Additional context**
|
||||
Add any other context about the problem here. This can be themes, plugins, custom configs.
|
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...
|
29
.github/ISSUE_TEMPLATE/feature_request.md
vendored
29
.github/ISSUE_TEMPLATE/feature_request.md
vendored
|
@ -1,29 +0,0 @@
|
|||
---
|
||||
name: Feature request
|
||||
about: Suggest a feature for Oh My Zsh
|
||||
labels: 'Feature'
|
||||
|
||||
---
|
||||
|
||||
<!--
|
||||
Fill this out before posting. You can delete irrelevant sections, but
|
||||
an issue where no sections have been filled will be deleted without comment.
|
||||
-->
|
||||
|
||||
**Is your feature request related to a particular plugin or theme? If so, specify it.**
|
||||
The name of the plugin, theme or alias that you would like us to improve. [...]
|
||||
|
||||
**Is your feature request related to a problem? Please describe.**
|
||||
A description of what the problem is. Ex. I'm always frustrated when [...]
|
||||
|
||||
**Describe the solution you'd like**
|
||||
A description of what you want to happen. [...]
|
||||
|
||||
**Describe alternatives you've considered**
|
||||
A description of any alternative solutions or features you've considered. This can also include other plugins or themes.
|
||||
|
||||
**Additional context**
|
||||
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.
|
||||
|
||||
**Related Issues**
|
||||
Is there any open or closed issues that is related to this feature request? If so please link them below! [...]
|
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!
|
1
.github/PULL_REQUEST_TEMPLATE.md
vendored
1
.github/PULL_REQUEST_TEMPLATE.md
vendored
|
@ -9,6 +9,7 @@
|
|||
- [ ] The code is mine or it's from somewhere with an MIT-compatible license.
|
||||
- [ ] The code is efficient, to the best of my ability, and does not waste computer resources.
|
||||
- [ ] The code is stable and I have tested it myself, to the best of my abilities.
|
||||
- [ ] If the code introduces new aliases, I provide a valid use case for all plugin users down below.
|
||||
|
||||
## Changes:
|
||||
|
||||
|
|
55
.github/workflows/installer.yml
vendored
Normal file
55
.github/workflows/installer.yml
vendored
Normal file
|
@ -0,0 +1,55 @@
|
|||
name: Test and Deploy installer
|
||||
on:
|
||||
workflow_dispatch: {}
|
||||
push:
|
||||
paths:
|
||||
- tools/install.sh
|
||||
- .github/workflows/installer
|
||||
- .github/workflows/installer.yml
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
|
||||
cancel-in-progress: false
|
||||
|
||||
permissions:
|
||||
contents: read # to checkout
|
||||
|
||||
jobs:
|
||||
test:
|
||||
name: Test installer
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
matrix:
|
||||
os:
|
||||
- ubuntu-latest
|
||||
- macos-latest
|
||||
steps:
|
||||
- name: Set up git repository
|
||||
uses: actions/checkout@v3
|
||||
- name: Install zsh
|
||||
if: runner.os == 'Linux'
|
||||
run: sudo apt-get update; sudo apt-get install zsh
|
||||
- name: Test installer
|
||||
run: sh ./tools/install.sh
|
||||
|
||||
deploy:
|
||||
name: Deploy installer in install.ohmyz.sh
|
||||
if: github.ref == 'refs/heads/master'
|
||||
runs-on: ubuntu-latest
|
||||
environment: vercel
|
||||
needs:
|
||||
- test
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
- name: Install Vercel CLI
|
||||
run: npm install -g vercel
|
||||
- name: Setup project and deploy
|
||||
env:
|
||||
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
|
||||
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
|
||||
run: |
|
||||
cp tools/install.sh .github/workflows/installer/install.sh
|
||||
cd .github/workflows/installer
|
||||
vc link --yes -t ${{ secrets.VERCEL_TOKEN }}
|
||||
vc deploy --prod -t ${{ secrets.VERCEL_TOKEN }}
|
1
.github/workflows/installer/.gitignore
vendored
Normal file
1
.github/workflows/installer/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
install.sh
|
2
.github/workflows/installer/.vercelignore
vendored
Normal file
2
.github/workflows/installer/.vercelignore
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
/*
|
||||
!/install.sh
|
14
.github/workflows/installer/vercel.json
vendored
Normal file
14
.github/workflows/installer/vercel.json
vendored
Normal file
|
@ -0,0 +1,14 @@
|
|||
{
|
||||
"headers": [
|
||||
{
|
||||
"source": "/((?!favicon.ico).*)",
|
||||
"headers": [{ "key": "Content-Type", "value": "text/plain" }]
|
||||
}
|
||||
],
|
||||
"rewrites": [
|
||||
{
|
||||
"source": "/((?!favicon.ico|install.sh).*)",
|
||||
"destination": "/install.sh"
|
||||
}
|
||||
]
|
||||
}
|
12
.github/workflows/main.yml
vendored
12
.github/workflows/main.yml
vendored
|
@ -10,21 +10,27 @@ on:
|
|||
branches:
|
||||
- master
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
|
||||
cancel-in-progress: true
|
||||
|
||||
permissions:
|
||||
contents: read # to fetch code (actions/checkout)
|
||||
|
||||
jobs:
|
||||
tests:
|
||||
name: Run tests
|
||||
runs-on: ${{ matrix.os }}
|
||||
if: github.repository == 'ohmyzsh/ohmyzsh'
|
||||
strategy:
|
||||
matrix:
|
||||
os: [ubuntu-latest, macos-latest]
|
||||
steps:
|
||||
- name: Set up git repository
|
||||
uses: actions/checkout@v2
|
||||
uses: actions/checkout@v3
|
||||
- name: Install zsh
|
||||
if: runner.os == 'Linux'
|
||||
run: sudo apt-get update; sudo apt-get install zsh
|
||||
- name: Test installer
|
||||
run: sh ./tools/install.sh
|
||||
- name: Check syntax
|
||||
run: |
|
||||
for file in ./oh-my-zsh.sh \
|
||||
|
|
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
|
4
.gitignore
vendored
4
.gitignore
vendored
|
@ -6,3 +6,7 @@ cache/
|
|||
log/
|
||||
*.swp
|
||||
.DS_Store
|
||||
|
||||
# editor configs
|
||||
.vscode
|
||||
.idea
|
||||
|
|
4
.prettierrc
Normal file
4
.prettierrc
Normal file
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
"printWidth": 110,
|
||||
"proseWrap": "always"
|
||||
}
|
|
@ -35,19 +35,19 @@ you would make is not already covered.
|
|||
Please be so kind as to [search](#use-the-search-luke) for any open issue already covering
|
||||
your problem.
|
||||
|
||||
If you find one, comment on it so we can know there are more people experiencing it.
|
||||
If you find one, comment on it, so we know more people are experiencing it.
|
||||
|
||||
If not, look at the [Troubleshooting](https://github.com/ohmyzsh/ohmyzsh/wiki/Troubleshooting)
|
||||
page for instructions on how to gather data to better debug your problem.
|
||||
|
||||
Then, you can go ahead and create an issue with as much detail as you can provide.
|
||||
It should include the data gathered as indicated above, along with:
|
||||
It should include the data gathered as indicated above, along with the following:
|
||||
|
||||
1. How to reproduce the problem
|
||||
2. What the correct behavior should be
|
||||
3. What the actual behavior is
|
||||
|
||||
Please copy to anyone relevant (_eg_ plugin maintainers) by mentioning their GitHub handle
|
||||
Please copy to anyone relevant (e.g. plugin maintainers) by mentioning their GitHub handle
|
||||
(starting with `@`) in your message.
|
||||
|
||||
We will do our very best to help you.
|
||||
|
@ -57,9 +57,9 @@ We will do our very best to help you.
|
|||
Please be so kind as to [search](#use-the-search-luke) for any open issue already covering
|
||||
your suggestion.
|
||||
|
||||
If you find one, comment on it so we can know there are more people supporting it.
|
||||
If you find one, comment on it, so we know more people are supporting it.
|
||||
|
||||
If not, you can go ahead and create an issue. Please copy to anyone relevant (_eg_ plugin
|
||||
If not, you can go ahead and create an issue. Please copy to anyone relevant (e.g. plugin
|
||||
maintainers) by mentioning their GitHub handle (starting with `@`) in your message.
|
||||
|
||||
## Submitting Pull Requests
|
||||
|
@ -84,7 +84,7 @@ your [problem](#you-have-a-problem), and any pending/merged/rejected PR covering
|
|||
|
||||
If the solution is already reported, try it out and +1 the pull request if the
|
||||
solution works ok. On the other hand, if you think your solution is better, post
|
||||
it with a reference to the other one so we can have both solutions to compare.
|
||||
it with reference to the other one so we can have both solutions to compare.
|
||||
|
||||
If not, then go ahead and submit a PR. Please copy to anyone relevant (e.g. plugin
|
||||
maintainers) by mentioning their GitHub handle (starting with `@`) in your message.
|
||||
|
@ -99,10 +99,31 @@ covering or related to what you want to add.
|
|||
|
||||
If you find one, try it out and work with the author on a common solution.
|
||||
|
||||
If not, then go ahead and submit a PR. Please copy to anyone relevant (_eg_ plugin
|
||||
If not, then go ahead and submit a PR. Please copy to anyone relevant (e.g. plugin
|
||||
maintainers) by mentioning their GitHub handle (starting with `@`) in your message.
|
||||
|
||||
For any extensive change, _eg_ a new plugin, you will have to find testers to +1 your PR.
|
||||
For any extensive change, such as a new plugin, you will have to find testers to +1 your PR.
|
||||
|
||||
### New plugin aliases
|
||||
|
||||
We acknowledge that aliases are a core part of Oh My Zsh. There are plugins that have +100 aliases!
|
||||
|
||||
This has become an issue for two opposing reasons:
|
||||
|
||||
- Some users want to have their personal aliases in Oh My Zsh.
|
||||
- Some users don't want any aliases at all and feel that there are too many.
|
||||
|
||||
Because of this, from now on, we require that new aliases follow these conditions:
|
||||
|
||||
1. They will be used by many people, not just a few.
|
||||
2. The aliases will be used many times and for common tasks.
|
||||
3. Prefer one generic alias over many specific ones.
|
||||
4. When justifying the need for an alias, talk about workflows where you'll use it,
|
||||
preferably in combination with other aliases.
|
||||
5. If a command with the same name exists, look for a different alias name.
|
||||
|
||||
This list is not exhaustive! Please remember that your alias will be in the machines of many people,
|
||||
so it should be justified why they should have it.
|
||||
|
||||
----
|
||||
|
||||
|
@ -193,7 +214,7 @@ type(scope)!: subject
|
|||
```
|
||||
|
||||
- `subject`: a brief description of the changes. This will be displayed in the changelog. If you need
|
||||
to specify other details you can use the commit body but it won't be visible.
|
||||
to specify other details, you can use the commit body, but it won't be visible.
|
||||
|
||||
Formatting tricks: the commit subject may contain:
|
||||
|
||||
|
@ -202,7 +223,7 @@ type(scope)!: subject
|
|||
feat(archlinux): add support for aura AUR helper (#9467)
|
||||
```
|
||||
|
||||
- Formatted inline code by using backticks: the text inbetween backticks will also be highlighted by
|
||||
- Formatted inline code by using backticks: the text between backticks will also be highlighted by
|
||||
the changelog tool:
|
||||
```
|
||||
feat(shell-proxy): enable unexported `DEFAULT_PROXY` setting (#9774)
|
||||
|
@ -210,9 +231,9 @@ type(scope)!: subject
|
|||
|
||||
### Style
|
||||
|
||||
Try to keep the first commit line short. This is harder to do using this commit style but try to be
|
||||
concise and if you need more space, you can use the commit body. Try to make sure that the commit
|
||||
subject is clear and precise enough that users will know what change by just looking at the changelog.
|
||||
Try to keep the first commit line short. It's harder to do using this commit style but try to be
|
||||
concise, and if you need more space, you can use the commit body. Try to make sure that the commit
|
||||
subject is clear and precise enough that users will know what changed by just looking at the changelog.
|
||||
|
||||
----
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2009-2021 Robby Russell and contributors (https://github.com/ohmyzsh/ohmyzsh/contributors)
|
||||
Copyright (c) 2009-2022 Robby Russell and contributors (https://github.com/ohmyzsh/ohmyzsh/contributors)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
|
220
README.md
220
README.md
|
@ -1,4 +1,4 @@
|
|||
<p align="center"><img src="https://s3.amazonaws.com/ohmyzsh/oh-my-zsh-logo.png" alt="Oh My Zsh"></p>
|
||||
<p align="center"><img src="https://ohmyzsh.s3.amazonaws.com/omz-ansi-github.png" alt="Oh My Zsh"></p>
|
||||
|
||||
Oh My Zsh is an open source, community-driven framework for managing your [zsh](https://www.zsh.org/) configuration.
|
||||
|
||||
|
@ -16,6 +16,45 @@ To learn more, visit [ohmyz.sh](https://ohmyz.sh), follow [@ohmyzsh](https://twi
|
|||
[![Follow @ohmyzsh](https://img.shields.io/twitter/follow/ohmyzsh?label=Follow+@ohmyzsh&style=flat)](https://twitter.com/intent/follow?screen_name=ohmyzsh)
|
||||
[![Discord server](https://img.shields.io/discord/642496866407284746)](https://discord.gg/ohmyzsh)
|
||||
[![Gitpod ready](https://img.shields.io/badge/Gitpod-ready-blue?logo=gitpod)](https://gitpod.io/#https://github.com/ohmyzsh/ohmyzsh)
|
||||
[![huntr.dev](https://cdn.huntr.dev/huntr_security_badge_mono.svg)](https://huntr.dev/bounties/disclose/?utm_campaign=ohmyzsh%2Fohmyzsh&utm_medium=social&utm_source=github&target=https%3A%2F%2Fgithub.com%2Fohmyzsh%2Fohmyzsh)
|
||||
|
||||
<details>
|
||||
<summary>Table of Contents</summary>
|
||||
|
||||
- [Getting Started](#getting-started)
|
||||
- [Prerequisites](#prerequisites)
|
||||
- [Basic Installation](#basic-installation)
|
||||
- [Manual inspection](#manual-inspection)
|
||||
- [Using Oh My Zsh](#using-oh-my-zsh)
|
||||
- [Plugins](#plugins)
|
||||
- [Enabling Plugins](#enabling-plugins)
|
||||
- [Using Plugins](#using-plugins)
|
||||
- [Themes](#themes)
|
||||
- [Selecting a Theme](#selecting-a-theme)
|
||||
- [FAQ](#faq)
|
||||
- [Advanced Topics](#advanced-topics)
|
||||
- [Advanced Installation](#advanced-installation)
|
||||
- [Custom Directory](#custom-directory)
|
||||
- [Unattended install](#unattended-install)
|
||||
- [Installing from a forked repository](#installing-from-a-forked-repository)
|
||||
- [Manual Installation](#manual-installation)
|
||||
- [Installation Problems](#installation-problems)
|
||||
- [Custom Plugins and Themes](#custom-plugins-and-themes)
|
||||
- [Enable GNU ls in macOS and freeBSD systems](#enable-gnu-ls)
|
||||
- [Skip aliases](#skip-aliases)
|
||||
- [Getting Updates](#getting-updates)
|
||||
- [Updates verbosity](#updates-verbosity)
|
||||
- [Manual Updates](#manual-updates)
|
||||
- [Uninstalling Oh My Zsh](#uninstalling-oh-my-zsh)
|
||||
- [How do I contribute to Oh My Zsh?](#how-do-i-contribute-to-oh-my-zsh)
|
||||
- [Do NOT send us themes](#do-not-send-us-themes)
|
||||
- [Contributors](#contributors)
|
||||
- [Follow Us](#follow-us)
|
||||
- [Merchandise](#merchandise)
|
||||
- [License](#license)
|
||||
- [About Planet Argon](#about-planet-argon)
|
||||
|
||||
</details>
|
||||
|
||||
## Getting Started
|
||||
|
||||
|
@ -31,18 +70,20 @@ To learn more, visit [ohmyz.sh](https://ohmyz.sh), follow [@ohmyzsh](https://twi
|
|||
Oh My Zsh is installed by running one of the following commands in your terminal. You can install this via the command-line with either `curl`, `wget` or another similar tool.
|
||||
|
||||
| Method | Command |
|
||||
|:----------|:--------------------------------------------------------------------------------------------------|
|
||||
| :-------- | :------------------------------------------------------------------------------------------------ |
|
||||
| **curl** | `sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"` |
|
||||
| **wget** | `sh -c "$(wget -O- https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"` |
|
||||
| **fetch** | `sh -c "$(fetch -o - https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"` |
|
||||
|
||||
_Note that any previous `.zshrc` will be renamed to `.zshrc.pre-oh-my-zsh`. After installation, you can move the configuration you want to preserve into the new `.zshrc`._
|
||||
|
||||
#### Manual inspection
|
||||
|
||||
It's a good idea to inspect the install script from projects you don't yet know. You can do
|
||||
that by downloading the install script first, looking through it so everything looks normal,
|
||||
then running it:
|
||||
|
||||
```shell
|
||||
```sh
|
||||
wget https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh
|
||||
sh install.sh
|
||||
```
|
||||
|
@ -57,18 +98,18 @@ Oh My Zsh comes with a shitload of plugins for you to take advantage of. You can
|
|||
|
||||
Once you spot a plugin (or several) that you'd like to use with Oh My Zsh, you'll need to enable them in the `.zshrc` file. You'll find the zshrc file in your `$HOME` directory. Open it with your favorite text editor and you'll see a spot to list all the plugins you want to load.
|
||||
|
||||
```shell
|
||||
```sh
|
||||
vi ~/.zshrc
|
||||
```
|
||||
|
||||
For example, this might begin to look like this:
|
||||
|
||||
```shell
|
||||
```sh
|
||||
plugins=(
|
||||
git
|
||||
bundler
|
||||
dotenv
|
||||
osx
|
||||
macos
|
||||
rake
|
||||
rbenv
|
||||
ruby
|
||||
|
@ -79,7 +120,7 @@ _Note that the plugins are separated by whitespace (spaces, tabs, new lines...).
|
|||
|
||||
#### Using Plugins
|
||||
|
||||
Each plugin includes a __README__, documenting it. This README should show the aliases (if the plugin adds any) and extra goodies that are included in that particular plugin.
|
||||
Each built-in plugin includes a **README**, documenting it. This README should show the aliases (if the plugin adds any) and extra goodies that are included in that particular plugin.
|
||||
|
||||
### Themes
|
||||
|
||||
|
@ -91,18 +132,18 @@ _Robby's theme is the default one. It's not the fanciest one. It's not the simpl
|
|||
|
||||
Once you find a theme that you'd like to use, you will need to edit the `~/.zshrc` file. You'll see an environment variable (all caps) in there that looks like:
|
||||
|
||||
```shell
|
||||
```sh
|
||||
ZSH_THEME="robbyrussell"
|
||||
```
|
||||
|
||||
To use a different theme, simply change the value to match the name of your desired theme. For example:
|
||||
|
||||
```shell
|
||||
```sh
|
||||
ZSH_THEME="agnoster" # (this is one of the fancy ones)
|
||||
# see https://github.com/ohmyzsh/ohmyzsh/wiki/Themes#agnoster
|
||||
```
|
||||
|
||||
_Note: many themes require installing the [Powerline Fonts](https://github.com/powerline/fonts) in order to render properly._
|
||||
_Note: many themes require installing a [Powerline Font](https://github.com/powerline/fonts) or a [Nerd Font](https://github.com/ryanoasis/nerd-fonts) in order to render properly. Without them, these themes will render [weird prompt symbols](https://github.com/ohmyzsh/ohmyzsh/wiki/FAQ#i-have-a-weird-character-in-my-prompt)_
|
||||
|
||||
Open up a new terminal window and your prompt should look something like this:
|
||||
|
||||
|
@ -112,13 +153,13 @@ In case you did not find a suitable theme for your needs, please have a look at
|
|||
|
||||
If you're feeling feisty, you can let the computer select one randomly for you each time you open a new terminal window.
|
||||
|
||||
```shell
|
||||
```sh
|
||||
ZSH_THEME="random" # (...please let it be pie... please be some pie..)
|
||||
```
|
||||
|
||||
And if you want to pick random theme from a list of your favorite themes:
|
||||
|
||||
```shell
|
||||
```sh
|
||||
ZSH_THEME_RANDOM_CANDIDATES=(
|
||||
"robbyrussell"
|
||||
"agnoster"
|
||||
|
@ -127,7 +168,7 @@ ZSH_THEME_RANDOM_CANDIDATES=(
|
|||
|
||||
If you only know which themes you don't like, you can add them similarly to an ignored list:
|
||||
|
||||
```shell
|
||||
```sh
|
||||
ZSH_THEME_RANDOM_IGNORED=(pygmalion tjkirch_mod)
|
||||
```
|
||||
|
||||
|
@ -152,17 +193,17 @@ If you'd like to change the install directory with the `ZSH` environment variabl
|
|||
`export ZSH=/your/path` before installing, or by setting it before the end of the install pipeline
|
||||
like this:
|
||||
|
||||
```shell
|
||||
```sh
|
||||
ZSH="$HOME/.dotfiles/oh-my-zsh" sh install.sh
|
||||
```
|
||||
|
||||
#### Unattended install
|
||||
|
||||
If you're running the Oh My Zsh install script as part of an automated install, you can pass the
|
||||
flag `--unattended` to the `install.sh` script. This will have the effect of not trying to change
|
||||
the default shell, and also won't run `zsh` when the installation has finished.
|
||||
If you're running the Oh My Zsh install script as part of an automated install, you can pass the `--unattended`
|
||||
flag to the `install.sh` script. This will have the effect of not trying to change
|
||||
the default shell, and it also won't run `zsh` when the installation has finished.
|
||||
|
||||
```shell
|
||||
```sh
|
||||
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" "" --unattended
|
||||
```
|
||||
|
||||
|
@ -185,41 +226,41 @@ The install script also accepts these variables to allow installation of a diffe
|
|||
|
||||
For example:
|
||||
|
||||
```shell
|
||||
```sh
|
||||
REPO=apjanke/oh-my-zsh BRANCH=edge sh install.sh
|
||||
```
|
||||
|
||||
#### Manual Installation
|
||||
|
||||
##### 1. Clone the repository
|
||||
##### 1. Clone the repository <!-- omit in toc -->
|
||||
|
||||
```shell
|
||||
```sh
|
||||
git clone https://github.com/ohmyzsh/ohmyzsh.git ~/.oh-my-zsh
|
||||
```
|
||||
|
||||
##### 2. *Optionally*, backup your existing `~/.zshrc` file
|
||||
##### 2. _Optionally_, backup your existing `~/.zshrc` file <!-- omit in toc -->
|
||||
|
||||
```shell
|
||||
```sh
|
||||
cp ~/.zshrc ~/.zshrc.orig
|
||||
```
|
||||
|
||||
##### 3. Create a new zsh configuration file
|
||||
##### 3. Create a new zsh configuration file <!-- omit in toc -->
|
||||
|
||||
You can create a new zsh config file by copying the template that we have included for you.
|
||||
|
||||
```shell
|
||||
```sh
|
||||
cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc
|
||||
```
|
||||
|
||||
##### 4. Change your default shell
|
||||
##### 4. Change your default shell <!-- omit in toc -->
|
||||
|
||||
```shell
|
||||
```sh
|
||||
chsh -s $(which zsh)
|
||||
```
|
||||
|
||||
You must log out from your user session and log back in to see this change.
|
||||
|
||||
##### 5. Initialize your new zsh configuration
|
||||
##### 5. Initialize your new zsh configuration <!-- omit in toc -->
|
||||
|
||||
Once you open up a new terminal window, it should load zsh with Oh My Zsh's configuration.
|
||||
|
||||
|
@ -227,10 +268,8 @@ Once you open up a new terminal window, it should load zsh with Oh My Zsh's conf
|
|||
|
||||
If you have any hiccups installing, here are a few common fixes.
|
||||
|
||||
- You _might_ need to modify your `PATH` in `~/.zshrc` if you're not able to find some commands after
|
||||
switching to `oh-my-zsh`.
|
||||
- If you installed manually or changed the install location, check the `ZSH` environment variable in
|
||||
`~/.zshrc`.
|
||||
- You _might_ need to modify your `PATH` in `~/.zshrc` if you're not able to find some commands after switching to `oh-my-zsh`.
|
||||
- If you installed manually or changed the install location, check the `ZSH` environment variable in `~/.zshrc`.
|
||||
|
||||
### Custom Plugins and Themes
|
||||
|
||||
|
@ -240,25 +279,120 @@ If you have many functions that go well together, you can put them as a `XYZ.plu
|
|||
|
||||
If you would like to override the functionality of a plugin distributed with Oh My Zsh, create a plugin of the same name in the `custom/plugins/` directory and it will be loaded instead of the one in `plugins/`.
|
||||
|
||||
## Getting Updates
|
||||
### Enable GNU ls in macOS and freeBSD systems
|
||||
|
||||
By default, you will be prompted to check for upgrades every few weeks. If you would like `oh-my-zsh` to automatically upgrade itself without prompting you, set the following in your `~/.zshrc`:
|
||||
<a name="enable-gnu-ls"></a>
|
||||
|
||||
```shell
|
||||
DISABLE_UPDATE_PROMPT=true
|
||||
The default behaviour in Oh My Zsh is to use BSD `ls` in macOS and freeBSD systems. If GNU `ls` is installed
|
||||
(as `gls` command), you can choose to use it instead. To do it, you can use zstyle-based config before
|
||||
sourcing `oh-my-zsh.sh`:
|
||||
|
||||
```zsh
|
||||
zstyle ':omz:lib:theme-and-appearance' gnu-ls yes
|
||||
```
|
||||
|
||||
To disable automatic upgrades, set the following in your `~/.zshrc`:
|
||||
_Note: this is not compatible with `DISABLE_LS_COLORS=true`_
|
||||
|
||||
```shell
|
||||
DISABLE_AUTO_UPDATE=true
|
||||
### Skip aliases
|
||||
|
||||
<a name="remove-directories-aliases"></a>
|
||||
|
||||
If you want to skip default Oh My Zsh aliases (those defined in `lib/*` files) or plugin aliases,
|
||||
you can use the settings below in your `~/.zshrc` file, **before Oh My Zsh is loaded**. Note that
|
||||
there are many different ways to skip aliases, depending on your needs.
|
||||
|
||||
```sh
|
||||
# Skip all aliases, in lib files and enabled plugins
|
||||
zstyle ':omz:*' aliases no
|
||||
|
||||
# Skip all aliases in lib files
|
||||
zstyle ':omz:lib:*' aliases no
|
||||
# Skip only aliases defined in the directories.zsh lib file
|
||||
zstyle ':omz:lib:directories' aliases no
|
||||
|
||||
# Skip all plugin aliases
|
||||
zstyle ':omz:plugins:*' aliases no
|
||||
# Skip only the aliases from the git plugin
|
||||
zstyle ':omz:plugins:git' aliases no
|
||||
```
|
||||
|
||||
You can combine these in other ways taking into account that more specific scopes takes precedence:
|
||||
|
||||
```sh
|
||||
# Skip all plugin aliases, except for the git plugin
|
||||
zstyle ':omz:plugins:*' aliases no
|
||||
zstyle ':omz:plugins:git' aliases yes
|
||||
```
|
||||
|
||||
A previous version of this feature was using the setting below, which has been removed:
|
||||
|
||||
```sh
|
||||
zstyle ':omz:directories' aliases no
|
||||
```
|
||||
|
||||
Instead, you can now use the following:
|
||||
|
||||
```sh
|
||||
zstyle ':omz:lib:directories' aliases no
|
||||
```
|
||||
|
||||
#### Notice <!-- omit in toc -->
|
||||
|
||||
> This feature is currently in a testing phase and it may be subject to change in the future.
|
||||
> It is also not currently compatible with plugin managers such as zpm or zinit, which don't
|
||||
> source the init script (`oh-my-zsh.sh`) where this feature is implemented in.
|
||||
|
||||
> It is also not currently aware of "aliases" that are defined as functions. Example of such
|
||||
> are `gccd`, `ggf`, or `ggl` functions from the git plugin.
|
||||
|
||||
## Getting Updates
|
||||
|
||||
By default, you will be prompted to check for updates every 2 weeks. You can choose other update modes by adding a line to your `~/.zshrc` file, **before Oh My Zsh is loaded**:
|
||||
|
||||
1. Automatic update without confirmation prompt:
|
||||
|
||||
```sh
|
||||
zstyle ':omz:update' mode auto
|
||||
```
|
||||
|
||||
2. Just offer a reminder every few days, if there are updates available:
|
||||
|
||||
```sh
|
||||
zstyle ':omz:update' mode reminder
|
||||
```
|
||||
|
||||
3. To disable automatic updates entirely:
|
||||
|
||||
```sh
|
||||
zstyle ':omz:update' mode disabled
|
||||
```
|
||||
|
||||
NOTE: you can control how often Oh My Zsh checks for updates with the following setting:
|
||||
|
||||
```sh
|
||||
# This will check for updates every 7 days
|
||||
zstyle ':omz:update' frequency 7
|
||||
# This will check for updates every time you open the terminal (not recommended)
|
||||
zstyle ':omz:update' frequency 0
|
||||
```
|
||||
|
||||
### Updates verbosity
|
||||
|
||||
You can also limit the update verbosity with the following settings:
|
||||
|
||||
```sh
|
||||
zstyle ':omz:update' verbose default # default update prompt
|
||||
|
||||
zstyle ':omz:update' verbose minimal # only few lines
|
||||
|
||||
zstyle ':omz:update' verbose silent # only errors
|
||||
```
|
||||
|
||||
### Manual Updates
|
||||
|
||||
If you'd like to upgrade at any point in time (maybe someone just released a new plugin and you don't want to wait a week?) you just need to run:
|
||||
If you'd like to update at any point in time (maybe someone just released a new plugin and you don't want to wait a week?) you just need to run:
|
||||
|
||||
```shell
|
||||
```sh
|
||||
omz update
|
||||
```
|
||||
|
||||
|
@ -276,7 +410,7 @@ Before you participate in our delightful community, please read the [code of con
|
|||
|
||||
I'm far from being a [Zsh](https://www.zsh.org/) expert and suspect there are many ways to improve – if you have ideas on how to make the configuration easier to maintain (and faster), don't hesitate to fork and send pull requests!
|
||||
|
||||
We also need people to test out pull-requests. So take a look through [the open issues](https://github.com/ohmyzsh/ohmyzsh/issues) and help where you can.
|
||||
We also need people to test out pull requests. So take a look through [the open issues](https://github.com/ohmyzsh/ohmyzsh/issues) and help where you can.
|
||||
|
||||
See [Contributing](CONTRIBUTING.md) for more details.
|
||||
|
||||
|
@ -311,4 +445,4 @@ Oh My Zsh is released under the [MIT license](LICENSE.txt).
|
|||
|
||||
![Planet Argon](https://pa-github-assets.s3.amazonaws.com/PARGON_logo_digital_COL-small.jpg)
|
||||
|
||||
Oh My Zsh was started by the team at [Planet Argon](https://www.planetargon.com/?utm_source=github), a [Ruby on Rails development agency](https://www.planetargon.com/skills/ruby-on-rails-development?utm_source=github). Check out our [other open source projects](https://www.planetargon.com/open-source?utm_source=github).
|
||||
Oh My Zsh was started by the team at [Planet Argon](https://www.planetargon.com/?utm_source=github), a [Ruby on Rails development agency](http://www.planetargon.com/services/ruby-on-rails-development?utm_source=github). Check out our [other open source projects](https://www.planetargon.com/open-source?utm_source=github).
|
||||
|
|
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.
|
|
@ -1,10 +1,12 @@
|
|||
# You can put files here to add functionality separated per file, which
|
||||
# will be ignored by git.
|
||||
# Files on the custom/ directory will be automatically loaded by the init
|
||||
# script, in alphabetical order.
|
||||
|
||||
# For example: add yourself some shortcuts to projects you often work on.
|
||||
# Put files in this folder to add your own custom functionality.
|
||||
# See: https://github.com/ohmyzsh/ohmyzsh/wiki/Customization
|
||||
#
|
||||
# Files in the custom/ directory will be:
|
||||
# - loaded automatically by the init script, in alphabetical order
|
||||
# - loaded last, after all built-ins in the lib/ directory, to override them
|
||||
# - ignored by git by default
|
||||
#
|
||||
# Example: add custom/shortcuts.zsh for shortcuts to your local projects
|
||||
#
|
||||
# brainstormr=~/Projects/development/planetargon/brainstormr
|
||||
# cd $brainstormr
|
||||
#
|
||||
|
|
|
@ -1,2 +1,3 @@
|
|||
# Add your own custom plugins in the custom/plugins directory. Plugins placed
|
||||
# here will override ones with the same name in the main plugins directory.
|
||||
# See: https://github.com/ohmyzsh/ohmyzsh/wiki/Customization#overriding-and-adding-plugins
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
# Put your custom themes in this folder.
|
||||
# See: https://github.com/ohmyzsh/ohmyzsh/wiki/Customization#overriding-and-adding-themes
|
||||
#
|
||||
# Example:
|
||||
|
||||
PROMPT="%{$fg[red]%}%n%{$reset_color%}@%{$fg[blue]%}%m %{$fg[yellow]%}%~ %{$reset_color%}%% "
|
||||
|
|
501
lib/cli.zsh
501
lib/cli.zsh
|
@ -11,7 +11,7 @@ function omz {
|
|||
|
||||
# Subcommand functions start with _ so that they don't
|
||||
# appear as completion entries when looking for `omz`
|
||||
(( $+functions[_omz::$command] )) || {
|
||||
(( ${+functions[_omz::$command]} )) || {
|
||||
_omz::help
|
||||
return 1
|
||||
}
|
||||
|
@ -26,8 +26,10 @@ function _omz {
|
|||
'help:Usage information'
|
||||
'plugin:Manage plugins'
|
||||
'pr:Manage Oh My Zsh Pull Requests'
|
||||
'reload:Reload the current zsh session'
|
||||
'theme:Manage themes'
|
||||
'update:Update Oh My Zsh'
|
||||
'version:Show the version'
|
||||
)
|
||||
|
||||
if (( CURRENT == 2 )); then
|
||||
|
@ -35,28 +37,78 @@ function _omz {
|
|||
elif (( CURRENT == 3 )); then
|
||||
case "$words[2]" in
|
||||
changelog) local -a refs
|
||||
refs=("${(@f)$(command git for-each-ref --format="%(refname:short):%(subject)" refs/heads refs/tags)}")
|
||||
refs=("${(@f)$(builtin cd -q "$ZSH"; command git for-each-ref --format="%(refname:short):%(subject)" refs/heads refs/tags)}")
|
||||
_describe 'command' refs ;;
|
||||
plugin) subcmds=('info:Get plugin information' 'list:List plugins')
|
||||
plugin) subcmds=(
|
||||
'disable:Disable plugin(s)'
|
||||
'enable:Enable plugin(s)'
|
||||
'info:Get plugin information'
|
||||
'list:List plugins'
|
||||
'load:Load plugin(s)'
|
||||
)
|
||||
_describe 'command' subcmds ;;
|
||||
pr) subcmds=('test:Test a Pull Request' 'clean:Delete all Pull Request branches')
|
||||
pr) subcmds=('clean:Delete all Pull Request branches' 'test:Test a Pull Request')
|
||||
_describe 'command' subcmds ;;
|
||||
theme) subcmds=('use:Load a theme' 'list:List themes')
|
||||
theme) subcmds=('list:List themes' 'set:Set a theme in your .zshrc file' 'use:Load a theme')
|
||||
_describe 'command' subcmds ;;
|
||||
esac
|
||||
elif (( CURRENT == 4 )); then
|
||||
case "$words[2]::$words[3]" in
|
||||
plugin::info) compadd "$ZSH"/plugins/*/README.md(.N:h:t) \
|
||||
"$ZSH_CUSTOM"/plugins/*/README.md(.N:h:t) ;;
|
||||
theme::use) compadd "$ZSH"/themes/*.zsh-theme(.N:t:r) \
|
||||
"$ZSH_CUSTOM"/**/*.zsh-theme(.N:r:gs:"$ZSH_CUSTOM"/themes/:::gs:"$ZSH_CUSTOM"/:::) ;;
|
||||
case "${words[2]}::${words[3]}" in
|
||||
plugin::(disable|enable|load))
|
||||
local -aU valid_plugins
|
||||
|
||||
if [[ "${words[3]}" = disable ]]; then
|
||||
# if command is "disable", only offer already enabled plugins
|
||||
valid_plugins=($plugins)
|
||||
else
|
||||
valid_plugins=("$ZSH"/plugins/*/{_*,*.plugin.zsh}(-.N:h:t) "$ZSH_CUSTOM"/plugins/*/{_*,*.plugin.zsh}(-.N:h:t))
|
||||
# if command is "enable", remove already enabled plugins
|
||||
[[ "${words[3]}" = enable ]] && valid_plugins=(${valid_plugins:|plugins})
|
||||
fi
|
||||
|
||||
_describe 'plugin' valid_plugins ;;
|
||||
plugin::info)
|
||||
local -aU plugins
|
||||
plugins=("$ZSH"/plugins/*/{_*,*.plugin.zsh}(-.N:h:t) "$ZSH_CUSTOM"/plugins/*/{_*,*.plugin.zsh}(-.N:h:t))
|
||||
_describe 'plugin' plugins ;;
|
||||
theme::(set|use))
|
||||
local -aU themes
|
||||
themes=("$ZSH"/themes/*.zsh-theme(-.N:t:r) "$ZSH_CUSTOM"/**/*.zsh-theme(-.N:r:gs:"$ZSH_CUSTOM"/themes/:::gs:"$ZSH_CUSTOM"/:::))
|
||||
_describe 'theme' themes ;;
|
||||
esac
|
||||
elif (( CURRENT > 4 )); then
|
||||
case "${words[2]}::${words[3]}" in
|
||||
plugin::(enable|disable|load))
|
||||
local -aU valid_plugins
|
||||
|
||||
if [[ "${words[3]}" = disable ]]; then
|
||||
# if command is "disable", only offer already enabled plugins
|
||||
valid_plugins=($plugins)
|
||||
else
|
||||
valid_plugins=("$ZSH"/plugins/*/{_*,*.plugin.zsh}(-.N:h:t) "$ZSH_CUSTOM"/plugins/*/{_*,*.plugin.zsh}(-.N:h:t))
|
||||
# if command is "enable", remove already enabled plugins
|
||||
[[ "${words[3]}" = enable ]] && valid_plugins=(${valid_plugins:|plugins})
|
||||
fi
|
||||
|
||||
# Remove plugins already passed as arguments
|
||||
# NOTE: $(( CURRENT - 1 )) is the last plugin argument completely passed, i.e. that which
|
||||
# has a space after them. This is to avoid removing plugins partially passed, which makes
|
||||
# the completion not add a space after the completed plugin.
|
||||
local -a args
|
||||
args=(${words[4,$(( CURRENT - 1))]})
|
||||
valid_plugins=(${valid_plugins:|args})
|
||||
|
||||
_describe 'plugin' valid_plugins ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
compdef _omz omz
|
||||
# If run from a script, do not set the completion function
|
||||
if (( ${+functions[compdef]} )); then
|
||||
compdef _omz omz
|
||||
fi
|
||||
|
||||
## Utility functions
|
||||
|
||||
|
@ -106,7 +158,7 @@ function _omz::log {
|
|||
## User-facing commands
|
||||
|
||||
function _omz::help {
|
||||
cat <<EOF
|
||||
cat >&2 <<EOF
|
||||
Usage: omz <command> [options]
|
||||
|
||||
Available commands:
|
||||
|
@ -115,8 +167,10 @@ Available commands:
|
|||
changelog Print the changelog
|
||||
plugin <command> Manage plugins
|
||||
pr <command> Manage Oh My Zsh Pull Requests
|
||||
reload Reload the current zsh session
|
||||
theme <command> Manage themes
|
||||
update Update Oh My Zsh
|
||||
version Show the version
|
||||
|
||||
EOF
|
||||
}
|
||||
|
@ -124,11 +178,14 @@ EOF
|
|||
function _omz::changelog {
|
||||
local version=${1:-HEAD} format=${3:-"--text"}
|
||||
|
||||
if ! command git -C "$ZSH" show-ref --verify refs/heads/$version &>/dev/null && \
|
||||
! command git -C "$ZSH" show-ref --verify refs/tags/$version &>/dev/null && \
|
||||
! command git -C "$ZSH" rev-parse --verify "${version}^{commit}" &>/dev/null; then
|
||||
cat <<EOF
|
||||
Usage: omz changelog [version]
|
||||
if (
|
||||
builtin cd -q "$ZSH"
|
||||
! command git show-ref --verify refs/heads/$version && \
|
||||
! command git show-ref --verify refs/tags/$version && \
|
||||
! command git rev-parse --verify "${version}^{commit}"
|
||||
) &>/dev/null; then
|
||||
cat >&2 <<EOF
|
||||
Usage: ${(j: :)${(s.::.)0#_}} [version]
|
||||
|
||||
NOTE: <version> must be a valid branch, tag or commit.
|
||||
EOF
|
||||
|
@ -139,14 +196,17 @@ EOF
|
|||
}
|
||||
|
||||
function _omz::plugin {
|
||||
(( $# > 0 && $+functions[_omz::plugin::$1] )) || {
|
||||
cat <<EOF
|
||||
Usage: omz plugin <command> [options]
|
||||
(( $# > 0 && $+functions[$0::$1] )) || {
|
||||
cat >&2 <<EOF
|
||||
Usage: ${(j: :)${(s.::.)0#_}} <command> [options]
|
||||
|
||||
Available commands:
|
||||
|
||||
info <plugin> Get information of a plugin
|
||||
list List all available Oh My Zsh plugins
|
||||
disable <plugin> Disable plugin(s)
|
||||
enable <plugin> Enable plugin(s)
|
||||
info <plugin> Get information of a plugin
|
||||
list List all available Oh My Zsh plugins
|
||||
load <plugin> Load plugin(s)
|
||||
|
||||
EOF
|
||||
return 1
|
||||
|
@ -155,12 +215,174 @@ EOF
|
|||
local command="$1"
|
||||
shift
|
||||
|
||||
_omz::plugin::$command "$@"
|
||||
$0::$command "$@"
|
||||
}
|
||||
|
||||
function _omz::plugin::disable {
|
||||
if [[ -z "$1" ]]; then
|
||||
echo >&2 "Usage: ${(j: :)${(s.::.)0#_}} <plugin> [...]"
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Check that plugin is in $plugins
|
||||
local -a dis_plugins
|
||||
for plugin in "$@"; do
|
||||
if [[ ${plugins[(Ie)$plugin]} -eq 0 ]]; then
|
||||
_omz::log warn "plugin '$plugin' is not enabled."
|
||||
continue
|
||||
fi
|
||||
dis_plugins+=("$plugin")
|
||||
done
|
||||
|
||||
# Exit if there are no enabled plugins to disable
|
||||
if [[ ${#dis_plugins} -eq 0 ]]; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Remove plugins substitution awk script
|
||||
local awk_subst_plugins="\
|
||||
gsub(/[ \t]+(${(j:|:)dis_plugins})/, \"\") # with spaces before
|
||||
gsub(/(${(j:|:)dis_plugins})[ \t]+/, \"\") # with spaces after
|
||||
gsub(/\((${(j:|:)dis_plugins})\)/, \"\") # without spaces (only plugin)
|
||||
"
|
||||
# Disable plugins awk script
|
||||
local awk_script="
|
||||
# if plugins=() is in oneline form, substitute disabled plugins and go to next line
|
||||
/^[ \t]*plugins=\([^#]+\).*\$/ {
|
||||
$awk_subst_plugins
|
||||
print \$0
|
||||
next
|
||||
}
|
||||
|
||||
# if plugins=() is in multiline form, enable multi flag and disable plugins if they're there
|
||||
/^[ \t]*plugins=\(/ {
|
||||
multi=1
|
||||
$awk_subst_plugins
|
||||
print \$0
|
||||
next
|
||||
}
|
||||
|
||||
# if multi flag is enabled and we find a valid closing parenthesis, remove plugins and disable multi flag
|
||||
multi == 1 && /^[^#]*\)/ {
|
||||
multi=0
|
||||
$awk_subst_plugins
|
||||
print \$0
|
||||
next
|
||||
}
|
||||
|
||||
multi == 1 && length(\$0) > 0 {
|
||||
$awk_subst_plugins
|
||||
if (length(\$0) > 0) print \$0
|
||||
next
|
||||
}
|
||||
|
||||
{ print \$0 }
|
||||
"
|
||||
|
||||
local zdot="${ZDOTDIR:-$HOME}"
|
||||
local zshrc="${${:-"${zdot}/.zshrc"}:A}"
|
||||
awk "$awk_script" "$zshrc" > "$zdot/.zshrc.new" \
|
||||
&& command cp -f "$zshrc" "$zdot/.zshrc.bck" \
|
||||
&& command mv -f "$zdot/.zshrc.new" "$zshrc"
|
||||
|
||||
# Exit if the new .zshrc file wasn't created correctly
|
||||
[[ $? -eq 0 ]] || {
|
||||
local ret=$?
|
||||
_omz::log error "error disabling plugins."
|
||||
return $ret
|
||||
}
|
||||
|
||||
# Exit if the new .zshrc file has syntax errors
|
||||
if ! command zsh -n "$zdot/.zshrc"; then
|
||||
_omz::log error "broken syntax in '"${zdot/#$HOME/\~}/.zshrc"'. Rolling back changes..."
|
||||
command mv -f "$zdot/.zshrc.bck" "$zshrc"
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Restart the zsh session if there were no errors
|
||||
_omz::log info "plugins disabled: ${(j:, :)dis_plugins}."
|
||||
|
||||
# Only reload zsh if run in an interactive session
|
||||
[[ ! -o interactive ]] || _omz::reload
|
||||
}
|
||||
|
||||
function _omz::plugin::enable {
|
||||
if [[ -z "$1" ]]; then
|
||||
echo >&2 "Usage: ${(j: :)${(s.::.)0#_}} <plugin> [...]"
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Check that plugin is not in $plugins
|
||||
local -a add_plugins
|
||||
for plugin in "$@"; do
|
||||
if [[ ${plugins[(Ie)$plugin]} -ne 0 ]]; then
|
||||
_omz::log warn "plugin '$plugin' is already enabled."
|
||||
continue
|
||||
fi
|
||||
add_plugins+=("$plugin")
|
||||
done
|
||||
|
||||
# Exit if there are no plugins to enable
|
||||
if [[ ${#add_plugins} -eq 0 ]]; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Enable plugins awk script
|
||||
local awk_script="
|
||||
# if plugins=() is in oneline form, substitute ) with new plugins and go to the next line
|
||||
/^[ \t]*plugins=\([^#]+\).*\$/ {
|
||||
sub(/\)/, \" $add_plugins&\")
|
||||
print \$0
|
||||
next
|
||||
}
|
||||
|
||||
# if plugins=() is in multiline form, enable multi flag
|
||||
/^[ \t]*plugins=\(/ {
|
||||
multi=1
|
||||
}
|
||||
|
||||
# if multi flag is enabled and we find a valid closing parenthesis,
|
||||
# add new plugins and disable multi flag
|
||||
multi == 1 && /^[^#]*\)/ {
|
||||
multi=0
|
||||
sub(/\)/, \" $add_plugins&\")
|
||||
print \$0
|
||||
next
|
||||
}
|
||||
|
||||
{ print \$0 }
|
||||
"
|
||||
|
||||
local zdot="${ZDOTDIR:-$HOME}"
|
||||
local zshrc="${${:-"${zdot}/.zshrc"}:A}"
|
||||
awk "$awk_script" "$zshrc" > "$zdot/.zshrc.new" \
|
||||
&& command cp -f "$zshrc" "$zdot/.zshrc.bck" \
|
||||
&& command mv -f "$zdot/.zshrc.new" "$zshrc"
|
||||
|
||||
# Exit if the new .zshrc file wasn't created correctly
|
||||
[[ $? -eq 0 ]] || {
|
||||
local ret=$?
|
||||
_omz::log error "error enabling plugins."
|
||||
return $ret
|
||||
}
|
||||
|
||||
# Exit if the new .zshrc file has syntax errors
|
||||
if ! command zsh -n "$zdot/.zshrc"; then
|
||||
_omz::log error "broken syntax in '"${zdot/#$HOME/\~}/.zshrc"'. Rolling back changes..."
|
||||
command mv -f "$zdot/.zshrc.bck" "$zshrc"
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Restart the zsh session if there were no errors
|
||||
_omz::log info "plugins enabled: ${(j:, :)add_plugins}."
|
||||
|
||||
# Only reload zsh if run in an interactive session
|
||||
[[ ! -o interactive ]] || _omz::reload
|
||||
}
|
||||
|
||||
function _omz::plugin::info {
|
||||
if [[ -z "$1" ]]; then
|
||||
echo >&2 "Usage: omz plugin info <plugin>"
|
||||
echo >&2 "Usage: ${(j: :)${(s.::.)0#_}} <plugin>"
|
||||
return 1
|
||||
fi
|
||||
|
||||
|
@ -194,21 +416,69 @@ function _omz::plugin::list {
|
|||
|
||||
if (( ${#custom_plugins} )); then
|
||||
print -P "%U%BCustom plugins%b%u:"
|
||||
print -l ${(q-)custom_plugins} | column
|
||||
print -lac ${(q-)custom_plugins}
|
||||
fi
|
||||
|
||||
if (( ${#builtin_plugins} )); then
|
||||
(( ${#custom_plugins} )) && echo # add a line of separation
|
||||
|
||||
print -P "%U%BBuilt-in plugins%b%u:"
|
||||
print -l ${(q-)builtin_plugins} | column
|
||||
print -lac ${(q-)builtin_plugins}
|
||||
fi
|
||||
}
|
||||
|
||||
function _omz::plugin::load {
|
||||
if [[ -z "$1" ]]; then
|
||||
echo >&2 "Usage: ${(j: :)${(s.::.)0#_}} <plugin> [...]"
|
||||
return 1
|
||||
fi
|
||||
|
||||
local plugin base has_completion=0
|
||||
for plugin in "$@"; do
|
||||
if [[ -d "$ZSH_CUSTOM/plugins/$plugin" ]]; then
|
||||
base="$ZSH_CUSTOM/plugins/$plugin"
|
||||
elif [[ -d "$ZSH/plugins/$plugin" ]]; then
|
||||
base="$ZSH/plugins/$plugin"
|
||||
else
|
||||
_omz::log warn "plugin '$plugin' not found"
|
||||
continue
|
||||
fi
|
||||
|
||||
# Check if its a valid plugin
|
||||
if [[ ! -f "$base/_$plugin" && ! -f "$base/$plugin.plugin.zsh" ]]; then
|
||||
_omz::log warn "'$plugin' is not a valid plugin"
|
||||
continue
|
||||
# It it is a valid plugin, add its directory to $fpath unless it is already there
|
||||
elif (( ! ${fpath[(Ie)$base]} )); then
|
||||
fpath=("$base" $fpath)
|
||||
fi
|
||||
|
||||
# Check if it has completion to reload compinit
|
||||
local -a comp_files
|
||||
comp_files=($base/_*(N))
|
||||
has_completion=$(( $#comp_files > 0 ))
|
||||
|
||||
# Load the plugin
|
||||
if [[ -f "$base/$plugin.plugin.zsh" ]]; then
|
||||
source "$base/$plugin.plugin.zsh"
|
||||
fi
|
||||
done
|
||||
|
||||
# If we have completion, we need to reload the completion
|
||||
# We pass -D to avoid generating a new dump file, which would overwrite our
|
||||
# current one for the next session (and we don't want that because we're not
|
||||
# actually enabling the plugins for the next session).
|
||||
# Note that we still have to pass -d "$_comp_dumpfile", so that compinit
|
||||
# doesn't use the default zcompdump location (${ZDOTDIR:-$HOME}/.zcompdump).
|
||||
if (( has_completion )); then
|
||||
compinit -D -d "$_comp_dumpfile"
|
||||
fi
|
||||
}
|
||||
|
||||
function _omz::pr {
|
||||
(( $# > 0 && $+functions[_omz::pr::$1] )) || {
|
||||
cat <<EOF
|
||||
Usage: omz pr <command> [options]
|
||||
(( $# > 0 && $+functions[$0::$1] )) || {
|
||||
cat >&2 <<EOF
|
||||
Usage: ${(j: :)${(s.::.)0#_}} <command> [options]
|
||||
|
||||
Available commands:
|
||||
|
||||
|
@ -222,7 +492,7 @@ EOF
|
|||
local command="$1"
|
||||
shift
|
||||
|
||||
_omz::pr::$command "$@"
|
||||
$0::$command "$@"
|
||||
}
|
||||
|
||||
function _omz::pr::clean {
|
||||
|
@ -263,7 +533,7 @@ function _omz::pr::test {
|
|||
|
||||
# Check the input
|
||||
if ! [[ -n "$1" && "$1" =~ ^[[:digit:]]+$ ]]; then
|
||||
echo >&2 "Usage: omz pr test <PR_NUMBER_or_URL>"
|
||||
echo >&2 "Usage: ${(j: :)${(s.::.)0#_}} <PR_NUMBER_or_URL>"
|
||||
return 1
|
||||
fi
|
||||
|
||||
|
@ -303,12 +573,27 @@ function _omz::pr::test {
|
|||
|
||||
# Rebase pull request branch against the current master
|
||||
_omz::log info "rebasing PR #$1..."
|
||||
command git rebase master ohmyzsh/pull-$1 || {
|
||||
command git rebase --abort &>/dev/null
|
||||
_omz::log warn "could not rebase PR #$1 on top of master."
|
||||
_omz::log warn "you might not see the latest stable changes."
|
||||
_omz::log info "run \`zsh\` to test the changes."
|
||||
return 1
|
||||
local ret gpgsign
|
||||
{
|
||||
# Back up commit.gpgsign setting: use --local to get the current repository
|
||||
# setting, not the global one. If --local is not a known option, it will
|
||||
# exit with a 129 status code.
|
||||
gpgsign=$(command git config --local commit.gpgsign 2>/dev/null) || ret=$?
|
||||
[[ $ret -ne 129 ]] || gpgsign=$(command git config commit.gpgsign 2>/dev/null)
|
||||
command git config commit.gpgsign false
|
||||
|
||||
command git rebase master ohmyzsh/pull-$1 || {
|
||||
command git rebase --abort &>/dev/null
|
||||
_omz::log warn "could not rebase PR #$1 on top of master."
|
||||
_omz::log warn "you might not see the latest stable changes."
|
||||
_omz::log info "run \`zsh\` to test the changes."
|
||||
return 1
|
||||
}
|
||||
} always {
|
||||
case "$gpgsign" in
|
||||
"") command git config --unset commit.gpgsign ;;
|
||||
*) command git config commit.gpgsign "$gpgsign" ;;
|
||||
esac
|
||||
}
|
||||
|
||||
_omz::log info "fetch of PR #${1} successful."
|
||||
|
@ -337,15 +622,26 @@ function _omz::pr::test {
|
|||
)
|
||||
}
|
||||
|
||||
function _omz::reload {
|
||||
# Delete current completion cache
|
||||
command rm -f $_comp_dumpfile $ZSH_COMPDUMP
|
||||
|
||||
# Old zsh versions don't have ZSH_ARGZERO
|
||||
local zsh="${ZSH_ARGZERO:-${functrace[-1]%:*}}"
|
||||
# Check whether to run a login shell
|
||||
[[ "$zsh" = -* || -o login ]] && exec -l "${zsh#-}" || exec "$zsh"
|
||||
}
|
||||
|
||||
function _omz::theme {
|
||||
(( $# > 0 && $+functions[_omz::theme::$1] )) || {
|
||||
cat <<EOF
|
||||
Usage: omz theme <command> [options]
|
||||
(( $# > 0 && $+functions[$0::$1] )) || {
|
||||
cat >&2 <<EOF
|
||||
Usage: ${(j: :)${(s.::.)0#_}} <command> [options]
|
||||
|
||||
Available commands:
|
||||
|
||||
list List all available Oh My Zsh themes
|
||||
use <theme> Load an Oh My Zsh theme
|
||||
set <theme> Set a theme in your .zshrc file
|
||||
use <theme> Load a theme
|
||||
|
||||
EOF
|
||||
return 1
|
||||
|
@ -354,7 +650,7 @@ EOF
|
|||
local command="$1"
|
||||
shift
|
||||
|
||||
_omz::theme::$command "$@"
|
||||
$0::$command "$@"
|
||||
}
|
||||
|
||||
function _omz::theme::list {
|
||||
|
@ -368,22 +664,94 @@ function _omz::theme::list {
|
|||
return
|
||||
fi
|
||||
|
||||
# Print theme in use
|
||||
if [[ -n "$ZSH_THEME" ]]; then
|
||||
print -Pn "%U%BCurrent theme%b%u: "
|
||||
[[ $ZSH_THEME = random ]] && echo "$RANDOM_THEME (via random)" || echo "$ZSH_THEME"
|
||||
echo
|
||||
fi
|
||||
|
||||
# Print custom themes if there are any
|
||||
if (( ${#custom_themes} )); then
|
||||
print -P "%U%BCustom themes%b%u:"
|
||||
print -l ${(q-)custom_themes} | column
|
||||
print -lac ${(q-)custom_themes}
|
||||
echo
|
||||
fi
|
||||
|
||||
if (( ${#builtin_themes} )); then
|
||||
(( ${#custom_themes} )) && echo # add a line of separation
|
||||
# Print built-in themes
|
||||
print -P "%U%BBuilt-in themes%b%u:"
|
||||
print -lac ${(q-)builtin_themes}
|
||||
}
|
||||
|
||||
print -P "%U%BBuilt-in themes%b%u:"
|
||||
print -l ${(q-)builtin_themes} | column
|
||||
function _omz::theme::set {
|
||||
if [[ -z "$1" ]]; then
|
||||
echo >&2 "Usage: ${(j: :)${(s.::.)0#_}} <theme>"
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Check that theme exists
|
||||
if [[ ! -f "$ZSH_CUSTOM/$1.zsh-theme" ]] \
|
||||
&& [[ ! -f "$ZSH_CUSTOM/themes/$1.zsh-theme" ]] \
|
||||
&& [[ ! -f "$ZSH/themes/$1.zsh-theme" ]]; then
|
||||
_omz::log error "%B$1%b theme not found"
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Enable theme in .zshrc
|
||||
local awk_script='
|
||||
!set && /^[ \t]*ZSH_THEME=[^#]+.*$/ {
|
||||
set=1
|
||||
sub(/^[ \t]*ZSH_THEME=[^#]+.*$/, "ZSH_THEME=\"'$1'\" # set by `omz`")
|
||||
print $0
|
||||
next
|
||||
}
|
||||
|
||||
{ print $0 }
|
||||
|
||||
END {
|
||||
# If no ZSH_THEME= line was found, return an error
|
||||
if (!set) exit 1
|
||||
}
|
||||
'
|
||||
|
||||
local zdot="${ZDOTDIR:-$HOME}"
|
||||
local zshrc="${${:-"${zdot}/.zshrc"}:A}"
|
||||
awk "$awk_script" "$zshrc" > "$zdot/.zshrc.new" \
|
||||
|| {
|
||||
# Prepend ZSH_THEME= line to .zshrc if it doesn't exist
|
||||
cat <<EOF
|
||||
ZSH_THEME="$1" # set by \`omz\`
|
||||
|
||||
EOF
|
||||
cat "$zdot/.zshrc"
|
||||
} > "$zdot/.zshrc.new" \
|
||||
&& command cp -f "$zshrc" "$zdot/.zshrc.bck" \
|
||||
&& command mv -f "$zdot/.zshrc.new" "$zshrc"
|
||||
|
||||
# Exit if the new .zshrc file wasn't created correctly
|
||||
[[ $? -eq 0 ]] || {
|
||||
local ret=$?
|
||||
_omz::log error "error setting theme."
|
||||
return $ret
|
||||
}
|
||||
|
||||
# Exit if the new .zshrc file has syntax errors
|
||||
if ! command zsh -n "$zdot/.zshrc"; then
|
||||
_omz::log error "broken syntax in '"${zdot/#$HOME/\~}/.zshrc"'. Rolling back changes..."
|
||||
command mv -f "$zdot/.zshrc.bck" "$zshrc"
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Restart the zsh session if there were no errors
|
||||
_omz::log info "'$1' theme set correctly."
|
||||
|
||||
# Only reload zsh if run in an interactive session
|
||||
[[ ! -o interactive ]] || _omz::reload
|
||||
}
|
||||
|
||||
function _omz::theme::use {
|
||||
if [[ -z "$1" ]]; then
|
||||
echo >&2 "Usage: omz theme use <theme>"
|
||||
echo >&2 "Usage: ${(j: :)${(s.::.)0#_}} <theme>"
|
||||
return 1
|
||||
fi
|
||||
|
||||
|
@ -395,19 +763,24 @@ function _omz::theme::use {
|
|||
elif [[ -f "$ZSH/themes/$1.zsh-theme" ]]; then
|
||||
source "$ZSH/themes/$1.zsh-theme"
|
||||
else
|
||||
_omz::log error "theme '$1' not found"
|
||||
_omz::log error "%B$1%b theme not found"
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Update theme settings
|
||||
ZSH_THEME="$1"
|
||||
[[ $1 = random ]] || unset RANDOM_THEME
|
||||
}
|
||||
|
||||
function _omz::update {
|
||||
local last_commit=$(cd "$ZSH"; git rev-parse HEAD)
|
||||
local last_commit=$(builtin cd -q "$ZSH"; git rev-parse HEAD)
|
||||
|
||||
# Run update script
|
||||
zstyle -s ':omz:update' verbose verbose_mode || verbose_mode=default
|
||||
if [[ "$1" != --unattended ]]; then
|
||||
ZSH="$ZSH" zsh -f "$ZSH/tools/upgrade.sh" --interactive
|
||||
ZSH="$ZSH" command zsh -f "$ZSH/tools/upgrade.sh" -i -v $verbose_mode || return $?
|
||||
else
|
||||
ZSH="$ZSH" zsh -f "$ZSH/tools/upgrade.sh"
|
||||
ZSH="$ZSH" command zsh -f "$ZSH/tools/upgrade.sh" -v $verbose_mode || return $?
|
||||
fi
|
||||
|
||||
# Update last updated file
|
||||
|
@ -417,10 +790,32 @@ function _omz::update {
|
|||
command rm -rf "$ZSH/log/update.lock"
|
||||
|
||||
# Restart the zsh session if there were changes
|
||||
if [[ "$1" != --unattended && "$(cd "$ZSH"; git rev-parse HEAD)" != "$last_commit" ]]; then
|
||||
if [[ "$1" != --unattended && "$(builtin cd -q "$ZSH"; git rev-parse HEAD)" != "$last_commit" ]]; then
|
||||
# Old zsh versions don't have ZSH_ARGZERO
|
||||
local zsh="${ZSH_ARGZERO:-${functrace[-1]%:*}}"
|
||||
# Check whether to run a login shell
|
||||
[[ "$zsh" = -* || -o login ]] && exec -l "${zsh#-}" || exec "$zsh"
|
||||
fi
|
||||
}
|
||||
|
||||
function _omz::version {
|
||||
(
|
||||
builtin cd -q "$ZSH"
|
||||
|
||||
# Get the version name:
|
||||
# 1) try tag-like version
|
||||
# 2) try branch name
|
||||
# 3) try name-rev (tag~<rev> or branch~<rev>)
|
||||
local version
|
||||
version=$(command git describe --tags HEAD 2>/dev/null) \
|
||||
|| version=$(command git symbolic-ref --quiet --short HEAD 2>/dev/null) \
|
||||
|| version=$(command git name-rev --no-undefined --name-only --exclude="remotes/*" HEAD 2>/dev/null) \
|
||||
|| version="<detached>"
|
||||
|
||||
# Get short hash for the current HEAD
|
||||
local commit=$(command git rev-parse --short HEAD 2>/dev/null)
|
||||
|
||||
# Show version and commit hash
|
||||
printf "%s (%s)\n" "$version" "$commit"
|
||||
)
|
||||
}
|
||||
|
|
|
@ -10,8 +10,8 @@
|
|||
# - pbcopy, pbpaste (macOS)
|
||||
# - cygwin (Windows running Cygwin)
|
||||
# - wl-copy, wl-paste (if $WAYLAND_DISPLAY is set)
|
||||
# - xclip (if $DISPLAY is set)
|
||||
# - xsel (if $DISPLAY is set)
|
||||
# - xclip (if $DISPLAY is set)
|
||||
# - lemonade (for SSH) https://github.com/pocke/lemonade
|
||||
# - doitclient (for SSH) http://www.chiark.greenend.org.uk/~sgtatham/doit/
|
||||
# - win32yank (Windows)
|
||||
|
@ -52,38 +52,38 @@ function detect-clipboard() {
|
|||
emulate -L zsh
|
||||
|
||||
if [[ "${OSTYPE}" == darwin* ]] && (( ${+commands[pbcopy]} )) && (( ${+commands[pbpaste]} )); then
|
||||
function clipcopy() { pbcopy < "${1:-/dev/stdin}"; }
|
||||
function clipcopy() { cat "${1:-/dev/stdin}" | pbcopy; }
|
||||
function clippaste() { pbpaste; }
|
||||
elif [[ "${OSTYPE}" == (cygwin|msys)* ]]; then
|
||||
function clipcopy() { cat "${1:-/dev/stdin}" > /dev/clipboard; }
|
||||
function clippaste() { cat /dev/clipboard; }
|
||||
elif (( $+commands[clip.exe] )) && (( $+commands[powershell.exe] )); then
|
||||
function clipcopy() { cat "${1:-/dev/stdin}" | clip.exe; }
|
||||
function clippaste() { powershell.exe -noprofile -command Get-Clipboard; }
|
||||
elif [ -n "${WAYLAND_DISPLAY:-}" ] && (( ${+commands[wl-copy]} )) && (( ${+commands[wl-paste]} )); then
|
||||
function clipcopy() { wl-copy < "${1:-/dev/stdin}"; }
|
||||
function clipcopy() { cat "${1:-/dev/stdin}" | wl-copy &>/dev/null &|; }
|
||||
function clippaste() { wl-paste; }
|
||||
elif [ -n "${DISPLAY:-}" ] && (( ${+commands[xclip]} )); then
|
||||
function clipcopy() { xclip -in -selection clipboard < "${1:-/dev/stdin}"; }
|
||||
function clippaste() { xclip -out -selection clipboard; }
|
||||
elif [ -n "${DISPLAY:-}" ] && (( ${+commands[xsel]} )); then
|
||||
function clipcopy() { xsel --clipboard --input < "${1:-/dev/stdin}"; }
|
||||
function clipcopy() { cat "${1:-/dev/stdin}" | xsel --clipboard --input; }
|
||||
function clippaste() { xsel --clipboard --output; }
|
||||
elif [ -n "${DISPLAY:-}" ] && (( ${+commands[xclip]} )); then
|
||||
function clipcopy() { cat "${1:-/dev/stdin}" | xclip -selection clipboard -in &>/dev/null &|; }
|
||||
function clippaste() { xclip -out -selection clipboard; }
|
||||
elif (( ${+commands[lemonade]} )); then
|
||||
function clipcopy() { lemonade copy < "${1:-/dev/stdin}"; }
|
||||
function clipcopy() { cat "${1:-/dev/stdin}" | lemonade copy; }
|
||||
function clippaste() { lemonade paste; }
|
||||
elif (( ${+commands[doitclient]} )); then
|
||||
function clipcopy() { doitclient wclip < "${1:-/dev/stdin}"; }
|
||||
function clipcopy() { cat "${1:-/dev/stdin}" | doitclient wclip; }
|
||||
function clippaste() { doitclient wclip -r; }
|
||||
elif (( ${+commands[win32yank]} )); then
|
||||
function clipcopy() { win32yank -i < "${1:-/dev/stdin}"; }
|
||||
function clipcopy() { cat "${1:-/dev/stdin}" | win32yank -i; }
|
||||
function clippaste() { win32yank -o; }
|
||||
elif [[ $OSTYPE == linux-android* ]] && (( $+commands[termux-clipboard-set] )); then
|
||||
function clipcopy() { termux-clipboard-set "${1:-/dev/stdin}"; }
|
||||
function clipcopy() { cat "${1:-/dev/stdin}" | termux-clipboard-set; }
|
||||
function clippaste() { termux-clipboard-get; }
|
||||
elif [ -n "${TMUX:-}" ] && (( ${+commands[tmux]} )); then
|
||||
function clipcopy() { tmux load-buffer "${1:--}"; }
|
||||
function clippaste() { tmux save-buffer -; }
|
||||
elif [[ $(uname -r) = *icrosoft* ]]; then
|
||||
function clipcopy() { clip.exe < "${1:-/dev/stdin}"; }
|
||||
function clippaste() { powershell.exe -noprofile -command Get-Clipboard; }
|
||||
else
|
||||
function _retry_clipboard_detection_or_fail() {
|
||||
local clipcmd="${1}"; shift
|
||||
|
|
|
@ -18,9 +18,9 @@ if [[ "$CASE_SENSITIVE" = true ]]; then
|
|||
zstyle ':completion:*' matcher-list 'r:|=*' 'l:|=* r:|=*'
|
||||
else
|
||||
if [[ "$HYPHEN_INSENSITIVE" = true ]]; then
|
||||
zstyle ':completion:*' matcher-list 'm:{a-zA-Z-_}={A-Za-z_-}' 'r:|=*' 'l:|=* r:|=*'
|
||||
zstyle ':completion:*' matcher-list 'm:{[:lower:][:upper:]-_}={[:upper:][:lower:]_-}' 'r:|=*' 'l:|=* r:|=*'
|
||||
else
|
||||
zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' 'r:|=*' 'l:|=* r:|=*'
|
||||
zstyle ':completion:*' matcher-list 'm:{[:lower:][:upper:]}={[:upper:][:lower:]}' 'r:|=*' 'l:|=* r:|=*'
|
||||
fi
|
||||
fi
|
||||
unset CASE_SENSITIVE HYPHEN_INSENSITIVE
|
||||
|
@ -58,9 +58,12 @@ zstyle ':completion:*:*:*:users' ignored-patterns \
|
|||
# ... unless we really want to.
|
||||
zstyle '*' single-ignored show
|
||||
|
||||
if [[ $COMPLETION_WAITING_DOTS = true ]]; then
|
||||
if [[ ${COMPLETION_WAITING_DOTS:-false} != false ]]; then
|
||||
expand-or-complete-with-dots() {
|
||||
print -Pn "%F{red}…%f"
|
||||
# use $COMPLETION_WAITING_DOTS either as toggle or as the sequence to show
|
||||
[[ $COMPLETION_WAITING_DOTS = true ]] && COMPLETION_WAITING_DOTS="%F{red}…%f"
|
||||
# turn off line wrapping and print prompt-expanded "dot" sequence
|
||||
printf '\e[?7l%s\e[?7h' "${(%)COMPLETION_WAITING_DOTS}"
|
||||
zle expand-or-complete
|
||||
zle redisplay
|
||||
}
|
||||
|
|
|
@ -1,14 +1,10 @@
|
|||
if [[ "$ENABLE_CORRECTION" == "true" ]]; then
|
||||
alias cp='nocorrect cp'
|
||||
alias ebuild='nocorrect ebuild'
|
||||
alias gist='nocorrect gist'
|
||||
alias heroku='nocorrect heroku'
|
||||
alias hpodder='nocorrect hpodder'
|
||||
alias man='nocorrect man'
|
||||
alias mkdir='nocorrect mkdir'
|
||||
alias mv='nocorrect mv'
|
||||
alias mysql='nocorrect mysql'
|
||||
alias sudo='nocorrect sudo'
|
||||
alias su='nocorrect su'
|
||||
|
||||
setopt correct_all
|
||||
fi
|
||||
|
|
|
@ -335,7 +335,7 @@ function _omz_diag_dump_os_specific_version() {
|
|||
builtin echo "OS Version: $osname $osver build $(sw_vers -buildVersion)"
|
||||
;;
|
||||
cygwin)
|
||||
command systeminfo | command head -4 | command tail -2
|
||||
command systeminfo | command head -n 4 | command tail -n 2
|
||||
;;
|
||||
esac
|
||||
|
||||
|
|
|
@ -1,15 +1,17 @@
|
|||
# Changing/making/removing directory
|
||||
setopt auto_cd
|
||||
setopt auto_pushd
|
||||
setopt pushd_ignore_dups
|
||||
setopt pushdminus
|
||||
|
||||
|
||||
alias -g ...='../..'
|
||||
alias -g ....='../../..'
|
||||
alias -g .....='../../../..'
|
||||
alias -g ......='../../../../..'
|
||||
|
||||
alias -- -='cd -'
|
||||
alias 1='cd -'
|
||||
alias 1='cd -1'
|
||||
alias 2='cd -2'
|
||||
alias 3='cd -3'
|
||||
alias 4='cd -4'
|
||||
|
@ -26,7 +28,7 @@ function d () {
|
|||
if [[ -n $1 ]]; then
|
||||
dirs "$@"
|
||||
else
|
||||
dirs -v | head -10
|
||||
dirs -v | head -n 10
|
||||
fi
|
||||
}
|
||||
compdef _dirs d
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
function zsh_stats() {
|
||||
fc -l 1 \
|
||||
| awk '{ CMD[$2]++; count++; } END { for (a in CMD) print CMD[a] " " CMD[a]*100/count "% " a }' \
|
||||
| grep -v "./" | sort -nr | head -20 | column -c3 -s " " -t | nl
|
||||
| grep -v "./" | sort -nr | head -n 20 | column -c3 -s " " -t | nl
|
||||
}
|
||||
|
||||
function uninstall_oh_my_zsh() {
|
||||
env ZSH="$ZSH" sh "$ZSH/tools/uninstall.sh"
|
||||
command env ZSH="$ZSH" sh "$ZSH/tools/uninstall.sh"
|
||||
}
|
||||
|
||||
function upgrade_oh_my_zsh() {
|
||||
|
@ -13,10 +13,6 @@ function upgrade_oh_my_zsh() {
|
|||
omz update
|
||||
}
|
||||
|
||||
function take() {
|
||||
mkdir -p $@ && cd ${@:$#}
|
||||
}
|
||||
|
||||
function open_command() {
|
||||
local open_cmd
|
||||
|
||||
|
@ -34,9 +30,48 @@ function open_command() {
|
|||
;;
|
||||
esac
|
||||
|
||||
# If a URL is passed, $BROWSER might be set to a local browser within SSH.
|
||||
# See https://github.com/ohmyzsh/ohmyzsh/issues/11098
|
||||
if [[ -n "$BROWSER" && "$1" = (http|https)://* ]]; then
|
||||
"$BROWSER" "$@"
|
||||
return
|
||||
fi
|
||||
|
||||
${=open_cmd} "$@" &>/dev/null
|
||||
}
|
||||
|
||||
# take functions
|
||||
|
||||
# mkcd is equivalent to takedir
|
||||
function mkcd takedir() {
|
||||
mkdir -p $@ && cd ${@:$#}
|
||||
}
|
||||
|
||||
function takeurl() {
|
||||
local data thedir
|
||||
data="$(mktemp)"
|
||||
curl -L "$1" > "$data"
|
||||
tar xf "$data"
|
||||
thedir="$(tar tf "$data" | head -n 1)"
|
||||
rm "$data"
|
||||
cd "$thedir"
|
||||
}
|
||||
|
||||
function takegit() {
|
||||
git clone "$1"
|
||||
cd "$(basename ${1%%.git})"
|
||||
}
|
||||
|
||||
function take() {
|
||||
if [[ $1 =~ ^(https?|ftp).*\.(tar\.(gz|bz2|xz)|tgz)$ ]]; then
|
||||
takeurl "$1"
|
||||
elif [[ $1 =~ ^([A-Za-z0-9]\+@|https?|git|ssh|ftps?|rsync).*\.git/?$ ]]; then
|
||||
takegit "$1"
|
||||
else
|
||||
takedir "$@"
|
||||
fi
|
||||
}
|
||||
|
||||
#
|
||||
# Get the value of an alias.
|
||||
#
|
||||
|
@ -116,7 +151,7 @@ zmodload zsh/langinfo
|
|||
# Returns nonzero if encoding failed.
|
||||
#
|
||||
# Usage:
|
||||
# omz_urlencode [-r] [-m] [-P] <string>
|
||||
# omz_urlencode [-r] [-m] [-P] <string> [<string> ...]
|
||||
#
|
||||
# -r causes reserved characters (;/?:@&=+$,) to be escaped
|
||||
#
|
||||
|
@ -128,7 +163,7 @@ function omz_urlencode() {
|
|||
local -a opts
|
||||
zparseopts -D -E -a opts r m P
|
||||
|
||||
local in_str=$1
|
||||
local in_str="$@"
|
||||
local url_str=""
|
||||
local spaces_as_plus
|
||||
if [[ -z $opts[(r)-P] ]]; then spaces_as_plus=1; fi
|
||||
|
@ -209,12 +244,11 @@ function omz_urldecode {
|
|||
tmp=${tmp:gs/\\/\\\\/}
|
||||
# Handle %-escapes by turning them into `\xXX` printf escapes
|
||||
tmp=${tmp:gs/%/\\x/}
|
||||
local decoded
|
||||
eval "decoded=\$'$tmp'"
|
||||
local decoded="$(printf -- "$tmp")"
|
||||
|
||||
# Now we have a UTF-8 encoded string in the variable. We need to re-encode
|
||||
# it if caller is in a non-UTF-8 locale.
|
||||
local safe_encodings
|
||||
local -a safe_encodings
|
||||
safe_encodings=(UTF-8 utf8 US-ASCII)
|
||||
if [[ -z ${safe_encodings[(r)$caller_encoding]} ]]; then
|
||||
decoded=$(echo -E "$decoded" | iconv -f UTF-8 -t $caller_encoding)
|
||||
|
|
10
lib/git.zsh
10
lib/git.zsh
|
@ -19,6 +19,7 @@ function git_prompt_info() {
|
|||
|
||||
local ref
|
||||
ref=$(__git_prompt_git symbolic-ref --short HEAD 2> /dev/null) \
|
||||
|| ref=$(__git_prompt_git describe --tags --exact-match HEAD 2> /dev/null) \
|
||||
|| ref=$(__git_prompt_git rev-parse --short HEAD 2> /dev/null) \
|
||||
|| return 0
|
||||
|
||||
|
@ -29,7 +30,7 @@ function git_prompt_info() {
|
|||
&& upstream=" -> ${upstream}"
|
||||
fi
|
||||
|
||||
echo "${ZSH_THEME_GIT_PROMPT_PREFIX}${ref}${upstream}$(parse_git_dirty)${ZSH_THEME_GIT_PROMPT_SUFFIX}"
|
||||
echo "${ZSH_THEME_GIT_PROMPT_PREFIX}${ref:gs/%/%%}${upstream:gs/%/%%}$(parse_git_dirty)${ZSH_THEME_GIT_PROMPT_SUFFIX}"
|
||||
}
|
||||
|
||||
# Checks if working tree is dirty
|
||||
|
@ -51,7 +52,7 @@ function parse_git_dirty() {
|
|||
FLAGS+="--ignore-submodules=${GIT_STATUS_IGNORE_SUBMODULES:-dirty}"
|
||||
;;
|
||||
esac
|
||||
STATUS=$(__git_prompt_git status ${FLAGS} 2> /dev/null | tail -1)
|
||||
STATUS=$(__git_prompt_git status ${FLAGS} 2> /dev/null | tail -n 1)
|
||||
fi
|
||||
if [[ -n $STATUS ]]; then
|
||||
echo "$ZSH_THEME_GIT_PROMPT_DIRTY"
|
||||
|
@ -82,7 +83,7 @@ function git_remote_status() {
|
|||
fi
|
||||
|
||||
if [[ -n $ZSH_THEME_GIT_PROMPT_REMOTE_STATUS_DETAILED ]]; then
|
||||
git_remote_status="$ZSH_THEME_GIT_PROMPT_REMOTE_STATUS_PREFIX$remote$git_remote_status_detailed$ZSH_THEME_GIT_PROMPT_REMOTE_STATUS_SUFFIX"
|
||||
git_remote_status="$ZSH_THEME_GIT_PROMPT_REMOTE_STATUS_PREFIX${remote:gs/%/%%}$git_remote_status_detailed$ZSH_THEME_GIT_PROMPT_REMOTE_STATUS_SUFFIX"
|
||||
fi
|
||||
|
||||
echo $git_remote_status
|
||||
|
@ -206,7 +207,8 @@ function git_prompt_status() {
|
|||
STASHED UNMERGED AHEAD BEHIND DIVERGED
|
||||
)
|
||||
|
||||
local status_text="$(__git_prompt_git status --porcelain -b 2> /dev/null)"
|
||||
local status_text
|
||||
status_text="$(__git_prompt_git status --porcelain -b 2> /dev/null)"
|
||||
|
||||
# Don't continue on a catastrophic failure
|
||||
if [[ $? -eq 128 ]]; then
|
||||
|
|
|
@ -24,8 +24,8 @@ else
|
|||
if [[ -n "$GREP_OPTIONS" ]]; then
|
||||
# export grep, egrep and fgrep settings
|
||||
alias grep="grep $GREP_OPTIONS"
|
||||
alias egrep="egrep $GREP_OPTIONS"
|
||||
alias fgrep="fgrep $GREP_OPTIONS"
|
||||
alias egrep="grep -E $GREP_OPTIONS"
|
||||
alias fgrep="grep -F $GREP_OPTIONS"
|
||||
|
||||
# write to cache file if cache directory is writable
|
||||
if [[ -w "$ZSH_CACHE_DIR" ]]; then
|
||||
|
|
12
lib/misc.zsh
12
lib/misc.zsh
|
@ -15,8 +15,9 @@ if [[ $DISABLE_MAGIC_FUNCTIONS != true ]]; then
|
|||
done
|
||||
fi
|
||||
|
||||
## jobs
|
||||
setopt long_list_jobs
|
||||
setopt multios # enable redirect to multiple streams: echo >file1 >file2
|
||||
setopt long_list_jobs # show long list format job notifications
|
||||
setopt interactivecomments # recognize comments
|
||||
|
||||
env_default 'PAGER' 'less'
|
||||
env_default 'LESS' '-R'
|
||||
|
@ -24,12 +25,9 @@ env_default 'LESS' '-R'
|
|||
## super user alias
|
||||
alias _='sudo '
|
||||
|
||||
## more intelligent acking for ubuntu users
|
||||
## more intelligent acking for ubuntu users and no alias for users without ack
|
||||
if (( $+commands[ack-grep] )); then
|
||||
alias afind='ack-grep -il'
|
||||
else
|
||||
elif (( $+commands[ack] )); then
|
||||
alias afind='ack -il'
|
||||
fi
|
||||
|
||||
# recognize comments
|
||||
setopt interactivecomments
|
||||
|
|
|
@ -2,5 +2,5 @@
|
|||
function nvm_prompt_info() {
|
||||
which nvm &>/dev/null || return
|
||||
local nvm_prompt=${$(nvm current)#v}
|
||||
echo "${ZSH_THEME_NVM_PROMPT_PREFIX}${nvm_prompt}${ZSH_THEME_NVM_PROMPT_SUFFIX}"
|
||||
echo "${ZSH_THEME_NVM_PROMPT_PREFIX}${nvm_prompt:gs/%/%%}${ZSH_THEME_NVM_PROMPT_SUFFIX}"
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ function chruby_prompt_info \
|
|||
vi_mode_prompt_info \
|
||||
virtualenv_prompt_info \
|
||||
jenv_prompt_info \
|
||||
azure_prompt_info \
|
||||
tf_prompt_info \
|
||||
{
|
||||
return 1
|
||||
|
@ -30,7 +31,7 @@ function rvm_prompt_info() {
|
|||
local rvm_prompt
|
||||
rvm_prompt=$($HOME/.rvm/bin/rvm-prompt ${=ZSH_THEME_RVM_PROMPT_OPTIONS} 2>/dev/null)
|
||||
[[ -z "${rvm_prompt}" ]] && return 1
|
||||
echo "${ZSH_THEME_RUBY_PROMPT_PREFIX}${rvm_prompt}${ZSH_THEME_RUBY_PROMPT_SUFFIX}"
|
||||
echo "${ZSH_THEME_RUBY_PROMPT_PREFIX}${rvm_prompt:gs/%/%%}${ZSH_THEME_RUBY_PROMPT_SUFFIX}"
|
||||
}
|
||||
|
||||
ZSH_THEME_RVM_PROMPT_OPTIONS="i v g"
|
||||
|
|
|
@ -20,16 +20,18 @@ done
|
|||
|
||||
# Show all 256 colors with color number
|
||||
function spectrum_ls() {
|
||||
setopt localoptions nopromptsubst
|
||||
local ZSH_SPECTRUM_TEXT=${ZSH_SPECTRUM_TEXT:-Arma virumque cano Troiae qui primus ab oris}
|
||||
for code in {000..255}; do
|
||||
print -P -- "$code: $FG[$code]$ZSH_SPECTRUM_TEXT%{$reset_color%}"
|
||||
print -P -- "$code: ${FG[$code]}${ZSH_SPECTRUM_TEXT}%{$reset_color%}"
|
||||
done
|
||||
}
|
||||
|
||||
# Show all 256 colors where the background is set to specific color
|
||||
function spectrum_bls() {
|
||||
setopt localoptions nopromptsubst
|
||||
local ZSH_SPECTRUM_TEXT=${ZSH_SPECTRUM_TEXT:-Arma virumque cano Troiae qui primus ab oris}
|
||||
for code in {000..255}; do
|
||||
print -P -- "$code: $BG[$code]$ZSH_SPECTRUM_TEXT%{$reset_color%}"
|
||||
print -P -- "$code: ${BG[$code]}${ZSH_SPECTRUM_TEXT}%{$reset_color%}"
|
||||
done
|
||||
}
|
||||
|
|
|
@ -7,17 +7,17 @@
|
|||
# (In screen, only short_tab_title is used)
|
||||
# Limited support for Apple Terminal (Terminal can't set window and tab separately)
|
||||
function title {
|
||||
emulate -L zsh
|
||||
setopt prompt_subst
|
||||
setopt localoptions nopromptsubst
|
||||
|
||||
[[ "$INSIDE_EMACS" == *term* ]] && return
|
||||
# Don't set the title if inside emacs, unless using vterm
|
||||
[[ -n "${INSIDE_EMACS:-}" && "$INSIDE_EMACS" != vterm ]] && return
|
||||
|
||||
# if $2 is unset use $1 as default
|
||||
# if it is set and empty, leave it as is
|
||||
: ${2=$1}
|
||||
|
||||
case "$TERM" in
|
||||
cygwin|xterm*|putty*|rxvt*|konsole*|ansi|mlterm*|alacritty|st*)
|
||||
cygwin|xterm*|putty*|rxvt*|konsole*|ansi|mlterm*|alacritty|st*|foot|contour*)
|
||||
print -Pn "\e]2;${2:q}\a" # set window name
|
||||
print -Pn "\e]1;${1:q}\a" # set tab name
|
||||
;;
|
||||
|
@ -29,12 +29,9 @@ function title {
|
|||
print -Pn "\e]2;${2:q}\a" # set window name
|
||||
print -Pn "\e]1;${1:q}\a" # set tab name
|
||||
else
|
||||
# Try to use terminfo to set the title
|
||||
# If the feature is available set title
|
||||
if [[ -n "$terminfo[fsl]" ]] && [[ -n "$terminfo[tsl]" ]]; then
|
||||
echoti tsl
|
||||
print -Pn "$1"
|
||||
echoti fsl
|
||||
# Try to use terminfo to set the title if the feature is available
|
||||
if (( ${+terminfo[fsl]} && ${+terminfo[tsl]} )); then
|
||||
print -Pn "${terminfo[tsl]}$1${terminfo[fsl]}"
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
|
@ -50,13 +47,13 @@ fi
|
|||
|
||||
# Runs before showing the prompt
|
||||
function omz_termsupport_precmd {
|
||||
[[ "${DISABLE_AUTO_TITLE:-}" == true ]] && return
|
||||
title $ZSH_THEME_TERM_TAB_TITLE_IDLE $ZSH_THEME_TERM_TITLE_IDLE
|
||||
[[ "${DISABLE_AUTO_TITLE:-}" != true ]] || return
|
||||
title "$ZSH_THEME_TERM_TAB_TITLE_IDLE" "$ZSH_THEME_TERM_TITLE_IDLE"
|
||||
}
|
||||
|
||||
# Runs before executing the command
|
||||
function omz_termsupport_preexec {
|
||||
[[ "${DISABLE_AUTO_TITLE:-}" == true ]] && return
|
||||
[[ "${DISABLE_AUTO_TITLE:-}" != true ]] || return
|
||||
|
||||
emulate -L zsh
|
||||
setopt extended_glob
|
||||
|
@ -99,39 +96,68 @@ function omz_termsupport_preexec {
|
|||
fi
|
||||
|
||||
# cmd name only, or if this is sudo or ssh, the next cmd
|
||||
local CMD=${1[(wr)^(*=*|sudo|ssh|mosh|rake|-*)]:gs/%/%%}
|
||||
local CMD="${1[(wr)^(*=*|sudo|ssh|mosh|rake|-*)]:gs/%/%%}"
|
||||
local LINE="${2:gs/%/%%}"
|
||||
|
||||
title '$CMD' '%100>...>$LINE%<<'
|
||||
title "$CMD" "%100>...>${LINE}%<<"
|
||||
}
|
||||
|
||||
autoload -U add-zsh-hook
|
||||
add-zsh-hook precmd omz_termsupport_precmd
|
||||
add-zsh-hook preexec omz_termsupport_preexec
|
||||
autoload -Uz add-zsh-hook
|
||||
|
||||
|
||||
# Keep Apple Terminal.app's current working directory updated
|
||||
# Based on this answer: https://superuser.com/a/315029
|
||||
# With extra fixes to handle multibyte chars and non-UTF-8 locales
|
||||
|
||||
if [[ "$TERM_PROGRAM" == "Apple_Terminal" ]] && [[ -z "$INSIDE_EMACS" ]]; then
|
||||
# Emits the control sequence to notify Terminal.app of the cwd
|
||||
# Identifies the directory using a file: URI scheme, including
|
||||
# the host name to disambiguate local vs. remote paths.
|
||||
function update_terminalapp_cwd() {
|
||||
emulate -L zsh
|
||||
|
||||
# Percent-encode the host and path names.
|
||||
local URL_HOST URL_PATH
|
||||
URL_HOST="$(omz_urlencode -P $HOST)" || return 1
|
||||
URL_PATH="$(omz_urlencode -P $PWD)" || return 1
|
||||
|
||||
# Undocumented Terminal.app-specific control sequence
|
||||
printf '\e]7;%s\a' "file://$URL_HOST$URL_PATH"
|
||||
}
|
||||
|
||||
# Use a precmd hook instead of a chpwd hook to avoid contaminating output
|
||||
add-zsh-hook precmd update_terminalapp_cwd
|
||||
# Run once to get initial cwd set
|
||||
update_terminalapp_cwd
|
||||
if [[ -z "$INSIDE_EMACS" || "$INSIDE_EMACS" = vterm ]]; then
|
||||
add-zsh-hook precmd omz_termsupport_precmd
|
||||
add-zsh-hook preexec omz_termsupport_preexec
|
||||
fi
|
||||
|
||||
# Keep terminal emulator's current working directory correct,
|
||||
# even if the current working directory path contains symbolic links
|
||||
#
|
||||
# References:
|
||||
# - Apple's Terminal.app: https://superuser.com/a/315029
|
||||
# - iTerm2: https://iterm2.com/documentation-escape-codes.html (iTerm2 Extension / CurrentDir+RemoteHost)
|
||||
# - Konsole: https://bugs.kde.org/show_bug.cgi?id=327720#c1
|
||||
# - libvte (gnome-terminal, mate-terminal, …): https://bugzilla.gnome.org/show_bug.cgi?id=675987#c14
|
||||
# Apparently it had a bug before ~2012 were it would display the unknown OSC 7 code
|
||||
#
|
||||
# As of May 2021 mlterm, PuTTY, rxvt, screen, termux & xterm simply ignore the unknown OSC.
|
||||
|
||||
# Don't define the function if we're inside Emacs or in an SSH session (#11696)
|
||||
if [[ -n "$INSIDE_EMACS" || -n "$SSH_CLIENT" || -n "$SSH_TTY" ]]; then
|
||||
return
|
||||
fi
|
||||
|
||||
# Don't define the function if we're in an unsupported terminal
|
||||
case "$TERM" in
|
||||
# all of these either process OSC 7 correctly or ignore entirely
|
||||
xterm*|putty*|rxvt*|konsole*|mlterm*|alacritty|screen*|tmux*) ;;
|
||||
contour*|foot*) ;;
|
||||
*)
|
||||
# Terminal.app and iTerm2 process OSC 7 correctly
|
||||
case "$TERM_PROGRAM" in
|
||||
Apple_Terminal|iTerm.app) ;;
|
||||
*) return ;;
|
||||
esac ;;
|
||||
esac
|
||||
|
||||
# Emits the control sequence to notify many terminal emulators
|
||||
# of the cwd
|
||||
#
|
||||
# Identifies the directory using a file: URI scheme, including
|
||||
# the host name to disambiguate local vs. remote paths.
|
||||
function omz_termsupport_cwd {
|
||||
# Percent-encode the host and path names.
|
||||
local URL_HOST URL_PATH
|
||||
URL_HOST="$(omz_urlencode -P $HOST)" || return 1
|
||||
URL_PATH="$(omz_urlencode -P $PWD)" || return 1
|
||||
|
||||
# Konsole errors if the HOST is provided
|
||||
[[ -z "$KONSOLE_VERSION" ]] || URL_HOST=""
|
||||
|
||||
# common control sequence (OSC 7) to set current host and path
|
||||
printf "\e]7;file://%s%s\e\\" "${URL_HOST}" "${URL_PATH}"
|
||||
}
|
||||
|
||||
# Use a precmd hook instead of a chpwd hook to avoid contaminating output
|
||||
# i.e. when a script or function changes directory without `cd -q`, chpwd
|
||||
# will be called the output may be swallowed by the script or function.
|
||||
add-zsh-hook precmd omz_termsupport_cwd
|
||||
|
|
|
@ -1,59 +1,81 @@
|
|||
# ls colors
|
||||
# Sets color variable such as $fg, $bg, $color and $reset_color
|
||||
autoload -U colors && colors
|
||||
|
||||
# Enable ls colors
|
||||
# Expand variables and commands in PROMPT variables
|
||||
setopt prompt_subst
|
||||
|
||||
# Prompt function theming defaults
|
||||
ZSH_THEME_GIT_PROMPT_PREFIX="git:(" # Beginning of the git prompt, before the branch name
|
||||
ZSH_THEME_GIT_PROMPT_SUFFIX=")" # End of the git prompt
|
||||
ZSH_THEME_GIT_PROMPT_DIRTY="*" # Text to display if the branch is dirty
|
||||
ZSH_THEME_GIT_PROMPT_CLEAN="" # Text to display if the branch is clean
|
||||
ZSH_THEME_RUBY_PROMPT_PREFIX="("
|
||||
ZSH_THEME_RUBY_PROMPT_SUFFIX=")"
|
||||
|
||||
|
||||
# Use diff --color if available
|
||||
if command diff --color /dev/null{,} &>/dev/null; then
|
||||
function diff {
|
||||
command diff --color "$@"
|
||||
}
|
||||
fi
|
||||
|
||||
# Don't set ls coloring if disabled
|
||||
[[ "$DISABLE_LS_COLORS" != true ]] || return 0
|
||||
|
||||
# Default coloring for BSD-based ls
|
||||
export LSCOLORS="Gxfxcxdxbxegedabagacad"
|
||||
|
||||
# TODO organise this chaotic logic
|
||||
|
||||
if [[ "$DISABLE_LS_COLORS" != "true" ]]; then
|
||||
# Find the option for using colors in ls, depending on the version
|
||||
if [[ "$OSTYPE" == netbsd* ]]; then
|
||||
# On NetBSD, test if "gls" (GNU ls) is installed (this one supports colors);
|
||||
# otherwise, leave ls as is, because NetBSD's ls doesn't support -G
|
||||
gls --color -d . &>/dev/null && alias ls='gls --color=tty'
|
||||
elif [[ "$OSTYPE" == openbsd* ]]; then
|
||||
# On OpenBSD, "gls" (ls from GNU coreutils) and "colorls" (ls from base,
|
||||
# with color and multibyte support) are available from ports. "colorls"
|
||||
# will be installed on purpose and can't be pulled in by installing
|
||||
# coreutils, so prefer it to "gls".
|
||||
gls --color -d . &>/dev/null && alias ls='gls --color=tty'
|
||||
colorls -G -d . &>/dev/null && alias ls='colorls -G'
|
||||
elif [[ "$OSTYPE" == (darwin|freebsd)* ]]; then
|
||||
# this is a good alias, it works by default just using $LSCOLORS
|
||||
ls -G . &>/dev/null && alias ls='ls -G'
|
||||
|
||||
# only use coreutils ls if there is a dircolors customization present ($LS_COLORS or .dircolors file)
|
||||
# otherwise, gls will use the default color scheme which is ugly af
|
||||
[[ -n "$LS_COLORS" || -f "$HOME/.dircolors" ]] && gls --color -d . &>/dev/null && alias ls='gls --color=tty'
|
||||
# Default coloring for GNU-based ls
|
||||
if [[ -z "$LS_COLORS" ]]; then
|
||||
# Define LS_COLORS via dircolors if available. Otherwise, set a default
|
||||
# equivalent to LSCOLORS (generated via https://geoff.greer.fm/lscolors)
|
||||
if (( $+commands[dircolors] )); then
|
||||
[[ -f "$HOME/.dircolors" ]] \
|
||||
&& source <(dircolors -b "$HOME/.dircolors") \
|
||||
|| source <(dircolors -b)
|
||||
else
|
||||
# For GNU ls, we use the default ls color theme. They can later be overwritten by themes.
|
||||
if [[ -z "$LS_COLORS" ]]; then
|
||||
(( $+commands[dircolors] )) && eval "$(dircolors -b)"
|
||||
fi
|
||||
|
||||
ls --color -d . &>/dev/null && alias ls='ls --color=tty' || { ls -G . &>/dev/null && alias ls='ls -G' }
|
||||
|
||||
# Take advantage of $LS_COLORS for completion as well.
|
||||
zstyle ':completion:*' list-colors "${(s.:.)LS_COLORS}"
|
||||
export LS_COLORS="di=1;36:ln=35:so=32:pi=33:ex=31:bd=34;46:cd=34;43:su=30;41:sg=30;46:tw=30;42:ow=30;43"
|
||||
fi
|
||||
fi
|
||||
|
||||
# enable diff color if possible.
|
||||
if command diff --color . . &>/dev/null; then
|
||||
alias diff='diff --color'
|
||||
fi
|
||||
function test-ls-args {
|
||||
local cmd="$1" # ls, gls, colorls, ...
|
||||
local args="${@[2,-1]}" # arguments except the first one
|
||||
command "$cmd" "$args" /dev/null &>/dev/null
|
||||
}
|
||||
|
||||
setopt auto_cd
|
||||
setopt multios
|
||||
setopt prompt_subst
|
||||
# Find the option for using colors in ls, depending on the version
|
||||
case "$OSTYPE" in
|
||||
netbsd*)
|
||||
# On NetBSD, test if `gls` (GNU ls) is installed (this one supports colors);
|
||||
# otherwise, leave ls as is, because NetBSD's ls doesn't support -G
|
||||
test-ls-args gls --color && alias ls='gls --color=tty'
|
||||
;;
|
||||
openbsd*)
|
||||
# On OpenBSD, `gls` (ls from GNU coreutils) and `colorls` (ls from base,
|
||||
# with color and multibyte support) are available from ports.
|
||||
# `colorls` will be installed on purpose and can't be pulled in by installing
|
||||
# coreutils (which might be installed for ), so prefer it to `gls`.
|
||||
test-ls-args gls --color && alias ls='gls --color=tty'
|
||||
test-ls-args colorls -G && alias ls='colorls -G'
|
||||
;;
|
||||
(darwin|freebsd)*)
|
||||
# This alias works by default just using $LSCOLORS
|
||||
test-ls-args ls -G && alias ls='ls -G'
|
||||
# Only use GNU ls if installed and there are user defaults for $LS_COLORS,
|
||||
# as the default coloring scheme is not very pretty
|
||||
zstyle -t ':omz:lib:theme-and-appearance' gnu-ls \
|
||||
&& test-ls-args gls --color \
|
||||
&& alias ls='gls --color=tty'
|
||||
;;
|
||||
*)
|
||||
if test-ls-args ls --color; then
|
||||
alias ls='ls --color=tty'
|
||||
elif test-ls-args ls -G; then
|
||||
alias ls='ls -G'
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
[[ -n "$WINDOW" ]] && SCREEN_NO="%B$WINDOW%b " || SCREEN_NO=""
|
||||
|
||||
# git theming default: Variables for theming the git info prompt
|
||||
ZSH_THEME_GIT_PROMPT_PREFIX="git:(" # Prefix at the very beginning of the prompt, before the branch name
|
||||
ZSH_THEME_GIT_PROMPT_SUFFIX=")" # At the very end of the prompt
|
||||
ZSH_THEME_GIT_PROMPT_DIRTY="*" # Text to display if the branch is dirty
|
||||
ZSH_THEME_GIT_PROMPT_CLEAN="" # Text to display if the branch is clean
|
||||
ZSH_THEME_RUBY_PROMPT_PREFIX="("
|
||||
ZSH_THEME_RUBY_PROMPT_SUFFIX=")"
|
||||
unfunction test-ls-args
|
||||
|
|
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 0
|
||||
|
||||
# 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
|
173
oh-my-zsh.sh
173
oh-my-zsh.sh
|
@ -1,3 +1,43 @@
|
|||
# Protect against non-zsh execution of Oh My Zsh (use POSIX syntax here)
|
||||
[ -n "$ZSH_VERSION" ] || {
|
||||
# ANSI formatting function (\033[<code>m)
|
||||
# 0: reset, 1: bold, 4: underline, 22: no bold, 24: no underline, 31: red, 33: yellow
|
||||
omz_f() {
|
||||
[ $# -gt 0 ] || return
|
||||
IFS=";" printf "\033[%sm" $*
|
||||
}
|
||||
# If stdout is not a terminal ignore all formatting
|
||||
[ -t 1 ] || omz_f() { :; }
|
||||
|
||||
omz_ptree() {
|
||||
# Get process tree of the current process
|
||||
pid=$$; pids="$pid"
|
||||
while [ ${pid-0} -ne 1 ] && ppid=$(ps -e -o pid,ppid | awk "\$1 == $pid { print \$2 }"); do
|
||||
pids="$pids $pid"; pid=$ppid
|
||||
done
|
||||
|
||||
# Show process tree
|
||||
case "$(uname)" in
|
||||
Linux) ps -o ppid,pid,command -f -p $pids 2>/dev/null ;;
|
||||
Darwin|*) ps -o ppid,pid,command -p $pids 2>/dev/null ;;
|
||||
esac
|
||||
|
||||
# If ps command failed, try Busybox ps
|
||||
[ $? -eq 0 ] || ps -o ppid,pid,comm | awk "NR == 1 || index(\"$pids\", \$2) != 0"
|
||||
}
|
||||
|
||||
{
|
||||
shell=$(ps -o pid,comm | awk "\$1 == $$ { print \$2 }")
|
||||
printf "$(omz_f 1 31)Error:$(omz_f 22) Oh My Zsh can't be loaded from: $(omz_f 1)${shell}$(omz_f 22). "
|
||||
printf "You need to run $(omz_f 1)zsh$(omz_f 22) instead.$(omz_f 0)\n"
|
||||
printf "$(omz_f 33)Here's the process tree:$(omz_f 22)\n\n"
|
||||
omz_ptree
|
||||
printf "$(omz_f 0)\n"
|
||||
} >&2
|
||||
|
||||
return 1
|
||||
}
|
||||
|
||||
# If ZSH is not defined, use the current script's directory.
|
||||
[[ -z "$ZSH" ]] && export ZSH="${${(%):-%x}:a:h}"
|
||||
|
||||
|
@ -7,18 +47,25 @@ if [[ -z "$ZSH_CACHE_DIR" ]]; then
|
|||
ZSH_CACHE_DIR="$ZSH/cache"
|
||||
fi
|
||||
|
||||
# Check for updates on initial load...
|
||||
if [ "$DISABLE_AUTO_UPDATE" != "true" ]; then
|
||||
source $ZSH/tools/check_for_upgrade.sh
|
||||
# Make sure $ZSH_CACHE_DIR is writable, otherwise use a directory in $HOME
|
||||
if [[ ! -w "$ZSH_CACHE_DIR" ]]; then
|
||||
ZSH_CACHE_DIR="${XDG_CACHE_HOME:-$HOME/.cache}/oh-my-zsh"
|
||||
fi
|
||||
|
||||
# Create cache and completions dir and add to $fpath
|
||||
mkdir -p "$ZSH_CACHE_DIR/completions"
|
||||
(( ${fpath[(Ie)"$ZSH_CACHE_DIR/completions"]} )) || fpath=("$ZSH_CACHE_DIR/completions" $fpath)
|
||||
|
||||
# Check for updates on initial load...
|
||||
source "$ZSH/tools/check_for_upgrade.sh"
|
||||
|
||||
# Initializes Oh My Zsh
|
||||
|
||||
# add a function path
|
||||
fpath=($ZSH/functions $ZSH/completions $fpath)
|
||||
fpath=("$ZSH/functions" "$ZSH/completions" $fpath)
|
||||
|
||||
# Load all stock functions (from $fpath files) called below.
|
||||
autoload -U compaudit compinit
|
||||
autoload -U compaudit compinit zrecompile
|
||||
|
||||
# Set ZSH_CUSTOM to the path where your custom config files
|
||||
# and plugins exists, or else we will use the default custom/
|
||||
|
@ -26,7 +73,6 @@ if [[ -z "$ZSH_CUSTOM" ]]; then
|
|||
ZSH_CUSTOM="$ZSH/custom"
|
||||
fi
|
||||
|
||||
|
||||
is_plugin() {
|
||||
local base_dir=$1
|
||||
local name=$2
|
||||
|
@ -37,10 +83,10 @@ is_plugin() {
|
|||
# Add all defined plugins to fpath. This must be done
|
||||
# before running compinit.
|
||||
for plugin ($plugins); do
|
||||
if is_plugin $ZSH_CUSTOM $plugin; then
|
||||
fpath=($ZSH_CUSTOM/plugins/$plugin $fpath)
|
||||
elif is_plugin $ZSH $plugin; then
|
||||
fpath=($ZSH/plugins/$plugin $fpath)
|
||||
if is_plugin "$ZSH_CUSTOM" "$plugin"; then
|
||||
fpath=("$ZSH_CUSTOM/plugins/$plugin" $fpath)
|
||||
elif is_plugin "$ZSH" "$plugin"; then
|
||||
fpath=("$ZSH/plugins/$plugin" $fpath)
|
||||
else
|
||||
echo "[oh-my-zsh] plugin '$plugin' not found"
|
||||
fi
|
||||
|
@ -49,14 +95,14 @@ done
|
|||
# Figure out the SHORT hostname
|
||||
if [[ "$OSTYPE" = darwin* ]]; then
|
||||
# macOS's $HOST changes with dhcp, etc. Use ComputerName if possible.
|
||||
SHORT_HOST=$(scutil --get ComputerName 2>/dev/null) || SHORT_HOST=${HOST/.*/}
|
||||
SHORT_HOST=$(scutil --get ComputerName 2>/dev/null) || SHORT_HOST="${HOST/.*/}"
|
||||
else
|
||||
SHORT_HOST=${HOST/.*/}
|
||||
SHORT_HOST="${HOST/.*/}"
|
||||
fi
|
||||
|
||||
# Save the location of the current completion dump file.
|
||||
if [ -z "$ZSH_COMPDUMP" ]; then
|
||||
ZSH_COMPDUMP="${ZDOTDIR:-${HOME}}/.zcompdump-${SHORT_HOST}-${ZSH_VERSION}"
|
||||
if [[ -z "$ZSH_COMPDUMP" ]]; then
|
||||
ZSH_COMPDUMP="${ZDOTDIR:-$HOME}/.zcompdump-${SHORT_HOST}-${ZSH_VERSION}"
|
||||
fi
|
||||
|
||||
# Construct zcompdump OMZ metadata
|
||||
|
@ -70,19 +116,20 @@ if ! command grep -q -Fx "$zcompdump_revision" "$ZSH_COMPDUMP" 2>/dev/null \
|
|||
zcompdump_refresh=1
|
||||
fi
|
||||
|
||||
if [[ $ZSH_DISABLE_COMPFIX != true ]]; then
|
||||
source $ZSH/lib/compfix.zsh
|
||||
# If completion insecurities exist, warn the user
|
||||
handle_completion_insecurities
|
||||
if [[ "$ZSH_DISABLE_COMPFIX" != true ]]; then
|
||||
source "$ZSH/lib/compfix.zsh"
|
||||
# Load only from secure directories
|
||||
compinit -i -C -d "${ZSH_COMPDUMP}"
|
||||
compinit -i -d "$ZSH_COMPDUMP"
|
||||
# If completion insecurities exist, warn the user
|
||||
handle_completion_insecurities &|
|
||||
else
|
||||
# If the user wants it, load from all found directories
|
||||
compinit -u -C -d "${ZSH_COMPDUMP}"
|
||||
compinit -u -d "$ZSH_COMPDUMP"
|
||||
fi
|
||||
|
||||
# Append zcompdump metadata if missing
|
||||
if (( $zcompdump_refresh )); then
|
||||
if (( $zcompdump_refresh )) \
|
||||
|| ! command grep -q -Fx "$zcompdump_revision" "$ZSH_COMPDUMP" 2>/dev/null; then
|
||||
# Use `tee` in case the $ZSH_COMPDUMP filename is invalid, to silence the error
|
||||
# See https://github.com/ohmyzsh/ohmyzsh/commit/dd1a7269#commitcomment-39003489
|
||||
tee -a "$ZSH_COMPDUMP" &>/dev/null <<EOF
|
||||
|
@ -91,40 +138,92 @@ $zcompdump_revision
|
|||
$zcompdump_fpath
|
||||
EOF
|
||||
fi
|
||||
|
||||
unset zcompdump_revision zcompdump_fpath zcompdump_refresh
|
||||
|
||||
# zcompile the completion dump file if the .zwc is older or missing.
|
||||
if command mkdir "${ZSH_COMPDUMP}.lock" 2>/dev/null; then
|
||||
zrecompile -q -p "$ZSH_COMPDUMP"
|
||||
command rm -rf "$ZSH_COMPDUMP.zwc.old" "${ZSH_COMPDUMP}.lock"
|
||||
fi
|
||||
|
||||
_omz_source() {
|
||||
local context filepath="$1"
|
||||
|
||||
# Construct zstyle context based on path
|
||||
case "$filepath" in
|
||||
lib/*) context="lib:${filepath:t:r}" ;; # :t = lib_name.zsh, :r = lib_name
|
||||
plugins/*) context="plugins:${filepath:h:t}" ;; # :h = plugins/plugin_name, :t = plugin_name
|
||||
esac
|
||||
|
||||
local disable_aliases=0
|
||||
zstyle -T ":omz:${context}" aliases || disable_aliases=1
|
||||
|
||||
# Back up alias names prior to sourcing
|
||||
local -A aliases_pre galiases_pre
|
||||
if (( disable_aliases )); then
|
||||
aliases_pre=("${(@kv)aliases}")
|
||||
galiases_pre=("${(@kv)galiases}")
|
||||
fi
|
||||
|
||||
# Source file from $ZSH_CUSTOM if it exists, otherwise from $ZSH
|
||||
if [[ -f "$ZSH_CUSTOM/$filepath" ]]; then
|
||||
source "$ZSH_CUSTOM/$filepath"
|
||||
elif [[ -f "$ZSH/$filepath" ]]; then
|
||||
source "$ZSH/$filepath"
|
||||
fi
|
||||
|
||||
# Unset all aliases that don't appear in the backed up list of aliases
|
||||
if (( disable_aliases )); then
|
||||
if (( #aliases_pre )); then
|
||||
aliases=("${(@kv)aliases_pre}")
|
||||
else
|
||||
(( #aliases )) && unalias "${(@k)aliases}"
|
||||
fi
|
||||
if (( #galiases_pre )); then
|
||||
galiases=("${(@kv)galiases_pre}")
|
||||
else
|
||||
(( #galiases )) && unalias "${(@k)galiases}"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
# Load all of the config files in ~/oh-my-zsh that end in .zsh
|
||||
# TIP: Add files you don't want in git to .gitignore
|
||||
for config_file ($ZSH/lib/*.zsh); do
|
||||
custom_config_file="${ZSH_CUSTOM}/lib/${config_file:t}"
|
||||
[ -f "${custom_config_file}" ] && config_file=${custom_config_file}
|
||||
source $config_file
|
||||
for config_file ("$ZSH"/lib/*.zsh); do
|
||||
_omz_source "lib/${config_file:t}"
|
||||
done
|
||||
unset custom_config_file
|
||||
|
||||
# Load all of the plugins that were defined in ~/.zshrc
|
||||
for plugin ($plugins); do
|
||||
if [ -f $ZSH_CUSTOM/plugins/$plugin/$plugin.plugin.zsh ]; then
|
||||
source $ZSH_CUSTOM/plugins/$plugin/$plugin.plugin.zsh
|
||||
elif [ -f $ZSH/plugins/$plugin/$plugin.plugin.zsh ]; then
|
||||
source $ZSH/plugins/$plugin/$plugin.plugin.zsh
|
||||
fi
|
||||
_omz_source "plugins/$plugin/$plugin.plugin.zsh"
|
||||
done
|
||||
unset plugin
|
||||
|
||||
# Load all of your custom configurations from custom/
|
||||
for config_file ($ZSH_CUSTOM/*.zsh(N)); do
|
||||
source $config_file
|
||||
for config_file ("$ZSH_CUSTOM"/*.zsh(N)); do
|
||||
source "$config_file"
|
||||
done
|
||||
unset config_file
|
||||
|
||||
# Load the theme
|
||||
if [ ! "$ZSH_THEME" = "" ]; then
|
||||
if [ -f "$ZSH_CUSTOM/$ZSH_THEME.zsh-theme" ]; then
|
||||
is_theme() {
|
||||
local base_dir=$1
|
||||
local name=$2
|
||||
builtin test -f $base_dir/$name.zsh-theme
|
||||
}
|
||||
|
||||
if [[ -n "$ZSH_THEME" ]]; then
|
||||
if is_theme "$ZSH_CUSTOM" "$ZSH_THEME"; then
|
||||
source "$ZSH_CUSTOM/$ZSH_THEME.zsh-theme"
|
||||
elif [ -f "$ZSH_CUSTOM/themes/$ZSH_THEME.zsh-theme" ]; then
|
||||
elif is_theme "$ZSH_CUSTOM/themes" "$ZSH_THEME"; then
|
||||
source "$ZSH_CUSTOM/themes/$ZSH_THEME.zsh-theme"
|
||||
else
|
||||
elif is_theme "$ZSH/themes" "$ZSH_THEME"; then
|
||||
source "$ZSH/themes/$ZSH_THEME.zsh-theme"
|
||||
else
|
||||
echo "[oh-my-zsh] theme '$ZSH_THEME' not found"
|
||||
fi
|
||||
fi
|
||||
|
||||
# set completion colors to be the same as `ls`, after theme has been loaded
|
||||
[[ -z "$LS_COLORS" ]] || zstyle ':completion:*' list-colors "${(s.:.)LS_COLORS}"
|
||||
|
|
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(s)>`: filter and highlight aliases by `<keyword>`
|
||||
|
||||
- `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
|
||||
|
||||
![screenshot](https://cloud.githubusercontent.com/assets/3602957/11581913/cb54fb8a-9a82-11e5-846b-5a67f67ad9ad.png)
|
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" "$@"
|
||||
}
|
||||
'
|
69
plugins/aliases/cheatsheet.py
Normal file
69
plugins/aliases/cheatsheet.py
Normal file
|
@ -0,0 +1,69 @@
|
|||
#!/usr/bin/env python3
|
||||
import sys
|
||||
import itertools
|
||||
import termcolor
|
||||
import argparse
|
||||
|
||||
def parse(line):
|
||||
left = line[0:line.find('=')].strip()
|
||||
right = line[line.find('=')+1:].strip('\'"\n ')
|
||||
try:
|
||||
cmd = next(part for part in right.split() if len([char for char in '=<>' if char in part])==0)
|
||||
except StopIteration:
|
||||
cmd = right
|
||||
return (left, right, cmd)
|
||||
|
||||
def cheatsheet(lines):
|
||||
exps = [ parse(line) for line in lines ]
|
||||
exps.sort(key=lambda exp:exp[2])
|
||||
cheatsheet = {'_default': []}
|
||||
for key, group in itertools.groupby(exps, lambda exp:exp[2]):
|
||||
group_list = [ item for item in group ]
|
||||
if len(group_list)==1:
|
||||
target_aliases = cheatsheet['_default']
|
||||
else:
|
||||
if key not in cheatsheet:
|
||||
cheatsheet[key] = []
|
||||
target_aliases = cheatsheet[key]
|
||||
target_aliases.extend(group_list)
|
||||
return cheatsheet
|
||||
|
||||
def pretty_print_group(key, aliases, highlight=None, only_groupname=False):
|
||||
if len(aliases) == 0:
|
||||
return
|
||||
group_hl_formatter = lambda g, hl: termcolor.colored(hl, 'yellow').join([termcolor.colored(part, 'red') for part in ('[%s]' % g).split(hl)])
|
||||
alias_hl_formatter = lambda alias, hl: termcolor.colored(hl, 'yellow').join([termcolor.colored(part, 'green') for part in ('\t%s = %s' % alias[0:2]).split(hl)])
|
||||
group_formatter = lambda g: termcolor.colored('[%s]' % g, 'red')
|
||||
alias_formatter = lambda alias: termcolor.colored('\t%s = %s' % alias[0:2], 'green')
|
||||
if highlight and len(highlight)>0:
|
||||
print (group_hl_formatter(key, highlight))
|
||||
if not only_groupname:
|
||||
print ('\n'.join([alias_hl_formatter(alias, highlight) for alias in aliases]))
|
||||
else:
|
||||
print (group_formatter(key))
|
||||
if not only_groupname:
|
||||
print ('\n'.join([alias_formatter(alias) for alias in aliases]))
|
||||
print ('')
|
||||
|
||||
def pretty_print(cheatsheet, wfilter, group_list=None, groups_only=False):
|
||||
sorted_key = sorted(cheatsheet.keys())
|
||||
for key in sorted_key:
|
||||
if group_list and key not in group_list:
|
||||
continue
|
||||
aliases = cheatsheet.get(key)
|
||||
if not wfilter:
|
||||
pretty_print_group(key, aliases, wfilter, groups_only)
|
||||
else:
|
||||
pretty_print_group(key, [ alias for alias in aliases if alias[0].find(wfilter)>-1 or alias[1].find(wfilter)>-1], wfilter)
|
||||
|
||||
if __name__ == '__main__':
|
||||
parser = argparse.ArgumentParser(description="Pretty print aliases.", prog="acs")
|
||||
parser.add_argument('filter', nargs="*", metavar="<keyword>", help="search aliases matching keywords")
|
||||
parser.add_argument('-g', '--group', dest="group_list", action='append', help="only print aliases in given groups")
|
||||
parser.add_argument('--groups', dest='groups_only', action='store_true', help="only print alias groups")
|
||||
args = parser.parse_args()
|
||||
|
||||
lines = sys.stdin.readlines()
|
||||
group_list = args.group_list or None
|
||||
wfilter = " ".join(args.filter) or None
|
||||
pretty_print(cheatsheet(lines), wfilter, group_list, args.groups_only)
|
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'])
|
||||
|
|
@ -2,9 +2,9 @@
|
|||
|
||||
This plugin provides completion for [Ant](https://ant.apache.org/).
|
||||
|
||||
To use it add ant to the plugins array in your zshrc file.
|
||||
To use it, add `ant` to the plugins array in your zshrc file:
|
||||
|
||||
```bash
|
||||
```zsh
|
||||
plugins=(... ant)
|
||||
```
|
||||
|
||||
|
|
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 "$@"
|
|
@ -1,16 +1,2 @@
|
|||
_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
|
||||
if _ant_does_target_list_need_generating; then
|
||||
ant -p | awk -F " " 'NR > 5 { print lastTarget }{lastTarget = $1}' > .ant_targets
|
||||
fi
|
||||
compadd -- `cat .ant_targets`
|
||||
fi
|
||||
}
|
||||
|
||||
compdef _ant ant
|
||||
# Default to colored output
|
||||
export ANT_ARGS='-logger org.apache.tools.ant.listener.AnsiColorLogger'
|
||||
|
|
|
@ -14,6 +14,7 @@ plugins=(... arcanist)
|
|||
| ------- | ---------------------------------- |
|
||||
| ara | `arc amend` |
|
||||
| arb | `arc branch` |
|
||||
| arbl | `arc bland` |
|
||||
| arco | `arc cover` |
|
||||
| arci | `arc commit` |
|
||||
| ard | `arc diff` |
|
||||
|
@ -24,6 +25,7 @@ plugins=(... arcanist)
|
|||
| ardpc | `arc diff --plan-changes` |
|
||||
| are | `arc export` |
|
||||
| arh | `arc help` |
|
||||
| arho | `arc hotfix` |
|
||||
| arl | `arc land` |
|
||||
| arli | `arc lint` |
|
||||
| arls | `arc list` |
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
|
||||
alias ara='arc amend'
|
||||
alias arb='arc branch'
|
||||
alias arbl='arc bland'
|
||||
alias arco='arc cover'
|
||||
alias arci='arc commit'
|
||||
|
||||
|
@ -17,6 +18,7 @@ alias ardp='arc diff --preview' # creates a new diff in the phab interface
|
|||
|
||||
alias are='arc export'
|
||||
alias arh='arc help'
|
||||
alias arho='arc hotfix'
|
||||
alias arl='arc land'
|
||||
alias arli='arc lint'
|
||||
alias arls='arc list'
|
||||
|
|
|
@ -17,8 +17,10 @@ plugins=(... archlinux)
|
|||
| pacin | `sudo pacman -S` | Install packages from the repositories |
|
||||
| pacins | `sudo pacman -U` | Install a package from a local file |
|
||||
| pacinsd | `sudo pacman -S --asdeps` | Install packages as dependencies of another package |
|
||||
| paclean | `sudo pacman -Sc` | Clean out old and unused caches and packages |
|
||||
| pacloc | `pacman -Qi` | Display information about a package in the local database |
|
||||
| paclocs | `pacman -Qs` | Search for packages in the local database |
|
||||
| paclr | `sudo pacman -Scc` | Remove all files from the cache |
|
||||
| paclsorphans | `sudo pacman -Qdt` | List all orphaned packages |
|
||||
| pacmir | `sudo pacman -Syy` | Force refresh of all package lists after updating mirrorlist |
|
||||
| pacre | `sudo pacman -R` | Remove packages, keeping its settings and dependencies |
|
||||
|
@ -32,7 +34,7 @@ plugins=(... archlinux)
|
|||
| pacfiles | `pacman -F` | Search package file names for matching strings |
|
||||
| pacls | `pacman -Ql` | List files in a package |
|
||||
| pacown | `pacman -Qo` | Show which package owns a file |
|
||||
| upgrade[²](#f2) | `sudo pacman -Syu` | Sync with repositories before upgrading packages |
|
||||
| upgrade[¹](#f1) | `sudo pacman -Syu` | Sync with repositories before upgrading packages |
|
||||
|
||||
| Function | Description |
|
||||
|----------------|-----------------------------------------------------------|
|
||||
|
@ -52,6 +54,8 @@ upgrades were available. Use `pacman -Que` instead.
|
|||
|
||||
| Alias | Command | Description |
|
||||
|---------|-------------------------------------------------|-------------------------------------------------------------------------|
|
||||
| auclean | `sudo aura -Sc` | Clean out old and unused caches and packages |
|
||||
| auclr | `sudo aura -Scc` | Remove all files from the cache |
|
||||
| auin | `sudo aura -S` | Install packages from the repositories |
|
||||
| aurin | `sudo aura -A` | Install packages from the repositories |
|
||||
| auins | `sudo aura -U` | Install a package from a local file |
|
||||
|
@ -73,7 +77,7 @@ upgrades were available. Use `pacman -Que` instead.
|
|||
| auupd | `sudo aura -Sy` | Update and refresh local package, ABS and AUR databases |
|
||||
| auupg | `sudo sh -c "aura -Syu && aura -Au"` | Sync with repositories before upgrading all packages (from AUR too) |
|
||||
| ausu | `sudo sh -c "aura -Syu --no-confirm && aura -Au --no-confirm"` | Same as `auupg`, but without confirmation |
|
||||
| upgrade[²](#f2) | `sudo aura -Syu` | Sync with repositories before upgrading packages |
|
||||
| upgrade[¹](#f1) | `sudo aura -Syu` | Sync with repositories before upgrading packages |
|
||||
|
||||
| Function | Description |
|
||||
|-----------------|---------------------------------------------------------------------|
|
||||
|
@ -84,6 +88,8 @@ upgrades were available. Use `pacman -Que` instead.
|
|||
|
||||
| Alias | Command | Description |
|
||||
|---------|-----------------------------------|---------------------------------------------------------------------|
|
||||
| pacclean| `pacaur -Sc` | Clean out old and unused caches and packages |
|
||||
| pacclr | `pacaur -Scc` | Remove all files from the cache |
|
||||
| pain | `pacaur -S` | Install packages from the repositories |
|
||||
| pains | `pacaur -U` | Install a package from a local file |
|
||||
| painsd | `pacaur -S --asdeps` | Install packages as dependencies of another package |
|
||||
|
@ -99,13 +105,15 @@ upgrades were available. Use `pacman -Que` instead.
|
|||
| paupd | `pacaur -Sy` | Update and refresh local package, ABS and AUR databases |
|
||||
| paupg | `pacaur -Syua` | Sync with repositories before upgrading all packages (from AUR too) |
|
||||
| pasu | `pacaur -Syua --no-confirm` | Same as `paupg`, but without confirmation |
|
||||
| upgrade[²](#f2) | `pacaur -Syu` | Sync with repositories before upgrading packages |
|
||||
| upgrade[¹](#f1) | `pacaur -Syu` | Sync with repositories before upgrading packages |
|
||||
|
||||
#### Trizen
|
||||
|
||||
| Alias | Command | Description |
|
||||
|---------|-----------------------------------|---------------------------------------------------------------------|
|
||||
| trconf | `trizen -C` | Fix all configuration files with vimdiff |
|
||||
| trclean | `trizen -Sc` | Clean out old and unused caches and packages |
|
||||
| trclr | `trizen -Scc` | Remove all files from the cache |
|
||||
| trin | `trizen -S` | Install packages from the repositories |
|
||||
| trins | `trizen -U` | Install a package from a local file |
|
||||
| trinsd | `trizen -S --asdeps` | Install packages as dependencies of another package |
|
||||
|
@ -121,35 +129,15 @@ upgrades were available. Use `pacman -Que` instead.
|
|||
| trupd | `trizen -Sy` | Update and refresh local package, ABS and AUR databases |
|
||||
| trupg | `trizen -Syua` | Sync with repositories before upgrading all packages (from AUR too) |
|
||||
| trsu | `trizen -Syua --no-confirm` | Same as `trupg`, but without confirmation |
|
||||
| upgrade[²](#f2) | `trizen -Syu` | Sync with repositories before upgrading packages |
|
||||
| upgrade[¹](#f1) | `trizen -Syu` | Sync with repositories before upgrading packages |
|
||||
|
||||
#### Yaourt[¹](#f1)
|
||||
|
||||
| Alias | Command | Description |
|
||||
|---------|-----------------------------------|---------------------------------------------------------------------|
|
||||
| yaconf | `yaourt -C` | Fix all configuration files with vimdiff |
|
||||
| yain | `yaourt -S` | Install packages from the repositories |
|
||||
| yains | `yaourt -U` | Install a package from a local file |
|
||||
| yainsd | `yaourt -S --asdeps` | Install packages as dependencies of another package |
|
||||
| yaloc | `yaourt -Qi` | Display information about a package in the local database |
|
||||
| yalocs | `yaourt -Qs` | Search for packages in the local database |
|
||||
| yalst | `yaourt -Qe` | List installed packages including from AUR (tagged as "local") |
|
||||
| yamir | `yaourt -Syy` | Force refresh of all package lists after updating mirrorlist |
|
||||
| yaorph | `yaourt -Qtd` | Remove orphans using yaourt |
|
||||
| yare | `yaourt -R` | Remove packages, keeping its settings and dependencies |
|
||||
| yarem | `yaourt -Rns` | Remove packages, including its settings and unneeded dependencies |
|
||||
| yarep | `yaourt -Si` | Display information about a package in the repositories |
|
||||
| yareps | `yaourt -Ss` | Search for packages in the repositories |
|
||||
| yaupd | `yaourt -Sy` | Update and refresh local package, ABS and AUR databases |
|
||||
| yaupg | `yaourt -Syua` | Sync with repositories before upgrading all packages (from AUR too) |
|
||||
| yasu | `yaourt -Syua --no-confirm` | Same as `yaupg`, but without confirmation |
|
||||
| upgrade[²](#f2) | `yaourt -Syu` | Sync with repositories before upgrading packages |
|
||||
|
||||
#### Yay[¹](#f1)
|
||||
#### Yay
|
||||
|
||||
| Alias | Command | Description |
|
||||
|---------|--------------------------------|-------------------------------------------------------------------|
|
||||
| yaconf | `yay -Pg` | Print current configuration |
|
||||
| yaclean | `yay -Sc` | Clean out old and unused caches and packages |
|
||||
| yaclr | `yay -Scc` | Remove all files from the cache |
|
||||
| yain | `yay -S` | Install packages from the repositories |
|
||||
| yains | `yay -U` | Install a package from a local file |
|
||||
| yainsd | `yay -S --asdeps` | Install packages as dependencies of another package |
|
||||
|
@ -165,23 +153,19 @@ upgrades were available. Use `pacman -Que` instead.
|
|||
| yaupd | `yay -Sy` | Update and refresh local package, ABS and AUR databases |
|
||||
| yaupg | `yay -Syu` | Sync with repositories before upgrading packages |
|
||||
| yasu | `yay -Syu --no-confirm` | Same as `yaupg`, but without confirmation |
|
||||
| upgrade[²](#f2) | `yay -Syu` | Sync with repositories before upgrading packages |
|
||||
| upgrade[¹](#f1) | `yay -Syu` | Sync with repositories before upgrading packages |
|
||||
|
||||
---
|
||||
|
||||
<span id="f1">¹</span>
|
||||
Yay and Yaourt aliases overlap. If both are installed, yay will take precedence.
|
||||
|
||||
<span id="f2">²</span>
|
||||
The `upgrade` alias is set for all package managers. Its value will depend on
|
||||
whether the package manager is installed, checked in the following order:
|
||||
|
||||
1. `yay`
|
||||
2. `yaourt`
|
||||
3. `trizen`
|
||||
4. `pacaur`
|
||||
5. `aura`
|
||||
6. `pacman`
|
||||
2. `trizen`
|
||||
3. `pacaur`
|
||||
4. `aura`
|
||||
5. `pacman`
|
||||
|
||||
## Contributors
|
||||
|
||||
|
@ -196,3 +180,5 @@ whether the package manager is installed, checked in the following order:
|
|||
- ornicar - thibault.duplessis@gmail.com
|
||||
- Ybalrid (Arthur Brainville) - ybalrid@ybalrid.info
|
||||
- Jeff M. Hubbard - jeffmhubbard@gmail.com
|
||||
- K. Harishankar(harishnkr) - hari2menon1234@gmail.com
|
||||
- WH-2099 - wh2099@outlook.com
|
|
@ -5,7 +5,9 @@
|
|||
# Pacman - https://wiki.archlinux.org/index.php/Pacman_Tips
|
||||
alias pacupg='sudo pacman -Syu'
|
||||
alias pacin='sudo pacman -S'
|
||||
alias paclean='sudo pacman -Sc'
|
||||
alias pacins='sudo pacman -U'
|
||||
alias paclr='sudo pacman -Scc'
|
||||
alias pacre='sudo pacman -R'
|
||||
alias pacrem='sudo pacman -Rns'
|
||||
alias pacrep='pacman -Si'
|
||||
|
@ -21,30 +23,27 @@ alias pacfiles='pacman -F'
|
|||
alias pacls='pacman -Ql'
|
||||
alias pacown='pacman -Qo'
|
||||
alias pacupd="sudo pacman -Sy"
|
||||
alias upgrade='sudo pacman -Syu'
|
||||
|
||||
function paclist() {
|
||||
# Based on https://bbs.archlinux.org/viewtopic.php?id=93683
|
||||
pacman -Qqe | \
|
||||
xargs -I '{}' \
|
||||
expac "${bold_color}% 20n ${fg_no_bold[white]}%d${reset_color}" '{}'
|
||||
pacman -Qqe | xargs -I{} -P0 --no-run-if-empty pacman -Qs --color=auto "^{}\$"
|
||||
}
|
||||
|
||||
function pacdisowned() {
|
||||
local tmp db fs
|
||||
tmp=${TMPDIR-/tmp}/pacman-disowned-$UID-$$
|
||||
db=$tmp/db
|
||||
fs=$tmp/fs
|
||||
local tmp_dir db fs
|
||||
tmp_dir=$(mktemp --directory)
|
||||
db=$tmp_dir/db
|
||||
fs=$tmp_dir/fs
|
||||
|
||||
mkdir "$tmp"
|
||||
trap 'rm -rf "$tmp"' EXIT
|
||||
trap "rm -rf $tmp_dir" EXIT
|
||||
|
||||
pacman -Qlq | sort -u > "$db"
|
||||
|
||||
find /bin /etc /lib /sbin /usr ! -name lost+found \
|
||||
find /etc /usr ! -name lost+found \
|
||||
\( -type d -printf '%p/\n' -o -print \) | sort > "$fs"
|
||||
|
||||
comm -23 "$fs" "$db"
|
||||
|
||||
rm -rf $tmp_dir
|
||||
}
|
||||
|
||||
alias pacmanallkeys='sudo pacman-key --refresh-keys'
|
||||
|
@ -88,6 +87,8 @@ fi
|
|||
if (( $+commands[aura] )); then
|
||||
alias auin='sudo aura -S'
|
||||
alias aurin='sudo aura -A'
|
||||
alias auclean='sudo aura -Sc'
|
||||
alias auclr='sudo aura -Scc'
|
||||
alias auins='sudo aura -U'
|
||||
alias auinsd='sudo aura -S --asdeps'
|
||||
alias aurinsd='sudo aura -A --asdeps'
|
||||
|
@ -104,8 +105,7 @@ if (( $+commands[aura] )); then
|
|||
alias auras='aura -As --both'
|
||||
alias auupd="sudo aura -Sy"
|
||||
alias auupg='sudo sh -c "aura -Syu && aura -Au"'
|
||||
alias ausu='sudo sh -c "aura -Syu --no-confirm && aura -Au --no-confirm"'
|
||||
alias upgrade='sudo aura -Syu'
|
||||
alias ausu='sudo sh -c "aura -Syu --no-confirm && aura -Au --no-confirm"'
|
||||
|
||||
# extra bonus specially for aura
|
||||
alias auown="aura -Qqo"
|
||||
|
@ -115,6 +115,8 @@ if (( $+commands[aura] )); then
|
|||
fi
|
||||
|
||||
if (( $+commands[pacaur] )); then
|
||||
alias pacclean='pacaur -Sc'
|
||||
alias pacclr='pacaur -Scc'
|
||||
alias paupg='pacaur -Syu'
|
||||
alias pasu='pacaur -Syu --noconfirm'
|
||||
alias pain='pacaur -S'
|
||||
|
@ -130,7 +132,6 @@ if (( $+commands[pacaur] )); then
|
|||
alias painsd='pacaur -S --asdeps'
|
||||
alias pamir='pacaur -Syy'
|
||||
alias paupd="pacaur -Sy"
|
||||
alias upgrade='pacaur -Syu'
|
||||
fi
|
||||
|
||||
if (( $+commands[trizen] )); then
|
||||
|
@ -138,6 +139,8 @@ if (( $+commands[trizen] )); then
|
|||
alias trupg='trizen -Syua'
|
||||
alias trsu='trizen -Syua --noconfirm'
|
||||
alias trin='trizen -S'
|
||||
alias trclean='trizen -Sc'
|
||||
alias trclr='trizen -Scc'
|
||||
alias trins='trizen -U'
|
||||
alias trre='trizen -R'
|
||||
alias trrem='trizen -Rns'
|
||||
|
@ -150,31 +153,12 @@ if (( $+commands[trizen] )); then
|
|||
alias trinsd='trizen -S --asdeps'
|
||||
alias trmir='trizen -Syy'
|
||||
alias trupd="trizen -Sy"
|
||||
alias upgrade='trizen -Syu'
|
||||
fi
|
||||
|
||||
if (( $+commands[yaourt] )); then
|
||||
alias yaconf='yaourt -C'
|
||||
alias yaupg='yaourt -Syua'
|
||||
alias yasu='yaourt -Syua --noconfirm'
|
||||
alias yain='yaourt -S'
|
||||
alias yains='yaourt -U'
|
||||
alias yare='yaourt -R'
|
||||
alias yarem='yaourt -Rns'
|
||||
alias yarep='yaourt -Si'
|
||||
alias yareps='yaourt -Ss'
|
||||
alias yaloc='yaourt -Qi'
|
||||
alias yalocs='yaourt -Qs'
|
||||
alias yalst='yaourt -Qe'
|
||||
alias yaorph='yaourt -Qtd'
|
||||
alias yainsd='yaourt -S --asdeps'
|
||||
alias yamir='yaourt -Syy'
|
||||
alias yaupd="yaourt -Sy"
|
||||
alias upgrade='yaourt -Syu'
|
||||
fi
|
||||
|
||||
if (( $+commands[yay] )); then
|
||||
alias yaconf='yay -Pg'
|
||||
alias yaclean='yay -Sc'
|
||||
alias yaclr='yay -Scc'
|
||||
alias yaupg='yay -Syu'
|
||||
alias yasu='yay -Syu --noconfirm'
|
||||
alias yain='yay -S'
|
||||
|
@ -190,6 +174,30 @@ if (( $+commands[yay] )); then
|
|||
alias yainsd='yay -S --asdeps'
|
||||
alias yamir='yay -Syy'
|
||||
alias yaupd="yay -Sy"
|
||||
alias upgrade='yay -Syu'
|
||||
fi
|
||||
|
||||
# Check Arch Linux PGP Keyring before System Upgrade to prevent failure.
|
||||
function upgrade() {
|
||||
echo ":: Checking Arch Linux PGP Keyring..."
|
||||
local installedver="$(sudo pacman -Qi archlinux-keyring | grep -Po '(?<=Version : ).*')"
|
||||
local currentver="$(sudo pacman -Si archlinux-keyring | grep -Po '(?<=Version : ).*')"
|
||||
if [ $installedver != $currentver ]; then
|
||||
echo " Arch Linux PGP Keyring is out of date."
|
||||
echo " Updating before full system upgrade."
|
||||
sudo pacman -Sy --needed --noconfirm archlinux-keyring
|
||||
else
|
||||
echo " Arch Linux PGP Keyring is up to date."
|
||||
echo " Proceeding with full system upgrade."
|
||||
fi
|
||||
if (( $+commands[yay] )); then
|
||||
yay -Syu
|
||||
elif (( $+commands[trizen] )); then
|
||||
trizen -Syu
|
||||
elif (( $+commands[pacaur] )); then
|
||||
pacaur -Syu
|
||||
elif (( $+commands[aura] )); then
|
||||
sudo aura -Syu
|
||||
else
|
||||
sudo pacman -Syu
|
||||
fi
|
||||
}
|
||||
|
|
20
plugins/argocd/README.md
Normal file
20
plugins/argocd/README.md
Normal file
|
@ -0,0 +1,20 @@
|
|||
# Argo CD plugin
|
||||
|
||||
This plugin adds completion for the [Argo CD](https://argoproj.github.io/cd/) CLI.
|
||||
|
||||
To use it, add `argocd` to the plugins array in your zshrc file:
|
||||
|
||||
```zsh
|
||||
plugins=(... argocd)
|
||||
```
|
||||
|
||||
This plugin does not add any aliases.
|
||||
|
||||
## Cache
|
||||
|
||||
This plugin caches the completion script and is automatically updated asynchronously when the plugin is
|
||||
loaded, which is usually when you start up a new terminal emulator.
|
||||
|
||||
The cache is stored at:
|
||||
|
||||
- `$ZSH_CACHE/completions/_argocd` completions script
|
14
plugins/argocd/argocd.plugin.zsh
Normal file
14
plugins/argocd/argocd.plugin.zsh
Normal file
|
@ -0,0 +1,14 @@
|
|||
# Autocompletion for argocd.
|
||||
if (( ! $+commands[argocd] )); then
|
||||
return
|
||||
fi
|
||||
|
||||
# If the completion file doesn't exist yet, we need to autoload it and
|
||||
# bind it to `argocd`. Otherwise, compinit will have already done that.
|
||||
if [[ ! -f "$ZSH_CACHE_DIR/completions/_argocd" ]]; then
|
||||
typeset -g -A _comps
|
||||
autoload -Uz _argocd
|
||||
_comps[argocd]=_argocd
|
||||
fi
|
||||
|
||||
argocd completion zsh >| "$ZSH_CACHE_DIR/completions/_argocd" &|
|
|
@ -6,22 +6,25 @@ Adds integration with [asdf](https://github.com/asdf-vm/asdf), the extendable ve
|
|||
|
||||
### Installation
|
||||
|
||||
1. Enable the plugin by adding it to your `plugins` definition in `~/.zshrc`.
|
||||
1. [Download asdf](https://asdf-vm.com/guide/getting-started.html#_2-download-asdf) by running the following:
|
||||
|
||||
```
|
||||
git clone https://github.com/asdf-vm/asdf.git ~/.asdf
|
||||
```
|
||||
|
||||
2. [Enable asdf](https://asdf-vm.com/guide/getting-started.html#_3-install-asdf) by adding it to your `plugins` definition in `~/.zshrc`.
|
||||
|
||||
```
|
||||
plugins=(asdf)
|
||||
```
|
||||
|
||||
2. [Install asdf](https://github.com/asdf-vm/asdf#setup) by running the following:
|
||||
```
|
||||
git clone https://github.com/asdf-vm/asdf.git ~/.asdf
|
||||
```
|
||||
|
||||
### Usage
|
||||
|
||||
See the [asdf usage documentation](https://github.com/asdf-vm/asdf#usage) for information on how to use asdf:
|
||||
See the [asdf documentation](https://asdf-vm.com/guide/getting-started.html#_4-install-a-plugin) for information on how to use asdf:
|
||||
|
||||
```
|
||||
asdf plugin-add nodejs git@github.com:asdf-vm/asdf-nodejs.git
|
||||
asdf install nodejs 5.9.1
|
||||
asdf plugin add nodejs https://github.com/asdf-vm/asdf-nodejs.git
|
||||
asdf install nodejs latest
|
||||
asdf global nodejs latest
|
||||
asdf local nodejs latest
|
||||
```
|
||||
|
|
|
@ -2,18 +2,26 @@
|
|||
ASDF_DIR="${ASDF_DIR:-$HOME/.asdf}"
|
||||
ASDF_COMPLETIONS="$ASDF_DIR/completions"
|
||||
|
||||
# If not found, check for archlinux/AUR package (/opt/asdf-vm/)
|
||||
if [[ ! -f "$ASDF_DIR/asdf.sh" || ! -f "$ASDF_COMPLETIONS/asdf.bash" ]] && [[ -f "/opt/asdf-vm/asdf.sh" ]]; then
|
||||
ASDF_DIR="/opt/asdf-vm"
|
||||
ASDF_COMPLETIONS="$ASDF_DIR"
|
||||
fi
|
||||
|
||||
# If not found, check for Homebrew package
|
||||
if [[ ! -f "$ASDF_DIR/asdf.sh" || ! -f "$ASDF_COMPLETIONS/asdf.bash" ]] && (( $+commands[brew] )); then
|
||||
ASDF_DIR="$(brew --prefix asdf)"
|
||||
ASDF_COMPLETIONS="$ASDF_DIR/etc/bash_completion.d"
|
||||
brew_prefix="$(brew --prefix asdf)"
|
||||
ASDF_DIR="${brew_prefix}/libexec"
|
||||
ASDF_COMPLETIONS="${brew_prefix}/etc/bash_completion.d"
|
||||
unset brew_prefix
|
||||
fi
|
||||
|
||||
# Load command
|
||||
if [[ -f "$ASDF_DIR/asdf.sh" ]]; then
|
||||
. "$ASDF_DIR/asdf.sh"
|
||||
. "$ASDF_DIR/asdf.sh"
|
||||
|
||||
# Load completions
|
||||
if [[ -f "$ASDF_COMPLETIONS/asdf.bash" ]]; then
|
||||
. "$ASDF_COMPLETIONS/asdf.bash"
|
||||
fi
|
||||
# Load completions
|
||||
if [[ -f "$ASDF_COMPLETIONS/asdf.bash" ]]; then
|
||||
. "$ASDF_COMPLETIONS/asdf.bash"
|
||||
fi
|
||||
fi
|
||||
|
|
|
@ -13,12 +13,17 @@ if ! type autoenv_init >/dev/null; then
|
|||
~/.autoenv
|
||||
~/.local/bin
|
||||
/usr/local/opt/autoenv
|
||||
/opt/homebrew/opt/autoenv
|
||||
/usr/local/bin
|
||||
/usr/share/autoenv-git
|
||||
~/Library/Python/bin
|
||||
.venv/bin
|
||||
venv/bin
|
||||
env/bin
|
||||
.env/bin
|
||||
)
|
||||
for d ( $install_locations ); do
|
||||
if [[ -e $d/activate.sh ]]; then
|
||||
if [[ -e $d/activate || -e $d/activate.sh ]]; then
|
||||
autoenv_dir=$d
|
||||
break
|
||||
fi
|
||||
|
@ -28,7 +33,7 @@ if ! type autoenv_init >/dev/null; then
|
|||
# Look for Homebrew path as a last resort
|
||||
if [[ -z "$autoenv_dir" ]] && (( $+commands[brew] )); then
|
||||
d=$(brew --prefix)/opt/autoenv
|
||||
if [[ -e $d/activate.sh ]]; then
|
||||
if [[ -e $d/activate || -e $d/activate.sh ]]; then
|
||||
autoenv_dir=$d
|
||||
fi
|
||||
fi
|
||||
|
@ -45,7 +50,11 @@ END
|
|||
return 1
|
||||
fi
|
||||
# Load autoenv
|
||||
source $autoenv_dir/activate.sh
|
||||
if [[ -e $autoenv_dir/activate ]]; then
|
||||
source $autoenv_dir/activate
|
||||
else
|
||||
source $autoenv_dir/activate.sh
|
||||
fi
|
||||
fi
|
||||
}
|
||||
[[ $? != 0 ]] && return $?
|
||||
|
|
|
@ -1,15 +1,18 @@
|
|||
declare -a autojump_paths
|
||||
autojump_paths=(
|
||||
$HOME/.autojump/etc/profile.d/autojump.zsh # manual installation
|
||||
$HOME/.autojump/share/autojump/autojump.zsh # manual installation
|
||||
$HOME/.nix-profile/etc/profile.d/autojump.sh # NixOS installation
|
||||
/run/current-system/sw/share/autojump/autojump.zsh # NixOS installation
|
||||
/usr/share/autojump/autojump.zsh # Debian and Ubuntu package
|
||||
/etc/profile.d/autojump.zsh # manual installation
|
||||
/etc/profile.d/autojump.sh # Gentoo installation
|
||||
/usr/local/share/autojump/autojump.zsh # FreeBSD installation
|
||||
/opt/local/etc/profile.d/autojump.sh # macOS with MacPorts
|
||||
/usr/local/etc/profile.d/autojump.sh # macOS with Homebrew (default)
|
||||
$HOME/.autojump/etc/profile.d/autojump.zsh # manual installation
|
||||
$HOME/.autojump/share/autojump/autojump.zsh # manual installation
|
||||
$HOME/.nix-profile/etc/profile.d/autojump.sh # NixOS installation
|
||||
/run/current-system/sw/share/autojump/autojump.zsh # NixOS installation
|
||||
/usr/share/autojump/autojump.zsh # Debian and Ubuntu package
|
||||
/etc/profile.d/autojump.zsh # manual installation
|
||||
/etc/profile.d/autojump.sh # Gentoo installation
|
||||
/usr/local/share/autojump/autojump.zsh # FreeBSD installation
|
||||
/usr/pkg/share/autojump/autojump.zsh # NetBSD installation
|
||||
/opt/local/etc/profile.d/autojump.sh # macOS with MacPorts
|
||||
/usr/local/etc/profile.d/autojump.sh # macOS with Homebrew (default)
|
||||
/opt/homebrew/etc/profile.d/autojump.sh # macOS with Homebrew (default on M1 macs)
|
||||
/etc/profiles/per-user/$USER/etc/profile.d/autojump.sh # macOS Nix, Home Manager and flakes
|
||||
)
|
||||
|
||||
for file in $autojump_paths; do
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
# aws
|
||||
|
||||
This plugin provides completion support for [awscli](https://docs.aws.amazon.com/cli/latest/reference/index.html)
|
||||
and a few utilities to manage AWS profiles and display them in the prompt.
|
||||
This plugin provides completion support for [awscli v2](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/index.html)
|
||||
and a few utilities to manage AWS profiles/regions and display them in the prompt.
|
||||
[awscli v1](https://docs.aws.amazon.com/cli/latest/userguide/cliv2-migration.html) is no longer supported.
|
||||
|
||||
To use it, add `aws` to the plugins array in your zshrc file.
|
||||
|
||||
|
@ -12,37 +13,52 @@ plugins=(... aws)
|
|||
## Plugin commands
|
||||
|
||||
* `asp [<profile>]`: sets `$AWS_PROFILE` and `$AWS_DEFAULT_PROFILE` (legacy) to `<profile>`.
|
||||
It also sets `$AWS_EB_PROFILE` to `<profile>` for the Elastic Beanstalk CLI.
|
||||
It also sets `$AWS_EB_PROFILE` to `<profile>` for the Elastic Beanstalk CLI. It sets `$AWS_PROFILE_REGION` for display in `aws_prompt_info`.
|
||||
Run `asp` without arguments to clear the profile.
|
||||
* `asp [<profile>] login`: If AWS SSO has been configured in your aws profile, it will run the `aws sso login` command following profile selection.
|
||||
|
||||
* `acp [<profile>]`: in addition to `asp` functionality, it actually changes the profile by
|
||||
assuming the role specified in the `<profile>` configuration. It supports MFA and sets
|
||||
`$AWS_ACCESS_KEY_ID`, `$AWS_SECRET_ACCESS_KEY` and `$AWS_SESSION_TOKEN`, if obtained. It
|
||||
requires the roles to be configured as per the
|
||||
* `asr [<region>]`: sets `$AWS_REGION` and `$AWS_DEFAULT_REGION` (legacy) to `<region>`.
|
||||
Run `asr` without arguments to clear the profile.
|
||||
|
||||
* `acp [<profile>] [<mfa_token>]`: in addition to `asp` functionality, it actually changes
|
||||
the profile by assuming the role specified in the `<profile>` configuration. It supports
|
||||
MFA and sets `$AWS_ACCESS_KEY_ID`, `$AWS_SECRET_ACCESS_KEY` and `$AWS_SESSION_TOKEN`, if
|
||||
obtained. It requires the roles to be configured as per the
|
||||
[official guide](https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-role.html).
|
||||
Run `acp` without arguments to clear the profile.
|
||||
|
||||
* `agp`: gets the current value of `$AWS_PROFILE`.
|
||||
|
||||
* `agr`: gets the current value of `$AWS_REGION`.
|
||||
|
||||
* `aws_change_access_key`: changes the AWS access key of a profile.
|
||||
|
||||
* `aws_profiles`: lists the available profiles in the `$AWS_CONFIG_FILE` (default: `~/.aws/config`).
|
||||
Used to provide completion for the `asp` function.
|
||||
|
||||
* `aws_regions`: lists the available regions.
|
||||
Used to provide completion for the `asr` function.
|
||||
|
||||
## Plugin options
|
||||
|
||||
* Set `SHOW_AWS_PROMPT=false` in your zshrc file if you want to prevent the plugin from modifying your RPROMPT.
|
||||
Some themes might overwrite the value of RPROMPT instead of appending to it, so they'll need to be fixed to
|
||||
see the AWS profile prompt.
|
||||
see the AWS profile/region prompt.
|
||||
|
||||
## Theme
|
||||
|
||||
The plugin creates an `aws_prompt_info` function that you can use in your theme, which displays
|
||||
the current `$AWS_PROFILE`. It uses two variables to control how that is shown:
|
||||
the current `$AWS_PROFILE` and `$AWS_REGION`. It uses four variables to control how that is shown:
|
||||
|
||||
* ZSH_THEME_AWS_PREFIX: sets the prefix of the AWS_PROFILE. Defaults to `<aws:`.
|
||||
* ZSH_THEME_AWS_PROFILE_PREFIX: sets the prefix of the AWS_PROFILE. Defaults to `<aws:`.
|
||||
|
||||
* ZSH_THEME_AWS_SUFFIX: sets the suffix of the AWS_PROFILE. Defaults to `>`.
|
||||
* ZSH_THEME_AWS_PROFILE_SUFFIX: sets the suffix of the AWS_PROFILE. Defaults to `>`.
|
||||
|
||||
* ZSH_THEME_AWS_REGION_PREFIX: sets the prefix of the AWS_REGION. Defaults to `<region:`.
|
||||
|
||||
* ZSH_THEME_AWS_REGION_SUFFIX: sets the suffix of the AWS_REGION. Defaults to `>`.
|
||||
|
||||
* ZSH_THEME_AWS_DIVIDER: sets the divider between ZSH_THEME_AWS_PROFILE_SUFFIX and ZSH_THEME_AWS_REGION_PREFIX. Defaults to ` ` (single space).
|
||||
|
||||
## Configuration
|
||||
|
||||
|
@ -52,7 +68,7 @@ the current `$AWS_PROFILE`. It uses two variables to control how that is shown:
|
|||
|
||||
Source profile credentials in `~/.aws/credentials`:
|
||||
|
||||
```
|
||||
```ini
|
||||
[source-profile-name]
|
||||
aws_access_key_id = ...
|
||||
aws_secret_access_key = ...
|
||||
|
@ -60,7 +76,7 @@ aws_secret_access_key = ...
|
|||
|
||||
Role configuration in `~/.aws/config`:
|
||||
|
||||
```
|
||||
```ini
|
||||
[profile source-profile-name]
|
||||
mfa_serial = arn:aws:iam::111111111111:mfa/myuser
|
||||
region = us-east-1
|
||||
|
|
|
@ -2,10 +2,14 @@ function agp() {
|
|||
echo $AWS_PROFILE
|
||||
}
|
||||
|
||||
function agr() {
|
||||
echo $AWS_REGION
|
||||
}
|
||||
|
||||
# AWS profile selection
|
||||
function asp() {
|
||||
if [[ -z "$1" ]]; then
|
||||
unset AWS_DEFAULT_PROFILE AWS_PROFILE AWS_EB_PROFILE
|
||||
unset AWS_DEFAULT_PROFILE AWS_PROFILE AWS_EB_PROFILE AWS_PROFILE_REGION
|
||||
echo AWS profile cleared.
|
||||
return
|
||||
fi
|
||||
|
@ -21,6 +25,31 @@ function asp() {
|
|||
export AWS_DEFAULT_PROFILE=$1
|
||||
export AWS_PROFILE=$1
|
||||
export AWS_EB_PROFILE=$1
|
||||
|
||||
export AWS_PROFILE_REGION=$(aws configure get region)
|
||||
|
||||
if [[ "$2" == "login" ]]; then
|
||||
aws sso login
|
||||
fi
|
||||
}
|
||||
|
||||
# AWS region selection
|
||||
function asr() {
|
||||
if [[ -z "$1" ]]; then
|
||||
unset AWS_DEFAULT_REGION AWS_REGION
|
||||
echo AWS region cleared.
|
||||
return
|
||||
fi
|
||||
|
||||
local -a available_regions
|
||||
available_regions=($(aws_regions))
|
||||
if [[ -z "${available_regions[(r)$1]}" ]]; then
|
||||
echo "${fg[red]}Available regions: \n$(aws_regions)"
|
||||
return 1
|
||||
fi
|
||||
|
||||
export AWS_REGION=$1
|
||||
export AWS_DEFAULT_REGION=$1
|
||||
}
|
||||
|
||||
# AWS profile switch
|
||||
|
@ -41,6 +70,7 @@ function acp() {
|
|||
fi
|
||||
|
||||
local profile="$1"
|
||||
local mfa_token="$2"
|
||||
|
||||
# Get fallback credentials for if the aws command fails or no command is run
|
||||
local aws_access_key_id="$(aws configure get aws_access_key_id --profile $profile)"
|
||||
|
@ -54,55 +84,56 @@ function acp() {
|
|||
|
||||
if [[ -n "$mfa_serial" ]]; then
|
||||
local -a mfa_opt
|
||||
local mfa_token
|
||||
echo -n "Please enter your MFA token for $mfa_serial: "
|
||||
read -r mfa_token
|
||||
if [[ -z "$mfa_token" ]]; then
|
||||
echo -n "Please enter your MFA token for $mfa_serial: "
|
||||
read -r mfa_token
|
||||
fi
|
||||
if [[ -z "$sess_duration" ]]; then
|
||||
echo -n "Please enter the session duration in seconds (900-43200; default: 3600, which is the default maximum for a role): "
|
||||
read -r sess_duration
|
||||
fi
|
||||
mfa_opt=(--serial-number "$mfa_serial" --token-code "$mfa_token" --duration-seconds "${sess_duration:-3600}")
|
||||
fi
|
||||
|
||||
# Now see whether we need to just MFA for the current role, or assume a different one
|
||||
local role_arn="$(aws configure get role_arn --profile $profile)"
|
||||
local sess_name="$(aws configure get role_session_name --profile $profile)"
|
||||
# Now see whether we need to just MFA for the current role, or assume a different one
|
||||
local role_arn="$(aws configure get role_arn --profile $profile)"
|
||||
local sess_name="$(aws configure get role_session_name --profile $profile)"
|
||||
|
||||
if [[ -n "$role_arn" ]]; then
|
||||
# Means we need to assume a specified role
|
||||
aws_command=(aws sts assume-role --role-arn "$role_arn" "${mfa_opt[@]}")
|
||||
if [[ -n "$role_arn" ]]; then
|
||||
# Means we need to assume a specified role
|
||||
aws_command=(aws sts assume-role --role-arn "$role_arn" "${mfa_opt[@]}")
|
||||
|
||||
# Check whether external_id is configured to use while assuming the role
|
||||
local external_id="$(aws configure get external_id --profile $profile)"
|
||||
if [[ -n "$external_id" ]]; then
|
||||
aws_command+=(--external-id "$external_id")
|
||||
fi
|
||||
|
||||
# Get source profile to use to assume role
|
||||
local source_profile="$(aws configure get source_profile --profile $profile)"
|
||||
if [[ -z "$sess_name" ]]; then
|
||||
sess_name="${source_profile:-profile}"
|
||||
fi
|
||||
aws_command+=(--profile="${source_profile:-profile}" --role-session-name "${sess_name}")
|
||||
|
||||
echo "Assuming role $role_arn using profile ${source_profile:-profile}"
|
||||
else
|
||||
# Means we only need to do MFA
|
||||
aws_command=(aws sts get-session-token --profile="$profile" "${mfa_opt[@]}")
|
||||
echo "Obtaining session token for profile $profile"
|
||||
# Check whether external_id is configured to use while assuming the role
|
||||
local external_id="$(aws configure get external_id --profile $profile)"
|
||||
if [[ -n "$external_id" ]]; then
|
||||
aws_command+=(--external-id "$external_id")
|
||||
fi
|
||||
|
||||
# Format output of aws command for easier processing
|
||||
aws_command+=(--query '[Credentials.AccessKeyId,Credentials.SecretAccessKey,Credentials.SessionToken]' --output text)
|
||||
|
||||
# Run the aws command to obtain credentials
|
||||
local -a credentials
|
||||
credentials=(${(ps:\t:)"$(${aws_command[@]})"})
|
||||
|
||||
if [[ -n "$credentials" ]]; then
|
||||
aws_access_key_id="${credentials[1]}"
|
||||
aws_secret_access_key="${credentials[2]}"
|
||||
aws_session_token="${credentials[3]}"
|
||||
# Get source profile to use to assume role
|
||||
local source_profile="$(aws configure get source_profile --profile $profile)"
|
||||
if [[ -z "$sess_name" ]]; then
|
||||
sess_name="${source_profile:-profile}"
|
||||
fi
|
||||
aws_command+=(--profile="${source_profile:-profile}" --role-session-name "${sess_name}")
|
||||
|
||||
echo "Assuming role $role_arn using profile ${source_profile:-profile}"
|
||||
else
|
||||
# Means we only need to do MFA
|
||||
aws_command=(aws sts get-session-token --profile="$profile" "${mfa_opt[@]}")
|
||||
echo "Obtaining session token for profile $profile"
|
||||
fi
|
||||
|
||||
# Format output of aws command for easier processing
|
||||
aws_command+=(--query '[Credentials.AccessKeyId,Credentials.SecretAccessKey,Credentials.SessionToken]' --output text)
|
||||
|
||||
# Run the aws command to obtain credentials
|
||||
local -a credentials
|
||||
credentials=(${(ps:\t:)"$(${aws_command[@]})"})
|
||||
|
||||
if [[ -n "$credentials" ]]; then
|
||||
aws_access_key_id="${credentials[1]}"
|
||||
aws_secret_access_key="${credentials[2]}"
|
||||
aws_session_token="${credentials[3]}"
|
||||
fi
|
||||
|
||||
# Switch to AWS profile
|
||||
|
@ -129,21 +160,60 @@ function aws_change_access_key() {
|
|||
return 1
|
||||
fi
|
||||
|
||||
echo "Insert the credentials when asked."
|
||||
asp "$1" || return 1
|
||||
AWS_PAGER="" aws iam create-access-key
|
||||
AWS_PAGER="" aws configure --profile "$1"
|
||||
local profile="$1"
|
||||
# Get current access key
|
||||
local original_aws_access_key_id="$(aws configure get aws_access_key_id --profile $profile)"
|
||||
|
||||
echo "You can now safely delete the old access key running \`aws iam delete-access-key --access-key-id ID\`"
|
||||
asp "$profile" || return 1
|
||||
echo "Generating a new access key pair for you now."
|
||||
if aws --no-cli-pager iam create-access-key; then
|
||||
echo "Insert the newly generated credentials when asked."
|
||||
aws --no-cli-pager configure --profile $profile
|
||||
else
|
||||
echo "Current access keys:"
|
||||
aws --no-cli-pager iam list-access-keys
|
||||
echo "Profile \"${profile}\" is currently using the $original_aws_access_key_id key. You can delete an old access key by running \`aws --profile $profile iam delete-access-key --access-key-id AccessKeyId\`"
|
||||
return 1
|
||||
fi
|
||||
|
||||
read -q "yn?Would you like to disable your previous access key (${original_aws_access_key_id}) now? "
|
||||
case $yn in
|
||||
[Yy]*)
|
||||
echo -n "\nDisabling access key ${original_aws_access_key_id}..."
|
||||
if aws --no-cli-pager iam update-access-key --access-key-id ${original_aws_access_key_id} --status Inactive; then
|
||||
echo "done."
|
||||
else
|
||||
echo "\nFailed to disable ${original_aws_access_key_id} key."
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
echo ""
|
||||
;;
|
||||
esac
|
||||
echo "You can now safely delete the old access key by running \`aws --profile $profile iam delete-access-key --access-key-id ${original_aws_access_key_id}\`"
|
||||
echo "Your current keys are:"
|
||||
AWS_PAGER="" aws iam list-access-keys
|
||||
aws --no-cli-pager iam list-access-keys
|
||||
}
|
||||
|
||||
function aws_regions() {
|
||||
if [[ $AWS_DEFAULT_PROFILE || $AWS_PROFILE ]];then
|
||||
aws ec2 describe-regions |grep RegionName | awk -F ':' '{gsub(/"/, "", $2);gsub(/,/, "", $2);gsub(/ /, "", $2); print $2}'
|
||||
else
|
||||
echo "You must specify a AWS profile."
|
||||
fi
|
||||
}
|
||||
|
||||
function aws_profiles() {
|
||||
aws --no-cli-pager configure list-profiles 2> /dev/null && return
|
||||
[[ -r "${AWS_CONFIG_FILE:-$HOME/.aws/config}" ]] || return 1
|
||||
grep --color=never -Eo '\[.*\]' "${AWS_CONFIG_FILE:-$HOME/.aws/config}" | sed -E 's/^[[:space:]]*\[(profile)?[[:space:]]*([-_[:alnum:]\.@]+)\][[:space:]]*$/\2/g'
|
||||
grep --color=never -Eo '\[.*\]' "${AWS_CONFIG_FILE:-$HOME/.aws/config}" | sed -E 's/^[[:space:]]*\[(profile)?[[:space:]]*([^[:space:]]+)\][[:space:]]*$/\2/g'
|
||||
}
|
||||
|
||||
function _aws_regions() {
|
||||
reply=($(aws_regions))
|
||||
}
|
||||
compctl -K _aws_regions asr
|
||||
|
||||
function _aws_profiles() {
|
||||
reply=($(aws_profiles))
|
||||
}
|
||||
|
@ -151,15 +221,25 @@ compctl -K _aws_profiles asp acp aws_change_access_key
|
|||
|
||||
# AWS prompt
|
||||
function aws_prompt_info() {
|
||||
[[ -z $AWS_PROFILE ]] && return
|
||||
echo "${ZSH_THEME_AWS_PREFIX:=<aws:}${AWS_PROFILE}${ZSH_THEME_AWS_SUFFIX:=>}"
|
||||
local _aws_to_show
|
||||
local region="${AWS_REGION:-${AWS_DEFAULT_REGION:-$AWS_PROFILE_REGION}}"
|
||||
|
||||
if [[ -n "$AWS_PROFILE" ]];then
|
||||
_aws_to_show+="${ZSH_THEME_AWS_PROFILE_PREFIX="<aws:"}${AWS_PROFILE}${ZSH_THEME_AWS_PROFILE_SUFFIX=">"}"
|
||||
fi
|
||||
|
||||
if [[ -n "$region" ]]; then
|
||||
[[ -n "$_aws_to_show" ]] && _aws_to_show+="${ZSH_THEME_AWS_DIVIDER=" "}"
|
||||
_aws_to_show+="${ZSH_THEME_AWS_REGION_PREFIX="<region:"}${region}${ZSH_THEME_AWS_REGION_SUFFIX=">"}"
|
||||
fi
|
||||
|
||||
echo "$_aws_to_show"
|
||||
}
|
||||
|
||||
if [[ "$SHOW_AWS_PROMPT" != false && "$RPROMPT" != *'$(aws_prompt_info)'* ]]; then
|
||||
RPROMPT='$(aws_prompt_info)'"$RPROMPT"
|
||||
fi
|
||||
|
||||
|
||||
# Load awscli completions
|
||||
|
||||
# AWS CLI v2 comes with its own autocompletion. Check if that is there, otherwise fall back
|
||||
|
@ -204,3 +284,4 @@ else
|
|||
[[ -r $_aws_zsh_completer_path ]] && source $_aws_zsh_completer_path
|
||||
unset _aws_zsh_completer_path _brew_prefix
|
||||
fi
|
||||
|
||||
|
|
49
plugins/azure/README.md
Normal file
49
plugins/azure/README.md
Normal file
|
@ -0,0 +1,49 @@
|
|||
# azure
|
||||
|
||||
This plugin provides completion support for [azure cli](https://docs.microsoft.com/en-us/cli/azure/)
|
||||
and a few utilities to manage azure subscriptions and display them in the prompt.
|
||||
|
||||
To use it, add `azure` to the plugins array in your zshrc file.
|
||||
|
||||
```zsh
|
||||
plugins=(... azure)
|
||||
```
|
||||
|
||||
## Plugin commands
|
||||
|
||||
|
||||
* `az_subscriptions`: lists the available subscriptions in the `AZURE_CONFIG_DIR` (default: `~/.azure/`).
|
||||
Used to provide completion for the `azss` function.
|
||||
|
||||
* `azgs`: gets the current value of `$azure_subscription`.
|
||||
|
||||
* `azss [<subscription>]`: sets the `$azure_subscription`.
|
||||
|
||||
|
||||
NOTE : because azure keeps the state of active subscription in ${AZURE_CONFIG_DIR:-$HOME/.azure/azureProfile.json}, the prompt command requires `jq` to be enabled to parse the file. If jq is not in the path the prompt will show nothing
|
||||
|
||||
## Theme
|
||||
|
||||
The plugin creates an `azure_prompt_info` function that you can use in your theme, which displays
|
||||
the current `$azure_subscription`. It uses two variables to control how that is shown:
|
||||
|
||||
- ZSH_THEME_AZURE_PREFIX: sets the prefix of the azure_subscription. Defaults to `<az:`.
|
||||
|
||||
- ZSH_THEME_azure_SUFFIX: sets the suffix of the azure_subscription. Defaults to `>`.
|
||||
|
||||
|
||||
```
|
||||
RPROMPT='$(azure_prompt_info)'
|
||||
```
|
||||
|
||||
## Develop
|
||||
|
||||
On ubuntu get a working environment with :
|
||||
|
||||
` docker run -it -v $(pwd):/mnt -w /mnt ubuntu bash`
|
||||
|
||||
```
|
||||
apt install -y curl jq zsh git vim
|
||||
sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
|
||||
curl -sL https://aka.ms/InstallAzureCLIDeb | bash
|
||||
```
|
60
plugins/azure/azure.plugin.zsh
Normal file
60
plugins/azure/azure.plugin.zsh
Normal file
|
@ -0,0 +1,60 @@
|
|||
# AZ Get Subscriptions
|
||||
function azgs() {
|
||||
az account show --output tsv --query 'name' 2>/dev/null
|
||||
}
|
||||
|
||||
# AZ Subscription Selection
|
||||
alias azss="az account set --subscription"
|
||||
|
||||
|
||||
function az_subscriptions() {
|
||||
az account list --all --output tsv --query '[*].name' 2> /dev/null
|
||||
}
|
||||
|
||||
function _az_subscriptions() {
|
||||
reply=($(az_subscriptions))
|
||||
}
|
||||
compctl -K _az_subscriptions azss
|
||||
|
||||
# Azure prompt
|
||||
function azure_prompt_info() {
|
||||
[[ ! -f "${AZURE_CONFIG_DIR:-$HOME/.azure}/azureProfile.json" ]] && return
|
||||
# azgs is too expensive, if we have jq, we enable the prompt
|
||||
(( $+commands[jq] )) || return 1
|
||||
azgs=$(jq -r '.subscriptions[] | select(.isDefault==true) .name' "${AZURE_CONFIG_DIR:-$HOME/.azure}/azureProfile.json")
|
||||
echo "${ZSH_THEME_AZURE_PREFIX:=<az:}${azgs}${ZSH_THEME_AZURE_SUFFIX:=>}"
|
||||
}
|
||||
|
||||
|
||||
# Load az completions
|
||||
function _az-homebrew-installed() {
|
||||
# check if Homebrew is installed
|
||||
(( $+commands[brew] )) || return 1
|
||||
|
||||
# if so, we assume it's default way to install brew
|
||||
if [[ ${commands[brew]:t2} == bin/brew ]]; then
|
||||
_brew_prefix="${commands[brew]:h:h}" # remove trailing /bin/brew
|
||||
else
|
||||
# ok, it is not in the default prefix
|
||||
# this call to brew is expensive (about 400 ms), so at least let's make it only once
|
||||
_brew_prefix=$(brew --prefix)
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
# get az.completion.sh location from $PATH
|
||||
_az_zsh_completer_path="$commands[az_zsh_completer.sh]"
|
||||
|
||||
# otherwise check common locations
|
||||
if [[ -z $_az_zsh_completer_path ]]; then
|
||||
# Homebrew
|
||||
if _az-homebrew-installed; then
|
||||
_az_zsh_completer_path=$_brew_prefix/etc/bash_completion.d/az
|
||||
# Linux
|
||||
else
|
||||
_az_zsh_completer_path=/etc/bash_completion.d/azure-cli
|
||||
fi
|
||||
fi
|
||||
|
||||
[[ -r $_az_zsh_completer_path ]] && autoload -U +X bashcompinit && bashcompinit && source $_az_zsh_completer_path
|
||||
unset _az_zsh_completer_path _brew_prefix
|
|
@ -8,15 +8,22 @@ To use, add `battery` to the list of plugins in your `.zshrc` file:
|
|||
|
||||
Then, add the `battery_pct_prompt` function to your custom theme. For example:
|
||||
|
||||
```
|
||||
```zsh
|
||||
RPROMPT='$(battery_pct_prompt) ...'
|
||||
```
|
||||
|
||||
## Requirements
|
||||
|
||||
On Linux, you must have the `acpi` tool installed on your operating system.
|
||||
- On Linux, you must have the `acpi` or `acpitool` commands installed on your operating system.
|
||||
On Debian/Ubuntu, you can do that with `sudo apt install acpi` or `sudo apt install acpitool`.
|
||||
|
||||
Here's an example of how to install with apt:
|
||||
```
|
||||
sudo apt-get install acpi
|
||||
```
|
||||
- On Android (via [Termux](https://play.google.com/store/apps/details?id=com.termux)), you must have:
|
||||
|
||||
1. The `Termux:API` addon app installed:
|
||||
[Google Play](https://play.google.com/store/apps/details?id=com.termux.api) | [F-Droid](https://f-droid.org/packages/com.termux.api/)
|
||||
|
||||
2. The `termux-api` package installed within termux:
|
||||
|
||||
```sh
|
||||
pkg install termux-api
|
||||
```
|
||||
|
|
|
@ -10,17 +10,17 @@
|
|||
# Author: J (927589452) #
|
||||
# Modified to add support for FreeBSD #
|
||||
###########################################
|
||||
# Author: Avneet Singh (kalsi-avneet) #
|
||||
# Modified to add support for Android #
|
||||
###########################################
|
||||
|
||||
if [[ "$OSTYPE" = darwin* ]]; then
|
||||
|
||||
function battery_is_charging() {
|
||||
ioreg -rc AppleSmartBattery | command grep -q '^.*"ExternalConnected"\ =\ Yes'
|
||||
}
|
||||
|
||||
function battery_pct() {
|
||||
pmset -g batt | grep -Eo "\d+%" | cut -d% -f1
|
||||
}
|
||||
|
||||
function battery_pct_remaining() {
|
||||
if battery_is_charging; then
|
||||
echo "External Power"
|
||||
|
@ -28,7 +28,6 @@ if [[ "$OSTYPE" = darwin* ]]; then
|
|||
battery_pct
|
||||
fi
|
||||
}
|
||||
|
||||
function battery_time_remaining() {
|
||||
local smart_battery_status="$(ioreg -rc "AppleSmartBattery")"
|
||||
if [[ $(echo $smart_battery_status | command grep -c '^.*"ExternalConnected"\ =\ No') -eq 1 ]]; then
|
||||
|
@ -42,7 +41,6 @@ if [[ "$OSTYPE" = darwin* ]]; then
|
|||
echo "∞"
|
||||
fi
|
||||
}
|
||||
|
||||
function battery_pct_prompt () {
|
||||
local battery_pct color
|
||||
if ioreg -rc AppleSmartBattery | command grep -q '^.*"ExternalConnected"\ =\ No'; then
|
||||
|
@ -61,17 +59,14 @@ if [[ "$OSTYPE" = darwin* ]]; then
|
|||
}
|
||||
|
||||
elif [[ "$OSTYPE" = freebsd* ]]; then
|
||||
|
||||
function battery_is_charging() {
|
||||
[[ $(sysctl -n hw.acpi.battery.state) -eq 2 ]]
|
||||
}
|
||||
|
||||
function battery_pct() {
|
||||
if (( $+commands[sysctl] )); then
|
||||
sysctl -n hw.acpi.battery.life
|
||||
fi
|
||||
}
|
||||
|
||||
function battery_pct_remaining() {
|
||||
if ! battery_is_charging; then
|
||||
battery_pct
|
||||
|
@ -79,7 +74,6 @@ elif [[ "$OSTYPE" = freebsd* ]]; then
|
|||
echo "External Power"
|
||||
fi
|
||||
}
|
||||
|
||||
function battery_time_remaining() {
|
||||
local remaining_time
|
||||
remaining_time=$(sysctl -n hw.acpi.battery.time)
|
||||
|
@ -89,7 +83,6 @@ elif [[ "$OSTYPE" = freebsd* ]]; then
|
|||
printf %02d:%02d $hour $minute
|
||||
fi
|
||||
}
|
||||
|
||||
function battery_pct_prompt() {
|
||||
local battery_pct color
|
||||
battery_pct=$(battery_pct_remaining)
|
||||
|
@ -106,19 +99,22 @@ elif [[ "$OSTYPE" = freebsd* ]]; then
|
|||
echo "%{$fg[$color]%}${battery_pct}%%%{$reset_color%}"
|
||||
fi
|
||||
}
|
||||
|
||||
elif [[ "$OSTYPE" = linux* ]]; then
|
||||
|
||||
elif [[ "$OSTYPE" = linux-android ]] && (( ${+commands[termux-battery-status]} )); then
|
||||
function battery_is_charging() {
|
||||
! acpi 2>/dev/null | command grep -v "rate information unavailable" | command grep -q '^Battery.*Discharging'
|
||||
termux-battery-status 2>/dev/null | command awk '/status/ { exit ($0 ~ /DISCHARGING/) }'
|
||||
}
|
||||
|
||||
function battery_pct() {
|
||||
if (( $+commands[acpi] )); then
|
||||
acpi 2>/dev/null | command grep -v "rate information unavailable" | command grep -E '^Battery.*(Full|(Disc|C)harging)' | cut -f2 -d ',' | tr -cd '[:digit:]'
|
||||
fi
|
||||
# Sample output:
|
||||
# {
|
||||
# "health": "GOOD",
|
||||
# "percentage": 93,
|
||||
# "plugged": "UNPLUGGED",
|
||||
# "status": "DISCHARGING",
|
||||
# "temperature": 29.0,
|
||||
# "current": 361816
|
||||
# }
|
||||
termux-battery-status 2>/dev/null | command awk '/percentage/ { gsub(/[,]/,""); print $2}'
|
||||
}
|
||||
|
||||
function battery_pct_remaining() {
|
||||
if ! battery_is_charging; then
|
||||
battery_pct
|
||||
|
@ -126,13 +122,72 @@ elif [[ "$OSTYPE" = linux* ]]; then
|
|||
echo "External Power"
|
||||
fi
|
||||
}
|
||||
|
||||
function battery_time_remaining() {
|
||||
if ! battery_is_charging; then
|
||||
acpi 2>/dev/null | command grep -v "rate information unavailable" | cut -f3 -d ','
|
||||
fi
|
||||
}
|
||||
|
||||
function battery_time_remaining() { } # Not available on android
|
||||
function battery_pct_prompt() {
|
||||
local battery_pct color
|
||||
battery_pct=$(battery_pct_remaining)
|
||||
if battery_is_charging; then
|
||||
echo "∞"
|
||||
else
|
||||
if [[ $battery_pct -gt 50 ]]; then
|
||||
color='green'
|
||||
elif [[ $battery_pct -gt 20 ]]; then
|
||||
color='yellow'
|
||||
else
|
||||
color='red'
|
||||
fi
|
||||
echo "%{$fg[$color]%}${battery_pct}%%%{$reset_color%}"
|
||||
fi
|
||||
}
|
||||
elif [[ "$OSTYPE" = linux* ]]; then
|
||||
function battery_is_charging() {
|
||||
if (( $+commands[acpitool] )); then
|
||||
! acpitool 2>/dev/null | command grep -qE '^\s+Battery.*Discharging'
|
||||
elif (( $+commands[acpi] )); then
|
||||
! acpi 2>/dev/null | command grep -v "rate information unavailable" | command grep -q '^Battery.*Discharging'
|
||||
fi
|
||||
}
|
||||
function battery_pct() {
|
||||
if (( $+commands[acpitool] )); then
|
||||
# Sample output:
|
||||
# Battery #1 : Unknown, 99.55%
|
||||
# Battery #2 : Discharging, 49.58%, 01:12:05
|
||||
# All batteries : 62.60%, 02:03:03
|
||||
local -i pct=$(acpitool 2>/dev/null | command awk -F, '
|
||||
/^\s+All batteries/ {
|
||||
gsub(/[^0-9.]/, "", $1)
|
||||
pct=$1
|
||||
exit
|
||||
}
|
||||
!pct && /^\s+Battery/ {
|
||||
gsub(/[^0-9.]/, "", $2)
|
||||
pct=$2
|
||||
}
|
||||
END { print pct }
|
||||
')
|
||||
echo $pct
|
||||
elif (( $+commands[acpi] )); then
|
||||
# Sample output:
|
||||
# Battery 0: Discharging, 0%, rate information unavailable
|
||||
# Battery 1: Full, 100%
|
||||
acpi 2>/dev/null | command awk -F, '
|
||||
/rate information unavailable/ { next }
|
||||
/^Battery.*: /{ gsub(/[^0-9]/, "", $2); print $2; exit }
|
||||
'
|
||||
fi
|
||||
}
|
||||
function battery_pct_remaining() {
|
||||
if ! battery_is_charging; then
|
||||
battery_pct
|
||||
else
|
||||
echo "External Power"
|
||||
fi
|
||||
}
|
||||
function battery_time_remaining() {
|
||||
if ! battery_is_charging; then
|
||||
acpi 2>/dev/null | command grep -v "rate information unavailable" | cut -f3 -d ','
|
||||
fi
|
||||
}
|
||||
function battery_pct_prompt() {
|
||||
local battery_pct color
|
||||
battery_pct=$(battery_pct_remaining)
|
||||
|
@ -149,7 +204,6 @@ elif [[ "$OSTYPE" = linux* ]]; then
|
|||
echo "%{$fg[$color]%}${battery_pct}%%%{$reset_color%}"
|
||||
fi
|
||||
}
|
||||
|
||||
else
|
||||
# Empty functions so we don't cause errors in prompts
|
||||
function battery_is_charging { false }
|
||||
|
@ -174,7 +228,7 @@ function battery_level_gauge() {
|
|||
local charging_color=${BATTERY_CHARGING_COLOR:-$color_yellow}
|
||||
local charging_symbol=${BATTERY_CHARGING_SYMBOL:-'⚡'}
|
||||
|
||||
local battery_remaining_percentage=$(battery_pct)
|
||||
local -i battery_remaining_percentage=$(battery_pct)
|
||||
local filled empty gauge_color
|
||||
|
||||
if [[ $battery_remaining_percentage =~ [0-9]+ ]]; then
|
||||
|
|
|
@ -1,5 +1,14 @@
|
|||
## Bazel autocomplete plugin
|
||||
# Bazel plugin
|
||||
|
||||
A copy of the completion script from the
|
||||
[bazelbuild/bazel](https://github.com/bazelbuild/bazel/master/scripts/zsh_completion/_bazel)
|
||||
git repo.
|
||||
This plugin adds completion for [bazel](https://bazel.build), an open-source build and
|
||||
test tool that scalably supports multi-language and multi-platform projects.
|
||||
|
||||
To use it, add `bazel` to the plugins array in your zshrc file:
|
||||
|
||||
```zsh
|
||||
plugins=(... bazel)
|
||||
```
|
||||
|
||||
The plugin has a copy of [the completion script from the git repository][1].
|
||||
|
||||
[1]: https://github.com/bazelbuild/bazel/blob/master/scripts/zsh_completion/_bazel
|
||||
|
|
|
@ -164,7 +164,7 @@ _get_build_targets() {
|
|||
;;
|
||||
esac
|
||||
completions=(${$(_bazel_b query "kind(\"${rule_re}\", ${pkg}:all)" 2>/dev/null)##*:})
|
||||
if ( (( ${#completions} > 0 )) && [[ $target_type != run ]] ); then
|
||||
if ( (( ${#completions} > 0 )) && [[ $target_type != bin ]] ); then
|
||||
completions+=(all)
|
||||
fi
|
||||
echo ${completions[*]}
|
||||
|
|
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
|
|
@ -1,77 +1,106 @@
|
|||
#!/usr/bin/env zsh
|
||||
|
||||
## setup ##
|
||||
## Setup
|
||||
|
||||
[[ -o interactive ]] || return #interactive only!
|
||||
zmodload zsh/datetime || { print "can't load zsh/datetime"; return } # faster than date()
|
||||
autoload -Uz add-zsh-hook || { print "can't add zsh hook!"; return }
|
||||
[[ -o interactive ]] || return # don't load on non-interactive shells
|
||||
[[ -z "$SSH_CLIENT" && -z "$SSH_TTY" ]] || return # don't load on a SSH connection
|
||||
|
||||
(( ${+bgnotify_threshold} )) || bgnotify_threshold=5 #default 10 seconds
|
||||
zmodload zsh/datetime # faster than `date`
|
||||
|
||||
|
||||
## definitions ##
|
||||
## Zsh Hooks
|
||||
|
||||
if ! (type bgnotify_formatted | grep -q 'function'); then ## allow custom function override
|
||||
function bgnotify_formatted { ## args: (exit_status, command, elapsed_seconds)
|
||||
elapsed="$(( $3 % 60 ))s"
|
||||
(( $3 >= 60 )) && elapsed="$((( $3 % 3600) / 60 ))m $elapsed"
|
||||
(( $3 >= 3600 )) && elapsed="$(( $3 / 3600 ))h $elapsed"
|
||||
[ $1 -eq 0 ] && bgnotify "#win (took $elapsed)" "$2" || bgnotify "#fail (took $elapsed)" "$2"
|
||||
function bgnotify_begin {
|
||||
bgnotify_timestamp=$EPOCHSECONDS
|
||||
bgnotify_lastcmd="${1:-$2}"
|
||||
}
|
||||
|
||||
function bgnotify_end {
|
||||
{
|
||||
local exit_status=$?
|
||||
local elapsed=$(( EPOCHSECONDS - bgnotify_timestamp ))
|
||||
|
||||
# check time elapsed
|
||||
[[ $bgnotify_timestamp -gt 0 ]] || return
|
||||
[[ $elapsed -ge $bgnotify_threshold ]] || return
|
||||
|
||||
# check if Terminal app is not active
|
||||
[[ $(bgnotify_appid) != "$bgnotify_termid" ]] || return
|
||||
|
||||
printf '\a' # beep sound
|
||||
bgnotify_formatted "$exit_status" "$bgnotify_lastcmd" "$elapsed"
|
||||
} always {
|
||||
bgnotify_timestamp=0
|
||||
}
|
||||
fi
|
||||
}
|
||||
|
||||
currentWindowId () {
|
||||
if hash osascript 2>/dev/null; then #osx
|
||||
osascript -e 'tell application (path to frontmost application as text) to id of front window' 2&> /dev/null || echo "0"
|
||||
elif (hash notify-send 2>/dev/null || hash kdialog 2>/dev/null); then #ubuntu!
|
||||
xprop -root 2> /dev/null | awk '/NET_ACTIVE_WINDOW/{print $5;exit} END{exit !$5}' || echo "0"
|
||||
autoload -Uz add-zsh-hook
|
||||
add-zsh-hook preexec bgnotify_begin
|
||||
add-zsh-hook precmd bgnotify_end
|
||||
|
||||
|
||||
## Functions
|
||||
|
||||
# allow custom function override
|
||||
(( ${+functions[bgnotify_formatted]} )) || \
|
||||
function bgnotify_formatted {
|
||||
local exit_status=$1
|
||||
local cmd="$2"
|
||||
|
||||
# humanly readable elapsed time
|
||||
local elapsed="$(( $3 % 60 ))s"
|
||||
(( $3 < 60 )) || elapsed="$((( $3 % 3600) / 60 ))m $elapsed"
|
||||
(( $3 < 3600 )) || elapsed="$(( $3 / 3600 ))h $elapsed"
|
||||
|
||||
if [[ $1 -eq 0 ]]; then
|
||||
bgnotify "#win (took $elapsed)" "$2"
|
||||
else
|
||||
echo $EPOCHSECONDS #fallback for windows
|
||||
bgnotify "#fail (took $elapsed)" "$2"
|
||||
fi
|
||||
}
|
||||
|
||||
bgnotify () { ## args: (title, subtitle)
|
||||
if hash terminal-notifier 2>/dev/null; then #osx
|
||||
[[ "$TERM_PROGRAM" == 'iTerm.app' ]] && term_id='com.googlecode.iterm2';
|
||||
[[ "$TERM_PROGRAM" == 'Apple_Terminal' ]] && term_id='com.apple.terminal';
|
||||
## now call terminal-notifier, (hopefully with $term_id!)
|
||||
[ -z "$term_id" ] && terminal-notifier -message "$2" -title "$1" >/dev/null ||
|
||||
terminal-notifier -message "$2" -title "$1" -activate "$term_id" -sender "$term_id" >/dev/null
|
||||
elif hash growlnotify 2>/dev/null; then #osx growl
|
||||
# for macOS, output is "app ID, window ID" (com.googlecode.iterm2, 116)
|
||||
function bgnotify_appid {
|
||||
if (( ${+commands[osascript]} )); then
|
||||
osascript -e 'tell application (path to frontmost application as text) to get the {id, id of front window}' 2>/dev/null
|
||||
elif (( ${+commands[xprop]} )); then
|
||||
xprop -root _NET_ACTIVE_WINDOW 2>/dev/null | cut -d' ' -f5
|
||||
else
|
||||
echo $EPOCHSECONDS
|
||||
fi
|
||||
}
|
||||
|
||||
function bgnotify {
|
||||
# $1: title, $2: message
|
||||
if (( ${+commands[terminal-notifier]} )); then # macOS
|
||||
local term_id="${bgnotify_termid%%,*}" # remove window id
|
||||
if [[ -z "$term_id" ]]; then
|
||||
case "$TERM_PROGRAM" in
|
||||
iTerm.app) term_id='com.googlecode.iterm2' ;;
|
||||
Apple_Terminal) term_id='com.apple.terminal' ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
if [[ -z "$term_id" ]]; then
|
||||
terminal-notifier -message "$2" -title "$1" &>/dev/null
|
||||
else
|
||||
terminal-notifier -message "$2" -title "$1" -activate "$term_id" -sender "$term_id" &>/dev/null
|
||||
fi
|
||||
elif (( ${+commands[growlnotify]} )); then # macOS growl
|
||||
growlnotify -m "$1" "$2"
|
||||
elif hash notify-send 2>/dev/null; then #ubuntu gnome!
|
||||
elif (( ${+commands[notify-send]} )); then # GNOME
|
||||
notify-send "$1" "$2"
|
||||
elif hash kdialog 2>/dev/null; then #ubuntu kde!
|
||||
elif (( ${+commands[kdialog]} )); then # KDE
|
||||
kdialog --title "$1" --passivepopup "$2" 5
|
||||
elif hash notifu 2>/dev/null; then #cygwyn support!
|
||||
elif (( ${+commands[notifu]} )); then # cygwin
|
||||
notifu /m "$2" /p "$1"
|
||||
fi
|
||||
}
|
||||
|
||||
## Defaults
|
||||
|
||||
## Zsh hooks ##
|
||||
# notify if command took longer than 5s by default
|
||||
bgnotify_threshold=${bgnotify_threshold:-5}
|
||||
|
||||
bgnotify_begin() {
|
||||
bgnotify_timestamp=$EPOCHSECONDS
|
||||
bgnotify_lastcmd="${1:-$2}"
|
||||
bgnotify_windowid=$(currentWindowId)
|
||||
}
|
||||
|
||||
bgnotify_end() {
|
||||
didexit=$?
|
||||
elapsed=$(( EPOCHSECONDS - bgnotify_timestamp ))
|
||||
past_threshold=$(( elapsed >= bgnotify_threshold ))
|
||||
if (( bgnotify_timestamp > 0 )) && (( past_threshold )); then
|
||||
if [ $(currentWindowId) != "$bgnotify_windowid" ]; then
|
||||
print -n "\a"
|
||||
bgnotify_formatted "$didexit" "$bgnotify_lastcmd" "$elapsed"
|
||||
fi
|
||||
fi
|
||||
bgnotify_timestamp=0 #reset it to 0!
|
||||
}
|
||||
|
||||
## only enable if a local (non-ssh) connection
|
||||
if [ -z "$SSH_CLIENT" ] && [ -z "$SSH_TTY" ]; then
|
||||
add-zsh-hook preexec bgnotify_begin
|
||||
add-zsh-hook precmd bgnotify_end
|
||||
fi
|
||||
# bgnotify_appid is slow in macOS and the terminal ID won't change, so cache it at startup
|
||||
bgnotify_termid="$(bgnotify_appid)"
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
## Boot2docker autocomplete plugin
|
||||
|
||||
- Adds autocomplete options for all boot2docker commands.
|
||||
|
||||
|
||||
Maintainer : Manfred Touron ([@moul](https://github.com/moul))
|
|
@ -1,73 +0,0 @@
|
|||
#compdef boot2docker
|
||||
|
||||
# Boot2docker autocompletion for oh-my-zsh
|
||||
# Requires: Boot2docker installed
|
||||
# Author: Manfred Touron (@moul)
|
||||
|
||||
local -a _1st_arguments
|
||||
_1st_arguments=(
|
||||
"init":"Create a new Boot2Docker VM."
|
||||
"up":"Start VM from any states."
|
||||
"start":"Start VM from any states."
|
||||
"boot":"Start VM from any states."
|
||||
"ssh":"[ssh-command] Login to VM via SSH."
|
||||
"save":"Suspend VM and save state to disk."
|
||||
"suspend":"Suspend VM and save state to disk."
|
||||
"down":"Gracefully shutdown the VM."
|
||||
"stop":"Gracefully shutdown the VM."
|
||||
"halt":"Gracefully shutdown the VM."
|
||||
"restart":"Gracefully reboot the VM."
|
||||
"poweroff":"Forcefully power off the VM (may corrupt disk image)."
|
||||
"reset":"Forcefully power cycle the VM (may corrupt disk image)."
|
||||
"delete":"Delete Boot2Docker VM and its disk image."
|
||||
"destroy":"Delete Boot2Docker VM and its disk image."
|
||||
"config":"Show selected profile file settings."
|
||||
"cfg":"Show selected profile file settings."
|
||||
"info":"Display detailed information of VM."
|
||||
"ip":"Display the IP address of the VM's Host-only network."
|
||||
"socket":"Display the DOCKER_HOST socket to connect to."
|
||||
"shellinit":"Display the shell command to set up the Docker client."
|
||||
"status":"Display current state of VM."
|
||||
"download":"Download Boot2Docker ISO image."
|
||||
"upgrade":"Upgrade the Boot2Docker ISO image (restart if running)."
|
||||
"version":"Display version information."
|
||||
)
|
||||
|
||||
_arguments \
|
||||
'(--basevmdk)--basevmdk[Path to VMDK to use as base for persistent partition]' \
|
||||
'(--cpus)'{-c,--cpus}'[number of CPUs for boot2docker.]' \
|
||||
'(--clobber)--clobber[overwrite Docker client binary on boot2docker upgrade]' \
|
||||
'(--dhcp)--dhcp[enable VirtualBox host-only network DHCP.]' \
|
||||
'(--dhcpip)--dhcpip[VirtualBox host-only network DHCP server address.]' \
|
||||
'(-s --disksize)'{-s,--disksize}'[boot2docker disk image size (in MB).]' \
|
||||
'(--dockerport)--dockerport[host Docker port (forward to port 2376 in VM). (deprecated - use with care)]' \
|
||||
'(--driver)--driver[hypervisor driver.]' \
|
||||
'(--force-upgrade-download)--force-upgrade-download[always download on boot2docker upgrade, never skip.]' \
|
||||
'(--hostip)--hostip[VirtualBox host-only network IP address.]' \
|
||||
'(--iso)--iso[path to boot2docker ISO image.]' \
|
||||
'(--iso-url)--iso-url[/api.github.com/repos/boot2docker/boot2docker/releases": source URL to provision the boot2docker ISO image.]' \
|
||||
'(--lowerip)--lowerip[VirtualBox host-only network DHCP lower bound.]' \
|
||||
'(--memory)'{-m,--memory}'[virtual machine memory size (in MB).]' \
|
||||
'(--netmask)--netmask[VirtualBox host-only network mask.]' \
|
||||
'(--no-dummy)--no-dummy[Example parameter for the dummy driver.]' \
|
||||
'(--retries)--retries[number of port knocking retries during 'start']' \
|
||||
'(--serial)--serial[try serial console to get IP address (experimental)]' \
|
||||
'(--serialfile)--serialfile[path to the serial socket/pipe.]' \
|
||||
'(--ssh)--ssh[path to SSH client utility.]' \
|
||||
'(--ssh-keygen)--ssh-keygen[path to ssh-keygen utility.]' \
|
||||
'(--sshkey)--sshkey[path to SSH key to use.]' \
|
||||
'(--sshport)--sshport[host SSH port (forward to port 22 in VM).]' \
|
||||
'(--upperip)--upperip[VirtualBox host-only network DHCP upper bound.]' \
|
||||
'(--vbm)--vbm[path to VirtualBox management utility.]' \
|
||||
'(--vbox-share)--vbox-share[(defaults to "/Users=Users" if no shares are specified; use "disable" to explicitly prevent any shares from being created) List of directories to share during "up|start|boot" via VirtualBox Guest Additions, with optional labels]' \
|
||||
'(--verbose)'{-v,--verbose}'[display verbose command invocations.]' \
|
||||
'(--vm)--vm[virtual machine name.]' \
|
||||
'(--waittime)--waittime[Time in milliseconds to wait between port knocking retries during 'start']' \
|
||||
'*:: :->subcmds' && return 0
|
||||
|
||||
#_arguments '*:: :->command'
|
||||
|
||||
if (( CURRENT == 1 )); then
|
||||
_describe -t commands "boot2docker command" _1st_arguments
|
||||
return
|
||||
fi
|
|
@ -1,4 +1,6 @@
|
|||
alias bi="bower install"
|
||||
alias bisd="bower install --save-dev"
|
||||
alias bis="bower install --save"
|
||||
alias bl="bower list"
|
||||
alias bs="bower search"
|
||||
|
||||
|
@ -7,7 +9,7 @@ _bower_installed_packages () {
|
|||
}
|
||||
_bower ()
|
||||
{
|
||||
local -a _1st_arguments _no_color _dopts _save_dev _force_lastest _production
|
||||
local -a _1st_arguments _no_color _dopts _save_dev _force_latest _production
|
||||
local expl
|
||||
typeset -A opt_args
|
||||
|
||||
|
@ -20,7 +22,7 @@ _bower ()
|
|||
|
||||
_save_dev=('(--save-dev)--save-dev[Save installed packages into the project"s bower.json devDependencies]')
|
||||
|
||||
_force_lastest=('(--force-latest)--force-latest[Force latest version on conflict]')
|
||||
_force_latest=('(--force-latest)--force-latest[Force latest version on conflict]')
|
||||
|
||||
_production=('(--production)--production[Do not install project devDependencies]')
|
||||
|
||||
|
@ -52,7 +54,7 @@ _bower ()
|
|||
_arguments \
|
||||
$_dopts \
|
||||
$_save_dev \
|
||||
$_force_lastest \
|
||||
$_force_latest \
|
||||
$_no_color \
|
||||
$_production
|
||||
;;
|
||||
|
@ -60,7 +62,7 @@ _bower ()
|
|||
_arguments \
|
||||
$_dopts \
|
||||
$_no_color \
|
||||
$_force_lastest
|
||||
$_force_latest
|
||||
_bower_installed_packages
|
||||
compadd "$@" $(echo $bower_package_list)
|
||||
;;
|
||||
|
|
|
@ -1,31 +1,47 @@
|
|||
# Branch
|
||||
# Branch plugin
|
||||
|
||||
Displays the current Git or Mercurial branch fast.
|
||||
This plugin displays the current Git or Mercurial branch, fast. If in a Mercurial repository,
|
||||
also display the current bookmark, if present.
|
||||
|
||||
To use it, add `branch` to the plugins array in your zshrc file:
|
||||
|
||||
```zsh
|
||||
plugins=(... branch)
|
||||
```
|
||||
|
||||
## Speed test
|
||||
|
||||
### Mercurial
|
||||
- `hg branch`:
|
||||
|
||||
```shell
|
||||
$ time hg branch
|
||||
0.11s user 0.14s system 70% cpu 0.355 total
|
||||
```
|
||||
```console
|
||||
$ time hg branch
|
||||
0.11s user 0.14s system 70% cpu 0.355 total
|
||||
```
|
||||
|
||||
### Branch plugin
|
||||
- branch plugin:
|
||||
|
||||
```shell
|
||||
$ time zsh /tmp/branch_prompt_info_test.zsh
|
||||
0.00s user 0.01s system 78% cpu 0.014 total
|
||||
```
|
||||
```console
|
||||
$ time zsh /tmp/branch_prompt_info_test.zsh
|
||||
0.00s user 0.01s system 78% cpu 0.014 total
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
Edit your theme file (eg.: `~/.oh-my-zsh/theme/robbyrussell.zsh-theme`)
|
||||
adding `$(branch_prompt_info)` in your prompt like this:
|
||||
Copy your theme to `$ZSH_CUSTOM/themes/` and modify it to add `$(branch_prompt_info)` in your prompt.
|
||||
This example is for the `robbyrussell` theme:
|
||||
|
||||
```diff
|
||||
- PROMPT='${ret_status}%{$fg_bold[green]%}%p %{$fg[cyan]%}%c %{$fg_bold[blue]%}$(git_prompt_info)%{$fg_bold[blue]%} % %{$reset_color%}'
|
||||
+ PROMPT='${ret_status}%{$fg_bold[green]%}%p %{$fg[cyan]%}%c %{$fg_bold[blue]%}$(git_prompt_info)$(branch_prompt_info)%{$fg_bold[blue]%} % %{$reset_color%}'
|
||||
diff --git a/themes/robbyrussell.zsh-theme b/themes/robbyrussell.zsh-theme
|
||||
index 2fd5f2cd..9d89a464 100644
|
||||
--- a/themes/robbyrussell.zsh-theme
|
||||
+++ b/themes/robbyrussell.zsh-theme
|
||||
@@ -1,5 +1,5 @@
|
||||
PROMPT="%(?:%{$fg_bold[green]%}➜ :%{$fg_bold[red]%}➜ )"
|
||||
-PROMPT+=' %{$fg[cyan]%}%c%{$reset_color%} $(git_prompt_info)'
|
||||
+PROMPT+=' %{$fg[cyan]%}%c%{$reset_color%} $(branch_prompt_info)'
|
||||
|
||||
ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg_bold[blue]%}git:(%{$fg[red]%}"
|
||||
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%} "
|
||||
```
|
||||
|
||||
## Maintainer
|
||||
|
|
|
@ -3,29 +3,33 @@
|
|||
# Oct 2, 2015
|
||||
|
||||
function branch_prompt_info() {
|
||||
# Defines path as current directory
|
||||
local current_dir=$PWD
|
||||
# While current path is not root path
|
||||
while [[ $current_dir != '/' ]]
|
||||
do
|
||||
# Git repository
|
||||
if [[ -d "${current_dir}/.git" ]]
|
||||
then
|
||||
echo '±' ${"$(<"$current_dir/.git/HEAD")"##*/}
|
||||
return;
|
||||
# Start checking in current working directory
|
||||
local branch="" dir="$PWD"
|
||||
while [[ "$dir" != '/' ]]; do
|
||||
# Found .git directory
|
||||
if [[ -d "${dir}/.git" ]]; then
|
||||
branch="${"$(<"${dir}/.git/HEAD")"##*/}"
|
||||
echo '±' "${branch:gs/%/%%}"
|
||||
return
|
||||
fi
|
||||
# Mercurial repository
|
||||
if [[ -d "${current_dir}/.hg" ]]
|
||||
then
|
||||
if [[ -f "$current_dir/.hg/branch" ]]
|
||||
then
|
||||
echo '☿' $(<"$current_dir/.hg/branch")
|
||||
|
||||
# Found .hg directory
|
||||
if [[ -d "${dir}/.hg" ]]; then
|
||||
if [[ -f "${dir}/.hg/branch" ]]; then
|
||||
branch="$(<"${dir}/.hg/branch")"
|
||||
else
|
||||
echo '☿ default'
|
||||
branch="default"
|
||||
fi
|
||||
return;
|
||||
|
||||
if [[ -f "${dir}/.hg/bookmarks.current" ]]; then
|
||||
branch="${branch}/$(<"${dir}/.hg/bookmarks.current")"
|
||||
fi
|
||||
|
||||
echo '☿' "${branch:gs/%/%%}"
|
||||
return
|
||||
fi
|
||||
# Defines path as parent directory and keeps looking for :)
|
||||
current_dir="${current_dir:h}"
|
||||
|
||||
# Check parent directory
|
||||
dir="${dir:h}"
|
||||
done
|
||||
}
|
||||
|
|
|
@ -8,22 +8,33 @@ To use it, add `brew` to the plugins array of your zshrc file:
|
|||
plugins=(... brew)
|
||||
```
|
||||
|
||||
## Shellenv
|
||||
|
||||
If `brew` is not found in the PATH, this plugin will attempt to find it in common
|
||||
locations, and execute `brew shellenv` to set the environment appropriately.
|
||||
This plugin will also export `HOMEBREW_PREFIX="$(brew --prefix)"` if not previously
|
||||
defined for convenience.
|
||||
|
||||
## Aliases
|
||||
|
||||
| Alias | Command | Description |
|
||||
|----------|---------------------------------------|---------------------------------------------------------------------|
|
||||
| `brewp` | `brew pin` | Pin a specified formula so that it's not upgraded. |
|
||||
| `brews` | `brew list -1` | List installed formulae or the installed files for a given formula. |
|
||||
| `brewsp` | `brew list --pinned` | List pinned formulae, or show the version of a given formula. |
|
||||
| `bubo` | `brew update && brew outdated` | Update Homebrew data, then list outdated formulae and casks. |
|
||||
| `bubc` | `brew upgrade && brew cleanup` | Upgrade outdated formulae and casks, then run cleanup. |
|
||||
| `bubu` | `bubo && bubc` | Do the last two operations above. |
|
||||
| `buf` | `brew upgrade --formula` | Upgrade only formulas (not casks). |
|
||||
| `bcubo` | `brew update && brew outdated --cask` | Update Homebrew data, then list outdated casks. |
|
||||
| `bcubc` | `brew upgrade --cask && brew cleanup` | Update outdated casks, then run cleanup. |
|
||||
| Alias | Command | Description |
|
||||
| -------- | --------------------------------------- | ------------------------------------------------------------------- |
|
||||
| `bcubc` | `brew upgrade --cask && brew cleanup` | Update outdated casks, then run cleanup. |
|
||||
| `bcubo` | `brew update && brew outdated --cask` | Update Homebrew data, then list outdated casks. |
|
||||
| `brewp` | `brew pin` | Pin a specified formula so that it's not upgraded. |
|
||||
| `brews` | `brew list -1` | List installed formulae or the installed files for a given formula. |
|
||||
| `brewsp` | `brew list --pinned` | List pinned formulae, or show the version of a given formula. |
|
||||
| `bubc` | `brew upgrade && brew cleanup` | Upgrade outdated formulae and casks, then run cleanup. |
|
||||
| `bugbc` | `brew upgrade --greedy && brew cleanup` | Upgrade outdated formulae and casks (greedy), then run cleanup. |
|
||||
| `bubo` | `brew update && brew outdated` | Update Homebrew data, then list outdated formulae and casks. |
|
||||
| `bubu` | `bubo && bubc` | Do the last two operations above. |
|
||||
| `bfu` | `brew upgrade --formula` | Upgrade only formulas (not casks). |
|
||||
| `buz` | `brew uninstall --zap` | Remove all files associated with a cask. |
|
||||
|
||||
## Completion
|
||||
|
||||
This plugin configures paths with Homebrew's completion functions automatically, so you don't need to do it manually. See: https://docs.brew.sh/Shell-Completion#configuring-completions-in-zsh.
|
||||
|
||||
With the release of Homebrew 1.0, they decided to bundle the zsh completion as part of the
|
||||
brew installation, so we no longer ship it with the brew plugin; now it only has brew
|
||||
aliases. If you find that brew completion no longer works, make sure you have your Homebrew
|
||||
|
|
|
@ -1,9 +1,56 @@
|
|||
alias brewp='brew pin'
|
||||
alias brews='brew list -1'
|
||||
alias brewsp='brew list --pinned'
|
||||
alias bubo='brew update && brew outdated'
|
||||
alias bubc='brew upgrade && brew cleanup'
|
||||
alias bubu='bubo && bubc'
|
||||
alias buf='brew upgrade --formula'
|
||||
if (( ! $+commands[brew] )); then
|
||||
if [[ -x /opt/homebrew/bin/brew ]]; then
|
||||
BREW_LOCATION="/opt/homebrew/bin/brew"
|
||||
elif [[ -x /usr/local/bin/brew ]]; then
|
||||
BREW_LOCATION="/usr/local/bin/brew"
|
||||
elif [[ -x /home/linuxbrew/.linuxbrew/bin/brew ]]; then
|
||||
BREW_LOCATION="/home/linuxbrew/.linuxbrew/bin/brew"
|
||||
elif [[ -x "$HOME/.linuxbrew/bin/brew" ]]; then
|
||||
BREW_LOCATION="$HOME/.linuxbrew/bin/brew"
|
||||
else
|
||||
return
|
||||
fi
|
||||
|
||||
# Only add Homebrew installation to PATH, MANPATH, and INFOPATH if brew is
|
||||
# not already on the path, to prevent duplicate entries. This aligns with
|
||||
# the behavior of the brew installer.sh post-install steps.
|
||||
eval "$("$BREW_LOCATION" shellenv)"
|
||||
unset BREW_LOCATION
|
||||
fi
|
||||
|
||||
if [[ -z "$HOMEBREW_PREFIX" ]]; then
|
||||
# Maintain compatability with potential custom user profiles, where we had
|
||||
# previously relied on always sourcing shellenv. OMZ plugins should not rely
|
||||
# on this to be defined due to out of order processing.
|
||||
export HOMEBREW_PREFIX="$(brew --prefix)"
|
||||
fi
|
||||
|
||||
if [[ -d "$HOMEBREW_PREFIX/share/zsh/site-functions" ]]; then
|
||||
fpath+=("$HOMEBREW_PREFIX/share/zsh/site-functions")
|
||||
fi
|
||||
|
||||
alias bcubc='brew upgrade --cask && brew cleanup'
|
||||
alias bcubo='brew update && brew outdated --cask'
|
||||
alias bcubc='brew upgrade --cask && brew cleanup'
|
||||
alias brewp='brew pin'
|
||||
alias brewsp='brew list --pinned'
|
||||
alias bubc='brew upgrade && brew cleanup'
|
||||
alias bugbc='brew upgrade --greedy && brew cleanup'
|
||||
alias bubo='brew update && brew outdated'
|
||||
alias bubu='bubo && bubc'
|
||||
alias bubug='bubo && bugbc'
|
||||
alias bfu='brew upgrade --formula'
|
||||
alias buz='brew uninstall --zap'
|
||||
|
||||
function brews() {
|
||||
local formulae="$(brew leaves | xargs brew deps --installed --for-each)"
|
||||
local casks="$(brew list --cask 2>/dev/null)"
|
||||
|
||||
local blue="$(tput setaf 4)"
|
||||
local bold="$(tput bold)"
|
||||
local off="$(tput sgr0)"
|
||||
|
||||
echo "${blue}==>${off} ${bold}Formulae${off}"
|
||||
echo "${formulae}" | sed "s/^\(.*\):\(.*\)$/\1${blue}\2${off}/"
|
||||
echo "\n${blue}==>${off} ${bold}Casks${off}\n${casks}"
|
||||
}
|
||||
|
|
26
plugins/bridgetown/README.md
Normal file
26
plugins/bridgetown/README.md
Normal file
|
@ -0,0 +1,26 @@
|
|||
# Bridgetown plugin
|
||||
|
||||
This plugin adds some aliases and autocompletion for common [Bridgetown](https://bridgetownrb.com/) commands.
|
||||
|
||||
To use it, add `bridgetown` to the plugins array in your zshrc file:
|
||||
|
||||
```zsh
|
||||
plugins=(... bridgetown)
|
||||
```
|
||||
|
||||
## Aliases
|
||||
|
||||
| Alias | Command |
|
||||
|-------|----------------------------|
|
||||
| br | `bridgetown` |
|
||||
| bra | `bin/bridgetown apply` |
|
||||
| brb | `bin/bridgetown build` |
|
||||
| brc | `bin/bridgetown console` |
|
||||
| brclean | `bin/bridgetown clean` |
|
||||
| brd | `bin/bridgetown deploy` |
|
||||
| brdoc | `bin/bridgetown doctor` |
|
||||
| brh | `bin/bridgetown help` |
|
||||
| brn | `bridgetown new` |
|
||||
| brp | `bridgetown plugins` |
|
||||
| brpl | `bridgetown plugins list` |
|
||||
| brs | `bin/bridgetown start` |
|
12
plugins/bridgetown/bridgetown.plugin.zsh
Normal file
12
plugins/bridgetown/bridgetown.plugin.zsh
Normal file
|
@ -0,0 +1,12 @@
|
|||
alias br='bridgetown'
|
||||
alias bra='bin/bridgetown apply'
|
||||
alias brb='bin/bridgetown build'
|
||||
alias brc='bin/bridgetown console'
|
||||
alias brclean='bin/bridgetown clean'
|
||||
alias brd='bin/bridgetown deploy'
|
||||
alias brdoc='bin/bridgetown doctor'
|
||||
alias brh='bin/bridgetown help'
|
||||
alias brn='bridgetown new'
|
||||
alias brp='bridgetown plugins'
|
||||
alias brpl='bridgetown plugins list'
|
||||
alias brs='bin/bridgetown start'
|
|
@ -18,6 +18,7 @@ case $state in
|
|||
"check[Determine whether the requirements for your application are installed]" \
|
||||
"list[Show all of the gems in the current bundle]" \
|
||||
"show[Show the source location of a particular gem in the bundle]" \
|
||||
"info[Show details of a particular gem in the bundle]" \
|
||||
"outdated[Show all of the outdated gems in the current bundle]" \
|
||||
"console[Start an IRB session in the context of the current bundle]" \
|
||||
"open[Open an installed gem in the editor]" \
|
||||
|
@ -84,7 +85,7 @@ case $state in
|
|||
'(--verbose)--verbose[Enable verbose output mode]'
|
||||
ret=0
|
||||
;;
|
||||
(open|show)
|
||||
(open|show|info)
|
||||
_gems=( $(bundle show 2> /dev/null | sed -e '/^ \*/!d; s/^ \* \([^ ]*\) .*/\1/') )
|
||||
if [[ $_gems != "" ]]; then
|
||||
_values 'gems' $_gems && ret=0
|
||||
|
|
|
@ -40,7 +40,7 @@ bundle_install() {
|
|||
else
|
||||
local cores_num="$(nproc)"
|
||||
fi
|
||||
bundle install --jobs="$cores_num" "$@"
|
||||
BUNDLE_JOBS="$cores_num" bundle install "$@"
|
||||
}
|
||||
|
||||
## Gem wrapper
|
||||
|
@ -81,14 +81,12 @@ bundled_commands=(
|
|||
)
|
||||
|
||||
# Remove $UNBUNDLED_COMMANDS from the bundled_commands list
|
||||
for cmd in $UNBUNDLED_COMMANDS; do
|
||||
bundled_commands=(${bundled_commands#$cmd});
|
||||
done
|
||||
bundled_commands=(${bundled_commands:|UNBUNDLED_COMMANDS})
|
||||
unset UNBUNDLED_COMMANDS
|
||||
|
||||
# Add $BUNDLED_COMMANDS to the bundled_commands list
|
||||
for cmd in $BUNDLED_COMMANDS; do
|
||||
bundled_commands+=($cmd);
|
||||
done
|
||||
bundled_commands+=($BUNDLED_COMMANDS)
|
||||
unset BUNDLED_COMMANDS
|
||||
|
||||
# Check if in the root or a subdirectory of a bundled project
|
||||
_within-bundled-project() {
|
||||
|
@ -126,5 +124,4 @@ for cmd in $bundled_commands; do
|
|||
compdef "_$cmd" "bundled_$cmd"="$cmd"
|
||||
fi
|
||||
done
|
||||
|
||||
unset cmd bundled_commands
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
# CakePHP 3 basic command completion
|
||||
_cakephp3_get_command_list () {
|
||||
bin/cake Completion commands
|
||||
bin/cake completion commands
|
||||
}
|
||||
|
||||
_cakephp3_get_sub_command_list () {
|
||||
bin/cake Completion subcommands ${words[2]}
|
||||
bin/cake completion subcommands ${words[2]}
|
||||
}
|
||||
|
||||
_cakephp3_get_3rd_argument () {
|
||||
|
@ -34,5 +34,5 @@ compdef _cakephp3 cake
|
|||
|
||||
#Alias
|
||||
alias c3='bin/cake'
|
||||
alias c3cache='bin/cake orm_cache clear'
|
||||
alias c3cache='bin/cake schema_cache clear'
|
||||
alias c3migrate='bin/cake migrations migrate'
|
||||
|
|
|
@ -1,11 +0,0 @@
|
|||
# cargo
|
||||
|
||||
This plugin adds completion for the Rust build tool [`Cargo`](https://github.com/rust-lang/cargo).
|
||||
|
||||
To use it, add `cargo` to the plugins array in your zshrc file:
|
||||
|
||||
```zsh
|
||||
plugins=(... cargo)
|
||||
```
|
||||
|
||||
Updated on March 3rd, 2019, from [Cargo 0.34.0](https://github.com/rust-lang/cargo/releases/tag/0.34.0).
|
|
@ -1,407 +0,0 @@
|
|||
#compdef cargo
|
||||
|
||||
autoload -U regexp-replace
|
||||
|
||||
_cargo() {
|
||||
local curcontext="$curcontext" ret=1
|
||||
local -a command_scope_spec common parallel features msgfmt triple target registry
|
||||
local -a state line state_descr # These are set by _arguments
|
||||
typeset -A opt_args
|
||||
|
||||
common=(
|
||||
'(-q --quiet)*'{-v,--verbose}'[use verbose output]'
|
||||
'(-q --quiet -v --verbose)'{-q,--quiet}'[no output printed to stdout]'
|
||||
'-Z+[pass unstable (nightly-only) flags to cargo]: :_cargo_unstable_flags'
|
||||
'--frozen[require that Cargo.lock and cache are up to date]'
|
||||
'--locked[require that Cargo.lock is up to date]'
|
||||
'--color=[specify colorization option]:coloring:(auto always never)'
|
||||
'(- 1 *)'{-h,--help}'[show help message]'
|
||||
)
|
||||
|
||||
# leading items in parentheses are an exclusion list for the arguments following that arg
|
||||
# See: http://zsh.sourceforge.net/Doc/Release/Completion-System.html#Completion-Functions
|
||||
# - => exclude all other options
|
||||
# 1 => exclude positional arg 1
|
||||
# * => exclude all other args
|
||||
# +blah => exclude +blah
|
||||
_arguments -s -S -C $common \
|
||||
'(- 1 *)--list[list installed commands]' \
|
||||
'(- 1 *)--explain=[provide a detailed explanation of an error message]:error code' \
|
||||
'(- 1 *)'{-V,--version}'[show version information]' \
|
||||
'(+beta +nightly)+stable[use the stable toolchain]' \
|
||||
'(+stable +nightly)+beta[use the beta toolchain]' \
|
||||
'(+stable +beta)+nightly[use the nightly toolchain]' \
|
||||
'1: :_cargo_cmds' \
|
||||
'*:: :->args'
|
||||
|
||||
# These flags are mutually exclusive specifiers for the scope of a command; as
|
||||
# they are used in multiple places without change, they are expanded into the
|
||||
# appropriate command's `_arguments` where appropriate.
|
||||
command_scope_spec=(
|
||||
'(--bin --example --test --lib)--bench=[specify benchmark name]: :_cargo_benchmark_names'
|
||||
'(--bench --bin --test --lib)--example=[specify example name]:example name'
|
||||
'(--bench --example --test --lib)--bin=[specify binary name]:binary name'
|
||||
'(--bench --bin --example --test)--lib=[specify library name]:library name'
|
||||
'(--bench --bin --example --lib)--test=[specify test name]:test name'
|
||||
)
|
||||
|
||||
parallel=(
|
||||
'(-j --jobs)'{-j+,--jobs=}'[specify number of parallel jobs]:jobs [# of CPUs]'
|
||||
)
|
||||
|
||||
features=(
|
||||
'(--all-features)--features=[specify features to activate]:feature'
|
||||
'(--features)--all-features[activate all available features]'
|
||||
"--no-default-features[don't build the default features]"
|
||||
)
|
||||
|
||||
msgfmt='--message-format=[specify error format]:error format [human]:(human json short)'
|
||||
triple='--target=[specify target triple]:target triple'
|
||||
target='--target-dir=[specify directory for all generated artifacts]:directory:_directories'
|
||||
manifest='--manifest-path=[specify path to manifest]:path:_directories'
|
||||
registry='--registry=[specify registry to use]:registry'
|
||||
|
||||
case $state in
|
||||
args)
|
||||
curcontext="${curcontext%:*}-${words[1]}:"
|
||||
case ${words[1]} in
|
||||
bench)
|
||||
_arguments -s -A "^--" $common $parallel $features $msgfmt $triple $target $manifest \
|
||||
"${command_scope_spec[@]}" \
|
||||
'--all-targets[benchmark all targets]' \
|
||||
"--no-run[compile but don't run]" \
|
||||
'(-p --package)'{-p+,--package=}'[specify package to run benchmarks for]:package:_cargo_package_names' \
|
||||
'--exclude=[exclude packages from the benchmark]:spec' \
|
||||
'--no-fail-fast[run all benchmarks regardless of failure]' \
|
||||
'1: :_guard "^-*" "bench name"' \
|
||||
'*:args:_default'
|
||||
;;
|
||||
|
||||
build|b)
|
||||
_arguments -s -S $common $parallel $features $msgfmt $triple $target $manifest \
|
||||
'--all-targets[equivalent to specifying --lib --bins --tests --benches --examples]' \
|
||||
"${command_scope_spec[@]}" \
|
||||
'(-p --package)'{-p+,--package=}'[specify package to build]:package:_cargo_package_names' \
|
||||
'--release[build in release mode]' \
|
||||
'--build-plan[output the build plan in JSON]' \
|
||||
;;
|
||||
|
||||
check|c)
|
||||
_arguments -s -S $common $parallel $features $msgfmt $triple $target $manifest \
|
||||
'--all-targets[equivalent to specifying --lib --bins --tests --benches --examples]' \
|
||||
"${command_scope_spec[@]}" \
|
||||
'(-p --package)'{-p+,--package=}'[specify package to check]:package:_cargo_package_names' \
|
||||
'--release[check in release mode]' \
|
||||
;;
|
||||
|
||||
clean)
|
||||
_arguments -s -S $common $triple $target $manifest \
|
||||
'(-p --package)'{-p+,--package=}'[specify package to clean]:package:_cargo_package_names' \
|
||||
'--release[clean release artifacts]' \
|
||||
'--doc[clean just the documentation directory]'
|
||||
;;
|
||||
|
||||
doc)
|
||||
_arguments -s -S $common $parallel $features $msgfmt $triple $target $manifest \
|
||||
'--no-deps[do not build docs for dependencies]' \
|
||||
'--document-private-items[include non-public items in the documentation]' \
|
||||
'--open[open docs in browser after the build]' \
|
||||
'(-p --package)'{-p+,--package=}'[specify package to document]:package:_cargo_package_names' \
|
||||
'--release[build artifacts in release mode, with optimizations]' \
|
||||
;;
|
||||
|
||||
fetch)
|
||||
_arguments -s -S $common $triple $manifest
|
||||
;;
|
||||
|
||||
fix)
|
||||
_arguments -s -S $common $parallel $features $msgfmt $triple $target $manifest \
|
||||
"${command_scope_spec[@]}" \
|
||||
'--broken-code[fix code even if it already has compiler errors]' \
|
||||
'--edition[fix in preparation for the next edition]' \
|
||||
'--edition-idioms[fix warnings to migrate to the idioms of an edition]' \
|
||||
'--allow-no-vcs[fix code even if a VCS was not detected]' \
|
||||
'--allow-dirty[fix code even if the working directory is dirty]' \
|
||||
'--allow-staged[fix code even if the working directory has staged changes]'
|
||||
;;
|
||||
|
||||
generate-lockfile)
|
||||
_arguments -s -S $common $manifest
|
||||
;;
|
||||
|
||||
git-checkout)
|
||||
_arguments -s -S $common \
|
||||
'--reference=:reference' \
|
||||
'--url=:url:_urls'
|
||||
;;
|
||||
|
||||
help)
|
||||
_cargo_cmds
|
||||
;;
|
||||
|
||||
init)
|
||||
_arguments -s -S $common $registry \
|
||||
'--lib[use library template]' \
|
||||
'--edition=[specify edition to set for the crate generated]:edition:(2015 2018)' \
|
||||
'--vcs=[initialize a new repo with a given VCS]:vcs:(git hg pijul fossil none)' \
|
||||
'--name=[set the resulting package name]:name' \
|
||||
'1:path:_directories'
|
||||
;;
|
||||
|
||||
install)
|
||||
_arguments -s -S $common $parallel $features $triple $registry \
|
||||
'(-f --force)'{-f,--force}'[force overwriting of existing crates or binaries]' \
|
||||
'--bin=[only install the specified binary]:binary' \
|
||||
'--branch=[branch to use when installing from git]:branch' \
|
||||
'--debug[build in debug mode instead of release mode]' \
|
||||
'--example=[install the specified example instead of binaries]:example' \
|
||||
'--git=[specify URL from which to install the crate]:url:_urls' \
|
||||
'--path=[local filesystem path to crate to install]: :_directories' \
|
||||
'--rev=[specific commit to use when installing from git]:commit' \
|
||||
'--root=[directory to install packages into]: :_directories' \
|
||||
'--tag=[tag to use when installing from git]:tag' \
|
||||
'--vers=[version to install from crates.io]:version' \
|
||||
'--list[list all installed packages and their versions]' \
|
||||
'*: :_guard "^-*" "crate"'
|
||||
;;
|
||||
|
||||
locate-project)
|
||||
_arguments -s -S $common $manifest
|
||||
;;
|
||||
|
||||
login)
|
||||
_arguments -s -S $common $registry \
|
||||
'*: :_guard "^-*" "token"'
|
||||
;;
|
||||
|
||||
metadata)
|
||||
_arguments -s -S $common $features $manifest \
|
||||
"--no-deps[output information only about the root package and don't fetch dependencies]" \
|
||||
'--format-version=[specify format version]:version [1]:(1)'
|
||||
;;
|
||||
|
||||
new)
|
||||
_arguments -s -S $common $registry \
|
||||
'--lib[use library template]' \
|
||||
'--vcs:initialize a new repo with a given VCS:(git hg none)' \
|
||||
'--name=[set the resulting package name]'
|
||||
;;
|
||||
|
||||
owner)
|
||||
_arguments -s -S $common $registry \
|
||||
'(-a --add)'{-a,--add}'[specify name of a user or team to invite as an owner]:name' \
|
||||
'--index=[specify registry index]:index' \
|
||||
'(-l --list)'{-l,--list}'[list owners of a crate]' \
|
||||
'(-r --remove)'{-r,--remove}'[specify name of a user or team to remove as an owner]:name' \
|
||||
'--token=[specify API token to use when authenticating]:token' \
|
||||
'*: :_guard "^-*" "crate"'
|
||||
;;
|
||||
|
||||
package)
|
||||
_arguments -s -S $common $parallel $features $triple $target $manifest \
|
||||
'(-l --list)'{-l,--list}'[print files included in a package without making one]' \
|
||||
'--no-metadata[ignore warnings about a lack of human-usable metadata]' \
|
||||
'--allow-dirty[allow dirty working directories to be packaged]' \
|
||||
"--no-verify[don't build to verify contents]"
|
||||
;;
|
||||
|
||||
pkgid)
|
||||
_arguments -s -S $common $manifest \
|
||||
'(-p --package)'{-p+,--package=}'[specify package to get ID specifier for]:package:_cargo_package_names' \
|
||||
'*: :_guard "^-*" "spec"'
|
||||
;;
|
||||
|
||||
publish)
|
||||
_arguments -s -S $common $parallel $features $triple $target $manifest $registry \
|
||||
'--index=[specify registry index]:index' \
|
||||
'--allow-dirty[allow dirty working directories to be packaged]' \
|
||||
"--no-verify[don't verify the contents by building them]" \
|
||||
'--token=[specify token to use when uploading]:token' \
|
||||
'--dry-run[perform all checks without uploading]'
|
||||
;;
|
||||
|
||||
read-manifest)
|
||||
_arguments -s -S $common $manifest
|
||||
;;
|
||||
|
||||
run|r)
|
||||
_arguments -s -S $common $parallel $features $msgfmt $triple $target $manifest \
|
||||
'--example=[name of the bin target]:name' \
|
||||
'--bin=[name of the bin target]:name' \
|
||||
'(-p --package)'{-p+,--package=}'[specify package with the target to run]:package:_cargo_package_names' \
|
||||
'--release[build in release mode]' \
|
||||
'*: :_default'
|
||||
;;
|
||||
|
||||
rustc)
|
||||
_arguments -s -S $common $parallel $features $msgfmt $triple $target $manifest \
|
||||
'(-p --package)'{-p+,--package=}'[specify package to build]:package:_cargo_package_names' \
|
||||
'--profile=[specify profile to build the selected target for]:profile' \
|
||||
'--release[build artifacts in release mode, with optimizations]' \
|
||||
"${command_scope_spec[@]}" \
|
||||
'*: : _dispatch rustc rustc -default-'
|
||||
;;
|
||||
|
||||
rustdoc)
|
||||
_arguments -s -S $common $parallel $features $msgfmt $triple $target $manifest \
|
||||
'--document-private-items[include non-public items in the documentation]' \
|
||||
'--open[open the docs in a browser after the operation]' \
|
||||
'(-p --package)'{-p+,--package=}'[specify package to document]:package:_cargo_package_names' \
|
||||
'--release[build artifacts in release mode, with optimizations]' \
|
||||
"${command_scope_spec[@]}" \
|
||||
'*: : _dispatch rustdoc rustdoc -default-'
|
||||
;;
|
||||
|
||||
search)
|
||||
_arguments -s -S $common $registry \
|
||||
'--index=[specify registry index]:index' \
|
||||
'--limit=[limit the number of results]:results [10]' \
|
||||
'*: :_guard "^-*" "query"'
|
||||
;;
|
||||
|
||||
test|t)
|
||||
_arguments -s -S $common $parallel $features $msgfmt $triple $target $manifest \
|
||||
'--test=[test name]: :_cargo_test_names' \
|
||||
'--no-fail-fast[run all tests regardless of failure]' \
|
||||
'--no-run[compile but do not run]' \
|
||||
'(-p --package)'{-p+,--package=}'[package to run tests for]:package:_cargo_package_names' \
|
||||
'--all[test all packages in the workspace]' \
|
||||
'--release[build artifacts in release mode, with optimizations]' \
|
||||
'1: :_cargo_test_names' \
|
||||
'(--doc --bin --example --test --bench)--lib[only test library]' \
|
||||
'(--lib --bin --example --test --bench)--doc[only test documentation]' \
|
||||
'(--lib --doc --example --test --bench)--bin=[binary name]' \
|
||||
'(--lib --doc --bin --test --bench)--example=[example name]' \
|
||||
'(--lib --doc --bin --example --bench)--test=[test name]' \
|
||||
'(--lib --doc --bin --example --test)--bench=[benchmark name]' \
|
||||
'*: :_default'
|
||||
;;
|
||||
|
||||
uninstall)
|
||||
_arguments -s -S $common \
|
||||
'(-p --package)'{-p+,--package=}'[specify package to uninstall]:package:_cargo_package_names' \
|
||||
'--bin=[only uninstall the specified binary]:name' \
|
||||
'--root=[directory to uninstall packages from]: :_files -/' \
|
||||
'*:crate:_cargo_installed_crates -F line'
|
||||
;;
|
||||
|
||||
update)
|
||||
_arguments -s -S $common $manifest \
|
||||
'--aggressive=[force dependency update]' \
|
||||
"--dry-run[don't actually write the lockfile]" \
|
||||
'(-p --package)'{-p+,--package=}'[specify package to update]:package:_cargo_package_names' \
|
||||
'--precise=[update single dependency to precise release]:release'
|
||||
;;
|
||||
|
||||
verify-project)
|
||||
_arguments -s -S $common $manifest
|
||||
;;
|
||||
|
||||
version)
|
||||
_arguments -s -S $common
|
||||
;;
|
||||
|
||||
yank)
|
||||
_arguments -s -S $common $registry \
|
||||
'--vers=[specify yank version]:version' \
|
||||
'--undo[undo a yank, putting a version back into the index]' \
|
||||
'--index=[specify registry index to yank from]:registry index' \
|
||||
'--token=[specify API token to use when authenticating]:token' \
|
||||
'*: :_guard "^-*" "crate"'
|
||||
;;
|
||||
*)
|
||||
# allow plugins to define their own functions
|
||||
if ! _call_function ret _cargo-${words[1]}; then
|
||||
# fallback on default completion for unknown commands
|
||||
_default && ret=0
|
||||
fi
|
||||
(( ! ret ))
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
_cargo_unstable_flags() {
|
||||
local flags
|
||||
flags=( help ${${${(M)${(f)"$(_call_program flags cargo -Z help)"}:#*--*}/ #-- #/:}##*-Z } )
|
||||
_describe -t flags 'unstable flag' flags
|
||||
}
|
||||
|
||||
_cargo_installed_crates() {
|
||||
local expl
|
||||
_description crates expl 'crate'
|
||||
compadd "$@" "$expl[@]" - ${${${(f)"$(cargo install --list)"}:# *}%% *}
|
||||
}
|
||||
|
||||
_cargo_cmds() {
|
||||
local -a commands
|
||||
# This uses Parameter Expansion Flags, which are a built-in Zsh feature.
|
||||
# See more: http://zsh.sourceforge.net/Doc/Release/Expansion.html#Parameter-Expansion-Flags
|
||||
# and http://zsh.sourceforge.net/Doc/Release/Expansion.html#Parameter-Expansion
|
||||
#
|
||||
# # How this work?
|
||||
#
|
||||
# First it splits the result of `cargo --list` at newline, then it removes the first line.
|
||||
# Then it removes indentation (4 whitespaces) before each items. (Note the x## pattern [1]).
|
||||
# Then it replaces those spaces between item and description with a `:`
|
||||
#
|
||||
# [1]: https://github.com/zsh-users/zsh-completions/blob/master/zsh-completions-howto.org#patterns
|
||||
commands=( ${${${(M)"${(f)$(_call_program commands cargo --list)}":# *}/ ##/}/ ##/:} )
|
||||
_describe -t commands 'command' commands
|
||||
}
|
||||
|
||||
|
||||
#FIXME: Disabled until fixed
|
||||
#gets package names from the manifest file
|
||||
_cargo_package_names() {
|
||||
_message -e packages package
|
||||
}
|
||||
|
||||
# Extracts the values of "name" from the array given in $1 and shows them as
|
||||
# command line options for completion
|
||||
_cargo_names_from_array() {
|
||||
# strip json from the path
|
||||
local manifest=${${${"$(cargo locate-project)"}%\"\}}##*\"}
|
||||
if [[ -z $manifest ]]; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
local last_line
|
||||
local -a names;
|
||||
local in_block=false
|
||||
local block_name=$1
|
||||
names=()
|
||||
while read -r line; do
|
||||
if [[ $last_line == "[[$block_name]]" ]]; then
|
||||
in_block=true
|
||||
else
|
||||
if [[ $last_line =~ '\s*\[\[.*' ]]; then
|
||||
in_block=false
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ $in_block == true ]]; then
|
||||
if [[ $line =~ '\s*name\s*=' ]]; then
|
||||
regexp-replace line '^\s*name\s*=\s*|"' ''
|
||||
names+=( "$line" )
|
||||
fi
|
||||
fi
|
||||
|
||||
last_line=$line
|
||||
done < "$manifest"
|
||||
_describe "$block_name" names
|
||||
|
||||
}
|
||||
|
||||
#Gets the test names from the manifest file
|
||||
_cargo_test_names() {
|
||||
_cargo_names_from_array "test"
|
||||
}
|
||||
|
||||
#Gets the bench names from the manifest file
|
||||
_cargo_benchmark_names() {
|
||||
_cargo_names_from_array "bench"
|
||||
}
|
||||
|
||||
_cargo
|
|
@ -2,7 +2,7 @@
|
|||
# catimg script by Eduardo San Martin Morote aka Posva #
|
||||
# https://posva.net #
|
||||
# #
|
||||
# Ouput the content of an image to the stdout using the 256 colors of the #
|
||||
# Output the content of an image to the stdout using the 256 colors of the #
|
||||
# terminal. #
|
||||
# GitHub: https://github.com/posva/catimg #
|
||||
################################################################################
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
# catimg script by Eduardo San Martin Morote aka Posva #
|
||||
# https://posva.net #
|
||||
# #
|
||||
# Ouput the content of an image to the stdout using the 256 colors of the #
|
||||
# Output the content of an image to the stdout using the 256 colors of the #
|
||||
# terminal. #
|
||||
# GitHub: https://github.com/posva/catimg #
|
||||
################################################################################
|
||||
|
|
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" &|
|
|
@ -5,6 +5,7 @@ current Ruby version, and completion and a prompt function to display the Ruby v
|
|||
Supports brew and manual installation of chruby.
|
||||
|
||||
To use it, add `chruby` to the plugins array in your zshrc file:
|
||||
|
||||
```zsh
|
||||
plugins=(... chruby)
|
||||
```
|
||||
|
@ -14,7 +15,7 @@ plugins=(... chruby)
|
|||
If you'd prefer to specify an explicit path to load chruby from
|
||||
you can set variables like so:
|
||||
|
||||
```
|
||||
```zsh
|
||||
zstyle :omz:plugins:chruby path /local/path/to/chruby.sh
|
||||
zstyle :omz:plugins:chruby auto /local/path/to/auto.sh
|
||||
```
|
||||
|
|
|
@ -1,121 +1,94 @@
|
|||
#
|
||||
# INSTRUCTIONS
|
||||
#
|
||||
# With either a manual or brew installed chruby things should just work.
|
||||
#
|
||||
# If you'd prefer to specify an explicit path to load chruby from
|
||||
# you can set variables like so:
|
||||
#
|
||||
# zstyle :omz:plugins:chruby path /local/path/to/chruby.sh
|
||||
# zstyle :omz:plugins:chruby auto /local/path/to/auto.sh
|
||||
#
|
||||
# TODO
|
||||
# - autodetermine correct source path on non OS X systems
|
||||
# - completion if ruby-install exists
|
||||
## load chruby from different locations
|
||||
|
||||
_source-from-omz-settings() {
|
||||
local _chruby_path _chruby_auto
|
||||
|
||||
zstyle -s :omz:plugins:chruby path _chruby_path || return 1
|
||||
zstyle -s :omz:plugins:chruby auto _chruby_auto || return 1
|
||||
|
||||
if [[ -r ${_chruby_path} ]]; then
|
||||
source ${_chruby_path}
|
||||
fi
|
||||
|
||||
if [[ -r ${_chruby_auto} ]]; then
|
||||
source ${_chruby_auto}
|
||||
fi
|
||||
}
|
||||
|
||||
_source-from-homebrew() {
|
||||
(( $+commands[brew] )) || return 1
|
||||
|
||||
local _brew_prefix
|
||||
# check default brew prefix
|
||||
if [[ -h /usr/local/opt/chruby ]];then
|
||||
_brew_prefix="/usr/local/opt/chruby"
|
||||
else
|
||||
# ok , it is not default prefix
|
||||
# this call to brew is expensive ( about 400 ms ), so at least let's make it only once
|
||||
_brew_prefix=$(brew --prefix chruby)
|
||||
fi
|
||||
|
||||
[[ -r "$_brew_prefix" ]] || return 1
|
||||
|
||||
source $_brew_prefix/share/chruby/chruby.sh
|
||||
source $_brew_prefix/share/chruby/auto.sh
|
||||
}
|
||||
|
||||
_load-chruby-dirs() {
|
||||
local dir
|
||||
for dir in "$HOME/.rubies" "$PREFIX/opt/rubies"; do
|
||||
if [[ -d "$dir" ]]; then
|
||||
RUBIES+=("$dir")
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
# Load chruby
|
||||
if _source-from-omz-settings; then
|
||||
_load-chruby-dirs
|
||||
elif [[ -r "/usr/local/share/chruby/chruby.sh" ]] ; then
|
||||
source /usr/local/share/chruby/chruby.sh
|
||||
source /usr/local/share/chruby/auto.sh
|
||||
_load-chruby-dirs
|
||||
elif _source-from-homebrew; then
|
||||
_load-chruby-dirs
|
||||
fi
|
||||
|
||||
unfunction _source-from-homebrew _source-from-omz-settings _load-chruby-dirs
|
||||
|
||||
|
||||
## chruby utility functions and aliases
|
||||
|
||||
# rvm and rbenv plugins also provide this alias
|
||||
alias rubies='chruby'
|
||||
|
||||
|
||||
_homebrew-installed() {
|
||||
whence brew &> /dev/null
|
||||
_xit=$?
|
||||
if [ $_xit -eq 0 ];then
|
||||
# ok , we have brew installed
|
||||
# speculatively we check default brew prefix
|
||||
if [ -h /usr/local/opt/chruby ];then
|
||||
_brew_prefix="/usr/local/opt/chruby"
|
||||
else
|
||||
# ok , it is not default prefix
|
||||
# this call to brew is expensive ( about 400 ms ), so at least let's make it only once
|
||||
_brew_prefix=$(brew --prefix chruby)
|
||||
fi
|
||||
return 0
|
||||
else
|
||||
return $_xit
|
||||
fi
|
||||
}
|
||||
|
||||
_chruby-from-homebrew-installed() {
|
||||
[ -r _brew_prefix ] &> /dev/null
|
||||
}
|
||||
|
||||
_ruby-build_installed() {
|
||||
whence ruby-build &> /dev/null
|
||||
}
|
||||
|
||||
_ruby-install-installed() {
|
||||
whence ruby-install &> /dev/null
|
||||
}
|
||||
|
||||
# Simple definition completer for ruby-build
|
||||
if _ruby-build_installed; then
|
||||
_ruby-build() { compadd $(ruby-build --definitions) }
|
||||
compdef _ruby-build ruby-build
|
||||
fi
|
||||
|
||||
_source_from_omz_settings() {
|
||||
local _chruby_path
|
||||
local _chruby_auto
|
||||
|
||||
zstyle -s :omz:plugins:chruby path _chruby_path
|
||||
zstyle -s :omz:plugins:chruby auto _chruby_auto
|
||||
|
||||
if [[ -r ${_chruby_path} ]]; then
|
||||
source ${_chruby_path}
|
||||
fi
|
||||
|
||||
if [[ -r ${_chruby_auto} ]]; then
|
||||
source ${_chruby_auto}
|
||||
fi
|
||||
}
|
||||
|
||||
_chruby_dirs() {
|
||||
chrubydirs=($HOME/.rubies/ $PREFIX/opt/rubies)
|
||||
for dir in chrubydirs; do
|
||||
if [[ -d $dir ]]; then
|
||||
RUBIES+=$dir
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
if _homebrew-installed && _chruby-from-homebrew-installed ; then
|
||||
source $_brew_prefix/share/chruby/chruby.sh
|
||||
source $_brew_prefix/share/chruby/auto.sh
|
||||
_chruby_dirs
|
||||
elif [[ -r "/usr/local/share/chruby/chruby.sh" ]] ; then
|
||||
source /usr/local/share/chruby/chruby.sh
|
||||
source /usr/local/share/chruby/auto.sh
|
||||
_chruby_dirs
|
||||
else
|
||||
_source_from_omz_settings
|
||||
_chruby_dirs
|
||||
fi
|
||||
|
||||
function ensure_chruby() {
|
||||
$(whence chruby)
|
||||
}
|
||||
|
||||
function current_ruby() {
|
||||
local _ruby
|
||||
_ruby="$(chruby |grep \* |tr -d '* ')"
|
||||
if [[ $(chruby |grep -c \*) -eq 1 ]]; then
|
||||
echo ${_ruby}
|
||||
else
|
||||
echo "system"
|
||||
fi
|
||||
local ruby
|
||||
ruby="$(chruby | grep \* | tr -d '* ')"
|
||||
if [[ $(chruby | grep -c \*) -eq 1 ]]; then
|
||||
echo ${ruby}
|
||||
else
|
||||
echo "system"
|
||||
fi
|
||||
}
|
||||
|
||||
function chruby_prompt_info() {
|
||||
echo "$(current_ruby)"
|
||||
echo "${$(current_ruby):gs/%/%%}"
|
||||
}
|
||||
|
||||
# complete on installed rubies
|
||||
# Complete chruby command with installed rubies
|
||||
_chruby() {
|
||||
compadd $(chruby | tr -d '* ')
|
||||
local default_path='/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin'
|
||||
if PATH=${default_path} type ruby &> /dev/null; then
|
||||
compadd system
|
||||
fi
|
||||
compadd $(chruby | tr -d '* ')
|
||||
if PATH="/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin" command ruby &>/dev/null; then
|
||||
compadd system
|
||||
fi
|
||||
}
|
||||
|
||||
compdef _chruby chruby
|
||||
|
||||
|
||||
# Simple definition completer for ruby-build
|
||||
if command ruby-build &> /dev/null; then
|
||||
_ruby-build() { compadd $(ruby-build --definitions) }
|
||||
compdef _ruby-build ruby-build
|
||||
fi
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
# chucknorris
|
||||
|
||||
Chuck Norris fortunes plugin for oh-my-zsh. Perfectly suitable as MOTD.
|
||||
|
||||
**Maintainers**: [apjanke](https://github.com/apjanke) [maff](https://github.com/maff)
|
||||
Chuck Norris fortunes plugin for Oh My Zsh. Perfectly suitable as MOTD.
|
||||
|
||||
To use it add `chucknorris` to the plugins array in you zshrc file.
|
||||
|
||||
|
|
|
@ -1,28 +1,24 @@
|
|||
# chucknorris: Chuck Norris fortunes
|
||||
|
||||
# Automatically generate or update Chuck's compiled fortune data file
|
||||
# $0 must be used outside a local function. This variable name is unlikly to collide.
|
||||
CHUCKNORRIS_PLUGIN_DIR=${0:h}
|
||||
|
||||
() {
|
||||
local DIR=$CHUCKNORRIS_PLUGIN_DIR/fortunes
|
||||
if [[ ! -f $DIR/chucknorris.dat ]] || [[ $DIR/chucknorris.dat -ot $DIR/chucknorris ]]; then
|
||||
# For some reason, Cygwin puts strfile in /usr/sbin, which is not on the path by default
|
||||
local strfile=strfile
|
||||
if ! which strfile &>/dev/null && [[ -f /usr/sbin/strfile ]]; then
|
||||
strfile=/usr/sbin/strfile
|
||||
# %x: name of file containing code being executed
|
||||
local fortunes_dir="${${(%):-%x}:h}/fortunes"
|
||||
|
||||
# Aliases
|
||||
alias chuck="fortune -a $fortunes_dir"
|
||||
alias chuck_cow="chuck | cowthink"
|
||||
|
||||
# Automatically generate or update Chuck's compiled fortune data file
|
||||
if [[ "$fortunes_dir/chucknorris" -ot "$fortunes_dir/chucknorris.dat" ]]; then
|
||||
return
|
||||
fi
|
||||
if which $strfile &> /dev/null; then
|
||||
$strfile $DIR/chucknorris $DIR/chucknorris.dat >/dev/null
|
||||
else
|
||||
|
||||
# For some reason, Cygwin puts strfile in /usr/sbin, which is not on the path by default
|
||||
local strfile="${commands[strfile]:-/usr/sbin/strfile}"
|
||||
if [[ ! -x "$strfile" ]]; then
|
||||
echo "[oh-my-zsh] chucknorris depends on strfile, which is not installed" >&2
|
||||
echo "[oh-my-zsh] strfile is often provided as part of the 'fortune' package" >&2
|
||||
return
|
||||
fi
|
||||
fi
|
||||
|
||||
# Aliases
|
||||
alias chuck="fortune -a $DIR"
|
||||
alias chuck_cow="chuck | cowthink"
|
||||
# Generate the compiled fortune data file
|
||||
$strfile "$fortunes_dir/chucknorris" "$fortunes_dir/chucknorris.dat" >/dev/null
|
||||
}
|
||||
|
||||
unset CHUCKNORRIS_PLUGIN_DIR
|
||||
|
|
|
@ -228,7 +228,7 @@ Chuck Norris once punched the ground to stop an earthquake. The resulting afters
|
|||
%
|
||||
Chuck Norris once round-house kicked a salesman. Over the phone.
|
||||
%
|
||||
Chuck Norris once rounhouse kicked a football. The astronomical society now considers it a planet.
|
||||
Chuck Norris once roundhouse kicked a football. The astronomical society now considers it a planet.
|
||||
%
|
||||
Chuck Norris once thought he was wrong. He was, however, mistaken.
|
||||
%
|
||||
|
@ -342,7 +342,7 @@ Every time there's an earthquake, you know Chuck Norris is hungry. The earthquak
|
|||
%
|
||||
Evolution's driving mechanism is nature's desperate attempt to escape Chuck Norris.
|
||||
%
|
||||
Fear of spiders is arachnaphobia. Fear of tight spaces is claustrophobia. Fear of Chuck Norris is called Logic.
|
||||
Fear of spiders is arachnophobia. Fear of tight spaces is claustrophobia. Fear of Chuck Norris is called Logic.
|
||||
%
|
||||
Fool me once, shame on you. Fool Chuck Norris once and he will roundhouse you in the face.
|
||||
%
|
||||
|
@ -426,7 +426,7 @@ Some people ask for a Kleenex when they sneeze, Chuck Norris asks for a body bag
|
|||
%
|
||||
Someone once videotaped Chuck Norris getting pissed off. It was called Walker: Texas Chain Saw Massacre.
|
||||
%
|
||||
Staring at Chuck Norris for extended periods of time without proper eye protection will cause blindess, and possibly foot sized brusies on the face.
|
||||
Staring at Chuck Norris for extended periods of time without proper eye protection will cause blindness, and possibly foot sized bruises on the face.
|
||||
%
|
||||
Taking Karate Lessons = $100, Buying MMA DVD's = $150, Subscribing to a UFC event = $50, Getting a Roundhouse Kick from Chuck Norris = PRICELESS.
|
||||
%
|
||||
|
@ -452,7 +452,7 @@ The best part of waking up is not Folgers in your cup. it's knowing that Chuck N
|
|||
%
|
||||
The chief export of Chuck Norris is pain.
|
||||
%
|
||||
The dictionary references Chuck Norris several times, he is metioned under Fear, Law, Order and Chucktatorship.
|
||||
The dictionary references Chuck Norris several times, he is mentioned under Fear, Law, Order and Chucktatorship.
|
||||
%
|
||||
The leading causes of death in the United States are: 1. Heart Disease 2. Chuck Norris 3. Cancer.
|
||||
%
|
||||
|
@ -468,7 +468,7 @@ The only way sharks will come near CN underwater is when CN is inside of a cage.
|
|||
%
|
||||
The only word that rhymes with orange is Chuck Norris.
|
||||
%
|
||||
The producers of the movie "The Last Airbender" are now in talks with Chuck Norris in Order to star him in their next sequal "The Last Skull Bender".
|
||||
The producers of the movie "The Last Airbender" are now in talks with Chuck Norris in Order to star him in their next sequel "The Last Skull Bender".
|
||||
%
|
||||
The quickest way to a man's heart is with Chuck Norris' fist.
|
||||
%
|
||||
|
@ -558,3 +558,11 @@ You know Chuck Norris' pet lizard, right? Last I heard, he was in the movie "God
|
|||
%
|
||||
http://chucknorrisfacts.com/ is built in Drupal because Chuck Norris knows a good CMS when he sees one.
|
||||
%
|
||||
Chuck Norris made the first Giraffe by uppercutting a horse.
|
||||
%
|
||||
Chuck Norris can hear sign language.
|
||||
%
|
||||
Chuck Norris make onions cry.
|
||||
%
|
||||
Chuck Norris doesn't shake hands, he makes them tremble.
|
||||
%
|
||||
|
|
|
@ -1,26 +0,0 @@
|
|||
# CloudApp plugin
|
||||
|
||||
## The CloudApp API is deprecated, so the plugin will be removed shortly
|
||||
|
||||
[CloudApp](https://www.getcloudapp.com) brings screen recording, screenshots, and GIF creation to the cloud, in an easy-to-use enterprise-level app. The CloudApp plugin allows you to upload a file to your CloadApp account from the command line.
|
||||
|
||||
To use it, add `cloudapp` to the plugins array of your `~/.zshrc` file:
|
||||
|
||||
```zsh
|
||||
plugins=(... cloudapp)
|
||||
```
|
||||
|
||||
## Requirements
|
||||
|
||||
1. [Aaron Russell's `cloudapp_api` gem](https://github.com/aaronrussell/cloudapp_api#installation)
|
||||
|
||||
2. That you set your CloudApp credentials in `~/.cloudapp` as a simple text file like below:
|
||||
```
|
||||
email
|
||||
password
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
- `cloudapp <filename>`: uploads `<filename>` to your CloudApp account, and if you're using
|
||||
macOS, copies the URL to your clipboard.
|
|
@ -1,4 +0,0 @@
|
|||
print -Pn "%F{yellow}"
|
||||
print "[oh-my-zsh] The CloudApp API no longer works, so the cloudapp plugin will"
|
||||
print "[oh-my-zsh] be removed shortly. Please remove it from your plugins list."
|
||||
print -Pn "%f"
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue