From 0986a42450e301c82e866bf719b6a77b32fcf1d5 Mon Sep 17 00:00:00 2001 From: Jason Rogers Date: Wed, 5 Jun 2013 12:50:11 -0400 Subject: [PATCH] add TBytes.sh --- themes/jacaetevha/TBytes.sh | 18 +++++++++++++ themes/jacaetevha/fish_prompt.fish | 43 +++++++++++++++--------------- 2 files changed, 40 insertions(+), 21 deletions(-) create mode 100755 themes/jacaetevha/TBytes.sh diff --git a/themes/jacaetevha/TBytes.sh b/themes/jacaetevha/TBytes.sh new file mode 100755 index 0000000..e452d01 --- /dev/null +++ b/themes/jacaetevha/TBytes.sh @@ -0,0 +1,18 @@ +#!/bin/bash +#Sum the number of bytes in a directory listing +TBytes=0 +# swap the next two lines in order to get a summary with the sizes of directories as well +#for Bytes in $(ls -l | awk '{ print $5 }') +for Bytes in $(ls -l | grep "^-" | awk '{ print $5 }') +do + let TBytes=$TBytes+$Bytes +done + +Total=$(echo -e "scale=3 \n$TBytes/1048576 \nquit" | bc) +Units=" Mb" +if [[ TBytes -lt 1048576 ]] +then + Total=$(echo -e "scale=3 \n$TBytes/1048 \nquit" | bc) + Units=" Kb" +fi +echo -n "$Total$Units" diff --git a/themes/jacaetevha/fish_prompt.fish b/themes/jacaetevha/fish_prompt.fish index 51f613f..e5ec779 100644 --- a/themes/jacaetevha/fish_prompt.fish +++ b/themes/jacaetevha/fish_prompt.fish @@ -1,27 +1,28 @@ function fish_prompt - set_color yellow - printf '%s' (whoami) - set_color normal - printf ' at ' + set -l script_dir (dirname (status -f)) + set_color yellow + printf '%s' (whoami) + set_color normal + printf ' at ' - set_color magenta - printf '%s' (hostname|cut -d . -f 1) - set_color normal - printf ' in ' + set_color magenta + printf '%s' (hostname|cut -d . -f 1) + set_color normal + printf ' in ' - set_color $fish_color_cwd - printf '%s ' (prompt_pwd) - set_color blue - printf '%s' (/Users/jrogers/bin/TBytes.sh) - set_color normal - printf '%s' (__fish_git_prompt) + set_color $fish_color_cwd + printf '%s ' (prompt_pwd) + set_color blue + printf '%s' ($script_dir/TBytes.sh) + set_color normal + printf '%s' (__fish_git_prompt) - # Line 2 - echo - if test $VIRTUAL_ENV - printf "(%s) " (set_color blue)(basename $VIRTUAL_ENV)(set_color normal) - end - printf '↪ ' - set_color normal + # Line 2 + echo + if test $VIRTUAL_ENV + printf "(%s) " (set_color blue)(basename $VIRTUAL_ENV)(set_color normal) + end + printf '↪ ' + set_color normal end