Last active
April 18, 2026 05:45
-
-
Save praeclarum/971b532f5fefa0c63c49cba69be32148 to your computer and use it in GitHub Desktop.
Fish function to recursively delete all bin and obj files in a directory
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function clean_bin_obj | |
| argparse --name clean_bin_obj 'n/dry-run' -- $argv | |
| or return $status | |
| set -l dry_run 0 | |
| if set -q _flag_n | |
| set dry_run 1 | |
| end | |
| set -l roots $argv | |
| if test (count $roots) -eq 0 | |
| set roots . | |
| end | |
| for root in $roots | |
| if not test -d $root | |
| echo "Skipping $root (not a directory)" | |
| continue | |
| end | |
| set -l matches (find "$root" -type d \( -name bin -o -name obj \)) | |
| if test (count $matches) -eq 0 | |
| continue | |
| end | |
| for dir in $matches | |
| if test $dry_run -eq 1 | |
| echo "[dry-run] Would clean $dir" | |
| continue | |
| end | |
| echo "Cleaning $dir" | |
| rm -rf "$dir" | |
| mkdir -p "$dir" | |
| dropbox_ignore "$dir" | |
| end | |
| end | |
| end | |
| function dropbox_ignore | |
| xattr -w com.dropbox.ignored 1 $argv | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment