1
0
mirror of https://github.com/RyanGreenup/cadmus.git synced 2025-08-06 14:16:33 +02:00

Modified TagFilter Logic to be more robust

This commit is contained in:
Ryan Greenup
2020-07-17 02:56:29 +10:00
parent 4c34cde2e6
commit 9bd277d9e9

View File

@@ -1,7 +1,11 @@
#!/usr/bin/env bash #!/usr/bin/env bash
readonly script_name=$(basename "${0}") readonly script_name=$(basename "${0}")
readonly script_dir=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) readonly script_dir=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
readonly NOTES_DIR="$HOME/Notes/MD/notes" if [[ "${1:-}" != "" ]]; then
readonly NOTES_DIR="${1}"
else
readonly NOTES_DIR="./"
fi
function main() { function main() {
@@ -11,7 +15,7 @@ function main() {
checkDependencies checkDependencies
regenTags regenTags
ConcurrentTags=$(tmsu tags) ConcurrentTags="$(tmsu tags)"
FilterTags FilterTags
makeSymlinks makeSymlinks
@@ -110,12 +114,13 @@ function openMatches() {
} }
FilterTags() { FilterTags() {
ChosenTags="$ChosenTags $(echo "$ConcurrentTags" | fzf)" chooseValue=$(echo "$ConcurrentTags" | fzf)
ChosenTags=$(echo -e ""$ChosenTags"\n"$chooseValue"")
ChosenTags="$ChosenTags "
MatchingFiles=$(tmsu files "$ChosenTags") MatchingFiles=$(tmsu files "$ChosenTags")
ConcurrentTags=$(tmsu tags $MatchingFiles | cut -f 2 -d ':' | space2NewLine | sort | uniq | sort -nr ) ConcurrentTags=$(tmsu tags $MatchingFiles | cut -f 2 -d ':' | space2NewLine | sort | uniq | sort -nr )
ChosenTags=$(echo "$ChosenTags" | space2NewLine | sort -u ) ChosenTags=$(echo "$ChosenTags" | space2NewLine | sort -u )
ConcurrentTags=$(comm -13 <(echo "$ChosenTags" | sort) <(echo "$ConcurrentTags" | sort)) ConcurrentTags="$(comm -13 <(echo "$ChosenTags" | sort) <(echo "$ConcurrentTags" | sort))"
echo -e " echo -e "