mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2026-01-24 01:37:27 +08:00
Compare commits
5 Commits
e195c7cb43
...
b5e6392f21
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b5e6392f21 | ||
|
|
d6658f9af3 | ||
|
|
05bf69c604 | ||
|
|
6f215cd692 | ||
|
|
4efad7ab1b |
@ -47,6 +47,11 @@ plugins=(... aws)
|
|||||||
Some themes might overwrite the value of RPROMPT instead of appending to it, so they'll need to be fixed to
|
Some themes might overwrite the value of RPROMPT instead of appending to it, so they'll need to be fixed to
|
||||||
see the AWS profile/region prompt.
|
see the AWS profile/region prompt.
|
||||||
|
|
||||||
|
* Set `AWS_PROFILE_STATE_ENABLED=true` in your zshrc file if you want the aws profile to persist between shell sessions.
|
||||||
|
This option might slow down your shell startup time.
|
||||||
|
By default the state file path is `/tmp/.aws_current_profile`. This means that the state won't survive a reboot or otherwise GC.
|
||||||
|
You can control the state file path using the `AWS_STATE_FILE` environment variable.
|
||||||
|
|
||||||
## Theme
|
## Theme
|
||||||
|
|
||||||
The plugin creates an `aws_prompt_info` function that you can use in your theme, which displays
|
The plugin creates an `aws_prompt_info` function that you can use in your theme, which displays
|
||||||
|
|||||||
@ -6,10 +6,26 @@ function agr() {
|
|||||||
echo $AWS_REGION
|
echo $AWS_REGION
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Update state file if enabled
|
||||||
|
function _aws_update_state() {
|
||||||
|
if [[ "$AWS_PROFILE_STATE_ENABLED" == true ]]; then
|
||||||
|
test -d $(dirname ${AWS_STATE_FILE}) || exit 1
|
||||||
|
echo "${AWS_PROFILE} ${AWS_REGION}" > "${AWS_STATE_FILE}"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function _aws_clear_state() {
|
||||||
|
if [[ "$AWS_PROFILE_STATE_ENABLED" == true ]]; then
|
||||||
|
test -d $(dirname ${AWS_STATE_FILE}) || exit 1
|
||||||
|
echo -n > "${AWS_STATE_FILE}"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
# AWS profile selection
|
# AWS profile selection
|
||||||
function asp() {
|
function asp() {
|
||||||
if [[ -z "$1" ]]; then
|
if [[ -z "$1" ]]; then
|
||||||
unset AWS_DEFAULT_PROFILE AWS_PROFILE AWS_EB_PROFILE AWS_PROFILE_REGION
|
unset AWS_DEFAULT_PROFILE AWS_PROFILE AWS_EB_PROFILE AWS_PROFILE_REGION
|
||||||
|
_aws_clear_state
|
||||||
echo AWS profile cleared.
|
echo AWS profile cleared.
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
@ -28,6 +44,8 @@ function asp() {
|
|||||||
|
|
||||||
export AWS_PROFILE_REGION=$(aws configure get region)
|
export AWS_PROFILE_REGION=$(aws configure get region)
|
||||||
|
|
||||||
|
_aws_update_state
|
||||||
|
|
||||||
if [[ "$2" == "login" ]]; then
|
if [[ "$2" == "login" ]]; then
|
||||||
if [[ -n "$3" ]]; then
|
if [[ -n "$3" ]]; then
|
||||||
aws sso login --sso-session $3
|
aws sso login --sso-session $3
|
||||||
@ -43,6 +61,7 @@ function asp() {
|
|||||||
function asr() {
|
function asr() {
|
||||||
if [[ -z "$1" ]]; then
|
if [[ -z "$1" ]]; then
|
||||||
unset AWS_DEFAULT_REGION AWS_REGION
|
unset AWS_DEFAULT_REGION AWS_REGION
|
||||||
|
_aws_update_state
|
||||||
echo AWS region cleared.
|
echo AWS region cleared.
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
@ -56,6 +75,7 @@ function asr() {
|
|||||||
|
|
||||||
export AWS_REGION=$1
|
export AWS_REGION=$1
|
||||||
export AWS_DEFAULT_REGION=$1
|
export AWS_DEFAULT_REGION=$1
|
||||||
|
_aws_update_state
|
||||||
}
|
}
|
||||||
|
|
||||||
# AWS profile switch
|
# AWS profile switch
|
||||||
@ -255,6 +275,22 @@ if [[ "$SHOW_AWS_PROMPT" != false && "$RPROMPT" != *'$(aws_prompt_info)'* ]]; th
|
|||||||
RPROMPT='$(aws_prompt_info)'"$RPROMPT"
|
RPROMPT='$(aws_prompt_info)'"$RPROMPT"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [[ "$AWS_PROFILE_STATE_ENABLED" == true ]]; then
|
||||||
|
AWS_STATE_FILE="${AWS_STATE_FILE:-/tmp/.aws_current_profile}"
|
||||||
|
test -s "${AWS_STATE_FILE}" || return
|
||||||
|
|
||||||
|
aws_state=($(cat $AWS_STATE_FILE))
|
||||||
|
|
||||||
|
export AWS_DEFAULT_PROFILE="${aws_state[1]}"
|
||||||
|
export AWS_PROFILE="$AWS_DEFAULT_PROFILE"
|
||||||
|
export AWS_EB_PROFILE="$AWS_DEFAULT_PROFILE"
|
||||||
|
|
||||||
|
test -z "${aws_state[2]}" && AWS_REGION=$(aws configure get region)
|
||||||
|
|
||||||
|
export AWS_REGION=${AWS_REGION:-$aws_state[2]}
|
||||||
|
export AWS_DEFAULT_REGION="$AWS_REGION"
|
||||||
|
fi
|
||||||
|
|
||||||
# Load awscli completions
|
# Load awscli completions
|
||||||
|
|
||||||
# AWS CLI v2 comes with its own autocompletion. Check if that is there, otherwise fall back
|
# AWS CLI v2 comes with its own autocompletion. Check if that is there, otherwise fall back
|
||||||
|
|||||||
@ -1,7 +1,6 @@
|
|||||||
# Bazel plugin
|
# Bazel plugin
|
||||||
|
|
||||||
This plugin adds completion for [bazel](https://bazel.build), an open-source build and
|
This plugin adds completion and aliases for [bazel](https://bazel.build), an open-source build and test tool that scalably supports multi-language and multi-platform projects.
|
||||||
test tool that scalably supports multi-language and multi-platform projects.
|
|
||||||
|
|
||||||
To use it, add `bazel` to the plugins array in your zshrc file:
|
To use it, add `bazel` to the plugins array in your zshrc file:
|
||||||
|
|
||||||
@ -12,3 +11,12 @@ plugins=(... bazel)
|
|||||||
The plugin has a copy of [the completion script from the git repository][1].
|
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
|
[1]: https://github.com/bazelbuild/bazel/blob/master/scripts/zsh_completion/_bazel
|
||||||
|
|
||||||
|
## Aliases
|
||||||
|
|
||||||
|
| Alias | Command | Description |
|
||||||
|
| ------- | -------------------------------------- | ------------------------------------------------------ |
|
||||||
|
| bzb | `bazel build` | The `bazel build` command |
|
||||||
|
| bzt | `bazel test` | The `bazel test` command |
|
||||||
|
| bzr | `bazel run` | The `bazel run` command |
|
||||||
|
| bzq | `bazel query` | The `bazel query` command |
|
||||||
|
|||||||
5
plugins/bazel/bazel.plugin.zsh
Normal file
5
plugins/bazel/bazel.plugin.zsh
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
# Aliases for bazel
|
||||||
|
alias bzb='bazel build'
|
||||||
|
alias bzt='bazel test'
|
||||||
|
alias bzr='bazel run'
|
||||||
|
alias bzq='bazel query'
|
||||||
@ -29,8 +29,9 @@ Where `type` is one of the following:
|
|||||||
- `rev`
|
- `rev`
|
||||||
- `style`
|
- `style`
|
||||||
- `test`
|
- `test`
|
||||||
|
- `wip`
|
||||||
|
|
||||||
> NOTE: the alias for `revert` type is `rev`, as otherwise it conflicts with the git command of the same name.
|
> NOTE: the alias for `revert` type is `rev`, as otherwise it conflicts with the git command of the same name.
|
||||||
> It will still generate a commit message in the format `revert: <message>`
|
> It will still generate a commit message in the format `revert: <message>`
|
||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
@ -38,5 +39,6 @@ Where `type` is one of the following:
|
|||||||
| Git alias | Command |
|
| Git alias | Command |
|
||||||
| --------------------------------------------- | ---------------------------------------------------- |
|
| --------------------------------------------- | ---------------------------------------------------- |
|
||||||
| `git style "remove trailing whitespace"` | `git commit -m "style: remove trailing whitespace"` |
|
| `git style "remove trailing whitespace"` | `git commit -m "style: remove trailing whitespace"` |
|
||||||
|
| `git wip "work in progress"` | `git commit -m "work in progress"` |
|
||||||
| `git fix -s "router" "correct redirect link"` | `git commit -m "fix(router): correct redirect link"` |
|
| `git fix -s "router" "correct redirect link"` | `git commit -m "fix(router): correct redirect link"` |
|
||||||
| `git rev -s "api" "rollback v2"` | `git commit -m "revert(api): rollback v2"` |
|
| `git rev -s "api" "rollback v2"` | `git commit -m "revert(api): rollback v2"` |
|
||||||
|
|||||||
@ -11,6 +11,7 @@ _git_commit_aliases=(
|
|||||||
'revert'
|
'revert'
|
||||||
'style'
|
'style'
|
||||||
'test'
|
'test'
|
||||||
|
'wip'
|
||||||
)
|
)
|
||||||
|
|
||||||
local alias type
|
local alias type
|
||||||
|
|||||||
@ -152,6 +152,7 @@ plugins=(... git)
|
|||||||
| `grbd` | `git rebase $(git_develop_branch)` |
|
| `grbd` | `git rebase $(git_develop_branch)` |
|
||||||
| `grbm` | `git rebase $(git_main_branch)` |
|
| `grbm` | `git rebase $(git_main_branch)` |
|
||||||
| `grbom` | `git rebase origin/$(git_main_branch)` |
|
| `grbom` | `git rebase origin/$(git_main_branch)` |
|
||||||
|
| `grf` | `git reflog` |
|
||||||
| `gr` | `git remote` |
|
| `gr` | `git remote` |
|
||||||
| `grv` | `git remote --verbose` |
|
| `grv` | `git remote --verbose` |
|
||||||
| `gra` | `git remote add` |
|
| `gra` | `git remote add` |
|
||||||
|
|||||||
@ -335,6 +335,7 @@ alias grbs='git rebase --skip'
|
|||||||
alias grbd='git rebase $(git_develop_branch)'
|
alias grbd='git rebase $(git_develop_branch)'
|
||||||
alias grbm='git rebase $(git_main_branch)'
|
alias grbm='git rebase $(git_main_branch)'
|
||||||
alias grbom='git rebase origin/$(git_main_branch)'
|
alias grbom='git rebase origin/$(git_main_branch)'
|
||||||
|
alias grf='git reflog'
|
||||||
alias gr='git remote'
|
alias gr='git remote'
|
||||||
alias grv='git remote --verbose'
|
alias grv='git remote --verbose'
|
||||||
alias gra='git remote add'
|
alias gra='git remote add'
|
||||||
|
|||||||
9
plugins/stripe/README.md
Normal file
9
plugins/stripe/README.md
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
# Struoe
|
||||||
|
|
||||||
|
This plugin provides completion for the [Stripe CLI](https://stripe.com/docs/stripe-cli).
|
||||||
|
|
||||||
|
To use it add stripe to the plugins array in your zshrc file.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
plugins=(... stripe)
|
||||||
|
```
|
||||||
13
plugins/stripe/stripe.plugin.zsh
Normal file
13
plugins/stripe/stripe.plugin.zsh
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
if (( ! $+commands[stripe] )); then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
# If the completion file doesn't exist yet, we need to autoload it and
|
||||||
|
# bind it to `stripe`. Otherwise, compinit will have already done that.
|
||||||
|
if [[ ! -f "$ZSH_CACHE_DIR/completions/_stripe" ]]; then
|
||||||
|
typeset -g -A _comps
|
||||||
|
autoload -Uz _stripe
|
||||||
|
_comps[stripe]=_stripe
|
||||||
|
fi
|
||||||
|
|
||||||
|
stripe completion --shell zsh --write-to-stdout >| "$ZSH_CACHE_DIR/completions/_stripe" &|
|
||||||
Loading…
Reference in New Issue
Block a user