1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-11-30 06:59:45 +01:00

k9s: add hotkey option (#4617)

* k9s: add hotkey option

This PR adds an option to customise k9s hotkeys.
The keyword `hotKey` must be in camel case on the user config.

* Update modules/programs/k9s.nix

Co-authored-by: Paul Meyer <49727155+katexochen@users.noreply.github.com>

* fix formatting

---------

Co-authored-by: Paul Meyer <49727155+katexochen@users.noreply.github.com>
This commit is contained in:
Li Yang 2023-11-02 04:40:14 +11:00 committed by GitHub
parent 9bc7d84b82
commit fc2a8842ea
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 46 additions and 2 deletions

View file

@ -8,7 +8,7 @@ let
yamlFormat = pkgs.formats.yaml { };
in {
meta.maintainers = [ hm.maintainers.katexochen ];
meta.maintainers = with maintainers; [ katexochen liyangau ];
options.programs.k9s = {
enable =
@ -49,6 +49,29 @@ in {
};
'';
};
hotkey = mkOption {
type = yamlFormat.type;
default = { };
description = ''
hotkeys written to
{file}`$XDG_CONFIG_HOME/k9s/hotkey.yml`. See
<https://k9scli.io/topics/hotkeys/>
for supported values.
'';
example = literalExpression ''
hotkey = {
# Make sure this is camel case
hotKey = {
shift-0 = {
shortCut = "Shift-0";
description = "Viewing pods";
command = "pods";
};
};
};
'';
};
};
config = mkIf cfg.enable {
@ -61,5 +84,9 @@ in {
xdg.configFile."k9s/skin.yml" = mkIf (cfg.skin != { }) {
source = yamlFormat.generate "k9s-skin" cfg.skin;
};
xdg.configFile."k9s/hotkey.yml" = mkIf (cfg.hotkey != { }) {
source = yamlFormat.generate "k9s-hotkey" cfg.hotkey;
};
};
}

View file

@ -0,0 +1,5 @@
hotKey:
shift-0:
command: pods
description: Viewing pods
shortCut: Shift-0

View file

@ -13,7 +13,15 @@
headless = false;
};
};
hotkey = {
hotKey = {
shift-0 = {
shortCut = "Shift-0";
description = "Viewing pods";
command = "pods";
};
};
};
skin = {
k9s = {
body = {
@ -35,8 +43,12 @@
home-files/.config/k9s/config.yml \
${./example-config-expected.yml}
assertFileExists home-files/.config/k9s/skin.yml
assertFileExists home-files/.config/k9s/hotkey.yml
assertFileContent \
home-files/.config/k9s/skin.yml \
${./example-skin-expected.yml}
assertFileContent \
home-files/.config/k9s/hotkey.yml \
${./example-hotkey-expected.yml}
'';
}