Mercurial > hg > cc > cirrus_home
comparison .bash_extras @ 157:cac9586291ad
no more gentoo,
split out functions into .bash_extras
| author | Henry S. Thompson <ht@inf.ed.ac.uk> |
|---|---|
| date | Mon, 04 Jul 2022 18:14:41 +0100 |
| parents | |
| children | acae526510e2 |
comparison
equal
deleted
inserted
replaced
| 156:ace590c2fdfc | 157:cac9586291ad |
|---|---|
| 1 # Sourced by .bashrc | |
| 2 | |
| 3 cu () | |
| 4 { | |
| 5 cvs update "$@" | egrep -v '^\?' | |
| 6 } | |
| 7 | |
| 8 lss () | |
| 9 { | |
| 10 /bin/ls -l "$@" | sort -nr -k 5 | |
| 11 } | |
| 12 | |
| 13 ff () | |
| 14 { | |
| 15 pat=$1; | |
| 16 shift; | |
| 17 find . -iname "*$pat*" $@ | |
| 18 } | |
| 19 | |
| 20 typecat () | |
| 21 { | |
| 22 tt=$(type $1); | |
| 23 case $tt in | |
| 24 *\ is\ hashed\ *) | |
| 25 cat $(echo $tt | cut -f 4 -d ' ' | tr -d '()') | |
| 26 ;; | |
| 27 *\ is\ /*) | |
| 28 cat $(echo $tt | cut -f 3 -d ' ' | tr -d '()') | |
| 29 ;; | |
| 30 *) | |
| 31 type $1 | |
| 32 ;; | |
| 33 esac | |
| 34 } | |
| 35 | |
| 36 sus () | |
| 37 { | |
| 38 sort "$@" | uniq -c | sort -k1nr,1 | |
| 39 } | |
| 40 | |
| 41 uz () | |
| 42 { | |
| 43 igzip -dc "$@" | |
| 44 } | |
| 45 | |
| 46 | |
| 47 function typecat () | |
| 48 { | |
| 49 tt=$(type $1) | |
| 50 case $tt in | |
| 51 *\ is\ hashed\ *) cat $(echo $tt | cut -f 4 -d ' ' | tr -d '()') ;; | |
| 52 *\ is\ /*) cat $(echo $tt | cut -f 3 -d ' ' | tr -d '()') ;; | |
| 53 *) type $1 ;; | |
| 54 esac | |
| 55 } | |
| 56 | |
| 57 function tot () | |
| 58 { | |
| 59 awk '{sum+=$1} END {printf "%u\n",sum}' | |
| 60 } | |
| 61 | |
| 62 btot () | |
| 63 { | |
| 64 python3 -c 'import sys | |
| 65 commas = False | |
| 66 if len(sys.argv)>1: | |
| 67 if sys.argv[1]=="-c": | |
| 68 commas = True | |
| 69 n=0 | |
| 70 for l in sys.stdin: | |
| 71 try: | |
| 72 n+=int(l) | |
| 73 except ValueError as e: | |
| 74 print(e,file=sys.stderr) | |
| 75 if commas: | |
| 76 print(f"{n:,}") | |
| 77 else: | |
| 78 print(n) | |
| 79 ' "$@" | |
| 80 } | |
| 81 | |
| 82 export -f cu lss ff typecat sus uz tot btot |
