cac982eccdc6930714e5472e5bfbbd18679c0fbe
4 local -r word
=$
(fzf
< /usr
/share
/dict
/words
)
8 shell_activity_report
() {
9 # TODO: optional concrete number output
10 # TODO: manual weekday calc (since forking date is so expensive)
11 # TODO: optional combinations of granularities: hour, weekday, month, year
18 echo "Usage: $0 [mon|dow]" >&2
22 |
awk -v group_by
="$group_by" '
23 function date2dow(y, m, d, _t, _i) {
25 # y > 1752, 1 <= m <= 12.
28 # https://en.wikipedia.org/wiki/Determination_of_the_day_of_the_week#Sakamoto%27s_methods
42 _i = int(y + y/4 - y/100 + y/400 + _t[m - 1] + d) % 7
43 _i = _i == 0 ? 7 : _i # Make Sunday last
49 # NOTE: $2 & $3 are specific to oh-my-zsh history output
52 d_fields = split(date, d, "-")
53 t_fields = split(time, t, ":")
54 if (t_fields && d_fields) {
55 # +0 to coerce number from string
60 dow = date2dow(year, month, day)
61 g = group_by == "mon" ? month : dow # dow is default
90 n = group_by == "mon" ? 12 : 7 # dow is default
92 for (gid = 1; gid <= n; gid++) {
93 group = group_by == "mon" ? m[gid] : w[gid]
95 for (hour=0; hour<24; hour++) {
98 for (i = 1; i <= (c * 100) / max; i++)
115 print count[cmd], cmd
122 c = count[NR] = $1 + 0 # + 0 to coerce number from string
128 for (i = 1; i <= NR; i++) {
130 printf "%s %d ", cmd[i], c
131 scaled = (c * 100) / max
132 for (j = 1; j <= scaled; j++)
140 # Top Disk-Using directories
141 # TODO: Consider using numfmt instead of awk
150 sub("^" $1 "\t+", "", path)
151 gb = size / 1024 / 1024
152 printf("%f\t%s\n", gb, path)
157 # Top Disk-Using Files
159 find "$1" -type f
-printf '%s\t%p\0' \
160 |
sort -z -n -k 1 -r \
166 sub("^" $1 "\t+", "", path)
167 gb = size / 1024 / 1024 / 1024
168 printf("%f\t%s\n", gb, path)
172 # Most-recently modified file system objects
175 # - intentionally not quoting the parameters, so that some can be ignored
176 # if not passed, rather than be passed to find as an empty string;
177 # - %T+ is a GNU extension;
178 # - gawk is able to split records on \0, while awk cannot.
179 find $@
-printf '%T@ %T+ %p\0' \
180 |
tee >(gawk
-v RS
='\0' 'END { printf("[INFO] Total found: %d\n", NR); }') \
181 |
sort -z -k 1 -n -r \
182 |
head -n "$(stty size | awk 'NR == 1 {print $1 - 5}')" -z \
185 sub("^" $1 " +", "") # Remove epoch time
186 sub("+", " ") # Blank-out the default separator
187 sub("\\.[0-9]+", "") # Remove fractional seconds
201 pactl info |
awk '/^Default Sink:/ {print $3}'
205 curl
"https://xq-api.voidlinux.org/v1/query/x86_64?q=$1" | jq
'.data'
210 LESS_TERMCAP_md
=$
'\e[01;31m' \
211 LESS_TERMCAP_me
=$
'\e[0m' \
212 LESS_TERMCAP_se
=$
'\e[0m' \
213 LESS_TERMCAP_so
=$
'\e[01;44;33m' \
214 LESS_TERMCAP_ue
=$
'\e[0m' \
215 LESS_TERMCAP_us
=$
'\e[01;32m' \
220 cd "$(~/bin/experiment $@)" ||
exit 1
224 ledit
-l "$(stty size | awk '{print $2}')" ocaml $@
228 cat "$(find ~/Archives/Documents/HOWTOs -mindepth 1 -maxdepth 1 | sort | fzf)"
238 _yt_id
=$
(youtube-dl
--get-id "$_yt_uri")
239 _yt_title
=$
(youtube-dl
--get-title "$_yt_uri")
240 _yt_dir
="${DIR_YOUTUBE}/individual-videos/${_yt_title}--${_yt_id}"
243 cd "$_yt_dir" ||
exit 1
244 echo "$_yt_uri" > 'uri'
245 youtube-dl
-c --write-description --write-info-json "$_yt_uri"
249 curl
"https://api.github.com/$1/$2/repos?page=1&per_page=10000"
255 gh_dir
="${DIR_GITHUB}/${gh_user_name}"
257 cd "$gh_dir" ||
exit 1
258 gh_fetch_repos
"$gh_user_type" "$gh_user_name" \
259 | jq
--raw-output '.[] | select(.fork | not) | .git_url' \
265 gh_clone
'users' "$1"
273 gh_username
=$
(echo "$1" |
awk -F / '"$1 == "https" && $3 == github.com" {print $4}')
274 gh_dir
="${DIR_GITHUB}/${gh_username}"
276 cd "$gh_dir" ||
exit 1
280 work_log_template
() {
300 mkdir
-p "$DIR_WORK_LOG"
301 file_work_log_today
="${DIR_WORK_LOG}/$(date +%F).md"
302 if [ ! -f "$file_work_log_today" ]
304 work_log_template
> "$file_work_log_today"
306 vim
-c 'set spell' "$file_work_log_today"
311 mkdir
-p "$DIR_NOTES"
312 vim
-c 'set spell' "$DIR_NOTES/$(date +'%Y_%m_%d--%H_%M_%S%z')--$1.md"
316 curl
"http://wttr.in/$WEATHER_LOCATION"
320 bluetoothctl
-- paired-devices \
322 |
xargs bluetoothctl
-- info
326 bluetoothctl
-- devices \
328 |
xargs bluetoothctl
-- info
333 $@
2> >(tee "$stderr")
337 0) urgency
='normal';;
338 *) urgency
='critical'
340 notify-send
-u "$urgency" "Job done: $code" "$(cat $stderr)"
This page took 0.113776 seconds and 4 git commands to generate.