{"id":17178000,"url":"https://github.com/curusarn/bash-zsh-compat-widgets","last_synced_at":"2026-01-20T20:02:44.197Z","repository":{"id":129172571,"uuid":"211972803","full_name":"curusarn/bash-zsh-compat-widgets","owner":"curusarn","description":"Use the same function as both Zsh ZLE widget and Bash readline \"widget\"","archived":false,"fork":false,"pushed_at":"2019-12-29T14:17:36.000Z","size":32,"stargazers_count":2,"open_issues_count":4,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-06T05:32:25.241Z","etag":null,"topics":["bash","compatibility","readline","zle-widgets","zsh"],"latest_commit_sha":null,"homepage":"","language":"Shell","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/curusarn.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2019-09-30T22:59:40.000Z","updated_at":"2023-03-07T17:44:44.000Z","dependencies_parsed_at":"2023-04-29T09:02:45.292Z","dependency_job_id":null,"html_url":"https://github.com/curusarn/bash-zsh-compat-widgets","commit_stats":{"total_commits":22,"total_committers":1,"mean_commits":22.0,"dds":0.0,"last_synced_commit":"95387d94a4f5350f0242ea2e84e2a77ff9d02c40"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/curusarn/bash-zsh-compat-widgets","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/curusarn%2Fbash-zsh-compat-widgets","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/curusarn%2Fbash-zsh-compat-widgets/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/curusarn%2Fbash-zsh-compat-widgets/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/curusarn%2Fbash-zsh-compat-widgets/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/curusarn","download_url":"https://codeload.github.com/curusarn/bash-zsh-compat-widgets/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/curusarn%2Fbash-zsh-compat-widgets/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28612157,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-20T18:56:40.769Z","status":"ssl_error","status_checked_at":"2026-01-20T18:54:26.653Z","response_time":117,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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","compatibility","readline","zle-widgets","zsh"],"created_at":"2024-10-15T00:05:41.494Z","updated_at":"2026-01-20T20:02:44.180Z","avatar_url":"https://github.com/curusarn.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# bash-zsh-compat-widgets\n\nThis project enables you to use the same function as both:\n\n- Zsh ZLE widget\n- Bash readline \"widget\"\n\n\n## Bindfunc\n\nBash uses `bind -x ...` to bind \"widgets\".\n\nZsh uses `zle -N ...` and then `keybind ...` to bind widgets.\n\n`bindfunc` is a wrapper around these commands that binds widgets in both bash and zsh.\n\nUse it like this:\n\n```sh\nsource bindfunc.sh\nbindfunc KEY_SEQUENCE SHELL_FUNCTION\n```\n\nWhen you need binding for a specific keymap (e.g. vi mode) use `-m`/`-M` option with zsh or bash keymap:\n\n```sh\nsource bindfunc.sh\nbindfunc -M vi-command KEY_SEQUENCE SHELL_FUNCTION\n```\n\nIf you need to be able to revert the binding later do it like this:\n\n```sh\nsource bindfunc.sh\nbindfunc --revert KEY_SEQUENCE SHELL_FUNCTION\n# using --revert options sets _bindfunc_revert variable to a command\n#         that can be evaluated to revert the bindfunc call\nrevert_bind=$_bindfunc_revert\n\n# do whatever\n\neval $revert_bind\n```\n\n*I know what you are thinking. Using `eval` is ugly and dangerous but just as in the case of `eval $(ssh-agent)` using `eval` is the best solution here.*\n\nYou can find more examples at the bottom of this page.\n\n## Compatibility wrapper\n\nPart of this project is a very simple compatibility layer that makes it possible to use simple zsh zle widgets in bash and all bash \"widgets\" in zsh.\n\nUse it like this:\n\n```sh\nmywidget_compat() {\n    __bindfunc_compat_wrapper mywidget_zsh\n}\n```\n\n## Example\n\nFull example showing how to use this project:\n\n```sh\nsource bindfunc.sh\n\nmywidget_bash() {\n    READLINE_LINE=\"# This was written by a bash readline \\\"widget\\\"\"\n}\n\nmywidget_zsh() {\n    BUFFER=\"# This was written by a zsh zle widget\"\n}\n\nmywidget_compat() {\n    __bindfunc_compat_wrapper mywidget_bash\n}\n\nmywidget_compat2() {\n    __bindfunc_compat_wrapper mywidget_zsh\n}\n\nbindfunc '\\C-o' \"mywidget_compat\"  \nbindfunc '\\C-p' \"mywidget_compat2\"  \n```\n\nJust run `source example.sh` in your terminal and press `Control-O` or `Control-P` to see it in practice.\n\nThere is a second `example_revert.sh` that shows how you can revert the bindings.\n\n1) activate the bindings by running `source example_revert.sh`\n1) press `Control-R` or `Control-P` to use them\n1) revert the bindings with `eval $revert_ctrl_r` and `eval $revert_ctrl_p`\n\nThere is yet another example `example_keymaps.sh` that shows how to bind to a specific keymap.\n\n## Dependencies\n\nbash 4.3+\n\nPretty much only OS that ships with bash older than this is macOS with bash 3.2.57\n \nzsh supports widgets since forever\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcurusarn%2Fbash-zsh-compat-widgets","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcurusarn%2Fbash-zsh-compat-widgets","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcurusarn%2Fbash-zsh-compat-widgets/lists"}