K9s: Shortcut to copy yaml to clipboard.

Created on 7 Oct 2019  Â·  11Comments  Â·  Source: derailed/k9s






It would be nice if there was a keyboard shortcut to just save yaml of current selected component to clipboard.

CTRL-Y for example.

This would enable quick copy/paste of resources from k8s to somewhere else.

enhancement

Most helpful comment

Already done, let me know if it's not up to par

All 11 comments

I actually also wanted this feature. I started already thinking about implementing it myself using plugins, but it looks like plugins don't support the yaml view as a scope. What do you think, would it be better to add more scopes so you could use a plugin to do this, or make this a part of k9s itself? I suppose all clipboard libs for go require external apps for them to function (at least this is the one I found: https://github.com/atotto/clipboard). As they require external apps, plugins would be a great fit for this, but then again this could function just as the "save" feature. As that already saves whatever is the current view and copying to clipboard could use the same logic

Hey @kapodes and @syvanpera, thanks for this request.

I think it make a lot of sense to integrate this inside of k9s. We already use atotto/clipboard (and yes it does need external tools @syvanpera) for the feature of copying the name of a resource with c when we are on the list view. Maybe we could make the shortcut c to copy the whole YAML when in the YAML view.

So the workflow would be:

  1. list pods with :po
  2. view YAML with y
  3. copy the YAML with c

What do you both think?

/cc @derailed

Sounds good, although using the Ctrl-Y or something like that would make sense if we'd like to make this work like the save command does. So basically just do the same thing as save now does, but only writing the result (csv, yaml whatever) to clipboard. I actually have quick and dirty version of this already working

Ah, nevermind. Of course the 'c' command works just as well, I mixed things up

But just not limiting this to only copy the yaml, but also copy whatever save command can save also.

Both c and ctrl-Y work for me. The ctrl makes more sense just for this but ‘c’ is better if it will work on other screens

Yeah, and I didn't notice that there already is a copy command that uses 'c', so it makes sense to use the same shortcut

Ah, but I just realized that the 'c' command only copies the current resource from the list. Okay, I guess that could work. I for one don't currently have any use for copying the list as a csv to clipboard at this time.

Can I take a stab at implementing this?

Yes! Thanks you both for the input on this request.

Of course you can implement this! If you need any help just send me a message and I can help you.

Already done, let me know if it's not up to par

@kapodes Should be fixed in 0.9.2! Thanks to @syvanpera awesome PR!!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kordianbruck picture kordianbruck  Â·  3Comments

vasicvuk picture vasicvuk  Â·  3Comments

steffen-geissinger-by picture steffen-geissinger-by  Â·  3Comments

ArnaudMsh picture ArnaudMsh  Â·  3Comments

cdunford picture cdunford  Â·  3Comments