From 3824d4d797d39bd6f2dee3655027a79713ef400c Mon Sep 17 00:00:00 2001 From: Linnnus Date: Tue, 7 Nov 2023 17:37:37 +0100 Subject: home/zsh+pkgs: Add watch-while for long commands lol --- home/zsh/default.nix | 1 + home/zsh/watch-while.nix | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 home/zsh/watch-while.nix (limited to 'home/zsh') diff --git a/home/zsh/default.nix b/home/zsh/default.nix index b759b0e..e45f731 100644 --- a/home/zsh/default.nix +++ b/home/zsh/default.nix @@ -2,6 +2,7 @@ imports = [ ./plugins.nix ./editing.nix + ./watch-while.nix ]; programs.zsh = { diff --git a/home/zsh/watch-while.nix b/home/zsh/watch-while.nix new file mode 100644 index 0000000..d3d6422 --- /dev/null +++ b/home/zsh/watch-while.nix @@ -0,0 +1,20 @@ +# This module configures some ZSH aliases such that 'watch-while' is invoked +{ + pkgs, + lib, + ... +}: let + # Program to invoke for long-running commands. + pkg = pkgs.watch-while; + exec = "${pkg}/bin/watch-while"; +in { + # Alias long-running commands to their prefixed versions. These aliases are + # only loaded for interactive use, so they won't mess with scripts. + programs.zsh.shellAliases = + lib.genAttrs ["nixos-rebuild" "darwin-rebuild"] (p: "${exec} ${p}") + # Enable alias expansion after sudo with this trick. + // {"sudo" = "sudo ";}; + + # Also add the program to the environment for manual invocation. + home.packages = [pkg]; +} -- cgit v1.2.3