usage() for os x and linux
authorFlorian Baumann <flo@noqqe.de>
Tue, 2 Nov 2010 13:50:45 +0000 (14:50 +0100)
committerFlorian Baumann <flo@noqqe.de>
Tue, 2 Nov 2010 13:50:45 +0000 (14:50 +0100)
plugins/base.plugin.bash

index 2d78028..d19b149 100644 (file)
@@ -32,12 +32,21 @@ pri() {
 
 
 # disk usage per directory
+# in Mac OS X and Linux
 usage ()
 {
-  if [ $1 ]
-  then
-    du -hd $1
-  else
-    du -hd 1
-  fi
+    if [ $(uname) = "Darwin" ]; then
+        if [ -n $1 ]; then
+            du -hd $1
+        else
+            du -hd 1
+        fi
+
+    elif [ $(uname) = "Linux" ]; then
+        if [ -n $1 ]; then
+            du -h --max-depth=1 $1
+        else
+            du -h --max-depth=1
+        fi
+    fi
 }