-
-
Notifications
You must be signed in to change notification settings - Fork 842
/
Copy pathalias-and-functions.fish
1197 lines (1018 loc) · 28.8 KB
/
alias-and-functions.fish
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
alias cwd='pwd | pbcopy'
alias js="just s" # TODO: do with watch like bun --watch
alias a="eza -I 'license'" # list files (without license)
alias af="type" # <cmd> - view definition of <cmd>
alias dF="cd ~/src/pause && eza"
alias gl="git pull"
alias rr="rm -rf"
alias wr="cursor readme.md"
alias da="cd ~/src && eza"
alias dj="cd ~/src/ts && eza"
alias ds="cd ~/test && eza"
alias pip="pip3"
alias dsr="cd ~/test/react && eza"
alias dv="cd ~/src/nikiv.dev && eza"
alias dn="cd ~/src/py && eza"
alias dm="cd ~/src/go && eza"
alias dl="cd ~/src/org/la/la && eza"
alias dL="cd ~/src/org/la/x && eza"
alias dz="cd ~/try && eza"
alias dZ="cd ~/try/z && eza"
alias dw="cd ~/x && eza"
alias de="cd ~/new && eza"
alias db="cd ~/src/base && eza"
alias dq="cd ~/Documents && eza"
alias dp="cd ~/past && eza"
alias dg="cd ~/src/other && eza"
alias dP="cd ~/past/private && eza"
alias dd="cd ~/data && eza"
alias dD="cd ~/data/private && eza"
alias dk="cd ~/src/org/solbond/solbond && eza"
alias dt="cd ~/desktop && eza"
alias df="cd ~/src/org && eza"
alias dv="cd ~/src/nikiv.dev && eza"
alias di="cd ~/clones && eza"
alias do="cd ~/forks && eza"
alias aa="eza -la" # list files (with hidden)
# alias r="ronin"
alias npm="bun"
alias v="mv" # move files/folders or rename
alias dc="cd ~/src/config && eza"
alias pr="gh pr checkout"
alias nb="nix-build"
function run_ts_script
set script_name $argv[1]
set script_path ~/src/ts/scripts/$script_name.ts
if test -f $script_path
set -e argv[1]
bun $script_path $argv
else
echo "Script not found: $script_path"
return 1
end
end
for script in ~/src/ts/scripts/*.ts
set script_name (basename $script .ts)
alias $script_name "run_ts_script $script_name"
end
# _functions
# TODO: make completions for `: ` so it gets the scripts found in package.json
# below is maybe hacky way to do it but it has to by dynamic
function :
if not set -q argv[1]
bun dev
# if ` <port-number>`, run `bun dev --port 300<port-number>`
else if string match -qr '^[0-9]+$' $argv[1]
set -l port_suffix $argv[1]
set -l full_port "300$port_suffix"
bun dev --port $full_port
else
bun $argv
end
end
function :p
bun dev --port $argv
end
function r
if not set -q argv[1]
encore run
else
encore $argv
end
end
function i
if not set -q argv[1]
bun i
else
bun i $argv
end
end
function ::
if not set -q argv[1]
deno repl # TODO: change
else
deno $argv
end
end
function :se
bun seed $argv
end
function w
if not set -q argv[1]
cursor .
else
cursor $argv
end
end
# tunnels local telegram mini app (usually on port 5173 with the `tma.internal` domain)
function ngTelegram
set -l port 5173
set -l domain "tma.internal"
ngrok http "https://$domain:$port" --host-header="$domain:$port"
end
function ng
ngrok http 3000
end
# g. - commit all with `.` as message
function g.
git add .
git commit -m "."
git push
end
function prettierAll
bunx prettier --write "**/*.{js,json,css,tsx,ts}"
end
# TODO: might be buggy
function gitSetSshOrigin
set -l repo_url $argv[1]
# Extract username and repo name from the URL
set -l repo_path (echo $repo_url | sed -E 's/.*github\.com[:/]([^/]+\/[^/]+)(\.git)?$/\1/')
# Construct the SSH URL
set -l ssh_url "[email protected]:$repo_path.git"
# Remove existing origin if it exists
git remote remove origin 2>/dev/null
# Add new origin with SSH URL
git remote add origin $ssh_url
# Get current branch name
set -l current_branch (git rev-parse --abbrev-ref HEAD)
# Check if this is a new repository
if test (git rev-parse HEAD 2>/dev/null)
# If repository has commits, try to set upstream
git push -u origin $current_branch
else
echo "New repository detected. Please make an initial commit first, then run:"
echo "git push -u origin $current_branch"
end
echo "Remote origin set to: $ssh_url"
end
function deleteNodeModules
find . -type d -name node_modules -prune -print | xargs rm -rf
end
# full `bun i` reset
function :d
find . -type d -name node_modules -prune -print | xargs rm -rf
test -f bun.lock && rm bun.lock
test -f bun.lockb && rm bun.lockb
bun i
end
# find .env files
function f.
for env_file in (find . -type d -name node_modules -prune -o -type f -name ".env" -print)
bat $env_file
end
end
function fg
if not set -q argv[1]
# cd ~/
# flox list
else
# cd ~/
# flox install $argv
end
end
function fi
if not set -q argv[1]
# flox init TODO:
else
flox install $argv
end
end
function fs
if not set -q argv[1]
# flox TODO:
else
flox search $argv
end
end
function fsa
if not set -q argv[1]
# flox TODO:
else
flox search $argv --all
end
end
function w.
cursor .env
end
function e.
bat .env
end
function n
if not set -q argv[1]
python3
else
uv run -m $argv
end
end
function nw
if test -z "$argv[1]"
echo "Usage: nw <script_name>"
return 1
end
watchexec --no-vcs-ignore --restart --exts py --clear --project-origin . "tput reset && uv run -m scripts.$argv"
end
function f
if not set -q argv[1]
open .
else
open $argv
end
end
function md
mkdir -p $argv[1] && cd $argv[1]
end
function :i
if not set -q argv[1]
bun i
else
bun i $argv
end
end
function :id
bun i -d $argv
end
function :g
bun i -g $argv
end
# set env vars in current shell
function x
if test (count $argv) -eq 1
set -x $argv[1]
else if test (count $argv) -ge 2
set -x $argv[1] $argv[2..-1]
else
echo "Usage: x VARIABLE [VALUE]"
return 1
end
end
# nix eval file (with watch)
function ne
if test -z "$argv[1]"
echo "Usage: ne <nix_file>"
return 1
end
set -l file $argv[1]
watchexec --no-vcs-ignore --restart --exts nix --clear --project-origin . "tput reset && nix-instantiate --eval --strict --json $file | jq"
end
# unstable, but does work for https://github.com/nikitavoloboev/cpp
function cpp
watchexec --no-vcs-ignore --restart --exts cpp --clear --project-origin . "tput reset && make -C build && src/main"
end
function nv
if not set -q argv[1]
nvim .
else
nvim $argv
end
end
# TODO: change
# function gh
# git fetch --unshallow
# juxta .
# end
function g
if not set -q argv[1]
smerge .
else
git $argv
end
end
# run `cargo run` when rust files change | <query> - run with query
function i
if not set -q argv[1]
cargo watch -q -- sh -c "tput reset && cargo run -q"
else
cargo watch -q -- sh -c "tput reset && cargo run -q -- $argv"
# TODO: test below, supposedly it's better and safer (per https://matrix.to/#/!YLTeaulxSDauOOxBoR:matrix.org/$mM0QC4VSo5BmI1o3qfKg5vjDs6sok1FwBtKy2UlI4Xs?via=gitter.im&via=matrix.org&via=tchncs.de)
# cargo watch -q -- sh -c 'tput reset && cargo run -q -- "$@"' watchscript $argv
end
end
# R - run tests with cargo and watch
function R
if not set -q argv[1]
cargo watch -q -- sh -c "tput reset && cargo test -q --lib"
else
cargo watch -q -- sh -c "tput reset && cargo test -q --lib -- $argv --nocapture"
# TODO: prob move it to separate cmd as there is use case of running specific test and not see logs as is usual
# cargo watch -q -- sh -c "tput reset && cargo test -q --lib -- $argv"
end
end
# rs - run rust test code for quick edits
function rs
cargo watch -q -- sh -c "tput reset && cargo test -q --lib -- run --nocapture"
end
# function :c
# if not set -q argv[1]
# set cli_file (fd -t f -p "cli.ts" | head -n 1)
# if test -n "$cli_file"
# cursor "$cli_file"
# bun cli
# else
# # TODO:
# # bun cli
# end
# else
# # TODO:
# end
# end
function :s
# set run_file (fd -t f -p "scripts/run.ts" | head -n 1)
# if test -n "$run_file"
# cursor "$run_file"
# end
bun s
end
function :sr
set run_file (find . -name "p-run.ts" -path "*/scripts/*" | head -n 1)
if test -n "$run_file"
cursor "$run_file"
end
bun sr
end
function find.git
find . -type d -name ".git"
end
function rmGitFoldersInsideThisFolder --description "Find and delete all nested .git directories except the one at current root"
# Find all .git directories
set -l git_dirs (find . -type d -name ".git")
# Separate root .git from nested ones
set -l to_delete
for dir in $git_dirs
# Only add to deletion list if it's not the root .git
if test "$dir" != "./.git"
set -a to_delete $dir
end
end
# Display what will be deleted
echo "Found root .git directory (will be kept):"
echo " ./.git"
if test (count $to_delete) -eq 0
echo "No nested .git directories to delete."
return 0
end
echo "The following nested .git directories will be deleted:"
for dir in $to_delete
echo " $dir"
end
# Ask for confirmation
read -l -P "Are you sure you want to delete these directories? (y/N) " confirm
if test "$confirm" != "y" -a "$confirm" != "Y"
echo "Operation cancelled."
return 1
end
# Perform deletion
for dir in $to_delete
echo "Deleting $dir"
rm -rf "$dir"
end
echo "Deletion complete."
end
function find.DS_Store
find . -type f -name ".DS_Store"
end
function m
if not set -q argv[1]
watchexec --no-vcs-ignore --restart --quiet --exts go --clear --project-origin . "go run ."
else
go $argv
end
end
# oi = go install ..
function mi
if not set -q argv[1]
echo "Usage: oi <github-user/repo>"
return 1
else
# TODO: turn this into ts script
# example cmd: go install github.com/no-src/gofs/...@latest
go install github.com/$argv[1]/...@latest
end
end
function re
if not set -q argv[1]
repopack .
else
repopack $argv
end
end
function fa
flox activate -s
end
function :u
bun update --latest
end
function fl
flox services logs --follow
end
function fr
flox services restart
end
# TODO: replace with own tool
# function e
# if not set -q argv[1]
# code2prompt .
# else
# code2prompt $argv
# end
# end
# function c
# if not set -q argv[1]
# else
# bat $argv
# end
# end
function e
if not set -q argv[1]
pwd | pbcopy $argv
else
bat $argv
end
end
function changeRemoteToFork
set -l repo_url $argv[1]
# Extract the repo name from the URL
set -l repo_name (string split '/' $repo_url | tail -n 1)
# Set the GitHub username directly in the function
set -l github_username "nikitavoloboev"
# Construct the new URL
set -l new_url "https://github.com/$github_username/$repo_name"
# Change the remote URL
git remote set-url origin $new_url
if test $status -eq 0
echo "Remote URL changed successfully to: $new_url"
echo "Current remotes:"
git remote -v
else
echo "Error: Failed to change remote URL"
end
end
function d
if not set -q argv[1]
cd
else
if cd $argv 2>/dev/null
eza
else
z $argv
if test $status -eq 0
eza
else
return 1
end
end
end
end
function :w
bun --watch $argv
end
# TODO: prob no need for this, can just get active path and pass it to bun --watch
# function :ws
# if test -n "$argv[1]"
# if test -f "$argv[1]"
# bun --watch "$argv[1]"
# else if test -f "scripts/$argv[1]"
# bun --watch "scripts/$argv[1]"
# else
# echo "Could not find file: $argv[1] or scripts/$argv[1]"
# return 1
# end
# else
# bun --watch
# end
# end
function ..
cd ..
eza
end
function l
ollama $argv
end
function p
if not set -q argv[1]
pnpm i
else
pnpm add $argv
end
end
# TODO: move
# function s
# if not set -q argv[1]
# else
# watchexec --no-vcs-ignore --restart --exts swift --clear --project-origin . "tput reset && swift $argv"
# end
# end
function :e
bunx $argv
end
function :ts
bun --watch ~/src/ts/lib/ts-utils/scripts/run.ts
end
function :r
bun --watch ~/test/ts/scripts/run.ts
end
# TODO: make into proper tool with completions etc.
# TODO: do I miss anything by taking over `.` builtin?
function `
bun ~/src/ts/scripts/new.ts $argv
eza
# TODO: only do it if its folder, the script should return something in that case, check for the return
cd $argv
end
function gitRemoteOpen
git remote get-url origin | sed -e 's/[email protected]:/https:\/\/github.com\//' | xargs open
end
function gitChangeRemote
if not set -q argv[1]
echo "Please provide a new repository URL"
return 1
end
# Extract username and repo name from the URL
set -l repo_path (echo $argv[1] | sed -E 's/.*github\.com[:/]([^/]+\/[^/]+)(\.git)?$/\1/')
# Construct the SSH URL
set -l ssh_url "[email protected]:$repo_path.git"
git remote remove origin
git remote add origin $ssh_url
echo "Remote origin set to: $ssh_url"
end
function j
if not set -q argv[1]
just run
else
just $argv
end
end
function co
if not set -q argv[1]
cody --help
else
cody $argv
end
end
function d:
cd ~/src/swift && eza
end
function d.
cd ~/rust && eza
end
function k
if not set -q argv[1]
# TODO: what is equivalent to `bun dev` in uv
# uv run main.py
watchexec --no-vcs-ignore --restart --exts py --clear --project-origin . "tput reset && uv run main.py"
else
uv $argv
end
end
# function dk
# if not set -q argv[1]
# # bunx drizzle-kit generate && bunx drizzle-kit migrate
# bunx drizzle-kit generate
# else
# bunx drizzle-kit $argv
# end
# end
function dkm
if not set -q argv[1]
bunx drizzle-kit migrate
else
bunx drizzle-kit $argv
end
end
function .a
set bike_file (find . -name "*.bike" | head -n 1)
if test -n "$bike_file"
open -a "Bike" "$bike_file"
else
pwd | pbcopy
open -a "Bike"
# TODO: maybe run KM macro and automate creating the file via the `new file` thing in bike
# https://support.hogbaysoftware.com/t/why-is-it-when-i-create-a-bike-file-from-shell-it-will-show-extension-in-app/6020 due to this issue
end
end
# TODO: not used until https://support.hogbaysoftware.com/t/why-is-it-when-i-create-a-bike-file-from-shell-it-will-show-extension-in-app/6020 is fixed
# function .a
# set bike_file (find . -name "*.bike" | head -n 1)
# if test -n "$bike_file"
# open -a "Bike" "$bike_file"
# else
# set dir_name (basename (pwd))
# set new_file "$dir_name.bike"
# touch "$new_file"
# open -a "Bike" "$new_file"
# end
# end
function replace
if test (count $argv) -ne 2
echo "Usage: replace <from> <to>"
echo "Example: replace '~' '~~'"
return 1
end
for file in *
set newname (string replace -a "$argv[1]" "$argv[2]" "$file")
if test "$file" != "$newname"
mv "$file" "$newname"
end
end
end
function :a
bun run deploy
end
function :c
find . -type d -name node_modules -prune -print | xargs rm -rf
bun i
end
# clone using SSH URL format
function gc
if not set -q argv[1]
echo "Usage: gc <github-url>"
return 1
end
# extract repo path from the URL
set repo_path (string replace -r 'https://github.com/' '' $argv[1])
# clone using SSH URL format
git clone "[email protected]:$repo_path.git"
end
function repoCleanup
find . -type f -name "README.md" -not -path "*/node_modules/*" -exec sh -c '
tmp="$1.tmp"
mv "$1" "$tmp" && mv "$tmp" "$(dirname "$1")/readme.md"
' _ {} \;
find . -type f -name "LICENSE" -not -path "*/node_modules/*" -exec sh -c '
tmp="$1.tmp"
mv "$1" "$tmp" && mv "$tmp" "$(dirname "$1")/license"
' _ {} \;
find . -type f -name "CHANGELOG.md" -not -path "*/node_modules/*" -exec sh -c '
tmp="$1.tmp"
mv "$1" "$tmp" && mv "$tmp" "$(dirname "$1")/changelog.md"
' _ {} \;
find . -type f -name "CODE_OF_CONDUCT.md" -not -path "*/node_modules/*" -exec sh -c '
tmp="$1.tmp"
mv "$1" "$tmp" && mv "$tmp" "$(dirname "$1")/code-of-conduct.md"
' _ {} \;
find . -type f -name "CONTRIBUTING.md" -not -path "*/node_modules/*" -exec sh -c '
tmp="$1.tmp"
mv "$1" "$tmp" && mv "$tmp" "$(dirname "$1")/contributing.md"
' _ {} \;
end
# sync local .git folder with remote repo
function gs
set current_folder (basename $PWD)
if string match -rq '(.+)--(.+)' $current_folder
set -l original_author (string match -r '(.+)--(.+)' $current_folder)[2]
set -l repo_name (string match -r '(.+)--(.+)' $current_folder)[3]
gh repo sync "nikitavoloboev/$repo_name" --source "[email protected]:$original_author/$repo_name"
git pull
else
echo "Error: Could not parse repository info from directory name"
echo "Directory should be in format: author--repo"
return 1
end
end
# git sync
function gsync
# Save current branch to return to it later
set current_branch (git rev-parse --abbrev-ref HEAD)
# Make sure we have upstream set
if not git remote | grep -q upstream
echo "No upstream remote found. Please add it first with:"
echo "git remote add upstream [email protected]:original-owner/repository.git"
return 1
end
# Fetch all from upstream
echo "Fetching all branches from upstream..."
git fetch upstream --prune
# Get list of all upstream branches
set upstream_branches (git branch -r | grep upstream/ | grep -v HEAD | sed 's/ upstream\///')
echo "Syncing branches from upstream..."
# For each upstream branch
for branch in $upstream_branches
# Skip if it's the same as our local test branch
if test "$branch" = "test"
echo "Skipping 'test' branch as you have a local branch with this name"
continue
end
# Check if we already have this branch locally
if git show-ref --verify --quiet refs/heads/$branch
# Branch exists, update it
echo "Updating existing branch: $branch"
git checkout $branch
git merge upstream/$branch
else
# Branch doesn't exist, create it
echo "Creating new branch: $branch"
git checkout -b $branch upstream/$branch
end
end
# Return to the original branch
echo "Returning to '$current_branch' branch"
git checkout $current_branch
echo "All branches have been synced with upstream"
end
function gsyncMain
# Save current branch to return to it later
set current_branch (git rev-parse --abbrev-ref HEAD)
# Make sure we have upstream set
if not git remote | grep -q upstream
echo "No upstream remote found. Please add it first with:"
echo "git remote add upstream [email protected]:original-owner/repository.git"
return 1
end
# Fetch all from upstream
echo "Fetching from upstream..."
git fetch upstream --prune
# Check if main branch exists locally
if git show-ref --verify --quiet refs/heads/main
# Branch exists, update it
echo "Updating main branch"
git checkout main
git merge upstream/main
else
# Branch doesn't exist, create it
echo "Creating main branch"
git checkout -b main upstream/main
end
# Return to the original branch
echo "Returning to '$current_branch' branch"
git checkout $current_branch
echo "Main branch has been synced with upstream"
end
# used as catch all for fast scripts
function ,
for dir in *=*
set newdir (string replace --all "=" "__" "$dir")
mv "$dir" "$newdir"
end
end
function triggerBuildWithNoCommit
set current_branch (git rev-parse --abbrev-ref HEAD)
# Validate git state
if not git rev-parse --git-dir >/dev/null 2>&1
echo "Error: Not in a git repository"; return 1
end
if not git diff --quiet HEAD
echo "Error: Working directory not clean"; return 1
end
# Push empty commit
git commit --allow-empty -m "temp: trigger build"
if not git push origin $current_branch
git reset HEAD~1; return 1
end
# Cleanup immediately
git reset HEAD~1
git push --force origin $current_branch || begin
echo "Error: Failed to cleanup. Run: git reset HEAD~1 && git push --force"
return 1
end
echo "✓ Build triggered"
end
function sf
if test -z "$argv[1]"
echo "Usage: sf <url>"
return 1
end
# Extract domain from URL (remove protocol if present and path)
set domain (echo $argv[1] | sed -E 's|^https?://||' | cut -d'/' -f1)
# Create filename from domain
set filename "$HOME/sites/$domain.txt"
# Check if URL already starts with http(s)://
if string match -q 'http*://*' $argv[1]
sitefetch "$argv[1]" -o $filename
else
sitefetch "https://$argv[1]" -o $filename
end
# Copy content to clipboard
cat $filename | pbcopy
echo "Saved to $filename (content copied to clipboard)"
end
function s
if test -z "$argv[1]"
echo "Usage: sf <url>"
return 1
end
# Extract domain and path from URL
set url (echo $argv[1] | sed -E 's|^https?://||')
set domain (echo $url | cut -d'/' -f1)
set path (echo $url | grep -o '/.*$' || echo '/')
# Create filename from domain
set filename "$HOME/sites/$domain.txt"
# Build the sitefetch command with exact path matching
if string match -q 'http*://*' $argv[1]
sitefetch "$argv[1]" -o $filename -m "$path"
else
sitefetch "https://$argv[1]" -o $filename -m "$path"
end
# Copy content to clipboard
cat $filename | pbcopy
echo "Saved to $filename (content copied to clipboard)"
end
function killPort
if test -z "$argv[1]"
echo "Usage: killPort <port_number>"
return 1
end
set port_processes (lsof -ti:$argv[1])
if test -z "$port_processes"
echo "No processes found on port $argv[1]"
return 0
end
kill $port_processes
echo "Killed process(es) on port $argv[1]"
end
function portCheck
if test -z "$argv[1]"
echo "Usage: portCheck <port_number>"
return 1
end
lsof -i :$argv[1]
end
# TODO: find how to do smth like `tree-layout | tee /dev/tty | pbcopy` but preserve colors
# print folder/file layout deeply + copy to clipboard
function t
tree-layout
tree-layout | pbcopy
end
function T
set current_path (string replace -r "^$HOME" "~" (pwd))
echo $current_path
tree-layout
begin
echo $current_path
tree-layout
end | pbcopy
end
function :b
bun run build
end
# function c