{"id":22787446,"url":"https://github.com/cdrubin/bash_ui","last_synced_at":"2025-04-15T23:39:35.218Z","repository":{"id":68785033,"uuid":"46491598","full_name":"cdrubin/bash_ui","owner":"cdrubin","description":"respond to arrow keys for selections in bash scripts","archived":false,"fork":false,"pushed_at":"2024-11-09T19:03:46.000Z","size":35,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-11-09T19:35:52.708Z","etag":null,"topics":["bash","ui"],"latest_commit_sha":null,"homepage":"","language":"Shell","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/cdrubin.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-11-19T12:44:24.000Z","updated_at":"2024-11-09T19:03:49.000Z","dependencies_parsed_at":"2024-11-09T19:27:40.247Z","dependency_job_id":"fb85e8e4-e2d2-43e4-ad1a-b80255d7dce2","html_url":"https://github.com/cdrubin/bash_ui","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cdrubin%2Fbash_ui","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cdrubin%2Fbash_ui/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cdrubin%2Fbash_ui/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cdrubin%2Fbash_ui/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cdrubin","download_url":"https://codeload.github.com/cdrubin/bash_ui/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":229313606,"owners_count":18053714,"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":["bash","ui"],"created_at":"2024-12-12T00:57:16.603Z","updated_at":"2024-12-12T00:57:17.119Z","avatar_url":"https://github.com/cdrubin.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# bash_ui \nSome helpful functions for making interactive bash scripts on Linux terminal respond to cursor keys for data entry.\n\n(and now not dependent on tput from ncurses)\n\n[_DOWNLOAD_](https://raw.githubusercontent.com/cdrubin/bash_ui/master/bash_ui.sh)\n\n\n## _select_, _multi-select_ and _select value_\n\n----------\n### Example 1 (_select_):\n\nAllow a user to select a path\n\n\n```sh\n\nsource bash_ui.sh\n\nCHOICES=`find . -maxdepth 1 -mindepth 1 -type d -printf '%f\\n'`\nchoose_one\n\necho $CHOSEN\n\n```\n\n\n---------\n### Example 2 (_select multiple_):\n\nAsk user to select from a set of options\n\n```sh\n\nsource bash_ui.sh\n\nCHOICES=`find . -maxdepth 1 -mindepth 1 -type d -printf '%f\\n'`\nchoose_multiple\n\necho $CHOSEN\n\n```\n\n\n---------\n### Example 3 (_select_):\n\n```sh\n\nsource bash_ui.sh\n\nread -r -d '' CHOICES \u003c\u003cEOT \n1. Option 1=1 \n2. Yes, option 2=2 \n3. Believe it or not, option 3=3 \nEOT \n\nchoose_one\n\nif [ \"$CHOSEN\" == \"3\" ]; then \n  echo \"Somehow it really was option 3 that was selected!\" \nfi \n```\n\n\n----------\n### Example 4 (_select value_):\n\n```sh\n\nsource bash_ui.sh\n\nread -r -d '' CHOICES \u003c\u003cEOT \none=1 \ntwo=2\nthree=3\nall=1\\n2\\n3\nEOT \n\nchoose_one\n\nif [ ${CHOSEN} == \"3\" ]; then \n  echo \"'three' which corresponds to value 3 was selected!\" \nfi \n```\n\n# shui\n\n(welcome to __shui__! [DOWNLOAD](https://raw.githubusercontent.com/cdrubin/bash_ui/master/shui))\n\nA helper script that does not need to be sourced, works in bash \u003c 4 (hello macOS) and with Linux and Mac terminals\n\n----------\n### Example 5 (_select_)\n\n```sh\n#!/bin/bash\n\nresult=$(find /home -maxdepth 1 -mindepth 1 -type d -printf '%f\\n' | ./shui 2\u003e\u00261 1\u003e/dev/tty)\necho \"Chosen home dir: $result\"\n\n```\n\n----------\n### Example 6 (_select multiple_)\n\n```sh\n#!/bin/bash\n\nresult=$(find /home -maxdepth 1 -mindepth 1 -type d -printf '%f\\n' | ./shui multiple 2\u003e\u00261 1\u003e/dev/tty)\necho \"Chosen home directories:\"\necho \"$result\"\n\n```\n\n----------\n### Example 7 (_select multiple from provided heredoc_)\n\n```sh\n#!/bin/bash\n\necho \"Choose your favourite characters\"\nread -r -d '' CHOICES \u003c\u003c- EOS\nRoger Ellison\nDuiwel Dewet\nRoger Rabbit\nEOS\n\nresult=$(echo -e \"$CHOICES\" | ./shui 2\u003e\u00261 1\u003e/dev/tty)\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcdrubin%2Fbash_ui","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcdrubin%2Fbash_ui","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcdrubin%2Fbash_ui/lists"}