@@ -11992,6 +11992,14 @@ lines at the top of the script:
@code{!#}
@end example
+To make a script that launches an interactive REPL directly from the
+shell, use the @code{--interactive} flag:
+
+@example
+@code{#!/usr/bin/env -S guix repl --interactive}
+@code{!#}
+@end example
+
Without a file name argument, a Guile REPL is started, allowing for
interactive use (@pxref{Using Guix Interactively}):
@@ -12040,6 +12048,10 @@ Accept connections on localhost on port 37146.
Accept connections on the Unix-domain socket @file{/tmp/socket}.
@end table
+@item --interactive
+@itemx -i
+Launch the interactive REPL after @var{FILE} is executed.
+
@item --load-path=@var{directory}
@itemx -L @var{directory}
Add @var{directory} to the front of the package module search path
@@ -62,6 +62,9 @@ (define %options
(option '(#\q) #f #f
(lambda (opt name arg result)
(alist-cons 'ignore-dot-guile? #t result)))
+ (option '(#\i "interactive") #f #f
+ (lambda (opt name arg result)
+ (alist-cons 'interactive? #t result)))
(option '(#\L "load-path") #t #f
(lambda (opt name arg result)
;; XXX: Imperatively modify the search paths.
@@ -84,6 +87,9 @@ (define (show-help)
-q inhibit loading of ~/.guile"))
(newline)
(display (G_ "
+ -i, --interactive launch REPL after evaluating FILE"))
+ (newline)
+ (display (G_ "
-L, --load-path=DIR prepend DIR to the package module search path"))
(newline)
(display (G_ "
@@ -196,7 +202,7 @@ (define script
;; file in %LOAD-PATH. Thus, pass (getcwd) instead of ".".
(load-in-vicinity (getcwd) (car script)))))
- (when (null? script)
+ (when (or (null? script) (assoc-ref opts 'interactive?))
;; Start REPL
(let ((type (assoc-ref opts 'type)))
(call-with-connection (assoc-ref opts 'listen)