Check for OS type in demula theme prompt string
authorJesus de Mula Cano <demula@gmail.com>
Mon, 7 Mar 2011 00:11:20 +0000 (01:11 +0100)
committerJesus de Mula Cano <demula@gmail.com>
Mon, 7 Mar 2011 00:11:20 +0000 (01:11 +0100)
plugins/battery.plugin.bash
themes/demula/demula.theme.bash

index 7e77aee..db1d6f9 100644 (file)
@@ -1,5 +1,5 @@
 #!/bin/bash
-# pmset -g batt
+
 battery_percentage(){
   if command_exists acpi;
   then
@@ -21,6 +21,11 @@ battery_percentage(){
         echo '-1'
         ;;
     esac
+  elif command_exists ioreg;
+  then
+    # http://hints.macworld.com/article.php?story=20100130123935998
+    local IOREG_OUTPUT_10_6=$(ioreg -l | grep -i capacity | tr '\n' ' | ' | awk '{printf("%.2f%%", $10/$5 * 100)}')
+    local IOREG_OUTPUT_10_5=$(ioreg -l | grep -i capacity | grep -v Legacy| tr '\n' ' | ' | awk '{printf("%.2f%%", $14/$7 * 100)}')
   else
     echo "no"
   fi
index 55be824..0e6744a 100644 (file)
@@ -89,7 +89,9 @@ prompt() {
   local MOVE_CURSOR_RIGHTMOST='\[\033[500C\]'
   local MOVE_CURSOR_5_LEFT='\[\033[5D\]'
 
-  PS1="${TITLEBAR}
+  if [ $(uname) = "Linux" ];
+  then
+    PS1="${TITLEBAR}
 ${SAVE_CURSOR}${MOVE_CURSOR_RIGHTMOST}${MOVE_CURSOR_5_LEFT}\
 $(battery_charge)${RESTORE_CURSOR}\
 ${D_USER_COLOR}\u ${D_INTERMEDIATE_COLOR}\
@@ -99,7 +101,18 @@ $(mitsuhikos_lastcommandfailed)\
 $(demula_vcprompt)\
 $(is_vim_shell)
 ${D_INTERMEDIATE_COLOR}$ ${D_DEFAULT_COLOR}"
-  
+  else
+    PS1="${TITLEBAR}
+${D_USER_COLOR}\u ${D_INTERMEDIATE_COLOR}\
+at ${D_MACHINE_COLOR}\h ${D_INTERMEDIATE_COLOR}\
+in ${D_DIR_COLOR}\w ${D_INTERMEDIATE_COLOR}\
+$(mitsuhikos_lastcommandfailed)\
+$(demula_vcprompt)\
+$(is_vim_shell)\
+$(battery_charge)
+${D_INTERMEDIATE_COLOR}$ ${D_DEFAULT_COLOR}"
+  fi
+
   PS2="${D_INTERMEDIATE_COLOR}$ ${D_DEFAULT_COLOR}"
 }