Skip to content

Commit 6341d3c

Browse files
committed
add display and add powershell alias
1 parent 42406e1 commit 6341d3c

File tree

4 files changed

+16
-6
lines changed

4 files changed

+16
-6
lines changed

pkg/cmd/env/rc_test.go

+7-3
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ alias gtc-='gardenctl target unset control-plane'
7272
alias gk='eval "$(gardenctl kubectl-env bash)"'
7373
alias gp='eval "$(gardenctl provider-env bash)"'
7474
alias gcv='gardenctl config view -o yaml'
75-
alias gh='gardenctl target history | fzf --tac --no-sort | bash'
75+
alias gh='gardenctl target history | fzf --tac --no-sort --height 40% --layout reverse --info inline --border --preview 'echo {}' --preview-window up,1,border-horizontal --color 'fg:#bbccdd,fg+:#ddeeff,bg:#334455,hl+:#ffaf5f,preview-bg:#223345,border:#778899' | bash'
7676
source <(gardenctl completion bash)
7777
complete -o default -F __start_gardenctl g
7878
gk
@@ -92,7 +92,7 @@ alias gtc-='gardenctl target unset control-plane'
9292
alias gk='eval "$(gardenctl kubectl-env zsh)"'
9393
alias gp='eval "$(gardenctl provider-env zsh)"'
9494
alias gcv='gardenctl config view -o yaml'
95-
alias gh='gardenctl target history | fzf --tac --no-sort | zsh'
95+
alias gh='gardenctl target history | fzf --tac --no-sort --height 40% --layout reverse --info inline --border --preview 'echo {}' --preview-window up,1,border-horizontal --color 'fg:#bbccdd,fg+:#ddeeff,bg:#334455,hl+:#ffaf5f,preview-bg:#223345,border:#778899' | zsh'
9696
if (( $+commands[gardenctl] )); then
9797
if [ -d "$ZSH_CACHE_DIR/completions" ] && (($fpath[(Ie)$ZSH_CACHE_DIR/completions])); then
9898
GCTL_COMPLETION_FILE="$ZSH_CACHE_DIR/completions/_gardenctl"
@@ -124,7 +124,7 @@ alias gtc-='gardenctl target unset control-plane'
124124
alias gk='eval (gardenctl kubectl-env fish)'
125125
alias gp='eval (gardenctl provider-env fish)'
126126
alias gcv='gardenctl config view -o yaml'
127-
alias gh='gardenctl target history | fzf --tac --no-sort | fish'
127+
alias gh='gardenctl target history | fzf --tac --no-sort --height 40% --layout reverse --info inline --border --preview 'echo {}' --preview-window up,1,border-horizontal --color 'fg:#bbccdd,fg+:#ddeeff,bg:#334455,hl+:#ffaf5f,preview-bg:#223345,border:#778899' | fish'
128128
gardenctl completion fish | source
129129
complete -c g -w gardenctl
130130
gk
@@ -162,6 +162,10 @@ function Gardenctl-Config-View {
162162
gardenctl config view -o yaml
163163
}
164164
Set-Alias -Name gcv -Value Gardenctl-Config-View -Option AllScope -Force
165+
function Gardenctl-Target-History {
166+
Invoke-Expression -Command "gardenctl target history | fzf --tac --no-sort --height 40% --layout reverse --info inline --border --preview 'echo {}' --preview-window up,1,border-horizontal --color 'fg:#bbccdd,fg+:#ddeeff,bg:#334455,hl+:#ffaf5f,preview-bg:#223345,border:#778899'" | Invoke-Expression
167+
}
168+
Set-Alias -Name gh -Value Gardenctl-Target-History -Option AllScope -Force
165169
function Gardenctl-Completion-Powershell {
166170
$s = (gardenctl completion powershell)
167171
@(

pkg/cmd/env/templates/rc.tmpl

+7-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ alias {{.prefix}}tc-='gardenctl target unset control-plane'
99
alias {{.prefix}}k='eval "$(gardenctl kubectl-env {{.shell}})"'
1010
alias {{.prefix}}p='eval "$(gardenctl provider-env {{.shell}})"'
1111
alias {{.prefix}}cv='gardenctl config view -o yaml'
12-
alias {{.prefix}}h='gardenctl target history | fzf --tac --no-sort | {{.shell}}'
12+
alias {{.prefix}}h='gardenctl target history | fzf --tac --no-sort --height 40% --layout reverse --info inline --border --preview 'echo {}' --preview-window up,1,border-horizontal --color 'fg:#bbccdd,fg+:#ddeeff,bg:#334455,hl+:#ffaf5f,preview-bg:#223345,border:#778899' | {{.shell}}'
1313
{{if not .noCompletion -}}
1414
source <(gardenctl completion {{.shell}})
1515
complete -o default -F __start_gardenctl {{.prefix}}
@@ -30,7 +30,7 @@ alias {{.prefix}}tc-='gardenctl target unset control-plane'
3030
alias {{.prefix}}k='eval "$(gardenctl kubectl-env {{.shell}})"'
3131
alias {{.prefix}}p='eval "$(gardenctl provider-env {{.shell}})"'
3232
alias {{.prefix}}cv='gardenctl config view -o yaml'
33-
alias {{.prefix}}h='gardenctl target history | fzf --tac --no-sort | {{.shell}}'
33+
alias {{.prefix}}h='gardenctl target history | fzf --tac --no-sort --height 40% --layout reverse --info inline --border --preview 'echo {}' --preview-window up,1,border-horizontal --color 'fg:#bbccdd,fg+:#ddeeff,bg:#334455,hl+:#ffaf5f,preview-bg:#223345,border:#778899' | {{.shell}}'
3434
{{if not .noCompletion -}}
3535
if (( $+commands[gardenctl] )); then
3636
if [ -d "$ZSH_CACHE_DIR/completions" ] && (($fpath[(Ie)$ZSH_CACHE_DIR/completions])); then
@@ -63,7 +63,7 @@ alias {{.prefix}}tc-='gardenctl target unset control-plane'
6363
alias {{.prefix}}k='eval (gardenctl kubectl-env {{.shell}})'
6464
alias {{.prefix}}p='eval (gardenctl provider-env {{.shell}})'
6565
alias {{.prefix}}cv='gardenctl config view -o yaml'
66-
alias {{.prefix}}h='gardenctl target history | fzf --tac --no-sort | {{.shell}}'
66+
alias {{.prefix}}h='gardenctl target history | fzf --tac --no-sort --height 40% --layout reverse --info inline --border --preview 'echo {}' --preview-window up,1,border-horizontal --color 'fg:#bbccdd,fg+:#ddeeff,bg:#334455,hl+:#ffaf5f,preview-bg:#223345,border:#778899' | {{.shell}}'
6767
{{if not .noCompletion -}}
6868
gardenctl completion {{.shell}} | source
6969
complete -c {{.prefix}} -w gardenctl
@@ -102,6 +102,10 @@ function Gardenctl-Config-View {
102102
gardenctl config view -o yaml
103103
}
104104
Set-Alias -Name {{.prefix}}cv -Value Gardenctl-Config-View -Option AllScope -Force
105+
function Gardenctl-Target-History {
106+
Invoke-Expression -Command "gardenctl target history | fzf --tac --no-sort --height 40% --layout reverse --info inline --border --preview 'echo {}' --preview-window up,1,border-horizontal --color 'fg:#bbccdd,fg+:#ddeeff,bg:#334455,hl+:#ffaf5f,preview-bg:#223345,border:#778899'" | Invoke-Expression
107+
}
108+
Set-Alias -Name gh -Value Gardenctl-Target-History -Option AllScope -Force
105109
{{if not .noCompletion -}}
106110
function Gardenctl-Completion-Powershell {
107111
$s = (gardenctl completion {{.shell}})

pkg/cmd/target/history.go

+1
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ func checkInstalled(name string) error {
8383

8484
func HistoryParse(f util.Factory, c *cobra.Command) (string, error) {
8585
var slice []string
86+
8687
m, err := f.Manager()
8788
if err != nil {
8889
return "", err

pkg/cmd/target/history_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
"github.com/gardener/gardenctl-v2/pkg/cmd/base"
1414
cmdtarget "github.com/gardener/gardenctl-v2/pkg/cmd/target"
1515
"github.com/gardener/gardenctl-v2/pkg/target"
16+
1617
"github.com/spf13/cobra"
1718

1819
. "github.com/onsi/ginkgo"

0 commit comments

Comments
 (0)