18e25971f4da7ef9a093ea0845308556f4e55e24
- Author
- TheEdgeOfRage <git@theedgeofrage.com>
- Committer
- TheEdgeOfRage <git@theedgeofrage.com>
- Date
Message
Add s3-size function to zsh
Diff
1diff --git a/dot_config/zsh/functions/s3-size b/dot_config/zsh/functions/s3-size
2new file mode 100644
3index 0000000000000000000000000000000000000000..257929519a1c650f19c3c603e4264664a608ec7e
4--- /dev/null
5+++ b/dot_config/zsh/functions/s3-size
6@@ -0,0 +1,10 @@
7+# vim: ft=zsh
8+
9+if (( $# != 1 )) || [[ "$1" != s3://* ]]; then
10+ print -u2 -- "Usage: s3-size s3://bucket/prefix"
11+ return 2
12+fi
13+
14+setopt localoptions pipefail
15+command aws s3 ls "$1" --recursive --summarize --human-readable |
16+ awk '/Total Size:/ { sub(/^[[:space:]]*/, ""); print }'