michaelmacinnis / Oh

Licence: mit
A new Unix shell.

Programming Languages

go
31211 projects - #10 most used programming language
shell
77523 projects
language
365 projects
scheme
763 projects

Projects that are alternatives of or similar to Oh

Simple
The Simple Intelligent and Modular Programming Language and Environment
Stars: ✭ 120 (-90.05%)
Mutual labels:  command-line, unix, interpreter
Enso Archive
Looking for Enso, the visual programming language? ➡️ https://github.com/enso-org/enso
Stars: ✭ 305 (-74.71%)
Mutual labels:  interpreter, functional
Melang
A script language of preemptive scheduling coroutine in single thread
Stars: ✭ 273 (-77.36%)
Mutual labels:  unix, interpreter
Tcl
The Tcl Core. (Mirror of core.tcl-lang.org)
Stars: ✭ 342 (-71.64%)
Mutual labels:  unix, interpreter
pocketlang
A lightweight, fast embeddable scripting language.
Stars: ✭ 1,412 (+17.08%)
Mutual labels:  functional, interpreter
tush
No description or website provided.
Stars: ✭ 23 (-98.09%)
Mutual labels:  unix, functional
Bfs
A breadth-first version of the UNIX find command
Stars: ✭ 336 (-72.14%)
Mutual labels:  command-line, unix
Bash Boilerplate
A collection of Bash scripts for creating safe and useful command line programs.
Stars: ✭ 447 (-62.94%)
Mutual labels:  command-line, unix
Jtc
JSON processing utility
Stars: ✭ 425 (-64.76%)
Mutual labels:  command-line, unix
Enso
Hybrid visual and textual functional programming.
Stars: ✭ 5,238 (+334.33%)
Mutual labels:  interpreter, functional
Jquery.terminal
jQuery Terminal Emulator - JavaScript library for creating web-based terminals with custom commands
Stars: ✭ 2,623 (+117.5%)
Mutual labels:  command-line, interpreter
Ed
A modern UNIX ed (line editor) clone written in Go
Stars: ✭ 44 (-96.35%)
Mutual labels:  command-line, unix
Survey
A golang library for building interactive and accessible prompts with full support for windows and posix terminals.
Stars: ✭ 2,843 (+135.74%)
Mutual labels:  command-line, unix
snap
Snap Programming Language
Stars: ✭ 20 (-98.34%)
Mutual labels:  functional, interpreter
Snapstub
Copy API endpoints to your fs and run a local server using them
Stars: ✭ 193 (-84%)
Mutual labels:  command-line, unix
Go Tea
Tea provides an Elm inspired functional framework for interactive command-line programs.
Stars: ✭ 329 (-72.72%)
Mutual labels:  command-line, functional
Unix Text Commands
Unix Text Processing Command Reference
Stars: ✭ 78 (-93.53%)
Mutual labels:  command-line, unix
Cli Boot.camp
💻 command-line bootcamp adventure in your browser
Stars: ✭ 88 (-92.7%)
Mutual labels:  command-line, unix
Cloe
Cloe programming language
Stars: ✭ 398 (-67%)
Mutual labels:  concurrent, functional
Ipt
Interactive Pipe To: The Node.js cli interactive workflow
Stars: ✭ 783 (-35.07%)
Mutual labels:  command-line, unix

Oh, a new Unix shell

Why oh?

Oh is a reimagining of the Unix shell as a programming language.

Oh provides:

  • Lexical scope;
  • Exceptions;
  • First-class channels, pipes, environments and functions;
  • A list type (no word splitting);
  • Rich return values that work with standard shell constructs;
  • Kernel-style fexprs (allowing the definition of new language constructs);
  • Support for modularity;
  • A simplified set of evaluation and quoting rules; and
  • A syntax that deviates as little as possible from established conventions;

Oh's goal is a language that is not only more powerful and more regular but one that respects the conventions established by the Unix shell over the last half-century.

Getting started

Installing

The easiest way to try oh is to download a precompiled binary.

DragonFly BSD

amd64

FreeBSD

386, amd64, arm, arm64

illumos

amd64

Linux

386, amd64, arm, arm64, mips, mips64, mips64le, mipsle, ppc64, ppc64le, riscv64, s390x

macOS

amd64, arm64

OpenBSD

386, amd64, arm, arm64, mips64

Solaris

amd64

You can also build oh from source. With Go 1.16 or later installed, type,

go get github.com/michaelmacinnis/oh

Configuring

When oh starts, it attempts to read a file called .oh-rc in the home directory of the current user. You can override this path by setting the OH_RC environment variable to the full path of an alternative file before invoking oh.

The oh rc file is useful for setting environment variables and defining custom commands. It's also a good place to override oh's default prompt. The command below replaces oh's default prompt method with one that displays the current date.

replace-make-prompt (method (suffix) {
    return `(date)$suffix
})

Oh (thanks to peterh/liner) also provides a searchable command history. By default, this history is stored in a file called .oh-history in your home directory. You can override this by setting the OH_HISTORY environment variable to the full path of an alternative file before invoking oh.

Comparing oh to other Unix shells

Oh is a Unix shell. If you've used other Unix shells, oh should feel familiar. Below are some specific differences you may encounter.

Clobbering

When redirecting output oh will not overwrite an existing file. To force oh to overwrite (clobber) an existing file add a pipe, |, character immediately after the redirection operator. For example,

command >| out.txt

Oh's pipe and redirection syntax is as follows.

Syntax Redirection
< input-from
> output-to
>& output-errors-to
>&| output-errors-clobbers
>> append-output-to
>>& append-output-errors-to
>| output-clobbers
| pipe-output-to
|& pipe-output-errors-to
|< -named-pipe-input-from*
|> -named-pipe-output-to*

* - Used in process substitution.

Command substitution

Many Unix shells support command substitution using the historical backtick syntax,

`command`

or the POSIX syntax,

$(command)

Oh has one syntax for command substitution,

`(command)

This syntax is both nestable and unambiguous.

Here documents

Oh does not have here documents. It does however allow strings to span lines and provides a here command that takes a string argument and can be used to the same effect. For example,

# Build oh for supported BSD platforms
here "
dragonfly amd64
freebsd 386
freebsd amd64
freebsd arm
freebsd arm64
openbsd 386
openbsd amd64
openbsd arm
openbsd arm64
openbsd mips64
" | mill (o a) {
    echo ${o}/${a}
    GOOS=${o} GOARCH=${a} go build -o oh-latest-${o}-${a}
}

Variables

To introduce a new variable, use the define command,

define x 3

To introduce a variable that will be visible to external processes, use the export command,

export GOROOT /usr/local/go

To set the value of an existing variable, use the set command,

set x 4

Variables and implicit concatenation

Like other shells, oh implicitly concatenates adjacent string/symbol values. Unlike other shells, oh allows a larger set of characters to appear in variable names. In addition to letters, numbers, and the underscore character, the following characters,

'!', '%', '*', '+', '-', '?', '[', ']',  and '^' 

can be used in oh variable names. The command,

echo $set!

will cause oh to attempt to resolve a variable called set!. The following characters,

',', '.', '/', ':', '=', '@', and '~'

always result in a symbol of one character. This ensures that commands like,

cd $PWD/$dir

work as expected. When using implicit concatentation, unexpected behavior can be avoided by enclosing variable names in braces.

More detailed comparison

For a detailed comparison to other Unix shells see: Comparing oh to other Unix Shells

Using oh

For more information on using oh, see: Using oh

Contributing to oh

Oh is an ongoing experiment and it needs your help. Try oh. Let me know what works for you and what doesn't.

Pull requests are welcome. For information on contributing, see: CONTRIBUTING

You can also sponsor me through GitHub Sponsors or Patreon.

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].