From: Jesus de Mula Cano Date: Mon, 7 Mar 2011 00:11:20 +0000 (+0100) Subject: Check for OS type in demula theme prompt string X-Git-Url: https://source.supwisdom.com/gerrit/gitweb?a=commitdiff_plain;h=f98a728866e13520996f236b0abb4729c83a4576;p=common%2Fbash_it.git Check for OS type in demula theme prompt string --- diff --git a/plugins/battery.plugin.bash b/plugins/battery.plugin.bash index 7e77aee..db1d6f9 100644 --- a/plugins/battery.plugin.bash +++ b/plugins/battery.plugin.bash @@ -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 diff --git a/themes/demula/demula.theme.bash b/themes/demula/demula.theme.bash index 55be824..0e6744a 100644 --- a/themes/demula/demula.theme.bash +++ b/themes/demula/demula.theme.bash @@ -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}" }