home
/
code
/
khome.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
fc2e11b
)
Add a cargo build space finder/counter script
author
Siraaj Khandkar
<siraaj@khandkar.net>
Fri, 6 Jan 2023 23:04:58 +0000
(18:04 -0500)
committer
Siraaj Khandkar
<siraaj@khandkar.net>
Fri, 6 Jan 2023 23:04:58 +0000
(18:04 -0500)
home/bin/cargo-space
[new file with mode: 0755]
patch
|
blob
diff --git a/home/bin/cargo-space
b/home/bin/cargo-space
new file mode 100755
(executable)
index 0000000..
624c08d
--- /dev/null
+++ b/
home/bin/cargo-space
@@ -0,0
+1,27
@@
+#! /bin/bash
+
+total_cargo_build_space() {
+ local -r dir="$1"
+
+ local cargo_toml_path
+ local target_path
+
+ find "$dir" -type f -name Cargo.toml \
+ | while read -r cargo_toml_path
+ do
+ target_path=$(dirname "$cargo_toml_path")/target;
+ if test -d "$target_path"
+ then
+ du -s "$target_path"; fi
+ done \
+ | awk '{tot += $1} END {print tot * 1024}' \
+ | numfmt --to=iec
+}
+
+main() {
+ local -r dir="${1-$HOME}"
+
+ total_cargo_build_space "$dir"
+}
+
+main "$@"
This page took
0.026711 seconds
and
4
git commands to generate.