-
Notifications
You must be signed in to change notification settings - Fork 4
/
aliases
1072 lines (843 loc) · 48.4 KB
/
aliases
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# This probably wants to go in ~/.oh-my-zsh/custom/aliases.zsh
echo "•••••••••• Loading aliases ••• $(date "+%a %b %d %H:%M:%S") "
# Generally helpful
alias hg="history | grep"
alias g="gcalcli"
alias be="bundle exec"
alias pomo="pomodoro"
alias vi="nvim"
alias vim="nvim"
# Navigation
alias vscode-global="cd ~/Library/Application\ Support/Code/User/"
alias dotrot="cd ~/workspace/dot-rot"
# Some alias / shell housekeeping
alias zr="source ~/.zshrc"
alias ze="code ~/.zshrc"
alias za="code ~/.oh-my-zsh/custom/aliases.zsh"
# An alias for dvorak typists
alias aoeu='asdf'
# Some todo apps
alias t='reminders'
alias ta='reminders add'
alias td='reminders complete Reminders'
alias rsl='reminders show-lists'
alias tl='reminders show Reminders'
# `Now.md` convenience methods
export FOAM_HOME=~/workspace/foam
alias todos="ack '^.[^|\[]\[[^x]\]\s\w' ~/workspace/foam/now.md -C2"
alias prev-todos="ack '^.[^|\[]\[[^x]\]\s\w' prev.md -C2"
alias h2s="ack '^\#{2}\s' ~/workspace/foam/now.md -C1"
alias projects-w-context="ack '(\+\+\w.*)' ~/workspace/foam/now.md --output '$1'"
alias projects="ack -o '\+\+\w+' ~/workspace/foam/now.md | sort | uniq"
alias prev-projects="ack '(\+\+\w.*)' ~/workspace/foam/prev.md --output '$1'"
alias foam="cd ~/workspace/foam"
alias frogs="ack '🐸' ~/workspace/foam/todo.md | sort"
alias nitty="ack '🧹' ~/workspace/foam/todo.md | sort"
alias cherry="ack '🍒' ~/workspace/foam/todo.md | sort"
# Github CLI
alias ttl="pmtl \n\n && gordtl \n\n && ghtl"
##################### ██████╗ ███╗ ███╗████████╗██╗ Product Management Task List
##################### ██╔══██╗████╗ ████║╚══██╔══╝██║
##################### ██████╔╝██╔████╔██║ ██║ ██║
##################### ██╔═══╝ ██║╚██╔╝██║ ██║ ██║
##################### ██║ ██║ ╚═╝ ██║ ██║ ███████╗
##################### ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚══════╝
function pmtl() {
local headers="|Order | Status | Title | Project | Link|\n|---|---|---|---|---|"
local result=$(gh p item-list 36 --limit 300 --format=json | jq -r '(.items | to_entries | map(select((.value.status == "In progress" or .value.status == "Backlog" or .value.status == "Waiting")))) | .[] | "| \(.key+1) | \(.value.status) | \(.value.title) | \(.value["project 🪚"]) | \((.value.content.repository | split("/")[-1]) + "/" + (.value.content.number|tostring)) |"')
echo -e "### SL PM Tasks"
echo -e "$headers"
echo "$result"
echo -e "$headers\n$result" | pbcopy
}
####################################################################################
####################################################################################
####################################################################################
####################################################################################
####################################################################################
################## ******* **** **** ********** ** ** ******* ******
################## /**////**/**/** **/**/////**/// /** /**/**////**/*////**
################## /** /**/**//** ** /** /** /** /**/** /**/* /**
################## /******* /** //*** /** /** /** ***** /**/******* /******
################## /**//// /** //* /** /** /** ///// /**/**//// /*//// **
################## /** /** / /** /** /** ** /**/** /* /**
################## /** /** /** /** /******** //***** /** /*******
################## // // // // //////// ///// // ///////
function pmtl-jpb() {
local headers="|Order | Status | Title | Project | Link|\n|---|---|---|---|---|"
local result=$(gh p item-list 36 --limit 300 --format=json | jq -r '(.items | to_entries | map(select((.value.status == "In progress" or .value.status == "Backlog" or .value.status == "Waiting") and (.value.assignees[]? | contains("jonathanpberger"))))) | .[] | "| \(.key+1) | \(.value.status) | \(.value.title) | \(.value["project 🪚"]) | \((.value.content.repository | split("/")[-1]) + "/" + (.value.content.number|tostring)) |"')
echo -e "### SL PM Tasks for JPB"
echo -e "$headers"
echo "$result"
echo -e "$headers\n$result" | pbcopy
}
# ######### this works
#
# function gordtl() {
# local headers="|Title|Status|url|Assignees|\n|--|--|--|--|"
# local result=$(gh p item-list 47 --limit 22 --format=json | jq -r '.items[] | "| \(.title) | \(.status) |\(.content.url) | \(.assignees // [] | if type == "array" then map(if type == "object" then .login else . end) else [] end | join(", ")) |"')
# echo -e "### Gordian Tasks"
# echo -e "$headers"
# echo "$result"
# echo -e "$headers\n$result" | pbcopy
# }
# #########
######################## ██████╗ ██████╗ ██████╗ ██████╗ ████████╗██╗ Gordian Task List
######################## ██╔════╝ ██╔═══██╗██╔══██╗██╔══██╗╚══██╔══╝██║
######################## ██║ ███╗██║ ██║██████╔╝██║ ██║ ██║ ██║
######################## ██║ ██║██║ ██║██╔══██╗██║ ██║ ██║ ██║
######################## ╚██████╔╝╚██████╔╝██║ ██║██████╔╝ ██║ ███████╗
######################## ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚═════╝ ╚═╝ ╚══════╝
function gordtl() {
echo "Version 0.42"
local headers="|Order|Status|Title|URL|Assignees|\n|--|--|--|--|--|"
local result=$(gh p item-list 47 --format=json | jq -r '.items | to_entries[] | "| \(.key + 1) | \(.value.status) | \(.value.title) | \(.value.content.url) | \(.value.assignees // [] | if type == "array" then map(if type == "object" then .login else . end) else [] end | join(", ")) |"')
local count=$(echo "$result" | wc -l | tr -d ' ')
echo -e "### Gordian Tasks"
echo -e "$headers\n$result"
echo -e "$headers\n$result" | pbcopy
echo -e "\n\n********* Gordian Tasks have been copied to the clipboard. There are $count tasks. :-) ###\n"
}
################# ██████╗ ██╗ ██╗████████╗██╗ Github Task List
################# ██╔════╝ ██║ ██║╚══██╔══╝██║ Map this to whichever project is top priority.
################# ██║ ███╗███████║ ██║ ██║
################# ██║ ██║██╔══██║ ██║ ██║
################# ╚██████╔╝██║ ██║ ██║ ███████╗
################# ╚═════╝ ╚═╝ ╚═╝ ╚═╝ ╚══════╝
function ghtl() {
local headers="|Order | Status | Title | url|"
local separators="|$(echo "$headers" | sed 's/[^|]//g' | sed 's/|/---|/g' | sed 's/|$//')"
local result=$(gh p item-list 46 --limit 300 --format=json | jq -r '(.items | to_entries | map(select((.value.status == "In progress" or .value.status == "Backlog" or .value.status == "Waiting") and (.value.assignees[]? | contains("jonathanpberger"))))) | .[] | "| \(.key+1) | \(.value.status) | \(.value.title) | \((.value.content.repository | split("/")[-1]) + "/" + (.value.content.number|tostring)) |"')
echo -e "### README.lint Tasks"
echo -e "$headers"
echo -e "$separators"
echo "$result"
echo -e "$headers\n$result" | pbcopy
}
#################### ██████╗ ██╗ ██╗██╗
#################### ██╔════╝ ██║ ██║██║
#################### ██║ ███╗███████║██║
#################### ██║ ██║██╔══██║██║
#################### ╚██████╔╝██║ ██║██║
#################### ╚═════╝ ╚═╝ ╚═╝╚═╝
function ghi() {
local user=$(gh api /user | jq -r '.login')
local header="| Repository | Number | State | Title |url|"
local separator="|------------|--------|-------|-----|--|"
local results=$(gh search issues --assignee=@me --state=open --limit 333 --include-prs --json="repository,number,state,title,url" | jq -r '.[] | "| \(.repository.name) | \(.number) | \(.state) | \(.title) | \(.url) |"')
local count=$(echo "$results" | wc -l | tr -d ' ')
local title="### $count Open GitHub Issues for @$user"
echo "$title"
echo "$header"
echo "$separator"
echo "$results"
echo -e "$title\n$header\n$separator\n$results" | pbcopy
echo -e "\n$title have been copied to the clipboard. There are $count issues. :-) ###"
}
function ghepic() {
local user=$(gh api /user | jq -r '.login')
local header="| EPIC |url|"
local separator="|---|---|"
local results=$(gh search issues --assignee=@me --state=open --limit 333 --include-prs --json="repository,number,state,title,url" | jq -r '.[] | "| \(.title) | \(.url) |"' | grep EPIC)
local count=$(echo "$results" | wc -l | tr -d ' ')
local title="### $count Open GitHub Issues for @$user"
echo "$title"
echo "$header"
echo "$separator"
echo "$results"
echo -e "$title\n$header\n$separator\n$results" | pbcopy
echo -e "\n$title have been copied to the clipboard. There are $count Epics. :-) ###"
}
function ghi2() {
gh search issues --assignee=@me --state=open
}
############ ██████╗ ██████╗ █████╗ ██╗ ██╗ ANSI Shadow
############ ██╔════╝ ██╔══██╗██╔══██╗╚██╗ ██╔╝
############ ██║ ███╗██║ ██║███████║ ╚████╔╝
############ ██║ ██║██║ ██║██╔══██║ ╚██╔╝
############ ╚██████╔╝██████╔╝██║ ██║ ██║
############ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝
############ TODO: extend lines in 30m increments, by duration
############ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝
########################################
# ChatGPT Pseudo-code
## Header Creation: Generates a header for the output, including the current date and week number (for Mondays).
#
## Table Headers: Prepares headers for the table that will display the calendar events.
#
## Fetching Calendar Data: Uses gcalcli to fetch today's agenda from Google Calendar. The --details length flag is used to include the duration of each event.
#
## Emoji Mapping: Defines a map of emojis for different times of the day. This is used to add a visual cue (emoji) to each event based on its start time.
#
## Processing Calendar Output: The main part of the script processes the output from gcalcli. It involves several steps:
#
## Removing ANSI color codes for plain text processing.
## Parsing each line to extract the time, duration, and description of events.
## Adding an emoji to the event if it doesn't start with one.
## Converting the event duration from hours and minutes to a total in minutes.
## Storing the processed information for each event.
## Expanding Events Longer than 30 Minutes: For events longer than 30 minutes, the script splits them into multiple 30-minute blocks. It uses a custom function add_pomodoro to increment the time by 30 minutes for each block.
#
## Handling Pomodoros and Event Conflicts: The script aims to remove pomodoro (🍅) events that conflict with longer events. This step seems to need refinement based on the issues you're experiencing.
#
## Final Output Assembly: Constructs the final output table with the processed event data.
## ------------
## # Gday is a script to integrate my gCal with my daily notes. To help organize my time, the day should be broken into pomodoros wheverer I don't have existing appointments
## As JPB
## I want to connect my gCal to my daily notes
## Because I prefer to work in plaintext and markdown
## When I run gday
## Then all my gcal appointments should come in
## And any appointments longer than a pomodoro should be broken into 30m chunks
## And any appointments without an emoji should be assigned one based on their start time
## And their emoji should be duplicated for each chunk, ie the first Most Important Thing should start with 👑 and the second with 👑👑, etc
## And any unscheduled time should be broken into pomodoros
## And any pomodoros that conflict with other events should be removed
## ## Pseudo-code
## - Create Table Headers and define clock Emoji Map
## - Fetch Calendar Data from Google Calendar
## - Remove ANSI color codes from Cal data
## - extract time, duration, and description of events from each line of Cal data
## - Add clock emoji to Cal data lines lacking emoji
## - Expand Events Longer than 30 Minutes into multiple lines, 30m each
## - Remove Pomodoro lines that conflict with other events
## - Render the final markdown table
#
########################################
########################################
########################################
########################################
function gday-neo() {
## 0.1 Create Table Headers
local date=$(date '+%m/%d - %A')
echo "Welcome to GDAY-NEO for $date"
processed_output+="# $date\n\n## 🪢 Todo Today\n"
processed_output+="| Time | Item | - |\n"
processed_output+="|---------|--------------------------------------------------|-----------------|\n"
## 0.2 Define clock Emoji Map
local -A emoji_map
emoji_map=( ["00"]="🕛" ["30"]="🕧" ["01"]="🕐" ["31"]="🕜" ["02"]="🕑" ["32"]="🕝"
["03"]="🕒" ["33"]="🕞" ["04"]="🕓" ["34"]="🕟" ["05"]="🕔" ["35"]="🕠"
["06"]="🕕" ["36"]="🕡" ["07"]="🕖" ["37"]="🕢" ["08"]="🕗" ["38"]="🕣"
["09"]="🕘" ["39"]="🕤" ["10"]="🕙" ["40"]="🕥" ["11"]="🕚" ["41"]="🕦" )
## 1. Fetch & sanitize Calendar Data from Google Calendar
local calendar_data=$(gcalcli --cal "JPB-DW" --cal "Pomo" --cal "JPB SL" --cal "JPB Private" agenda "1am today" "11pm today" --nocolor --no-military --details length --tsv)
# give a count of lines in calendar_data
calendar_data_lines=$(echo "$calendar_data" | wc -l)
# set a new var calendar_data_sifted to remove any pomodoro rows with a start time we've already seen in another row. Preserve the initial order of the rows
# Initial results
# 2024-04-29 00:00 2024-04-30 00:00 Home
# 2024-04-29 06:30 2024-04-29 08:45 get the kids up and out
# 2024-04-29 08:30 2024-04-29 09:00 🍅
# 2024-04-29 08:45 2024-04-29 09:00 🐸 15m of Monarch categorization
# 2024-04-29 09:00 2024-04-29 09:30 🍅
# 2024-04-29 09:00 2024-04-29 09:30 🪢 Todo today
# 2024-04-29 09:15 2024-04-29 09:30 Check slack for open dYdX proposals which need to be voted on (search term: `in:#govstatements-votes dydx "new proposal"`)
# 2024-04-29 09:30 2024-04-29 10:00 🍅
# 2024-04-29 09:30 2024-04-29 10:00 🪢📆 JPB IPM
# 2024-04-29 10:00 2024-04-29 10:30 🍅
# 2024-04-29 10:00 2024-04-29 10:30 JPB and Alix Keller
# 2024-04-29 10:30 2024-04-29 11:00 🍅
# 2024-04-29 10:30 2024-04-29 11:00 🐸 Eat 3 frogs
# 2024-04-29 11:00 2024-04-29 11:30 🍅
# 2024-04-29 11:00 2024-04-29 11:20 Infra Standup
# 2024-04-29 11:30 2024-04-29 12:00 🍅
# 2024-04-29 12:00 2024-04-29 12:30 🍅
# 2024-04-29 12:00 2024-04-29 12:30 🌎 Weekly SPoG review
# 2024-04-29 12:00 2024-04-29 13:00 Strangelove Family Mgmt Weekly
# 2024-04-29 12:00 2024-04-29 12:55 Art of Action Stand-up V6 (weekly)
# 2024-04-29 12:30 2024-04-29 13:00 🍅
# 2024-04-29 13:00 2024-04-29 13:30 🍅
# 2024-04-29 13:00 2024-04-29 13:30 🍜 Lunch
# 2024-04-29 13:00 2024-04-29 13:15 Yard Patrol 🌱 Touch grass
# 2024-04-29 13:30 2024-04-29 14:00 🍅
# 2024-04-29 13:30 2024-04-29 14:00 🧹 Knock out ~3 nitty-gritties
# 2024-04-29 14:00 2024-04-29 14:30 🍅
# 2024-04-29 14:00 2024-04-29 15:00 🦊 Ship README.lint PR (or owe 🍺 to @Ollie)
# 2024-04-29 14:00 2024-04-29 16:30 👑 A-priority only focus time
# 2024-04-29 14:30 2024-04-29 15:00 🍅
# 2024-04-29 15:00 2024-04-29 15:30 🍅
# 2024-04-29 15:30 2024-04-29 16:00 🍅
# 2024-04-29 16:00 2024-04-29 16:30 🍅
# 2024-04-29 16:30 2024-04-29 17:00 🍅
# 2024-04-29 17:00 2024-04-29 17:30 🍅
# 2024-04-29 17:00 2024-04-29 17:15 🍒 What did you 🚢 today?
# Desired results
# 2024-04-29 00:00 2024-04-30 00:00 Home
# 2024-04-29 06:30 2024-04-29 08:45 get the kids up and out
# 2024-04-29 08:45 2024-04-29 09:00 🐸 15m of Monarch categorization
# 2024-04-29 09:00 2024-04-29 09:30 🪢 Todo today
# 2024-04-29 09:15 2024-04-29 09:30 Check slack for open dYdX proposals which need to be voted on (search term: `in:#govstatements-votes dydx "new proposal"`)
# 2024-04-29 09:30 2024-04-29 10:00 🪢📆 JPB IPM
# 2024-04-29 10:00 2024-04-29 10:30 JPB and Alix Keller
# 2024-04-29 10:30 2024-04-29 11:00 🐸 Eat 3 frogs
# 2024-04-29 11:00 2024-04-29 11:20 Infra Standup
# 2024-04-29 11:00 2024-04-29 11:30 🍅
# 2024-04-29 11:30 2024-04-29 12:00 🍅
# 2024-04-29 12:00 2024-04-29 12:30 🌎 Weekly SPoG review
# 2024-04-29 12:00 2024-04-29 13:00 Strangelove Family Mgmt Weekly
# 2024-04-29 12:00 2024-04-29 12:55 Art of Action Stand-up V6 (weekly)
# 2024-04-29 12:30 2024-04-29 13:00 🍅
# 2024-04-29 13:00 2024-04-29 13:30 🍜 Lunch
# 2024-04-29 13:00 2024-04-29 13:15 Yard Patrol 🌱 Touch grass
# 2024-04-29 13:30 2024-04-29 14:00 🧹 Knock out ~3 nitty-gritties
# 2024-04-29 14:00 2024-04-29 14:30 🍅
# 2024-04-29 14:00 2024-04-29 15:00 🦊 Ship README.lint PR (or owe 🍺 to @Ollie)
# 2024-04-29 14:00 2024-04-29 16:30 👑 A-priority only focus time
# 2024-04-29 15:00 2024-04-29 15:30 🍅
# 2024-04-29 15:30 2024-04-29 16:00 🍅
# 2024-04-29 16:00 2024-04-29 16:30 🍅
# 2024-04-29 16:30 2024-04-29 17:00 🍅
# 2024-04-29 17:00 2024-04-29 17:30 🍅
# 2024-04-29 17:00 2024-04-29 17:15 🍒 What did you 🚢 today?
## 1a. Fetch
## 1b. Remove ANSI color codes from Cal data
## 3. extract time, duration, and description of events from each line of Cal data
## 3a. create list of h2s
## 4. Add clock emoji to Cal data lines lacking emoji
## 5. Expand Events Longer than 30 Minutes into multiple lines, 30m each
## 6. Remove Pomodoro lines that conflict with other events
## 7. Render the final markdown table
}
########################################
########################################
########################################
########################################
# Increment time function
function increment_time() {
local time=$1
local hour=$(echo $time | cut -d ':' -f 1)
local minute=$(echo $time | cut -d ':' -f 2 | sed 's/[apm]*//g')
local period=$(echo $time | grep -o '[apm]*')
local new_minute=$((minute + 30))
if [[ $new_minute -ge 60 ]]; then
new_minute=$((new_minute % 60))
hour=$((hour % 12 + 1))
fi
if [[ $hour -eq 12 && $period == "am" ]]; then
period="pm"
elif [[ $hour -eq 12 && $period == "pm" ]]; then
period="am"
fi
printf "%d:%02d%s" $hour $new_minute $period
}
# Transform gcalcli output to desired markdown format
function transform_gcal_output() {
local raw_output=$1
echo "***************** Debug: Starting transform_gcal_output \n\n\n\n\n\n"
local processed_output=""
local current_time=""
local current_event=""
local current_length=""
local -A emoji_map
emoji_map=( ["00"]="🕛" ["30"]="🕧" ["01"]="🕐" ["31"]="🕜" ["02"]="🕑" ["32"]="🕝"
["03"]="🕒" ["33"]="🕞" ["04"]="🕓" ["34"]="🕟" ["05"]="🕔" ["35"]="🕠"
["06"]="🕕" ["36"]="🕡" ["07"]="🕖" ["37"]="🕢" ["08"]="🕗" ["38"]="🕣"
["09"]="🕘" ["39"]="🕤" ["10"]="🕙" ["40"]="🕥" ["11"]="🕚" ["41"]="🕦" )
# Header
local date=$(date '+%m/%d - %A')
processed_output+="# $date\n\n## 🪢 Todo Today\n"
processed_output+="| Time | Item | - |\n"
processed_output+="|---------|--------------------------------------------------|-----------------|\n"
local -a lines
lines=("${(@f)raw_output}")
echo "########### lines starting here"
echo $lines
echo "########### end of lines var"
local is_event_line=false
for line in $lines; do
echo "$line"
if [[ $line =~ ^[[:space:]]*[0-9]{1,2}:[0-9]{2}[apm]{2} ]]; then
current_time=$(echo $line | awk '{print $1}')
current_event=$(echo $line | awk '{$1=""; print substr($0,2)}' | xargs)
current_length=""
is_event_line=true
elif [[ $line =~ Length: ]] && $is_event_line; then
current_length=$(echo $line | awk '{print $2}')
local duration_minutes=$(echo $current_length | awk -F: '{print $1 * 60 + $2}')
if [[ $duration_minutes -gt 30 ]]; then
local blocks=$((duration_minutes / 30))
for ((i=1; i<=blocks; i++)); do
local emoji_time=$(echo $current_time | cut -d ':' -f 2 | cut -d [apm]* -f 1)
local emoji=${emoji_map[$emoji_time]}
local prefix=$(printf "%.0s${emoji}" $(seq 1 $i))
processed_output+="| $current_time | $prefix $current_event | Length: $current_length |\n"
current_time=$(increment_time $current_time)
done
else
processed_output+="| $current_time | $current_event | |\n"
fi
is_event_line=false
fi
done
# Footer
processed_output+="\n- 👑 Most Important Thing Today:\n- 1st 🐸 I'll eat:\n- 2nd 🐸 I'll eat:\n- 3rd 🐸 I'll eat:\n"
echo -e "$processed_output"
}
# Main gday function
function gday-factored() {
# Display header
echo " 🌞🌞🌞🌞🌞🌞🌞🌞🌞🌞🌞🌞🌞🌞🌞🌞🌞🌞🌞"
echo " 🌞🌞🌞 gday Version 1.64.1 🌞🌞🌞"
echo " 🌞🌞🌞🌞🌞🌞🌞🌞🌞🌞🌞🌞🌞🌞🌞🌞🌞🌞🌞 \n\n"
# Fetch calendar data
echo "################### Debug: Fetching calendar data \n"
local raw_output=$(gcalcli --cal "JPB-DW" --cal "Pomo" --cal "JPB SL" --cal "JPB Private" agenda "1am today" "11pm today" --nocolor --no-military --details length --tsv)
# Process and transform the output
transform_gcal_output "$raw_output"
}
########################################
########################################
########################################
########################################
# path/filename: ~/scripts/todo_project_count.sh
# This script generates a markdown table with a list of unique projects and their counts from the todo.md file.
# Function to extract projects and count occurrences
generate_project_table() {
local todo_file=$1
echo "| Project | Count |"
echo "|---------|-------|"
grep -o "++[a-zA-Z0-9_]*" "$todo_file" | sort | uniq -c | while read -r count project; do
# Clean project name and format as markdown table row
project=${project//++/}
echo "| $project | $count |"
done
}
# Call the function with the path to the todo.md file
# generate_project_table "/path/to/todo.md"
########################################
########################################
########################################
########################################
############# GDAY MIKE
########################################
########################################
########################################
########################################
# gday-mike Version 1.38.0
function gday-mike() {
echo " 🌞🌞🌞🌞🌞🌞🌞🌞🌞🌞🌞🌞🌞🌞🌞🌞🌞🌞🌞"
echo " 🌞🌞🌞 gday Version 1.38.0 Mike 🌞🌞🌞"
echo " 🌞🌞🌞🌞🌞🌞🌞🌞🌞🌞🌞🌞🌞🌞🌞🌞🌞🌞🌞 \n\n"
local calendar_data=$(gcalcli --cal "JPB-DW" --cal "Pomo" --cal "JPB SL" --cal "JPB Private" agenda "1am today" "11pm today" --nocolor --no-military --details length --tsv)
echo "Raw gcalcli results:"
echo "$calendar_data"
local line_count=$(echo "$calendar_data" | wc -l | xargs)
echo "Line count: $line_count"
echo "-----------------"
if [[ -z "$calendar_data" || "$line_count" -eq 0 ]]; then
echo "No calendar data found or gcalcli failed."
return
fi
typeset -A all_items
while IFS=$'\t' read -r start_date start_time end_date end_time item; do
# Convert to 12-hour format and remove leading zero
start_time=$(date -d "$start_date $start_time" +"%I:%M %p" 2>/dev/null || date -jf "%Y-%m-%d %H:%M" "$start_date $start_time" +"%I:%M %p" 2>/dev/null | sed 's/^0//')
# Use a unique key combining time and item to ensure uniqueness
all_items["$start_time,$item"]=1
done <<< "$(echo "$calendar_data")"
# Sort and print the items
echo "## 🪢 Todo Today"
echo "| Time | Item |"
echo "|---------|------|"
for key in ${(ok)all_items}; do
local time=${key%%,*}
local item=${key#*,}
# Directly print without quotes
printf "| %s | %s |\n" "$time" "$item"
done
echo "\n- 👑 Most Important Thing Today:"
echo "- 1st 🐸 I'll eat:"
echo "- 2nd 🐸 I'll eat:"
echo "- 3rd 🐸 I'll eat:\n"
}
# Note: Adjust the `date` command as needed for compatibility with macOS or Linux.
########################################
########################################
########################################
########################################
extract_h2s() {
awk '
BEGIN {
print "## Later Today..."
print "```"
}
function normalize(str) {
gsub(/[^a-zA-Z0-9 ]/, "", str);
return str;
}
/^\| [0-9]/ {
sub(/^\|[^|]+\| /, "## ");
gsub(/ \|$/, "");
norm = normalize($0);
if (!seen[norm]++) {
print $0
}
}
END { print "```" }
'
}
########################################
########################################
########################################
########################################
function gday-old() {
echo " 🌞🌞🌞🌞🌞🌞🌞🌞🌞🌞🌞🌞🌞🌞🌞🌞🌞🌞🌞"
echo " 🌞🌞🌞 gday Version 1.31.0 🌞🌞🌞"
echo " 🌞🌞🌞🌞🌞🌞🌞🌞🌞🌞🌞🌞🌞🌞🌞🌞🌞🌞🌞 \n\n"
# TODO: Cull pomodoros for times which already have appointments
# TODO: When splitting long events into multiple pomodoros, duplicate the emoji for each pomodoro
# TODO: Add tests. Maybe <https://github.com/shellspec/shellspec>?
# TODO: Parse pseudo-code into Features List / Release Notes
# TODO: Factor this out into more sane methods. And pull out of `alias` file.
##### Setup
declare -A emoji_map=(
[800]="🕗" [830]="🕣" [900]="🕘" [930]="🕤"
[1000]="🕙" [1030]="🕥" [1100]="🕚" [1130]="🕦"
[1200]="🕛" [1230]="🕧" [100]="🕐" [130]="🕜"
[200]="🕑" [230]="🕝" [300]="🕒" [330]="🕞"
[400]="🕓" [430]="🕟" [500]="🕔" [530]="🕠"
[600]="🕕" [630]="🕡" [700]="🕖" [730]="🕢"
)
local title="## 🪢 Todo Today"
local table_header="| Time | Item |"
local table_separator="|---------|------|"
local kicker="\n******* DO WHATEVER THE SCHEDULE TELLS ME. AND ONLY THAT.**********\n\n### Brain Dump (for 👑s)\n\n\n --- \n\n\n- 1st 🐸 I'll eat:\n- 2nd 🐸 I'll eat:\n- 3rd 🐸 I'll eat:\n\n"
###### Day of week should include 📅 and weeknum on Mondays
local day_of_week=$(date '+%A')
local h1="# $(date '+%m/%d') - ${day_of_week}"
if [[ $day_of_week == "Monday" ]]; then
h1+=" - 📆 Week $(date '+%V')"
fi
# local calendar_names=("JPB-DW" "Pomo" "JPB SL" "JPB Private" "Jonathan Berger (TripIt)")
local calendar_data=$(gcalcli --cal "JPB-DW" --cal "Pomo" --cal "JPB SL" --cal "JPB Private" agenda "1am today" "11pm today" --nocolor --no-military --details length)
local calendar_data_no_color=$(echo "$calendar_data" | sed 's/\x1b\[[0-9;]*m//g')
###### convert pipe characters to an em-dash (bc escaping pipes is hard)
calendar_data_no_color=$(echo "$calendar_data_no_color" | sed 's/|/—/g')
local body=""
local lines=()
local time_count=()
##### Process the calendar data
while IFS= read -r line; do
line=$(echo "$line" | sed 's/^[ \t]*//') # trim whitespace
# Function to add a pomodoro (30 minutes) to a given time
add_pomodoro() {
local time=$1
local new_time=$(date -j -v+30M -f "%I:%M%p" "$time" +"%I:%M%p")
echo $new_time | sed 's/^0//' | tr '[:upper:]' '[:lower:]'
}
if [[ $line =~ ^[0-9]{1,2}:[0-9]{2}[apm]{2} ]]; then # if line starts with time
local time=$(echo "$line" | awk '{print $1}') # extract vars
local item=$(echo "$line" | awk '{$1=""; print substr($0,2)}')
# Split >30m events into multiple lines
IFS= read -r next_line
local duration_raw=$(echo "$next_line" | awk '/Length:/ {print $2}')
local hours=$(echo "$duration_raw" | cut -d ':' -f 1)
local minutes=$(echo "$duration_raw" | cut -d ':' -f 2)
local total_minutes=$((hours * 60 + minutes))
local blocks=$((total_minutes / 30))
for ((i=0; i<blocks; i++)); do
lines+=("$time|$item")
time=$(add_pomodoro "$time")
done
fi
done <<< "$calendar_data_no_color"
##### Add emoji to items lacking emoji and construct the final table
for line in "${lines[@]}"; do
IFS='|' read -r time item <<< "$line"
local time_number=$(echo "$time" | tr -d '[:alpha:]' | tr -d ':')
if ! [[ $item =~ ^[^[:alnum:]] ]]; then # if item lacks emoji
local emoji=${emoji_map[$time_number]} # then add emoji
item="${emoji} $item"
fi
body+="| ${time} | ${item} |"$'\n'
done
echo -e "${h1}\n\n${title}\n${table_header}\n${table_separator}\n${body}\n\n${kicker}"
echo $body | extract_h2s
}
############################ ___| ____| __ __| _ \ _ \ _ \ | ____| ___| __ __| _ _| __ __| ____| \ | ___| ###################
############################ | __| | | | | | | | | __| | | | | __| |\/ | \___ \ ################### Get project items, done w/ copilot.
############################ | | | | ___/ __ < | | \ | | | | | | | | | | ################### THIS WORKS
############################ \____| _____| _| _| _| \_\ \___/ \___/ _____| \____| _| ___| _| _____| _| _| _____/ ###################
function get_project_items {
# Version 1.1.0
# Usage: `get_project_items "assignee_name" 36 49 48 30 39` or `get_project_items "" 36 49 48 30 39`
assignee_filter=${1:-""}
shift
project_numbers=("$@")
current_date=$(date +"%m-%d-%Y")
limit=3
echo "~~~~~~~~~~~~~~~~~~ limit: $limit ~~~~~~~~~~~~~~~~~~\n\n"
echo "~~~ Assignee filter: $assignee_filter"
echo -e "\n\n### 👑 Epics (as of $current_date)\n| Project | Title | Status | Story Type | Assignees | URL |\n|---------|-------|--------|------------|-----------|-----|"
for project in "${project_numbers[@]}"; do
gh p item-list $project --format json --limit $limit -q ".items[] | select((.status? // \"\") | test(\"In progress|Backlog|Waiting/Review\")) | select(.assignees==\"$assignee_filter\" or \"$assignee_filter\"==\"\") | select(if .[\"story Type\"]? then (.[\"story Type\"] // \"\") | test(\"Epic\") else false end) | \"| $project | \(.title) | \(.status) | \(.[\"story Type\"]) | \(.assignees) | \(.content.url | sub(\"https://github.com/strangelove-ventures/\"; \"\")) |\""
echo "~~ Project: $project"
break
done
echo -e "\n\n### ⭐️🐞⚙️🏁 Stories (as of $current_date, excluding Icebox and Done)\n| Project | Title | Status | Story Type | Assignees | URL |\n|---------|-------|--------|------------|-----------|-----|"
for project in "${project_numbers[@]}"; do
gh p item-list $project --format json --limit $limit -q ".items[] | select((.status? // \"\") | test(\"In progress|Backlog|Waiting/Review\")) | select(.assignees==\"$assignee_filter\" or \"$assignee_filter\"==\"\") | select(if .[\"story Type\"]? then ((.[\"story Type\"] // \"\") | test(\"Epic\")) | not else true end) | \"| $project | \(.title) | \(.status) | \(.[\"story Type\"]) | \(.assignees) | \(.content.url | sub(\"https://github.com/strangelove-ventures/\"; \"\")) |\""
sleep 1
done
}
# Optimized function to reduce API calls
function get_project_items2 {
# Version 1.2.2
# Usage: `get_project_items "assignee_name" 36 49 48 30 39` or `get_project_items "" 36 49 48 30 39`
assignee_filter=${1:-""}
echo "Assignee filter: $assignee_filter"
shift
project_numbers=("$@")
echo "Project numbers: ${project_numbers[@]}"
current_date=$(date +"%m-%d-%Y")
limit=3
echo "~~~~~~~~~~~~~~~~~~ limit: $limit ~~~~~~~~~~~~~~~~~~\n\n"
total_api_calls=0
echo "total_api_calls: $total_api_calls"
echo -e "\n\n### 👑 Epics (as of $current_date)\n| Project | Title | Status | Story Type | Assignees | URL |\n|---------|-------|--------|------------|-----------|-----|"
echo -e "\n\n### ⭐️🐞⚙️🏁 Stories (as of $current_date, excluding Icebox and Done)\n| Project | Title | Status | Story Type | Assignees | URL |\n|---------|-------|--------|------------|-----------|-----|"
for project in "${project_numbers[@]}"; do
echo "~~~ Processing project number $project ~~~"
# Fetch all items for the project
items=$(gh p item-list $project --format json --limit $limit -q ".items[]")
total_api_calls=$((total_api_calls+1))
echo "total_api_calls: $total_api_calls"
# Loop through each item and filter based on conditions
while read -r item; do
# echo "/// in while loop for project $project"
# echo "//// item: $item"
item_status=$(jq -r '.status' <<< "$item")
# echo "///// status: $item_status"
story_type=$(jq -r '.["story Type"] // ""' <<< "$item")
# echo "////// story_type: $story_type"
assignees=$(jq -r '.assignees' <<< "$item")
# echo "/////// assignees: $assignees"
url=$(jq -r '.content.url' <<< "$item")
# echo "//////// url: $url"
if [[ "$item_status" =~ (in progress|backlog|waiting/review) ]] && [[ "$assignees" == "$assignee_filter" || "$assignee_filter" == "" ]]; then
if [[ "${story_type,,}" == *"epic"* ]]; then
echo "| $project | $(jq -r '.title' <<< "$item") | $item_status | $story_type | $assignees | ${url//"https://github.com/strangelove-ventures/"/} |"
else
echo "| $project | $(jq -r '.title' <<< "$item") | $item_status | $story_type | $assignees | ${url//"https://github.com/strangelove-ventures/"/} |"
fi
fi
done <<< "$items"
done
echo "API calls used: $total_api_calls"
}
###################### █████╗ ██╗ ██╗ ████████╗██╗ # alltl function v0.1
###################### ██╔══██╗██║ ██║ ╚══██╔══╝██║ # Retrieves a combined list of all GitHub issues assigned to me and their project status.
###################### ███████║██║ ██║ ██║ ██║ # Depends on GitHub CLI (`gh`) and `jq` for processing JSON.
###################### ██╔══██║██║ ██║ ██║ ██║
###################### ██║ ██║███████╗███████╗██║ ███████╗
###################### ╚═╝ ╚═╝╚══════╝╚══════╝╚═╝ ╚══════╝
function alltl() {
# Get list of issues assigned to me
local issues=$(gh issue list --assignee @me --json number,title,repository --jq '.[] | {number, title, repo: .repository.nameWithOwner}')
# Get list of projects I'm a member of
local projects=$(gh api graphql -f query='
{
viewer {
projectsV2(first: 10) {
nodes {
name
items(first: 100) {
nodes {
content {
... on Issue {
number
}
}
fieldValues(first: 10) {
nodes {
projectField {
name
}
value
}
}
}
}
}
}
}
}' --jq '.data.viewer.projectsV2.nodes[] | {project: .name, items: [.items.nodes[] | {number: .content.number, status: (.fieldValues.nodes[] | select(.projectField.name == "Status") | .value)]}}')
# Synthesize table with combined data
local header="| Title | Repo Name / Issue Number | Assigned Project | Status |"
local separator="|-------|-------------------------|------------------|--------|"
echo "$header"
echo "$separator"
for issue in $(echo "$issues" | jq -c '.'); do
local issue_number=$(echo "$issue" | jq -r '.number')
local issue_title=$(echo "$issue" | jq -r '.title')
local issue_repo=$(echo "$issue" | jq -r '.repo')
local project_name="none"
local status="none"
# Check projects for this issue
for project in $(echo "$projects" | jq -c '.'); do
local p_name=$(echo "$project" | jq -r '.project')
local p_issue=$(echo "$project" | jq --arg number "$issue_number" '.items[] | select(.number == ($number | tonumber))')
if [ "$p_issue" != "" ]; then
if [ "$project_name" == "none" ]; then
project_name=$p_name
status=$(echo "$p_issue" | jq -r '.status')
else
project_name="many"
status="many"
break
fi
fi
done
echo "| $issue_title | $issue_repo / $issue_number | $project_name | $status |"
done | column -t -s '|'
echo "Table has been synthesized."
}
function collect_field_names() {
local version="v0.4"
# Emit the version information
echo "••••••••• collect_field_names [$version] •••••••••"
# Retrieve and map the project names to their numbers
local project_info=$(gh project list --owner strangelove-ventures --format json ) | jq -r '[.[] | {number, name}]'
# Define the list of project numbers
local project_numbers=(46 49 39 36 34 30 24 18)
# Iterate over the project numbers to retrieve and print field names
for project_number in $project_numbers; do
# Extract the project name using the project number
local project_name=$(echo "$project_info" | jq -r --argjson number $project_number '.[] | select(.number == $number) | .name')
# Print the project name
echo "Project $project_number ($project_name) fields:"
# Retrieve and print the field names for the project
gh project field-list $project_number --owner strangelove-ventures --format json |
jq -r '[.fields[].name] | join(", ")'
echo # Print a newline for better readability
done
}
################################################## ██████╗ ██████╗ ██╗ Map all issues to projects.
################################################## ██╔══██╗██╔══██╗██║
################################################## ██████╔╝██████╔╝██║
################################################## ██╔═══╝ ██╔═══╝ ██║
################################################## ██║ ██║ ██║
################################################## ╚═╝ ╚═╝ ╚═╝
function ppi() {
echo "Version 0.6.1"
echo "Fetching current user..."
local user=$(gh api /user | jq -r '.login')
echo "Fetching Gordian tasks..."
local gordianTasks=$(gh p item-list 47 --format=json | jq -r '
.items | map({
status: .status,
title: .title,
url: .content.url,
assignees: (.assignees // [] | join(", "))
})'
)
echo "Fetching PM tasks from another project..."
local pmTasks=$(gh p item-list 36 --limit 300 --format=json | jq -r '
.items | map(select(.content.url != null)) | map({
status: .status,
title: .title,
project: .["project 🪚"],
url: .content.url,
projectStatuses: [{project: .project, status: .status}]
})'
)
echo "Fetching GitHub issues..."
local gitHubIssues=$(gh search issues --assignee=@me --state=open --limit=333 --include-prs --json="repository,number,state,title,url" | jq -r '.[] | {repository: .repository.name, number: .number, state: .state, title: .title, url: .url}')
echo "Combining tasks and issues..."
local combinedResults=$(jq -n '
input as $gordianTasks | input as $pmTasks | input as $gitHubIssues |
($gordianTasks + $pmTasks + $gitHubIssues) | group_by(.url) | map({
title: .[0].title,
status: .[0].status,
state: (.[0].state // ""),
assignees: .[0].assignees,
repository: (.[0].repository // ""),
number: (.[0].number // ""),
url: .[0].url,
projectStatuses: (reduce .[] as $item ([]; . + ($item.projectStatuses // [])))
})' <(echo "$gordianTasks") <(echo "$pmTasks") <(echo "$gitHubIssues"))
local combinedTable=$(echo "$combinedResults" | jq -r '.[] | select(.url != null) | "| \(.title) | \(.status) // (if .projectStatuses then (.projectStatuses | map(.status) | join(", ")) else "N/A" end) | \(.assignees) | \(.repository) | \(.number) | \(.state) | \(.url) |"')
local count=$(echo "$combinedResults" | jq -r 'length')
local title="### Combined Gordian and SL PM Tasks with GitHub Issues for @$user"
local tableHeader="|URL|Title|Status|Assignees|Repository|Issue Number|Issue State|"
local separator="|---|-----|------|---------|----------|------------|-----------|"
echo -e "$title\n$tableHeader\n$separator\n$combinedTable"
echo -e "$title\n$tableHeader\n$separator\n$combinedTable" | pbcopy
echo -e "\n$title have been copied to the clipboard. There are $count combined tasks and issues. :-) ###"
}
#!/bin/zsh # v0.3.0
# Function to fetch and display assigned issues for a user
gh_assigned_issues() {
local GITHUB_USERNAME="jonathanpberger"
local ASSIGNEE="$1"
# Function to fetch issue details
fetch_issue_details() {
local url="$1"
curl -s -H "Authorization: token $GITHUB_TOKEN" "$url" | jq -r '.[] | [.title, .html_url, (.project | if length == 0 then "none" elif length == 1 then .[0].name else "many" end), (.project | if length == 0 then "none" elif length == 1 then .[0].columns[0].name else [.[] | .columns[0].name] | unique | join(", ") end)] | @tsv' | column -t -s $'\t'
}
# Fetching assigned issues for the user
local issues_url="https://api.github.com/issues?assignee=$ASSIGNEE"
fetch_issue_details "$issues_url"
}
#!/bin/zsh # v0.5.0
# Function to fetch and display assigned issues for a user
gh_assigned_issues() {
echo "~~~~~~~~~~~~ gh_assigned_issues v0.5.1 ~~~~~~~~~~~~"
local GITHUB_USERNAME="jonthanpberger"
local ASSIGNEE="jonthanpberger"
echo "Assignee: $ASSIGNEE"
# GraphQL query to fetch assigned issues along with projects and their statuses
local graphql_query=$(cat <<EOF
{
user(login: "$ASSIGNEE") {
issues(first: 100, states: OPEN, orderBy: {field: CREATED_AT, direction: DESC}) {
nodes {