searchCD, fastdu upgrade, whatismyip.. try out!
This commit is contained in:
1
bin/whatismyip
Symbolic link
1
bin/whatismyip
Symbolic link
@@ -0,0 +1 @@
|
|||||||
|
../web/whatismyip
|
||||||
36
files/fastdu
36
files/fastdu
@@ -4,6 +4,7 @@ function helpexit() {
|
|||||||
echo "Display file/folder sizes like 'du', but faster and actual byte sizes"
|
echo "Display file/folder sizes like 'du', but faster and actual byte sizes"
|
||||||
echo "Returns only the size as number"
|
echo "Returns only the size as number"
|
||||||
echo " -h Human readable units"
|
echo " -h Human readable units"
|
||||||
|
echo " -s Summary mode, otherwise each argument folder calculated separate"
|
||||||
echo " --help This help"
|
echo " --help This help"
|
||||||
exit
|
exit
|
||||||
}
|
}
|
||||||
@@ -26,14 +27,31 @@ function filesize {
|
|||||||
}' || return $?
|
}' || return $?
|
||||||
}
|
}
|
||||||
|
|
||||||
[[ -z "$1" ]] && what="."
|
function displaysize() {
|
||||||
[[ "$1" = "-h" ]] && { HUMAN=1; shift 1; }
|
SIZE=$( find "$@" -type f -printf %s"\n" | awk '{ sum += $1 } END { print int(sum)+0 }' )
|
||||||
[[ "$1" = "--help" ]] && helpexit
|
|
||||||
|
|
||||||
SIZE=$( find $what "$@" -type f -printf %s"\n" | awk '{ sum += $1 } END { print int(sum)+0 }' )
|
|
||||||
|
|
||||||
[[ "$HUMAN" -eq 1 ]] && {
|
[[ "$HUMAN" -eq 1 ]] && {
|
||||||
filesize "$SIZE"
|
SIZE=$( filesize "$SIZE" )
|
||||||
exit
|
|
||||||
}
|
}
|
||||||
echo $SIZE
|
echo "$SIZE"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Get options
|
||||||
|
what=()
|
||||||
|
for (( i=1; i<=$#; i++ )); do
|
||||||
|
[[ "${!i}" = "--help" ]] && helpexit
|
||||||
|
[[ "${!i}" = "-h" ]] && { HUMAN=1; continue; }
|
||||||
|
[[ "${!i}" = "-s" ]] && { SUMMARY=1; continue; }
|
||||||
|
what+=( "${!i}" )
|
||||||
|
done
|
||||||
|
[[ -z "${what[@]}" ]] && what="."
|
||||||
|
|
||||||
|
if [[ "$SUMMARY" -eq 1 ]]; then
|
||||||
|
# Display one line
|
||||||
|
displaysize "${what[@]}"
|
||||||
|
else
|
||||||
|
# One size for each argument
|
||||||
|
for dir in "${what[@]}"; do
|
||||||
|
printf "%s\t%s\n" "$( displaysize "$dir" )" "$dir"
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
|||||||
18
qcd_function
18
qcd_function
@@ -209,6 +209,24 @@ function ncd() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function scd() {
|
||||||
|
# search cd, find first recursively match in a folder
|
||||||
|
[[ "$1" = "-h" ]] && {
|
||||||
|
echo Search cd. First argument path to search, optionally second argument where to search from.
|
||||||
|
return
|
||||||
|
}
|
||||||
|
local cdto cdfrom
|
||||||
|
[[ -z "$2" ]] && {
|
||||||
|
cdfrom="."
|
||||||
|
} || {
|
||||||
|
cdfrom="$2"
|
||||||
|
}
|
||||||
|
cdto=$( find "$cdfrom" -mindepth 1 -type d -iname "*$1*" | sort -V | head -n 1 )
|
||||||
|
echo $cdto
|
||||||
|
[[ -z "$cdto" ]] && return
|
||||||
|
\cd "$cdto"
|
||||||
|
} # scd ends
|
||||||
|
|
||||||
## File processing functions
|
## File processing functions
|
||||||
|
|
||||||
function foldermenu_prompt {
|
function foldermenu_prompt {
|
||||||
|
|||||||
23
web/whatismyip
Executable file
23
web/whatismyip
Executable file
@@ -0,0 +1,23 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
|
||||||
|
function helpexit() {
|
||||||
|
echo "Print your public internet IP address."
|
||||||
|
echo "-n return as host name."
|
||||||
|
exit
|
||||||
|
}
|
||||||
|
for (( i=1; i<=$#; i++ )); do
|
||||||
|
[[ "${!i}" = "--help" ]] && helpexit
|
||||||
|
[[ "${!i}" = "-h" ]] && helpexit
|
||||||
|
[[ "${!i}" = "-n" ]] && { NAME=1; continue; }
|
||||||
|
done
|
||||||
|
|
||||||
|
|
||||||
|
IP=$( dig +short myip.opendns.com @resolver1.opendns.com )
|
||||||
|
|
||||||
|
if [[ "$NAME" -eq 1 ]]; then
|
||||||
|
dig +short -x "$IP"
|
||||||
|
else
|
||||||
|
echo $IP
|
||||||
|
fi
|
||||||
|
|
||||||
Reference in New Issue
Block a user