-
Notifications
You must be signed in to change notification settings - Fork 1
/
.bash_aliases.busybox
59 lines (54 loc) · 2.74 KB
/
.bash_aliases.busybox
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# vim: ft=bash noet:
! declare 2>&1 | grep -wq ^colors= && [ $BASH_VERSINFO -ge 4 ] && source $initDir/.colors
test "$debug" -gt 0 && echo "=> Running $bold${colors[blue]}$(basename ${BASH_SOURCE[0]})$normal ..."
export busybox="command busybox"
alias l="$busybox ls --color"
alias ls="$busybox ls --color -F"
#alias touch="$busybox touch"
#alias date="$busybox date"
for tool in date touch; do alias $tool="$busybox $tool";done
alias cp="$busybox cp -pv"
alias df="$busybox df -PTh"
alias du="$busybox du -h"
alias ln="$busybox ln -v"
alias mv="$busybox mv -iv"
alias rm="$busybox rm -iv"
alias chown="$busybox chown -v"
alias chmod="$busybox chmod -v"
alias ps="$busybox ps | grep -wv grep"
alias egrep="grep -E"
alias topd="\du -cxmd 1 2>/dev/null | grep -v '\s*\.$' | sort -nr | head -n"
alias topf10="$find . -xdev -type f -size +10240k -exec busybox ls -al {} + 2>/dev/null | sort -nrk5 | awk '{size=\$5/2^20;sub(\" *\"\$5,sprintf(\" %10.3fM\",size));print}' | head | awk '{total+=\$5;print}END{print\"=> total = \"total\" MiB\"}'"
alias topf50="$find . -xdev -type f -size +10240k -exec busybox ls -al {} + 2>/dev/null | sort -nrk5 | awk '{size=\$5/2^20;sub(\" *\"\$5,sprintf(\" %10.3fM\",size));print}' | head -50 | awk '{total+=\$5;print}END{print\"=> total = \"total\" MiB\"}'"
alias topf5="$find . -xdev -type f -size +10240k -exec busybox ls -al {} + 2>/dev/null | sort -nrk5 | awk '{size=\$5/2^20;sub(\" *\"\$5,sprintf(\" %10.3fM\",size));print}' | head -5' | awk '{total+=\$5;print}END{print\"=> total = \"total\" MiB\"}'"
alias topf="$find . -xdev -type f -size +10240k -exec busybox ls -al {} + 2>/dev/null | sort -nrk5 | awk '{size=\$5/2^20;sub(\" *\"\$5,sprintf(\" %10.3fM\",size));print}' | head -n | awk '{total+=\$5;print}END{print\"=> total = \"total\" MiB\"}'"
function findSeb {
local find="$(type -P find)"
local dir=$1
echo $dir | \grep -q "\-" && dir=. || shift
local args=("${@}")
if echo "${args[@]}" | \grep -q "\-ls"
then
args=("${args[@]/-ls/}")
$find $dir $firstPredicate ${args[@]} -exec busybox ls -alde {} + 2>/dev/null | awk '{
unit=" "
size=int($5)
if(size==0)exponent=0
else exponent=10*int(log(size)/(10*log(2)))
size=size/(2**exponent)
if(exponent==10)unit="K"
else if(exponent==20)unit="M"
else if(exponent==30)unit="G"
#sub($5,sprintf("%10.3f%s",size,unit))
sub(" *"$5,sprintf(" %10.3f%s",size,unit))
print
}'
else
$find $dir $firstPredicate ${args[@]}
fi
}
function topflines {
$find "$@" -xdev -type f -size +10240k -exec busybox ls -al {} + 2>/dev/null | sort -nrk5 | awk '{size=$5/2^20;sub(" *"$5,sprintf(" %10.3fM",size));print}' | head -n $(($LINES-4)) | awk '{total+=$5;print}END{if(total) print"=> total = "total" MiB"}'
}
set +x
test "$debug" -gt 0 && echo "=> END of $bold${colors[blue]}$(basename ${BASH_SOURCE[0]})$normal"