mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2026-08-19 22:48:26 +08:00
Compare commits
2 Commits
0912e05c05
...
6f39351fef
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6f39351fef | ||
|
|
069512d14a |
11
plugins/codex/README.md
Normal file
11
plugins/codex/README.md
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
# codex Plugin
|
||||||
|
|
||||||
|
## Introduction
|
||||||
|
|
||||||
|
This `codex` plugin sets up completion for [codex](https://github.com/openai/codex).
|
||||||
|
|
||||||
|
To use it, add `codex` to the plugins array of your zshrc file:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
plugins=(... codex)
|
||||||
|
```
|
||||||
14
plugins/codex/codex.plugin.zsh
Normal file
14
plugins/codex/codex.plugin.zsh
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
# COMPLETION FUNCTION
|
||||||
|
if (( ! $+commands[codex] )); then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
# If the completion file doesn't exist yet, we need to autoload it and
|
||||||
|
# bind it to `codex`. Otherwise, compinit will have already done that.
|
||||||
|
if [[ ! -f "$ZSH_CACHE_DIR/completions/_codex" ]]; then
|
||||||
|
typeset -g -A _comps
|
||||||
|
autoload -Uz _codex
|
||||||
|
_comps[codex]=_codex
|
||||||
|
fi
|
||||||
|
|
||||||
|
codex completion zsh 2> /dev/null >| "$ZSH_CACHE_DIR/completions/_codex" &|
|
||||||
@@ -10,12 +10,48 @@ function gi() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_gitignoreio_get_command_list() {
|
_gitignoreio_get_command_list() {
|
||||||
|
setopt local_options pipe_fail
|
||||||
_gi_curl "list" | tr "," "\n"
|
_gi_curl "list" | tr "," "\n"
|
||||||
}
|
}
|
||||||
|
|
||||||
_gitignoreio () {
|
__gitignoreio_caching_policy() {
|
||||||
compset -P '*,'
|
local -a oldp
|
||||||
compadd -S '' $(_gitignoreio_get_command_list)
|
oldp=("$1"(Nm+7))
|
||||||
|
(($#oldp))
|
||||||
}
|
}
|
||||||
|
|
||||||
compdef _gitignoreio gi
|
_gitignoreio_retrieve_stale_cache() {
|
||||||
|
zstyle -t ":completion:${curcontext}:" use-cache || return 1
|
||||||
|
|
||||||
|
local cache_dir
|
||||||
|
zstyle -s ":completion:${curcontext}:" cache-path cache_dir
|
||||||
|
: ${cache_dir:=${ZDOTDIR:-$HOME}/.zcompcache}
|
||||||
|
|
||||||
|
[[ -e "$cache_dir/gi-list" ]] || return 1
|
||||||
|
. "$cache_dir/gi-list"
|
||||||
|
}
|
||||||
|
|
||||||
|
_gitignoreio() {
|
||||||
|
compset -P '*,'
|
||||||
|
|
||||||
|
local cache_policy
|
||||||
|
zstyle -s ":completion:${curcontext}:" cache-policy cache_policy
|
||||||
|
if [[ -z "$cache_policy" ]]; then
|
||||||
|
zstyle ":completion:${curcontext}:" cache-policy __gitignoreio_caching_policy
|
||||||
|
fi
|
||||||
|
|
||||||
|
local -a _gi_list
|
||||||
|
if _cache_invalid gi-list || ! _retrieve_cache gi-list; then
|
||||||
|
local command_list
|
||||||
|
if command_list="$(_gitignoreio_get_command_list)" && [[ -n "$command_list" ]]; then
|
||||||
|
_gi_list=(${(f)command_list})
|
||||||
|
_store_cache gi-list _gi_list
|
||||||
|
else
|
||||||
|
_gitignoreio_retrieve_stale_cache
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
compadd -S '' -a _gi_list
|
||||||
|
}
|
||||||
|
|
||||||
|
compdef _gitignoreio gi
|
||||||
|
|||||||
Reference in New Issue
Block a user