From 69f965cdc84973f554ba077dcba8527ff0efb004 Mon Sep 17 00:00:00 2001 From: Michael Mandl Date: Mon, 16 Dec 2024 08:41:05 +0100 Subject: [PATCH] feat(zsh): select kas file on fu-build --- horsch/zsh.nix | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/horsch/zsh.nix b/horsch/zsh.nix index 4cc6a3d..407e92b 100644 --- a/horsch/zsh.nix +++ b/horsch/zsh.nix @@ -15,11 +15,35 @@ } function fu-build { - ./kas-container build kas/kas-ttc-image-horsch.yml + local fzf_preview='bat --color always --style plain {}' + + kas_file=$(find kas -maxdepth 1 -type f -name "*image*.yml" \ + | fzf --select-1 --exit-0 --header "Select a image file" --preview ''${fzf_preview}) + + if [ -z ''${kas_file} ]; then + echo "no file selected" + return 1 + fi + + ./kas-container build ''${kas_file} } function fu-build-dev { - ./kas-container build kas/kas-ttc-image-horsch-dev.yml + local fzf_preview='bat --color always --style plain {}' + + local kas_file=kas/kas-ttc-image-horsch-dev.yml + + if [ ! -f ''${kas_file} ]; then + kas_file=$(find kas -maxdepth 1 -type f -name "*image*.yml" \ + | fzf --select-1 --exit-0 --header "Select a image file" --preview ''${fzf_preview}) + fi + + if [ -z ''${kas_file} ]; then + echo "no file selected" + return 1 + fi + + ./kas-container build ''${kas_file} } function fu-reboot {