mirror of
https://github.com/oh-my-fish/oh-my-fish
synced 2024-11-03 15:40:32 +00:00
port TBytes.sh to tbytes.fish
This commit is contained in:
parent
0986a42450
commit
0ecde036f4
@ -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"
|
@ -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)
|
||||
|
||||
|
12
themes/jacaetevha/tbytes.fish
Executable file
12
themes/jacaetevha/tbytes.fish
Executable file
@ -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
|
Loading…
Reference in New Issue
Block a user