From b30909b32ad0271f2dd284e4b5bbe10682cf52f0 Mon Sep 17 00:00:00 2001 From: Oliver Davies Date: Mon, 19 Aug 2024 22:18:02 +0100 Subject: [PATCH] zsh: add some suffix aliases Aliases that run when files of a matching type are opened. See https://youtu.be/8CZIv3MJvic?si=QVqtaCDNaygs2qaE&t=670. --- lib/shared/modules/zsh.nix | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lib/shared/modules/zsh.nix b/lib/shared/modules/zsh.nix index b0ce874..2d0894f 100644 --- a/lib/shared/modules/zsh.nix +++ b/lib/shared/modules/zsh.nix @@ -13,6 +13,19 @@ }; initExtra = '' + # suffix + alias -s gz="tar -tf" + alias -s {html,HTML}="background firefox" + alias -s {jpg,JPG,png,PNG}="background okular" + alias -s {pdf,PDF}="background okular" + alias -s {zip,ZIP}="unzip -l" + + background() { + for ((i=2;i<=$#;i++)); do + ''${@[1]} ''${@[$i]} &> /dev/null & + done + } + git() { if [[ "''${1}" == "root" ]]; then shift