diff options
author | Adam Hovorka <[email protected]> | 2017-11-30 12:23:06 -0700 |
---|---|---|
committer | Adam Hovorka <[email protected]> | 2017-11-30 12:23:06 -0700 |
commit | 6988fb701d245d11d84bfe534f3fdf5037a57e68 (patch) | |
tree | db6607ea9ec907b994be53c0305a6e31f4b2fddb /base/zsh | |
parent | 741e8cba2f0db78182b1078d78b3c7956fb806eb (diff) |
Make human readable file sizes default in k.zsh
Diffstat (limited to 'base/zsh')
-rw-r--r-- | base/zsh/k.zsh | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/base/zsh/k.zsh b/base/zsh/k.zsh index e7dc9fb..fe80c3c 100644 --- a/base/zsh/k.zsh +++ b/base/zsh/k.zsh @@ -11,16 +11,18 @@ k () { setopt local_options null_glob typeset_silent no_auto_pushd # Process options and get files/directories - typeset -a o_all o_almost_all o_human o_si o_directory o_no_directory o_no_vcs o_help + typeset -a o_all o_almost_all o_raw o_si o_directory o_no_directory o_no_vcs o_help + #typeset -a o_all o_almost_all o_human o_si o_directory o_no_directory o_no_vcs o_help zparseopts -E -D \ a=o_all -all=o_all \ A=o_almost_all -almost-all=o_almost_all \ d=o_directory -directory=o_directory \ - h=o_human -human=o_human \ + r=o_raw -raw-size=o_raw \ -si=o_si \ n=o_no_directory -no-directory=o_no_directory \ -no-vcs=o_no_vcs \ -help=o_help + #h=o_human -human=o_human \ # Print Help if bad usage, or they asked for it if [[ $? != 0 || "$o_help" != "" ]] @@ -31,7 +33,8 @@ k () { print -u2 "\t-A --almost-all list all except . and .." print -u2 "\t-d --directory list only directories" print -u2 "\t-n --no-directory do not list directories" - print -u2 "\t-h --human show filesizes in human-readable format" + #print -u2 "\t-h --human show filesizes in human-readable format" + print -u2 "\t-r --raw-size show filesizes in byte format" print -u2 "\t --si with -h, use powers of 1000 not 1024" print -u2 "\t --no-vcs do not get VCS status (much faster)" print -u2 "\t --help show this help" @@ -47,16 +50,20 @@ k () { # Check which numfmt available (if any), warn user if not available typeset -i numfmt_available=0 typeset -i gnumfmt_available=0 - if [[ "$o_human" != "" ]]; then + #if [[ "$o_human" != "" ]]; then + if [[ "$o_raw" == "" ]]; then if [[ $+commands[numfmt] == 1 ]]; then numfmt_available=1 elif [[ $+commands[gnumfmt] == 1 ]]; then gnumfmt_available=1 else print -u2 "'numfmt' or 'gnumfmt' command not found, human readable output will not work." - print -u2 "\tFalling back to normal file size output" + #print -u2 "\tFalling back to normal file size output" + print -u2 "\tFalling back to bytewise file size output" # Set o_human to off - o_human="" + #o_human="" + # Set o_raw to on + o_raw="on" fi fi @@ -266,7 +273,8 @@ k () { if [[ ${#sv[uid]} -gt $MAX_LEN[3] ]]; then MAX_LEN[3]=${#sv[uid]} ; fi if [[ ${#sv[gid]} -gt $MAX_LEN[4] ]]; then MAX_LEN[4]=${#sv[gid]} ; fi - if [[ "$o_human" != "" ]]; then + #if [[ "$o_human" != "" ]]; then + if [[ "$o_raw" == "" ]]; then h=$(numfmt_local ${sv[size]}) if (( ${#h} > $MAX_LEN[5] )); then MAX_LEN[5]=${#h}; fi else @@ -353,7 +361,8 @@ k () { fi # Get human readable output if necessary - if [[ "$o_human" != "" ]]; then + #if [[ "$o_human" != "" ]]; then + if [[ "$o_raw" == "" ]]; then # I hate making this call twice, but its either that, or do a bunch # of calculations much earlier. FILESIZE_OUT=$(numfmt_local $FILESIZE) |