From 1ed7b15259d04bf6d2eb722851485e57cf435837 Mon Sep 17 00:00:00 2001 From: "D. Ben Knoble" Date: Sat, 26 Oct 2024 13:16:29 -0400 Subject: [PATCH] zsh(racket): manage Racket paths with symlinks Use `zuo . symlink-racket-paths` to update the symlinks to the correct paths, and then (as ~/.zsh/paths.zsh) make sure those paths are on the right PATH variables. This eliminates a lot of pathrm/pathadd when new Rackets are released. Ref: https://racket.discourse.group/t/is-there-a-better-way-to-manage-getting-the-right-user-console-bin-dir-on-path-for-running-shells-when-upgrading-racket/3203/2 --- links/zsh/mac/paths.zsh | 11 ----------- links/zsh/paths.zsh | 2 ++ main.zuo | 24 +++++++++++++++++++++++- 3 files changed, 25 insertions(+), 12 deletions(-) create mode 100644 links/zsh/paths.zsh diff --git a/links/zsh/mac/paths.zsh b/links/zsh/mac/paths.zsh index a53c5154..4f1ddc19 100644 --- a/links/zsh/mac/paths.zsh +++ b/links/zsh/mac/paths.zsh @@ -14,14 +14,3 @@ pathadd_front /usr/local/opt/openjdk/bin pathadd_front man /usr/local/opt/openjdk/libexec/openjdk.jdk/Contents/Home/man } - -command -v racket &>/dev/null && { - racket_paths=($(IFS=$'\n' racket -I racket/base -e ' - (require setup/dirs) - (for-each displayln - (list (find-user-console-bin-dir) - (find-user-man-dir))) - ')) - pathadd $racket_paths[1] - pathadd man $racket_paths[2] -} diff --git a/links/zsh/paths.zsh b/links/zsh/paths.zsh new file mode 100644 index 00000000..655e1fbf --- /dev/null +++ b/links/zsh/paths.zsh @@ -0,0 +1,2 @@ +pathadd ~/.racket-bin +pathadd man ~/.racket-man diff --git a/main.zuo b/main.zuo index 4b43e96b..df8f34eb 100644 --- a/main.zuo +++ b/main.zuo @@ -138,7 +138,29 @@ (rm* dest) (symlink src #;<- dest) (alert (~a dest " -> " src))) - (hash-keys the-links)))])) + (hash-keys the-links)))] + [:target symlink-racket-paths () + ,(lambda (token) + (define paths + (car + (string-read + (shell/output `("racket -I racket/base -e" + ,(string->shell + (string-join + '("(require setup/dirs)" + "(write (map path->bytes" + " (list (find-user-console-bin-dir)" + " (find-user-man-dir))))"))))) + 0 + "$(racket -I racket/base -e ...)"))) + (define bin-dir (car paths)) + (define man-dir (cadr paths)) + (define racket-bin (at-home ".racket-bin")) + (define racket-man (at-home ".racket-man")) + (symlink bin-dir #;<- racket-bin) + (alert (~a racket-bin " -> " bin-dir)) + (symlink man-dir #;<- racket-man) + (alert (~a racket-man " -> " man-dir)))])) (make-targets targets))