{"id":13438856,"url":"https://github.com/andrewchambers/janetsh","last_synced_at":"2025-07-10T01:33:21.899Z","repository":{"id":147602396,"uuid":"185770038","full_name":"andrewchambers/janetsh","owner":"andrewchambers","description":"A powerful new shell that uses the janet programming language for both the implementation and repl.","archived":false,"fork":false,"pushed_at":"2020-01-19T22:08:54.000Z","size":1074,"stargazers_count":381,"open_issues_count":43,"forks_count":13,"subscribers_count":14,"default_branch":"master","last_synced_at":"2025-07-05T10:15:43.760Z","etag":null,"topics":["janet","shell"],"latest_commit_sha":null,"homepage":"https://janet-shell.org","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/andrewchambers.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":"support/build-and-run","governance":null,"roadmap":null,"authors":null},"funding":{"github":null,"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"custom":"https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick\u0026hosted_button_id=Y3SWVCXV3PEA6\u0026source=url"}},"created_at":"2019-05-09T09:37:07.000Z","updated_at":"2025-06-21T16:56:01.000Z","dependencies_parsed_at":"2023-07-10T02:21:34.973Z","dependency_job_id":null,"html_url":"https://github.com/andrewchambers/janetsh","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/andrewchambers/janetsh","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrewchambers%2Fjanetsh","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrewchambers%2Fjanetsh/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrewchambers%2Fjanetsh/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrewchambers%2Fjanetsh/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/andrewchambers","download_url":"https://codeload.github.com/andrewchambers/janetsh/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrewchambers%2Fjanetsh/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264512352,"owners_count":23620320,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["janet","shell"],"created_at":"2024-07-31T03:01:09.011Z","updated_at":"2025-07-10T01:33:21.833Z","avatar_url":"https://github.com/andrewchambers.png","language":"C","funding_links":["https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick\u0026hosted_button_id=Y3SWVCXV3PEA6\u0026source=url"],"categories":["C","shell"],"sub_categories":["repl"],"readme":"# Janetsh \n\n[![Gitter](https://badges.gitter.im/janetsh/community.svg)](https://gitter.im/janetsh/community?utm_source=badge\u0026utm_medium=badge\u0026utm_campaign=pr-badge)\n\n[Website](https://janet-shell.org)\n\n[Mailing list](https://lists.sr.ht/~ach/janetsh)\n\n[CI](https://builds.sr.ht/~ach/janetsh)\n\n\nA new system shell that uses the [Janet](https://janet-lang.org/) programming language\nfor high level scripting while also supporting the things we love about sh.\n\nMinimal knowledge of janet is required for basic shell usage,\nbut know that as you become more familiar with janet, your shell will gain the power of:\n\n- A powerful standard library.\n- Functional and imperative programming.\n- Powerful lisp macros.\n- Runtime loadable extension modules written in C/C++/rust/zig...\n- Coroutines and exceptions.\n- Much much more.\n\nHelp develop janetsh [donate via paypal](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick\u0026hosted_button_id=Y3SWVCXV3PEA6\u0026source=url)\n\n# Status\n\nJanetsh development has slowed and I am not actively working on it for now.\nSome of it is no longer compatible with the latest janet release.\n\nThat being said, I consider janetsh a successful proof of concept and place to draw\ncode and ideas from whenever the next attempt at fixing shells gets my attention.\n\nOne potential avenue for janetsh2 in the future is to integrate janet syntax\nwith the shell library:\n\nhttps://github.com/emersion/mrsh\n\nIf we do this, we can have POSIX compatibility when we need it, as well as avoid implementing\nmost of the complexity in a shell, and can instead focusing on delivering on the important\nideas of janetsh.\n\n# See it in action\n\n[![asciicast](https://asciinema.org/a/248403.svg)](https://asciinema.org/a/248403)\n\n[demo source code](./demos/demos.janet) [demo rc file](https://github.com/andrewchambers/janetsh/blob/master/www/gallery/simple-andrew-chambers.rc)\n\n# Examples\n\n## Basic shell usage\n\nAs you would expect:\n```\n$ ls -la | head -n 3\ntotal 100\ndrwxr-xr-x 1 ac users   220 May 13 20:16 .\ndrwxr-xr-x 1 ac users   760 May 12 21:08 ..\n0\n\n$ echo foo \u003e /dev/null\n0\n\n$ sleep 5 \u0026\n@{:pgid 82190 :procs @[@{:args @[\"sleep\" \"5\"]\n      :pid 82190\n      :stopped false\n      :redirs @[]}]}\n\n$ rm ./demos/*.gif\n0\n```\n\n## Functional programming\n\n```\n$ (map string/ascii-upper [\"functional\" \"programming\"])\n@[\"FUNCTIONAL\" \"PROGRAMMING\"]\n\n$ (defn lines [s] (string/split \"\\n\" s))\n\u003cfunction lines\u003e\n\n$ (lines ($$ ls | head -n 3))\n@[\"build.sh\" \"demos\" \"janetsh\" \"\"]\n\n$ echo (reduce + 0 [1 2 3])\n6\n0\n```\n\n## Command capture\n\n```\n$ (string/ascii-upper ($$ echo command string capture))\n\"COMMAND STRING CAPTURE\\n\"\n\n$ ($$_ echo trimmed capture)\n\"trimmed capture\"\n\n$ (if (= 0 ($? touch /tmp/test.txt)) \"success\")\n\"success\"\n\n$ (if ($?? touch /tmp/test.txt) \"shorthand success\")\n\"shorthand success\"\n```\n\n## Exceptions/Errors\n\n```\n$ (try\n    (do\n      ($ rm foo.txt)\n      ($ rm bar.txt)\n      ($ rm baz.txt))\n    ([err] (print \"got an error:\" err)))\n```\n\n## Mixing janet code and shell commands\n\n```\n$ (each f files (sh/$ wc -l [f]))\n```\n\n## Subshells\n\n```\n$ ls | head -n 3 | (out-lines string/ascii-upper)\nBUILD.SH\nDEMOS\nJANETSH\n0\n```\n\n# Reference Documentation\n\nHopefully in the future this sparse reference set will become more polished, but for now\nthe following snippets may help advanced users play with the shell in it's current state.\n\n## RC files\n\nJanetsh runs a user rc script ```~/.janetsh.rc``` at startup when in interactive mode. This\nfile can changed or disabled via command line flags.\n\nJanetsh runs ```/etc/janetsh.rc``` on any run if it exists. This file can be changed or disabled via\ncommand line flags.\n\n## Custom prompts\n\nUsers can set a custom prompt:\n```\n(set *get-prompt* (fn [p] \"$ \"))\n```\np is a janet standard library parser, which can be used to find the current repl nesting level.\n\n## Custom line completions\n\nUsers can set a custom line completion function:\n```\n(set *get-completions*\n  (fn [line word-start word-end]\n    @[\"your-completion\"]))\n```\n\n## History file\n\nBy default janetsh does not store any history to avoid accidental information leaks.\n\nTo enable history add the following line to your janet rc file:\n\n```\n(set *hist-file* (first (sh/expand \"~/.janetsh.hist\")))\n```\n\n## Job control\n\nA list of running jobs can be found in the variable sh/jobs, each\nof which is a janet table containing the current state of a user job/pipeline.\n\nThe sh package has some functions for manipulating jobs, such\nas putting them in the foreground, or terminating them. This\nis not a stable interface for now, so you will need to read the code yourself\nfor documentation.\n\nSome examples:\n\n```\nvim\n...\nCtrl+Z\n$ (sh/fg-job (first sh/jobs))\n...\nCtrl+Z\n$ sleep 60 \u0026\n$ (sh/terminate-all-jobs)\n$ (sh/disown-job (sh/$ sleep 60 \u0026))\n```\n\n# Custom builtin shell commands\n\nHere is an example of defining a new builtin shell command.\n```\n(defn- make-my-builtin\n  []\n  @{\n    :pre-fork\n      (fn pre-fork\n        [self args]\n        (print \"hello from shell process\"))\n    :post-fork\n      (fn post-fork\n        [self args]\n        (print \"hello from child process\"))\n  })\n\n(put sh/*builtins* \"my-builtin\" make-my-builtin)\n```\nIt is important to catch any errors and only report them\nfrom the child process. This means builtins can manipulate the\nshell internal state, but still behave like regular processes\nfor the purpose of exit codes, pipes and job control.\n\n# Installation\n\nFor the default build you will need pre released janet 1.0.0 built from source, readline and pkg-config installed on your system, then you can run:\n\n```\n./configure \u0026\u0026 make install\n```\n\nIf you want libedit instead of readline you can build with:\n\n```\n./configure --with-pkg-config-libedit\n```\n\nIf you don't want to depend on readline or libedit, you can use the bundled emulation.\n\n```\n./configure --with-readnoise\n```\n\nYou can also manually specify header paths, install paths and flags.\n\nTry ```./configure --help``` for a list of options.\n\n# Janetsh Internals\n\nInternally janetsh is implemented as a low level C library for the janet programming\nlanguage, a janet library and a small launcher that does some necessary setup/teardown.\n\nThe janet main implementation is a set of janet functions and macros that perform shell\njob control, control user input and manage your command pipelines.\n\nAt the highest level the user is presented with an\ninteractive repl interface which implicitly invokes a janet macro\nto give janet the familiar sh syntax. You can escape this implicit\nmacro by prefixing a line with '(' which reverts to regular janet mode.\n\nJanetsh can also be used for scripting, in which case it acts a small job control runtime and\nlauncher for janet programs.\n\n\n# Project Status and Donations\n\nThe project is at the proof of concept phase and is only\nusable by people brave and willing to fix things for\nthemselves.\n\nThe author would love donations or help from fellow developers to keep things going forward.\nDonations will go towards living expenses while developing janetsh and providing upstream support for\nthe janet programming language issues that affect Janetsh.\n\n\nThis project takes considerable time an effort, please [donate here via paypal](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick\u0026hosted_button_id=Y3SWVCXV3PEA6\u0026source=url) to keep the project alive.\n\nAt your request with each donation leave a message and if appropriate, it will be included below.\n\n# Sponsors\n\nYou - Your message\n\n# Authors\n\nThis project is being built with care by Andrew Chambers.\n\n# Thanks\n\nSpecial thanks to Calvin Rose for creating the Janet programming language.\n\nThanks to the authors of [closh](https://github.com/dundalek/closh), [rash](https://rash-lang.org/)\nand [xonsh](https://github.com/xonsh/xonsh) for providing inspiration for the project.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandrewchambers%2Fjanetsh","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fandrewchambers%2Fjanetsh","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandrewchambers%2Fjanetsh/lists"}