aboutsummaryrefslogtreecommitdiff
path: root/functions/rsxattr.fish
diff options
context:
space:
mode:
authorDeposite Pirate2025-10-12 13:37:46 +0200
committerDeposite Pirate2025-10-12 13:37:46 +0200
commitf671c8b0b63bc31997012f5452ec745d44549606 (patch)
treef53cb3e0c0db6c51c5d1e6d4b5cb30849b79e978 /functions/rsxattr.fish
parent91c2f0ba73d041823fbd665c4baf60fef3cf9b32 (diff)
Scripts to tame macOS noise
rsmac.fish -> recursively delete all .DS_Store files rsdos.fish -> recursively delete all user.DOSATTRIB xattrs rsxattr.fish -> recursively delete all user xattrs new file: functions/rsdos.fish new file: functions/rsmac.fish new file: functions/rsxattr.fish
Diffstat (limited to 'functions/rsxattr.fish')
-rw-r--r--functions/rsxattr.fish29
1 files changed, 29 insertions, 0 deletions
diff --git a/functions/rsxattr.fish b/functions/rsxattr.fish
new file mode 100644
index 0000000..4101890
--- /dev/null
+++ b/functions/rsxattr.fish
@@ -0,0 +1,29 @@
+function rsxattr --description 'Recursively delete all user xattrs'
+
+if not command -sq 'find'
+ echo "Can't find find."
+ return 1
+end
+
+if not command -sq 'sed'
+ echo "Can't find sed."
+ return 1
+end
+
+if not command -sq 'awk'
+ echo "Can't find awk."
+ return 1
+end
+
+if not command -sq 'setfattr'; and command -sq 'getfattr'
+ echo "Can't find xattr tools."
+ return 1
+end
+
+for file in (getfattr -R -h -d . 2>/dev/null | grep '^# file:' | sed 's/^# file: //')
+ for attr in (getfattr -m '^user\.' "$file" 2>/dev/null | awk '/^[^#]/ {print $1}')
+ setfattr -x $attr $file 2>/dev/null
+ end
+end
+
+end