[Linux] Extract #hashtags and use them to tag files

In Linux we have file managers (I use Dolphin by KDE) that can organize files and folders using tags, so I decided to tag my Logseq files according to the hashtags they contain.

I have written this simple script:

#!/bin/bash
for i in grep -o '#[a-zA-Z0-9_]\+' "$1" | tr ' ' '\n' | sort | uniq | more | cut -c2-
do
    tagctl -xt "$i" "$1"
    kdialog --icon tag-new --title "$1" --passivepopup "$i"
done

that takes a file as an input, look for hashtags (using grep), apply each of them to that file (using tagctl) and show a notification (using kdialog).

tagctl can be installed from here: Kody VB / tagctl · GitLab

Now I can browse my Logseq files by tag or by multiple tags at once directly from my file browser:

Let me know if you need more help setting up this.