From fa31fdc0f912e757c13893db71a36d25b1254948 Mon Sep 17 00:00:00 2001
From: Luca Bilke <luca@bil.ke>
Date: Wed, 6 Mar 2024 15:34:19 +0100
Subject: [PATCH] cleanup

---
 .config/lf/lfrc     | 8 ++++++++
 .local/bin/upgrades | 7 ++-----
 2 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/.config/lf/lfrc b/.config/lf/lfrc
index c1118b1b..ad20dfdb 100644
--- a/.config/lf/lfrc
+++ b/.config/lf/lfrc
@@ -213,6 +213,14 @@ cmd new_lf_term &{{
     [ -n "$TMUX" ] && previewer=ueberzug
     [ -n "$VIM" ] && previewer=chafa
     lf -remote "send $id set_previewer $previewer"
+
+    # Clean up tags that don't exist anymore
+    echo "$(
+        while read -r l; do
+            file=$(echo "$l" | cut -d ':' -f 1)
+            [ -e "$file" ] && echo "$l"
+        done <"${XDG_DATA_HOME}/lf/tags"
+    )" >"${XDG_DATA_HOME}/lf/tags"
 }}
 on-cd
 
diff --git a/.local/bin/upgrades b/.local/bin/upgrades
index 8e139589..c193d946 100755
--- a/.local/bin/upgrades
+++ b/.local/bin/upgrades
@@ -1,12 +1,9 @@
 #!/bin/sh
 
-read -r script<<EOF
-sudo xbps-install -Su
-pkill -RTMIN+8 dwmblocks
-EOF
+script="sudo xbps-install -Su; pkill -RTMIN+8 dwmblocks"
 
 if [ -n "$TERM_PROGRAM" ]; then
-    $script
+    sh -c "$script"
 else
     st -e sh -c "
         $script