Skip to content

Commit

Permalink
zsh(racket): manage Racket paths with symlinks
Browse files Browse the repository at this point in the history
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
  • Loading branch information
benknoble committed Oct 26, 2024
1 parent 0c9fda8 commit 1ed7b15
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 12 deletions.
11 changes: 0 additions & 11 deletions links/zsh/mac/paths.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -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]
}
2 changes: 2 additions & 0 deletions links/zsh/paths.zsh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
pathadd ~/.racket-bin
pathadd man ~/.racket-man
24 changes: 23 additions & 1 deletion main.zuo
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand Down

0 comments on commit 1ed7b15

Please sign in to comment.