mirror of https://github.com/ohmyzsh/ohmyzsh.git
Compare commits
5 Commits
be79a641d4
...
2664ad7a36
Author | SHA1 | Date |
---|---|---|
|
2664ad7a36 | |
|
cae2e45193 | |
|
276e540eed | |
|
5c17bcd21f | |
|
ae6c131137 |
|
@ -1,6 +1,7 @@
|
||||||
#!/usr/bin/env zsh
|
#!/usr/bin/env zsh
|
||||||
|
|
||||||
function omz {
|
function omz {
|
||||||
|
setopt localoptions noksharrays
|
||||||
[[ $# -gt 0 ]] || {
|
[[ $# -gt 0 ]] || {
|
||||||
_omz::help
|
_omz::help
|
||||||
return 1
|
return 1
|
||||||
|
|
|
@ -43,6 +43,23 @@ starting with "_": "MP-1234_fix_dashboard". In both these cases, the issue opene
|
||||||
This is also checks if the prefix is in the name, and adds it if not, so: "MP-1234" opens the issue "MP-1234",
|
This is also checks if the prefix is in the name, and adds it if not, so: "MP-1234" opens the issue "MP-1234",
|
||||||
"mp-1234" opens the issue "mp-1234", and "1234" opens the issue "MP-1234".
|
"mp-1234" opens the issue "mp-1234", and "1234" opens the issue "MP-1234".
|
||||||
|
|
||||||
|
If your branch naming convention deviates, you can overwrite the jira_branch function to determine and echo the Jira issue key yourself.
|
||||||
|
Create a file at `~/.oh-my-zsh/plugins/jira-patch/jira-patch.plugin.zsh` and add `jira-patch` after `jira` in the $plugins variable
|
||||||
|
(see https://github.com/ohmyzsh/ohmyzsh/wiki/Customization#partially-overriding-an-existing-plugin).
|
||||||
|
Example:
|
||||||
|
```zsh
|
||||||
|
# Determine branch name from naming convention 'type/KEY-123/description'.
|
||||||
|
function jira_branch() {
|
||||||
|
# Get name of the branch
|
||||||
|
issue_arg=$(git rev-parse --abbrev-ref HEAD)
|
||||||
|
# Strip prefixes like feature/ or bugfix/
|
||||||
|
issue_arg=${issue_arg#*/}
|
||||||
|
# Strip suffixes like /some-branch-description
|
||||||
|
issue_arg=${issue_arg%%/*}
|
||||||
|
# Return the value
|
||||||
|
echo $issue_arg
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
#### Debugging usage
|
#### Debugging usage
|
||||||
|
|
|
@ -17,6 +17,30 @@ jira branch Opens an existing issue matching the current bra
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# If your branch naming convention deviates, you can partially override this plugin function
|
||||||
|
# to determine the jira issue key based on your formatting.
|
||||||
|
# See https://github.com/ohmyzsh/ohmyzsh/wiki/Customization#partially-overriding-an-existing-plugin
|
||||||
|
function jira_branch() {
|
||||||
|
# Get name of the branch
|
||||||
|
issue_arg=$(git rev-parse --abbrev-ref HEAD)
|
||||||
|
# Strip prefixes like feature/ or bugfix/
|
||||||
|
issue_arg=${issue_arg##*/}
|
||||||
|
# Strip suffixes starting with _
|
||||||
|
issue_arg=(${(s:_:)issue_arg})
|
||||||
|
# If there is only one part, it means that there is a different delimiter. Try with -
|
||||||
|
if [[ ${#issue_arg[@]} = 1 && ${issue_arg} == *-* ]]; then
|
||||||
|
issue_arg=(${(s:-:)issue_arg})
|
||||||
|
issue_arg="${issue_arg[1]}-${issue_arg[2]}"
|
||||||
|
else
|
||||||
|
issue_arg=${issue_arg[1]}
|
||||||
|
fi
|
||||||
|
if [[ "${issue_arg:l}" = ${jira_prefix:l}* ]]; then
|
||||||
|
echo "${issue_arg}"
|
||||||
|
else
|
||||||
|
echo "${jira_prefix}${issue_arg}"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
function jira() {
|
function jira() {
|
||||||
emulate -L zsh
|
emulate -L zsh
|
||||||
local action jira_url jira_prefix
|
local action jira_url jira_prefix
|
||||||
|
@ -91,24 +115,7 @@ function jira() {
|
||||||
# but `branch` is a special case that will parse the current git branch
|
# but `branch` is a special case that will parse the current git branch
|
||||||
local issue_arg issue
|
local issue_arg issue
|
||||||
if [[ "$action" == "branch" ]]; then
|
if [[ "$action" == "branch" ]]; then
|
||||||
# Get name of the branch
|
issue=$(jira_branch)
|
||||||
issue_arg=$(git rev-parse --abbrev-ref HEAD)
|
|
||||||
# Strip prefixes like feature/ or bugfix/
|
|
||||||
issue_arg=${issue_arg##*/}
|
|
||||||
# Strip suffixes starting with _
|
|
||||||
issue_arg=(${(s:_:)issue_arg})
|
|
||||||
# If there is only one part, it means that there is a different delimiter. Try with -
|
|
||||||
if [[ ${#issue_arg[@]} = 1 && ${issue_arg} == *-* ]]; then
|
|
||||||
issue_arg=(${(s:-:)issue_arg})
|
|
||||||
issue_arg="${issue_arg[1]}-${issue_arg[2]}"
|
|
||||||
else
|
|
||||||
issue_arg=${issue_arg[1]}
|
|
||||||
fi
|
|
||||||
if [[ "${issue_arg:l}" = ${jira_prefix:l}* ]]; then
|
|
||||||
issue="${issue_arg}"
|
|
||||||
else
|
|
||||||
issue="${jira_prefix}${issue_arg}"
|
|
||||||
fi
|
|
||||||
else
|
else
|
||||||
issue_arg=${(U)action}
|
issue_arg=${(U)action}
|
||||||
issue="${jira_prefix}${issue_arg}"
|
issue="${jira_prefix}${issue_arg}"
|
||||||
|
|
|
@ -22,5 +22,5 @@ fi
|
||||||
rustup completions zsh >| "$ZSH_CACHE_DIR/completions/_rustup" &|
|
rustup completions zsh >| "$ZSH_CACHE_DIR/completions/_rustup" &|
|
||||||
cat >| "$ZSH_CACHE_DIR/completions/_cargo" <<'EOF'
|
cat >| "$ZSH_CACHE_DIR/completions/_cargo" <<'EOF'
|
||||||
#compdef cargo
|
#compdef cargo
|
||||||
source "$(rustc +${${(z)$(rustup default)}[1]} --print sysroot)"/share/zsh/site-functions/_cargo
|
source "$(rustup run ${${(z)$(rustup default)}[1]} rustc --print sysroot)"/share/zsh/site-functions/_cargo
|
||||||
EOF
|
EOF
|
||||||
|
|
|
@ -52,6 +52,7 @@ Available search contexts are:
|
||||||
| `gopkg` | `https://pkg.go.dev/search?m=package&q=` |
|
| `gopkg` | `https://pkg.go.dev/search?m=package&q=` |
|
||||||
| `chatgpt` | `https://chatgpt.com/?q=` |
|
| `chatgpt` | `https://chatgpt.com/?q=` |
|
||||||
| `reddit` | `https://www.reddit.com/search/?q=` |
|
| `reddit` | `https://www.reddit.com/search/?q=` |
|
||||||
|
| `ppai` | `https://www.perplexity.ai/search/new?q=` |
|
||||||
|
|
||||||
Also there are aliases for bang-searching DuckDuckGo:
|
Also there are aliases for bang-searching DuckDuckGo:
|
||||||
|
|
||||||
|
|
|
@ -33,6 +33,7 @@ function web_search() {
|
||||||
gopkg "https://pkg.go.dev/search?m=package&q="
|
gopkg "https://pkg.go.dev/search?m=package&q="
|
||||||
chatgpt "https://chatgpt.com/?q="
|
chatgpt "https://chatgpt.com/?q="
|
||||||
reddit "https://www.reddit.com/search/?q="
|
reddit "https://www.reddit.com/search/?q="
|
||||||
|
ppai "https://www.perplexity.ai/search/new?q="
|
||||||
)
|
)
|
||||||
|
|
||||||
# check whether the search engine is supported
|
# check whether the search engine is supported
|
||||||
|
@ -87,6 +88,7 @@ alias packagist='web_search packagist'
|
||||||
alias gopkg='web_search gopkg'
|
alias gopkg='web_search gopkg'
|
||||||
alias chatgpt='web_search chatgpt'
|
alias chatgpt='web_search chatgpt'
|
||||||
alias reddit='web_search reddit'
|
alias reddit='web_search reddit'
|
||||||
|
alias ppai='web_search ppai'
|
||||||
|
|
||||||
#add your own !bang searches here
|
#add your own !bang searches here
|
||||||
alias wiki='web_search duckduckgo \!w'
|
alias wiki='web_search duckduckgo \!w'
|
||||||
|
|
Loading…
Reference in New Issue