Skip to content

Commit

Permalink
add display and add powershell alias
Browse files Browse the repository at this point in the history
  • Loading branch information
tedteng committed Jul 5, 2022
1 parent 42406e1 commit 6341d3c
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 6 deletions.
10 changes: 7 additions & 3 deletions pkg/cmd/env/rc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ alias gtc-='gardenctl target unset control-plane'
alias gk='eval "$(gardenctl kubectl-env bash)"'
alias gp='eval "$(gardenctl provider-env bash)"'
alias gcv='gardenctl config view -o yaml'
alias gh='gardenctl target history | fzf --tac --no-sort | bash'
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'
source <(gardenctl completion bash)
complete -o default -F __start_gardenctl g
gk
Expand All @@ -92,7 +92,7 @@ alias gtc-='gardenctl target unset control-plane'
alias gk='eval "$(gardenctl kubectl-env zsh)"'
alias gp='eval "$(gardenctl provider-env zsh)"'
alias gcv='gardenctl config view -o yaml'
alias gh='gardenctl target history | fzf --tac --no-sort | zsh'
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'
if (( $+commands[gardenctl] )); then
if [ -d "$ZSH_CACHE_DIR/completions" ] && (($fpath[(Ie)$ZSH_CACHE_DIR/completions])); then
GCTL_COMPLETION_FILE="$ZSH_CACHE_DIR/completions/_gardenctl"
Expand Down Expand Up @@ -124,7 +124,7 @@ alias gtc-='gardenctl target unset control-plane'
alias gk='eval (gardenctl kubectl-env fish)'
alias gp='eval (gardenctl provider-env fish)'
alias gcv='gardenctl config view -o yaml'
alias gh='gardenctl target history | fzf --tac --no-sort | fish'
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'
gardenctl completion fish | source
complete -c g -w gardenctl
gk
Expand Down Expand Up @@ -162,6 +162,10 @@ function Gardenctl-Config-View {
gardenctl config view -o yaml
}
Set-Alias -Name gcv -Value Gardenctl-Config-View -Option AllScope -Force
function Gardenctl-Target-History {
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
}
Set-Alias -Name gh -Value Gardenctl-Target-History -Option AllScope -Force
function Gardenctl-Completion-Powershell {
$s = (gardenctl completion powershell)
@(
Expand Down
10 changes: 7 additions & 3 deletions pkg/cmd/env/templates/rc.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ alias {{.prefix}}tc-='gardenctl target unset control-plane'
alias {{.prefix}}k='eval "$(gardenctl kubectl-env {{.shell}})"'
alias {{.prefix}}p='eval "$(gardenctl provider-env {{.shell}})"'
alias {{.prefix}}cv='gardenctl config view -o yaml'
alias {{.prefix}}h='gardenctl target history | fzf --tac --no-sort | {{.shell}}'
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}}'
{{if not .noCompletion -}}
source <(gardenctl completion {{.shell}})
complete -o default -F __start_gardenctl {{.prefix}}
Expand All @@ -30,7 +30,7 @@ alias {{.prefix}}tc-='gardenctl target unset control-plane'
alias {{.prefix}}k='eval "$(gardenctl kubectl-env {{.shell}})"'
alias {{.prefix}}p='eval "$(gardenctl provider-env {{.shell}})"'
alias {{.prefix}}cv='gardenctl config view -o yaml'
alias {{.prefix}}h='gardenctl target history | fzf --tac --no-sort | {{.shell}}'
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}}'
{{if not .noCompletion -}}
if (( $+commands[gardenctl] )); then
if [ -d "$ZSH_CACHE_DIR/completions" ] && (($fpath[(Ie)$ZSH_CACHE_DIR/completions])); then
Expand Down Expand Up @@ -63,7 +63,7 @@ alias {{.prefix}}tc-='gardenctl target unset control-plane'
alias {{.prefix}}k='eval (gardenctl kubectl-env {{.shell}})'
alias {{.prefix}}p='eval (gardenctl provider-env {{.shell}})'
alias {{.prefix}}cv='gardenctl config view -o yaml'
alias {{.prefix}}h='gardenctl target history | fzf --tac --no-sort | {{.shell}}'
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}}'
{{if not .noCompletion -}}
gardenctl completion {{.shell}} | source
complete -c {{.prefix}} -w gardenctl
Expand Down Expand Up @@ -102,6 +102,10 @@ function Gardenctl-Config-View {
gardenctl config view -o yaml
}
Set-Alias -Name {{.prefix}}cv -Value Gardenctl-Config-View -Option AllScope -Force
function Gardenctl-Target-History {
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
}
Set-Alias -Name gh -Value Gardenctl-Target-History -Option AllScope -Force
{{if not .noCompletion -}}
function Gardenctl-Completion-Powershell {
$s = (gardenctl completion {{.shell}})
Expand Down
1 change: 1 addition & 0 deletions pkg/cmd/target/history.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ func checkInstalled(name string) error {

func HistoryParse(f util.Factory, c *cobra.Command) (string, error) {
var slice []string

m, err := f.Manager()
if err != nil {
return "", err
Expand Down
1 change: 1 addition & 0 deletions pkg/cmd/target/history_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"github.com/gardener/gardenctl-v2/pkg/cmd/base"
cmdtarget "github.com/gardener/gardenctl-v2/pkg/cmd/target"
"github.com/gardener/gardenctl-v2/pkg/target"

"github.com/spf13/cobra"

. "github.com/onsi/ginkgo"
Expand Down

0 comments on commit 6341d3c

Please sign in to comment.