A shell by the beach!
I'm a bored sophomore in college working on projects to fill the time. If you enjoy my work, consider supporting me by buying me a coffee!
I feel that bash is great in a lot of ways, but it doesn't exactly feel cozy: it's lacking a sort of personal touch, and it's also missing quick and easy customizability. With my last shell, Atom, I had accomplished some of the coziness that bash was missing, but I also introduced a lot of really fatal flaws in the syntax and the type system.
Dune, however, is designed completely differently from Atom (although you might notice the similarities in their widget systems). The interpreter itself is standalone, and it holds almost none of the functionality you see in the default distribution of Dune. If you wanted to, you could write a custom frontend and make a unique Dune based shell of your own!
This frontend implementation turns the coziness dial to 11. Just check out the shell's default startup script!
I put a lot of work into making Dune just fun to use. It's like a neat little operating system itself!
Dune also attempts to be a usable scripting language, and even offers a few niche metaprogramming features such as quoting (borrowed from Lisp), operator overloading, and macros!
Overall, I wrote Dune to have a complete shell of my own: one that's fast, useful, and pretty.
(Also, writing a shell is just kinda really fun)
Dune has a bunch of customizable components. Here's how you can change them and make your shell your own!
Before entering interactive mode, Dune executes the prelude. The prelude is just the startup file
.dune-prelude stored in the home directory for your user. If you don't provide your own prelude file, Dune will execute its own default prelude with an introduction to the shell.
You can see my example personal prelude here.
Dune's REPL is entirely customizable by overloading the following functions:
||This function is called to generate the text which prompts the user for input. It takes the current working directory, and returns a string.||
let prompt = cwd -> [email protected] (([email protected]@blue "(dune) ") +
||This function is called to generate the text which prompts the user for input when they have entered an incomplete expression. It takes the current working directory, and returns a string.||
let incomplete_prompt = cwd -> ((len cwd) +
||This function is called to print a value to the console after evaluation.||The default implementation is a builtin function (implemented in Rust), but you can overload it with any callable value nonetheless.|
I highly recommend using the
fmt module when implementing your own customizations for your prompt!
This distribution of Dune uses the
Symbol type (the type of variable names and paths) to implement calling programs. Whenever an expression of type
Symbol is evaluated as a command in interactive mode, it is invoked as a program.
Because of this, you can define aliases by assigning a variable to a program's name like so!
If you have defined a variable that overshadows your program's name (such as an alias), you can quote the program name to run it.
To write functions that modify your shell's environment and act like commands or programs themselves, use a macro!
Macros, when called with zero arguments, are passed the current working directory. When invoked, they assume the environment of the callee: if you execute a macro, it will execute as if you executed the contents of the macro itself with the parameter defined as the argument passed.
Piping and redirection are done with the
>> operators. Here's some example uses!
If a value is piped into a callable object, like a function or macro, it is performed as an application; otherwise, the expression is treated like a regular call to a program.
Dune offers an extensive standard library, and also provides a pretty interface to see all the functions available in each module!
Dune offers the following builtin libraries:
||A library for randomness|
||A library with date and time functions|
||A module for math and trig functionality|
||A module for interacting with the file system|
||A functional programming library|
||A library for text formatting on the console (color, styling, hyperlinks, text wrapping, etc.)|
||A small module with the host's OS info|
||A module for creating text widgets|
||A small module for information about the Dune shell|
||A library for manipulating the console|
For more information about each, just run
To install, you must download Rust from here. If you already have Rust installed you will probably need to update. Dune uses a lot of recently stabilized features.
# Install directly from git with cargo cargo install --git https://github.com/adam-mcdaniel/dune # Or, alternatively, the repo and install from source git clone https://github.com/adam-mcdaniel/dune cd dune cargo install -f --path .
To get the current release build, install from crates.io.
# Also works for updating dune cargo install -f dune
Currently, since Dune is in its early stages of development, I would recommend against using releases at the moment. There are a lot of bug fixes and new features added inbetween releases.
# Just run the dune executable! dunesh