mirror of
https://github.com/IlanCosman/tide.git
synced 2024-09-11 09:05:37 +03:00
add kubectl item (#178)
* add kube context * handle missing namespace * Rename to kubectl * Minor edits * Fix test * Use hex brand colors, add kubectl to right items Co-authored-by: Ilan Cosman <ilancosman@gmail.com>
This commit is contained in:
parent
2a8ed6b2ef
commit
9d16aec7a3
4
functions/_tide_item_kubectl.fish
Normal file
4
functions/_tide_item_kubectl.fish
Normal file
@ -0,0 +1,4 @@
|
||||
function _tide_item_kubectl
|
||||
set -l context (kubectl config view --minify --output 'jsonpath={.current-context}/{..namespace}' 2>/dev/null) &&
|
||||
_tide_print_item kubectl $tide_kubectl_icon' ' (string replace --regex '/(|default)$' '' $context)
|
||||
end
|
@ -1,6 +1,6 @@
|
||||
function _tide_remove_unusable_items
|
||||
# Remove tool-specific items for tools the machine doesn't have installed
|
||||
for item in chruby git go nvm php rustc virtual_env
|
||||
for item in chruby git go kubectl nvm php rustc virtual_env
|
||||
set -l cli_names $item
|
||||
switch $item
|
||||
case virtual_env
|
||||
|
@ -36,6 +36,9 @@ tide_go_icon
|
||||
tide_jobs_bg_color 444444
|
||||
tide_jobs_color $_tide_color_dark_green
|
||||
tide_jobs_icon ''
|
||||
tide_kubectl_bg_color 444444
|
||||
tide_kubectl_color 326CE5
|
||||
tide_kubectl_icon '⎈'
|
||||
tide_left_prompt_frame_enabled true
|
||||
tide_left_prompt_items pwd git newline
|
||||
tide_left_prompt_prefix ''
|
||||
@ -65,7 +68,7 @@ tide_pwd_icon_home
|
||||
tide_pwd_icon_unwritable ''
|
||||
tide_pwd_markers .bzr .citc .git .hg .node-version .python-version .ruby-version .shorten_folder_marker .svn .terraform Cargo.toml composer.json CVS go.mod package.json
|
||||
tide_right_prompt_frame_enabled true
|
||||
tide_right_prompt_items status cmd_duration context jobs nvm virtual_env rustc php chruby go vi_mode
|
||||
tide_right_prompt_items status cmd_duration context jobs nvm virtual_env rustc php chruby go kubectl vi_mode
|
||||
tide_right_prompt_prefix ''
|
||||
tide_right_prompt_separator_diff_color ''
|
||||
tide_right_prompt_separator_same_color ''
|
||||
|
@ -24,6 +24,8 @@ tide_go_bg_color black
|
||||
tide_go_color brcyan
|
||||
tide_jobs_bg_color black
|
||||
tide_jobs_color green
|
||||
tide_kubectl_bg_color black
|
||||
tide_kubectl_color blue
|
||||
tide_nvm_bg_color black
|
||||
tide_nvm_color green
|
||||
tide_os_bg_color black
|
||||
|
@ -36,6 +36,9 @@ tide_go_icon
|
||||
tide_jobs_bg_color normal
|
||||
tide_jobs_color $_tide_color_dark_green
|
||||
tide_jobs_icon ''
|
||||
tide_kubectl_bg_color normal
|
||||
tide_kubectl_color 326CE5
|
||||
tide_kubectl_icon '⎈'
|
||||
tide_left_prompt_frame_enabled false
|
||||
tide_left_prompt_items pwd git newline character
|
||||
tide_left_prompt_prefix ''
|
||||
@ -65,7 +68,7 @@ tide_pwd_icon_home
|
||||
tide_pwd_icon_unwritable ''
|
||||
tide_pwd_markers .bzr .citc .git .hg .node-version .python-version .ruby-version .shorten_folder_marker .svn .terraform Cargo.toml composer.json CVS go.mod package.json
|
||||
tide_right_prompt_frame_enabled false
|
||||
tide_right_prompt_items status cmd_duration context jobs nvm virtual_env rustc php chruby go
|
||||
tide_right_prompt_items status cmd_duration context jobs nvm virtual_env rustc php chruby go kubectl
|
||||
tide_right_prompt_prefix ' '
|
||||
tide_right_prompt_separator_diff_color ' '
|
||||
tide_right_prompt_separator_same_color ' '
|
||||
|
@ -24,6 +24,8 @@ tide_go_bg_color normal
|
||||
tide_go_color brcyan
|
||||
tide_jobs_bg_color normal
|
||||
tide_jobs_color green
|
||||
tide_kubectl_bg_color normal
|
||||
tide_kubectl_color blue
|
||||
tide_nvm_bg_color normal
|
||||
tide_nvm_color green
|
||||
tide_os_bg_color normal
|
||||
|
@ -36,6 +36,9 @@ tide_go_icon
|
||||
tide_jobs_bg_color 444444
|
||||
tide_jobs_color 4E9A06
|
||||
tide_jobs_icon ''
|
||||
tide_kubectl_bg_color 326CE5
|
||||
tide_kubectl_color 000000
|
||||
tide_kubectl_icon '⎈'
|
||||
tide_left_prompt_frame_enabled true
|
||||
tide_left_prompt_items pwd git newline
|
||||
tide_left_prompt_prefix ''
|
||||
@ -65,7 +68,7 @@ tide_pwd_icon_home
|
||||
tide_pwd_icon_unwritable ''
|
||||
tide_pwd_markers .bzr .citc .git .hg .node-version .python-version .ruby-version .shorten_folder_marker .svn .terraform Cargo.toml composer.json CVS go.mod package.json
|
||||
tide_right_prompt_frame_enabled true
|
||||
tide_right_prompt_items status cmd_duration context jobs nvm virtual_env rustc php chruby go vi_mode
|
||||
tide_right_prompt_items status cmd_duration context jobs nvm virtual_env rustc php chruby go kubectl vi_mode
|
||||
tide_right_prompt_prefix ''
|
||||
tide_right_prompt_separator_diff_color ''
|
||||
tide_right_prompt_separator_same_color ''
|
||||
|
@ -24,6 +24,8 @@ tide_go_bg_color brcyan
|
||||
tide_go_color black
|
||||
tide_jobs_bg_color brblack
|
||||
tide_jobs_color green
|
||||
tide_kubectl_bg_color blue
|
||||
tide_kubectl_color black
|
||||
tide_nvm_bg_color green
|
||||
tide_nvm_color black
|
||||
tide_os_bg_color white
|
||||
|
19
tests/_tide_item_kubectl.test.fish
Normal file
19
tests/_tide_item_kubectl.test.fish
Normal file
@ -0,0 +1,19 @@
|
||||
# RUN: %fish %s
|
||||
|
||||
function _kubectl
|
||||
_tide_decolor (_tide_item_kubectl)
|
||||
end
|
||||
|
||||
set -lx tide_kubectl_icon ⎈
|
||||
|
||||
mock kubectl "config view --minify --output" "echo error: current-context must exist in order to minify >&2; false"
|
||||
_kubectl # CHECK:
|
||||
|
||||
mock kubectl "config view --minify --output" "printf curr-context/default"
|
||||
_kubectl # CHECK: ⎈ curr-context
|
||||
|
||||
mock kubectl "config view --minify --output" "printf curr-context/"
|
||||
_kubectl # CHECK: ⎈ curr-context
|
||||
|
||||
mock kubectl "config view --minify --output" "printf curr-context/curr-namespace"
|
||||
_kubectl # CHECK: ⎈ curr-context/curr-namespace
|
Loading…
Reference in New Issue
Block a user