1
1
Fork 0
mirror of https://github.com/tonydamage/nux-env.git synced 2025-12-11 13:24:28 +01:00

Added listing support to mark

This commit is contained in:
Tony Tkáčik 2024-10-18 16:15:03 +02:00
parent 0e8835ca30
commit 9987f1759c

View file

@ -126,6 +126,43 @@ MARK_PREFIX=""
--draw-tinted "$@"
}
## unmarked:: mark [file+]
## List files, which are not marked by particular mark
## Note that this assumes current filename is same
## TODO: Add support for different filenames in future
##
@command unmarked mark {
mark_root=$(mark.dir $pwd)
nux.log debug $(mark.dir $pwd) $mark_root;
for path in "$@"; do
nux.log debug "Checking file $path";
name=${path##*/};
marks="$(mark.marks-for-path "$mark_root" "$mark" "$path")"
nux.log debug "$path has '$marks'";
if [ -z "$marks" ]; then
echo $path;
fi
done
}
## unmarked:: mark [file+]
## List files, which are not marked by particular mark
## Note that this assumes current filename is same
## TODO: Add support for different filenames in future
##
@command list {
mark_root=$(mark.dir $pwd)
nux.log debug $(mark.dir $pwd) $mark_root;
for path in "$@"; do
nux.log debug "Checking file $path";
name=${path##*/};
marks="$(mark.marks-for-path "$mark_root" "$mark" "$path")"
for m in ${marks}; do
fs:info "$path" "$m"
done
done
}
@namespace mark. {
function :dir item {
@ -148,4 +185,13 @@ MARK_PREFIX=""
fs:symlink "$item" "$root/$mark" "$name"
}
function :marks-for-path root mark path {
name=${path##*/};
find "$root/$mark" -iname "$name" 2> /dev/null | while read mark; do
m="${mark#$root/}"
m="${m%/*}";
echo "$m";
done
}
}