nixos-config/pkgs/shell-menu.nix

21 lines
454 B
Nix

{ pkgs, ... }:
pkgs.writeScript "tmux-menu" ''
s="$(${pkgs.tmux}/bin/tmux ls 2>/dev/null)"
[ "$s" ] && s="$s
"
c=$(${pkgs.fzf}/bin/fzf -1 <<-EOF
''${s}New Session
Raw Shell
EOF
) || exit
case "$c" in
"New Session")
read -p "Name? " -r n
${pkgs.tmux}/bin/tmux new -s "$n" ;;
"Raw Shell")
${pkgs.bashInteractive}/bin/bash --login ;;
*)
${pkgs.tmux}/bin/tmux attach-session -t "''${c%%:*}" ;;
esac
''