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:
parent
2b47bfba47
commit
a061ecbdf2
2 changed files with 9 additions and 12 deletions
|
|
@ -2,4 +2,5 @@
|
|||
|
||||
- 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.
|
||||
- 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
|
||||
|
|
|
|||
|
|
@ -103,7 +103,7 @@
|
|||
fi
|
||||
}
|
||||
|
||||
# Papis tag function - add multiple tags using hash-separated format
|
||||
# Papis tag function - rewrite tags using hash-separated format
|
||||
patag() {
|
||||
if [ $# -ne 2 ]; then
|
||||
echo "Usage: patag \"tag1#tag2#tag3\" <query>"
|
||||
|
|
@ -115,21 +115,17 @@
|
|||
local tags_string="$1"
|
||||
local query="$2"
|
||||
|
||||
# Build --add arguments by processing each tag
|
||||
local add_args=""
|
||||
local oldIFS="$IFS"
|
||||
IFS='#'
|
||||
for tag in $tags_string; do
|
||||
# First, drop all existing tags
|
||||
papis tag --drop "$query"
|
||||
|
||||
# Add each tag individually by splitting on #
|
||||
echo "$tags_string" | tr '#' '\n' | while read tag; do
|
||||
# Trim whitespace
|
||||
tag=$(echo "$tag" | xargs)
|
||||
if [ -n "$tag" ]; then
|
||||
add_args="$add_args --add \"$tag\""
|
||||
papis tag --add "$tag" "$query"
|
||||
fi
|
||||
done
|
||||
IFS="$oldIFS"
|
||||
|
||||
# Execute the papis tag command
|
||||
eval "papis tag $add_args \"$query\""
|
||||
}
|
||||
'';
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue