Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
meishi125478
ohmyzsh
提交
c96b4776
O
ohmyzsh
项目概览
meishi125478
/
ohmyzsh
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
O
ohmyzsh
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
c96b4776
编写于
5月 28, 2017
作者:
S
Stanislaw Szydlo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add 'kubectx' plugin.
上级
291e96dc
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
41 addition
and
1 deletion
+41
-1
lib/prompt_info_functions.zsh
lib/prompt_info_functions.zsh
+1
-1
plugins/kubectx/README.md
plugins/kubectx/README.md
+26
-0
plugins/kubectx/kubectx.plugin.zsh
plugins/kubectx/kubectx.plugin.zsh
+14
-0
plugins/kubectx/prod.png
plugins/kubectx/prod.png
+0
-0
plugins/kubectx/stage.png
plugins/kubectx/stage.png
+0
-0
未找到文件。
lib/prompt_info_functions.zsh
浏览文件 @
c96b4776
...
...
@@ -12,7 +12,7 @@
# Real implementations will be used when the respective plugins are loaded
function
chruby_prompt_info hg_prompt_info pyenv_prompt_info
\
rbenv_prompt_info svn_prompt_info vi_mode_prompt_info
\
virtualenv_prompt_info
{
virtualenv_prompt_info
kubectx_prompt_info
{
return
1
}
...
...
plugins/kubectx/README.md
0 → 100644
浏览文件 @
c96b4776
# kubectx - show active kubectl context
This plugins adds
```kubectx_prompt_info()```
function. It shows name of the
active kubectl context (
```kubectl config current-context```
).
You can use it to customize prompt and know if You are on prod cluster ;)
_Example_
. Add to
**.zshrc**
:
```
RPS1='$(kubectx_prompt_info)'
```
### custom ctx names
One can rename default context name for better readability.
_Example_
. Add to
**.zshrc**
:
```
kubectx_mapping[minikube] = "mini"
kubectx_mapping[context_name_from_kubeconfig]="$emoji[wolf_face]"
kubectx_mapping[production_cluster]="%{$fg[yellow]%}prod!%{$reset_color%}"
```
![
staging
](
stage.png
)
![
production
](
prod.png
)
plugins/kubectx/kubectx.plugin.zsh
0 → 100644
浏览文件 @
c96b4776
typeset
-A
kubectx_mapping
function
kubectx_prompt_info
()
{
if
[
$commands
[
kubectl]
]
;
then
local
current_ctx
=
`
kubectl config current-context
`
#if associative array declared
if
[[
-n
$kubectx_mapping
]]
;
then
echo
"
${
kubectx_mapping
[
$current_ctx
]
}
"
else
echo
$current_ctx
fi
fi
}
plugins/kubectx/prod.png
0 → 100644
浏览文件 @
c96b4776
3.7 KB
plugins/kubectx/stage.png
0 → 100644
浏览文件 @
c96b4776
3.7 KB
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录