Schemesh revolutionizes command line interaction by merging a Unix shell with a Lisp REPL. Like traditional shells, it provides interactive editing, autocompletion, job control and redirections. Unlike them, it offers powerful Lisp programming capabilities integrated with shell syntax. This innovative tool enhances productivity for users looking for a robust and efficient command-line experience.
Schemesh is an innovative fusion of a Unix shell and a Lisp REPL, designed to enhance user interaction within a Unix-like environment. This interactive shell allows scripting in Lisp, providing a modern alternative to traditional shells such as bash or zsh.
Key Features:
-
Interactive Unix Shell: Schemesh serves as a replacement for conventional Unix login shells, offering a familiar syntax while supporting essential features like interactive line editing, autocompletion, and command history. It can execute shell commands and manage jobs with typical Unix command structures, such as redirections, pipelines, and job concatenation.
-
Integrated Lisp REPL: At its core, Schemesh incorporates a complete Lisp REPL powered by Chez Scheme, enabling complex scripting capabilities. Users can execute Lisp expressions seamlessly alongside standard shell commands.
-
Flexible Syntax Switching: Schemesh allows users to switch between shell and Lisp syntax effortlessly. For instance, an open parenthesis
(
indicates Lisp syntax, while an open brace{
activates shell syntax. This dual approach facilitates writing advanced scripts that leverage both functionalities without friction.
Usage Example:
Executing commands and integrating Lisp control structures is streamlined. Here’s a brief demonstration:
(if (some_expression arg1 (sub_expression2))
(sh-run/i {then_run_this_command foo bar $VAR})
(sh-run/i {else_run_this_command foo bar $VAR}))
Some more examples:
find (lisp-function-returning-some-string) -type f | grep ^lib | wc -l &
(sh-fg 1)
(define txt (sh-run/string {git log}))
(display txt)
(import (schemesh all))
(for ((f (in-list (string-split-after-nuls (sh-run/string {find -type f -print0})))))
(file-rename f (string-replace f ".old" ".bak")))
In contrast to traditional shell syntax, this approach minimizes errors related to string expansion and splitting, making scripting more reliable and intuitive.
Additional Benefits:
- Job Management: Control jobs easily with keyboard shortcuts or Lisp functions. For example, suspend a job with CTRL+Z or execute a foreground job with
(sh-run/i job-object)
. - Enhanced Editing Features: Schemesh supports multi-line editing with parentheses highlighting, history scrolling and search via PageUp/PageDown, configurable command execution with a single keypress, and customizable prompts.
- Persistent History: User history is saved and loaded automatically, ensuring a streamlined experience across sessions.
- Highly Optimized Performance: Built on the efficient Chez Scheme compiler, Schemesh is capable of generating optimized native code, enhancing execution speeds for scripts.
Future Developments:
Active work is ongoing to improve features, including enhanced autocomplete functionalities for shell paths and Scheme strings, as well as potential addition of missing shell builtins, and more Lisp functions to interact with shell commands and with the file system.
Schemesh represents a robust solution for users seeking an advanced and productive shell environment that marries the power of Lisp with the functionality of Unix shell scripting.
No comments yet.
Sign in to be the first to comment.