Fix patag function to rewrite tags instead of adding

- Changed patag function to drop existing tags before adding new ones
- Fixed tag parsing to properly split on '#' separator using tr command
- Tags are now stored as individual entries instead of single string
- Function now properly rewrites tags instead of adding to existing ones

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Yan Lin 2025-07-29 23:36:28 +02:00
parent 2b47bfba47
commit a061ecbdf2
2 changed files with 9 additions and 12 deletions

View file

@ -3,3 +3,4 @@
- This is my nix configuration system. Whenever you need to introduce update to my config, remember to check the current config. - This is my nix configuration system. Whenever you need to introduce update to my config, remember to check the current config.
- When you are going to introduce update to my nix config, do it on a experimental branch (use 'nightly'), and commit to that branch after you perform test to check the updates work as intended. Never work on the master branch which I will perform merge manually. - When you are going to introduce update to my nix config, do it on a experimental branch (use 'nightly'), and commit to that branch after you perform test to check the updates work as intended. Never work on the master branch which I will perform merge manually.
- After you introduce updates, remember to reflect those updates in the readme, should they bring any changes. - After you introduce updates, remember to reflect those updates in the readme, should they bring any changes.
- You can use `hms` to perform home-manager switch and `exec zsh` to refresh shell environment

View file

@ -103,7 +103,7 @@
fi fi
} }
# Papis tag function - add multiple tags using hash-separated format # Papis tag function - rewrite tags using hash-separated format
patag() { patag() {
if [ $# -ne 2 ]; then if [ $# -ne 2 ]; then
echo "Usage: patag \"tag1#tag2#tag3\" <query>" echo "Usage: patag \"tag1#tag2#tag3\" <query>"
@ -115,21 +115,17 @@
local tags_string="$1" local tags_string="$1"
local query="$2" local query="$2"
# Build --add arguments by processing each tag # First, drop all existing tags
local add_args="" papis tag --drop "$query"
local oldIFS="$IFS"
IFS='#' # Add each tag individually by splitting on #
for tag in $tags_string; do echo "$tags_string" | tr '#' '\n' | while read tag; do
# Trim whitespace # Trim whitespace
tag=$(echo "$tag" | xargs) tag=$(echo "$tag" | xargs)
if [ -n "$tag" ]; then if [ -n "$tag" ]; then
add_args="$add_args --add \"$tag\"" papis tag --add "$tag" "$query"
fi fi
done done
IFS="$oldIFS"
# Execute the papis tag command
eval "papis tag $add_args \"$query\""
} }
''; '';
} }