# shorter vs code c() { if [[ $# -eq 0 ]]; then command code "$(pwd)" else command code $@ fi } # Get gzip size of file gzip-size() { local bytesize=$(gzip -c $1 | wc -c) local kbsize=$(bc -l <<< "($bytesize/1024)") local formatted=$(printf "%.2f\n" $kbsize) echo "$formatted"kb } # Create a new directory and enter it mk() { mkdir -p "$@" && cd "$@" } # get current weather # can pass a city name, airport code, etc. to specify location # (see wttr.in/:help for location possibilities) # -f flag can be set to get a 3 day forecast # usage: # weather # weather phx # weather -f London weather() { zparseopts -D -a opts -- f local argstr="$@" local location=${argstr// /+} local request="wttr.in/${location}?Fq" if (( ${opts[(Ie)-f]} )); then [ "$COLUMNS" -lt 125 ] && request+='n' else request+='0' fi curl -H "Accept-Language: ${LANG%_*}" --compressed "$request" }