Introduce ssh picker

This commit is contained in:
Quentin Boyer 2022-10-04 18:41:10 +02:00
parent 90fd6dc35e
commit 817d89e4e7
2 changed files with 26 additions and 0 deletions

View file

@ -68,12 +68,37 @@ in {
zoxide = {
enable = true;
};
ssh = {
enable = true;
matchBlocks = {
};
};
};
home.file = {
"bin" = {
source = ./scripts;
recursive = true;
};
"bin/ssh-picker" = let
ssh_hosts = builtins.attrNames config.programs.ssh.matchBlocks;
ssh_specific = builtins.filter (h: !(lib.strings.hasInfix "*" h)) ssh_hosts;
ssh_specific_echo = builtins.map (h: "echo ${h}") ssh_specific;
picker =
if config.wm.kind == "sway"
then "${pkgs.wofi}/bin/wofi -S dmenu"
else "${pkgs.rofi}/bin/rofi -dmenu";
in {
text = ''
#!/usr/bin/env bash
{
${lib.strings.concatStringsSep "\n" ssh_specific_echo}
} | ${picker} | xargs ${config.terminal.command} ssh
'';
executable = true;
};
".zfunc" = {
source = ./zfunc;
recursive = true;

View file

@ -171,6 +171,7 @@
"${mod}+Return" = "exec ${config.terminal.command}";
"${mod}+p" = "mode resize";
"${mod}+Shift+P" = "restart";
"${mod}+Shift+S" = "exec ~/bin/ssh-picker";
};
};
}