diff --git a/themes/jacaetevha/TBytes.sh b/themes/jacaetevha/TBytes.sh deleted file mode 100755 index e452d01..0000000 --- a/themes/jacaetevha/TBytes.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/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 e5ec779..964f16d 100644 --- a/themes/jacaetevha/fish_prompt.fish +++ b/themes/jacaetevha/fish_prompt.fish @@ -1,5 +1,7 @@ function fish_prompt set -l script_dir (dirname (status -f)) + . $script_dir/tbytes.sh + set_color yellow printf '%s' (whoami) set_color normal @@ -13,7 +15,7 @@ function fish_prompt set_color $fish_color_cwd printf '%s ' (prompt_pwd) set_color blue - printf '%s' ($script_dir/TBytes.sh) + printf '%s' (tbytes) set_color normal printf '%s' (__fish_git_prompt) diff --git a/themes/jacaetevha/tbytes.fish b/themes/jacaetevha/tbytes.fish new file mode 100755 index 0000000..01f203b --- /dev/null +++ b/themes/jacaetevha/tbytes.fish @@ -0,0 +1,12 @@ +function tbytes -d 'calculates the total size of the files in the current directory' + set -g tBytes (ls -al | grep "^-" | awk 'BEGIN {i=0} { i += $5 } END { print i }') + + if test $tBytes -lt 1048576 + set -g total (echo -e "scale=3 \n$tBytes/1048 \nquit" | bc) + set -g units " Kb" + else + set -g total (echo -e "scale=3 \n$tBytes/1048576 \nquit" | bc) + set -g units " Mb" + end + echo -n "$total$units" +end