• Stars
    star
    682
  • Rank 66,258 (Top 2 %)
  • Language
    Rust
  • License
    Apache License 2.0
  • Created about 3 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A shell🐚 by the beach🏖️!

dune

A shell by the beach!

NOTE: Click the image above for a video demonstration.

About the Author

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!

Buy Me A Coffee

Why write another shell?

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)

Usage

Dune has a bunch of customizable components. Here's how you can change them and make your shell your own!

The Prelude

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.

The REPL

Dune's REPL is entirely customizable by overloading the following functions:

Name Purpose Default Implementation
prompt 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 -> fmt@bold ((fmt@dark@blue "(dune) ") +
(fmt@bold (fmt@dark@green cwd)) +
(fmt@bold (fmt@dark@blue "$ ")))
incomplete_prompt 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) +
(len "(dune) ")) * " " +
(fmt@bold (fmt@dark@yellow "> "));
report 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!

Aliases

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.

Overshadowed

Macros

To write functions that modify your shell's environment and act like commands or programs themselves, use a macro!

Macros

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

Piping and redirection are done with the | and >> operators. Here's some example uses!

Piping and Redirection

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.

Standard Library

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:

Name Description
rand A library for randomness
time A library with date and time functions
math A module for math and trig functionality
fs A module for interacting with the file system
fn A functional programming library
fmt A library for text formatting on the console (color, styling, hyperlinks, text wrapping, etc.)
os A small module with the host's OS info
widget A module for creating text widgets
shell A small module for information about the Dune shell
console A library for manipulating the console

For more information about each, just run echo library-name.

Installation

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.

Development Build

# 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 .

Releases

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.

After Install

# Just run the dune executable!
dunesh

More Repositories

1

oakc

A portable programming language with a compact intermediate representation
Rust
697
star
2

chess-engine

A dependency-free chess engine♟️ library built to run anywhere.
Rust
379
star
3

free

An esoteric programming language with an unusual compiler backend
Rust
320
star
4

atom

Shell scripting that will knock your socks off
Rust
258
star
5

wisp

A lisp👽 written in C++
C++
172
star
6

harbor

A language that ports⚓: examining the limits of compilation⚙️.
Rust
80
star
7

sage

A programming language that's wise beyond its bytes!🌱🌿🪴
Rust
32
star
8

smpl

A superset of brainfuck with dynamic memory management.
C++
23
star
9

maroon-lang

A (nearly) pure functional programming language.
Rust
22
star
10

tsar

Tsar programming language
Rust
13
star
11

honeycomb

A portable parser combinator library that does not require a runtime
Rust
10
star
12

game-of-life

A game of life🔬 simulator on an infinite♾️ plane
Rust
8
star
13

qalc

A very unstable and terrible language for quickly writing calculator programs
Rust
5
star
14

xasm

A cross platform, compiled and dynamically typed programming / intermediate language
Rust
5
star
15

sight

A library for Vision Processing
Python
5
star
16

lasm

A tiny and portable assembly language for complex compilers
Rust
4
star
17

program-evolution

Evolutionary algorithms applied to SKI combinator calclus and a Turing-machine-based architecture
Python
3
star
18

rusty-ci

A tool to generate buildbot projects from a YAML file
Rust
3
star
19

wisp-bootstrap

A bootstrapped lisp compiler
Common Lisp
3
star
20

battaliants

A roguelike ant-catching game written for a hackathon
GDScript
3
star
21

calendar

A tiny calendar program
Nim
2
star
22

pink-lang

A high level programming language that compiles to native
C++
2
star
23

blame-tracker

Accuse guilty developers!
Python
2
star
24

cable-lang-cxx

A fast dynamically typed language interoperable with C++
C++
2
star
25

adam-mcdaniel.github.io

My site📖
HTML
2
star
26

hlvm

A high level virtual machine library that can be used to easily make powerful programming languages
Rust
2
star
27

finn-assembler

The assembler for the Finn IR implemented using my HLVM in Rust
Rust
2
star
28

sage-chess

A chess engine written in my programming language, Sage🌱
C
2
star
29

xasm-vm

All of the implementations of virtual machines for the Xasm intermediate representation
1
star
30

Octaculus

Octaculus - 8-way directional gesture detection using machine learning and light dependent resistors
Jupyter Notebook
1
star
31

toki-pona-dataset

Dataset for Toki Pona constructed language
Jupyter Notebook
1
star
32

periwinkle

Language inspired by Python, Rust, and C++
Python
1
star
33

hlvm_runtime

The runtime library for HLVM
Rust
1
star
34

xassembler

The assembler for XASM
Rust
1
star
35

Dynamite

An interpreted programming language with speed and extensibility in mind.
Go
1
star
36

dune-old

A cross platform shell built with my ideals in mind
Rust
1
star
37

comment

Strip multiple types of comments
Rust
1
star
38

ski

SKI combinator calculus implemented in rust
Rust
1
star
39

xmachine

A fast, cross platform virtual machine implemented in Rust without the Standard Library.
Rust
1
star
40

adams-bot

A mini me for my Discord server!
C
1
star
41

adam-mcdaniel

My profile📝
1
star
42

rapture

A library to write installation programs / a tool to install programs. Meant to be to the future backend of rusty-ci.
Rust
1
star
43

xgopher

Golang Xasm virtual machine implementation
Go
1
star
44

lite

A tiny text editor📝 with syntax highlighting🎨, undo/redo🧰, and a language for customizing the editor🏗️
Rust
1
star
45

resume

My Resume
1
star
46

vpn

A VPN implemented over TLS/SSL written in C
C
1
star
47

gc-rust

A rust library to implement reference counting garbage collection
Rust
1
star
48

ramify

A functional programming language with builtin parallelism
Rust
1
star
49

music-generator

A tool to generate a lead sheet in a specified key given a certain number of choruses and verses.
Rust
1
star