# Colorful man
man() {
- LESS_TERMCAP_md=$'\e[01;31m' \
+ # mb: begin blink
+ # md: begin bold
+ # me: end bold, blink and underline
+ #
+ # so: begin standout (reverse video)
+ # se: end standout
+ #
+ # us: begin underline
+ # ue: end underline
+
+ LESS_TERMCAP_md=$'\e[01;30m' \
LESS_TERMCAP_me=$'\e[0m' \
- LESS_TERMCAP_se=$'\e[0m' \
LESS_TERMCAP_so=$'\e[01;44;33m' \
+ LESS_TERMCAP_se=$'\e[0m' \
+ LESS_TERMCAP_us=$'\e[01;33m' \
LESS_TERMCAP_ue=$'\e[0m' \
- LESS_TERMCAP_us=$'\e[01;32m' \
command man "$@"
}
cat "$(find ~/Archives/Documents/HOWTOs -mindepth 1 -maxdepth 1 | sort | fzf)"
}
-yt() {
- local _yt_uri
- local _yt_id
- local _yt_title
- local _yt_dir
-
- _yt_uri="$1"
- _yt_id=$(youtube-dl --get-id "$_yt_uri")
- _yt_title=$(youtube-dl --get-title "$_yt_uri")
- _yt_dir="${DIR_YOUTUBE}/individual-videos/${_yt_title}--${_yt_id}"
-
- mkdir -p "$_yt_dir"
- cd "$_yt_dir" || kill -INT $$
- echo "$_yt_uri" > 'uri'
- youtube-dl -c --write-description --write-info-json "$_yt_uri"
+_yt() {
+ local -r base_dir="$1"
+ local -r opts="$2"
+ local -r uri="$3"
+
+ local -r id=$(youtube-dlc --get-id "$uri")
+ local -r title=$(youtube-dlc --get-title "$uri" | sed 's/[^A-Za-z0-9._-]/_/g')
+ local -r dir="${base_dir}/${title}--${id}"
+
+ mkdir -p "$dir"
+ cd "$dir" || kill -INT $$
+ echo "$uri" > 'uri'
+ youtube-dlc $opts -c --write-description --write-info-json "$uri"
+}
+
+yt_audio() {
+ local -r uri="$1"
+ _yt "${DIR_YOUTUBE_AUDIO}/individual" '-f 140' "$uri"
+}
+
+yt_video() {
+ local -r uri="$1"
+ _yt "${DIR_YOUTUBE_VIDEO}/individual" "$uri"
}
gh_fetch_repos() {
Morning report
--------------
-### Previous
+### Prev
-### Current
+### Curr
+
+### Next
### Blockers
'') _weather_location="$WEATHER_LOCATION";;
*) _weather_location="$1"
esac
- curl "http://wttr.in/$_weather_location"
+ curl "http://wttr.in/$_weather_location?format=v2"
}
bt_devs_paired() {
notify-send -u "$urgency" "Job done: $code" "$(cat $stderr)"
rm "$stderr"
}
+
+bar_gauge() {
+ local -r width="$1"
+
+ awk -v width="$width" '
+ {
+ used = $1
+ total = $2
+
+ u = num_scale(used, total, 1, width)
+
+ printf "["
+ for (i=1; i<=width; i++) {
+ c = i <= u ? "|" : " "
+ printf "%c", c
+ }
+ printf "]\n"
+ }
+
+ function num_scale(src_cur, src_max, dst_min, dst_max) {
+ return dst_min + ((src_cur * (dst_max - dst_min)) / src_max)
+ }
+ '
+}
+
+motd() {
+ uname -srvmo
+ hostname | figlet
+ uptime
+
+ echo
+
+ printf 'mem '
+ free \
+ | awk '$1 == "Mem:" {total=$2; used=$3; print used, total}' \
+ | bar_gauge 73
+
+ printf 'disk '
+ df ~ \
+ | awk 'NR == 2 {used=$3; avail=$4; total=used+avail; print used, total}' \
+ | bar_gauge 73
+
+ case "$(uname)" in
+ 'Linux')
+ printf 'batt '
+ upower --dump \
+ | awk '
+ /^Device:[ \t]+/ {
+ device["path"] = $2
+ next
+ }
+
+ / battery/ && device["path"] {
+ device["is_battery"] = 1
+ next
+ }
+
+ / percentage:/ && device["is_battery"] {
+ device["battery_percentage"] = $2
+ sub("%$", "", device["battery_percentage"])
+ next
+ }
+
+ /^$/ {
+ if (device["is_battery"] && device["path"] == "/org/freedesktop/UPower/devices/DisplayDevice")
+ print device["battery_percentage"], 100
+ delete device
+ }
+ ' \
+ | bar_gauge 73
+ ;;
+ esac
+
+ #echo
+ # TODO: netstat summary
+ # WARN: ensure: $USER ALL=(ALL) NOPASSWD:/bin/netstat
+ #sudo -n netstat -tulpn | awk '/^udp/ && !first++ {printf "\n"} 1'
+}