{"id":15061183,"url":"https://github.com/ocaml-community/ocaml-linenoise","last_synced_at":"2025-07-01T10:04:52.745Z","repository":{"id":59414557,"uuid":"53555897","full_name":"ocaml-community/ocaml-linenoise","owner":"ocaml-community","description":"Self-contained OCaml bindings to linenoise, easy high level readline functionality in OCaml","archived":false,"fork":false,"pushed_at":"2024-07-29T18:06:49.000Z","size":272,"stargazers_count":55,"open_issues_count":4,"forks_count":10,"subscribers_count":8,"default_branch":"main","last_synced_at":"2025-06-25T23:15:35.754Z","etag":null,"topics":["c-bindings","linenoise","ocaml","readline","standalone"],"latest_commit_sha":null,"homepage":"http://ocaml-community.github.io/ocaml-linenoise/","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ocaml-community.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGES.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-03-10T04:50:15.000Z","updated_at":"2025-04-12T06:27:30.000Z","dependencies_parsed_at":"2024-02-21T06:25:14.983Z","dependency_job_id":"4077009f-74ce-41ba-84d6-b9dd8890ce69","html_url":"https://github.com/ocaml-community/ocaml-linenoise","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"purl":"pkg:github/ocaml-community/ocaml-linenoise","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ocaml-community%2Focaml-linenoise","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ocaml-community%2Focaml-linenoise/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ocaml-community%2Focaml-linenoise/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ocaml-community%2Focaml-linenoise/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ocaml-community","download_url":"https://codeload.github.com/ocaml-community/ocaml-linenoise/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ocaml-community%2Focaml-linenoise/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262941543,"owners_count":23388148,"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":["c-bindings","linenoise","ocaml","readline","standalone"],"created_at":"2024-09-24T23:11:17.621Z","updated_at":"2025-07-01T10:04:52.720Z","avatar_url":"https://github.com/ocaml-community.png","language":"C","funding_links":[],"categories":["User Interface"],"sub_categories":[],"readme":"Linenoise in OCaml\n--------------------\n\n[![build](https://github.com/ocaml-community/ocaml-linenoise/actions/workflows/main.yml/badge.svg)](https://github.com/ocaml-community/ocaml-linenoise/actions/workflows/main.yml)\n\n# Benefits\n1. BSD licensed.\n2. No system dependencies, no need for `readline` on your machine.\n3. Related to 2, these bindings are self-contained, the source for\n   `linenoise` is in this repo and compiled all together with the\n   `OCaml`.\n4. Written in OCaml + C.\n5. Pretty cool hints feature, see the gif.\n6. Additional features compared to linenoise, such as history search\n\n# Installation\n\nIt is easy with `opam`\n\n```shell\n$ opam install linenoise\n```\n\nSee the pretty\ndocumentation [here](https://ocaml-community.github.io/ocaml-linenoise/)\n\n# Example code\nThis example is also included in the repo under examples:\n\n\u003cp align=\"center\" style='min-width:100%'\u003e \n  \u003cimg style='min-width:100%' src='example.gif'/\u003e \n\u003c/p\u003e\n\n\n```ocaml\nlet rec user_input prompt cb =\n  match LNoise.linenoise prompt with\n  | None -\u003e ()\n  | Some v -\u003e\n    cb v;\n    user_input prompt cb\n\nlet () =\n  (* LNoise.set_multiline true; *)\n  LNoise.set_hints_callback (fun line -\u003e\n      if line \u003c\u003e \"git remote add \" then None\n      else Some (\" \u003cthis is the remote name\u003e \u003cthis is the remote URL\u003e\",\n                 LNoise.Yellow,\n                 true)\n    );\n  LNoise.history_load ~filename:\"history.txt\" |\u003e ignore;\n  LNoise.history_set ~max_length:100 |\u003e ignore;\n  LNoise.set_completion_callback begin fun line_so_far ln_completions -\u003e\n    if line_so_far \u003c\u003e \"\" \u0026\u0026 line_so_far.[0] = 'h' then\n      [\"Hey\"; \"Howard\"; \"Hughes\";\"Hocus\"]\n      |\u003e List.iter (LNoise.add_completion ln_completions);\n  end;\n  [\"These are OCaml bindings to linenoise\";\n   \"get tab completion with \u003cTAB\u003e, type h then hit \u003cTAB\u003e\";\n   \"type quit to exit gracefully\";\n   \"By Edgar Aroutiounian\\n\"]\n  |\u003e List.iter print_endline;\n  (fun from_user -\u003e\n     if from_user = \"quit\" then exit 0;\n     LNoise.history_add from_user |\u003e ignore;\n     LNoise.history_save ~filename:\"history.txt\" |\u003e ignore;\n     Printf.sprintf \"Got: %s\" from_user |\u003e print_endline\n  )\n  |\u003e user_input \"test_program\u003e \"\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Focaml-community%2Focaml-linenoise","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Focaml-community%2Focaml-linenoise","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Focaml-community%2Focaml-linenoise/lists"}