diff --git a/home.nix b/home.nix index 2d65503..5c6e18f 100644 --- a/home.nix +++ b/home.nix @@ -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; diff --git a/wm/default.nix b/wm/default.nix index 071edf7..43ef99c 100644 --- a/wm/default.nix +++ b/wm/default.nix @@ -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"; }; }; }