Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kubectx specific fzf options #423

Open
TheKangaroo opened this issue Jun 18, 2024 · 5 comments
Open

kubectx specific fzf options #423

TheKangaroo opened this issue Jun 18, 2024 · 5 comments

Comments

@TheKangaroo
Copy link

Is it possible to pass fzf options for kubectx only?
I can tune the behaviour of fzf for kubectx by setting FZF_DEFAULT_OPTS, but this applies to anything that uses fzf.
Is there such a thing as KUBECTX_FZF_OPTS?

@Ant0wan
Copy link

Ant0wan commented Sep 30, 2024

More than that, would it be possible to specify other binaires ? Like skim (a rust version of fzf)
If you allow me, I would be please to code this for you @ahmetb
WDYT ?

@Ant0wan
Copy link

Ant0wan commented Oct 9, 2024

@TheKangaroo I think there is an easier way to fix your issue: junegunn/fzf#1408
Use environment variables to change the behavior of fzf in your setup. Crazy example here:

export FZF_DEFAULT_COMMAND='fd --type f --hidden --follow --exclude .git'
export FZF_DEFAULT_OPTS="
  --height=80%
  --layout=default
  --border
  --reverse
  --info=inline
  --prompt='🔍 Find > '
  --pointer='=>'
  --marker='✅'
  --multi
  --color=fg:#ffb86c,bg:#282a36,hl:#50fa7b,fg+:#f8f8f2,bg+:#44475a,hl+:#ff5555
  --color=info:#8be9fd,prompt:#ff79c6,pointer:#ff5555,marker:#bd93f9,spinner:#f1fa8c
  --cycle
  --preview='bat --style=numbers --color=always {} || cat {}'
  --preview-window=right:70%:wrap
  --bind='?:toggle-preview'
  --bind='ctrl-j:accept'
  --scroll-off=5
"
export FZF_CTRL_T_COMMAND='fd --type f --hidden --follow --exclude .git'
export FZF_CTRL_T_OPTS="--preview 'head -n 100 {}' --layout=default --height=50%"
export FZF_CTRL_R_OPTS="--height=80% --layout=default --reverse --info=inline --prompt='🔍 History > '"
export FZF_ALT_C_COMMAND="fd --type d"
export FZF_ALT_C_OPTS="--preview 'tree -C {} | head -n 50' --layout=default --height=50%"
export FZF_TMUX=1
export FZF_TMUX_OPTS="-p100%,100%"
export FZF_PREVIEW_COMMAND="bat --style=numbers --color=always {} || cat {}"
export FZF

I hope this helped.

@TheKangaroo
Copy link
Author

@Ant0wan I don't think I understand. I already have FZF_DEFAULT_OPTS set, but I want different options just for fzf invoked by kubectx.
Or do you mean in should just

alias kubectx="FZF_DEFAULT_OPTS='xxxx' kubectx

?

@Ant0wan
Copy link

Ant0wan commented Oct 9, 2024

An alias is a great choice if you do not want to modify your local fzf config. An example:

alias kubectx="FZF_DEFAULT_OPTS=\"
  --height=80%
  --layout=default
  --border
  --reverse
  --info=inline
  --prompt='🔍 Find > '
  --pointer='=>'
  --marker='✅'
  --multi
  --color=fg:#ffb86c,bg:#282a36,hl:#50fa7b,fg+:#f8f8f2,bg+:#44475a,hl+:#ff5555
  --color=info:#8be9fd,prompt:#ff79c6,pointer:#ff5555,marker:#bd93f9,spinner:#f1fa8c
  --cycle
  --preview='bat --style=numbers --color=always {} || cat {}'
  --preview-window=right:70%:wrap
  --bind='?:toggle-preview'
  --bind='ctrl-j:accept'
  --scroll-off=5\" kubectx"

WDYT about this ? @TheKangaroo

@TheKangaroo
Copy link
Author

Actually, I hadn't thought about using an alias until I was trying to understand your example. I'll try it the other day.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants