{"id":23391273,"url":"https://github.com/techcable/zsh2xonsh","last_synced_at":"2026-03-04T20:02:53.599Z","repository":{"id":57478575,"uuid":"445746937","full_name":"Techcable/zsh2xonsh","owner":"Techcable","description":"A highly-compatible translator from zsh -\u003e xonsh","archived":false,"fork":false,"pushed_at":"2023-01-25T21:39:46.000Z","size":107,"stargazers_count":5,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-02-28T17:27:18.011Z","etag":null,"topics":["compat","python","xonsh","zsh"],"latest_commit_sha":null,"homepage":"","language":"Python","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/Techcable.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-01-08T06:52:25.000Z","updated_at":"2026-02-12T06:45:44.000Z","dependencies_parsed_at":"2023-02-14T11:45:54.494Z","dependency_job_id":null,"html_url":"https://github.com/Techcable/zsh2xonsh","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/Techcable/zsh2xonsh","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Techcable%2Fzsh2xonsh","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Techcable%2Fzsh2xonsh/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Techcable%2Fzsh2xonsh/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Techcable%2Fzsh2xonsh/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Techcable","download_url":"https://codeload.github.com/Techcable/zsh2xonsh/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Techcable%2Fzsh2xonsh/sbom","scorecard":{"id":138593,"data":{"date":"2025-08-11","repo":{"name":"github.com/Techcable/zsh2xonsh","commit":"a16f5097d141949d0d986ea1a175286533d24f08"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3,"checks":[{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Code-Review","score":0,"reason":"Found 0/30 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE.md:0","Info: FSF or OSI recognized license: MIT License: LICENSE.md:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}}]},"last_synced_at":"2025-08-16T07:19:58.559Z","repository_id":57478575,"created_at":"2025-08-16T07:19:58.559Z","updated_at":"2025-08-16T07:19:58.559Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30091574,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-04T19:41:02.502Z","status":"ssl_error","status_checked_at":"2026-03-04T19:40:05.550Z","response_time":59,"last_error":"SSL_read: 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":["compat","python","xonsh","zsh"],"created_at":"2024-12-22T04:14:34.852Z","updated_at":"2026-03-04T20:02:53.558Z","avatar_url":"https://github.com/Techcable.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"zsh2xonsh ![pypy](https://img.shields.io/pypi/v/zsh2xonsh) ![powered-by-xonsh](https://img.shields.io/badge/powered%20by-xonsh-brightgreen)\n=========\nHave you heard of [xonsh](https://xon.sh/)? It's a Python-powered shell.\n\nYou can do amazing things like this:\n````xonsh\n# Interpolate python -\u003e shell\necho @(i for i in range(42))\n\n# Interpolate shell -\u003e python\nfor filename in `.*`:\n    print(filename)\n    du -sh @(filename)\n\n# Execute regular shell commands too\ncat /etc/passwd | grep root\n````\n\nAs you can immagine, this awesomeness is not POSIX-compliant :(\n\nThis makes it difficult to setup your `$PATH` and do things like `eval $(brew shellenv)`\n\nThis package exists to translate traditional `zsh` scripts into `xonsh` code.\n\n## Compatibility (and how it works)\nThe goal is 100% compatibility for a *subset* of shell. \n\nCompatibility is achived by delegating most of the work to zsh.\n\nThat is, `export FOO=\"$(echo bar)\"` in a shell script becomes (essentially)  `$FOO=$(zsh -c 'echo bar')` in xonsh.\n\nWe have `zsh` handle all the globbing/quoting/bizzare POSIX quirks.\n\nIn the face of ambiguity, or if we encounter an unsupported feature (like a `for` loop), then we fail-fast.\n\nThis is the most important feature. If something can't be supported 100%, then it will throw a descriptive error. Anything else is a bug :)\n\n### Features\nThe included shell features include:\n\n1. Quoted expressions `\"$VAR glob/*\"` (zsh does expansion here)\n2. Unquoted literals `12`, `foo` `~/foo` (mostly translated directly)\n3. Command substitutions \"$(cat file.txt | grep bar)\" \n   - zsh does all the work here\n   - Supports both quoted and unquoted forms\n3. If/then statements\n   - Conditionals are executed by zsh (so `[[ -d \"foo\" ]]` works perfectly)\n   - Translated into python if (so body will not run unless conditional passes)\n4. Exporting variables `export FOO=$BAR`\n   - Translates `$PATH` correctly (xonsh thinks it's a list, zsh thinks it's a string)\n   - This is where the subprocess approach doesn't work blindly....\n      - We support it cleanly by doing the left-hand assignment xonsh, and the right-hand expression in `zsh` :)\n   - Local variables (local var=x) are supported too (with the proper scoping)\n5. Support `alias foo=\"bar\"`\n   - This even supports globbing in the alias, so `alias lsdot=\"echo .*\"` would glob in the same way that zsh does (experimental)\n6. Basic support for function declarations (and having positional arguments)\n   - Local variables are scoped properly inside the function :)\n7. Support for 'echo' builtin as a python 'print'\n\nYou can also add \"external builtins\", which are extra commands that the script can invoke. In my own files, I use this to add an `extend_path` command (even though zsh2xonsh properly translates $PATH variables already, it's still a nice utility)\n\nMy [macbook config](./examples/macbook2021-config.zsh) is a good example of the full power of the translator. It supports function declarations, if/then statements and conditionals (all in an attempt to cleanup homebrew cludges lol).\n\nAll of these behaviors should be 100% compatible with their zsh equivalents.\nIf you try anything else (or encounter an unsupported corner case), then you will get a descripitive error :)\n\n## Installation \u0026 Usage\nThis is a pypi package, install it with `pip install zsh2xonsh`.\n\nThe API is simple, run `translate_to_xonsh(str) -\u003e str` to translate from `zsh` -\u003e `xonsh` code.\nThis does not require xonsh at runtime, and can be done ahead of time. \n\nIf you want to evaluate the code immediately after translating it (for example in a `.xonshrc`), you can use\n. This requires xonsh at runtime (obviously) and uses the `evalx` builtin.\n\nAdditionally you can use the CLI (`python -m zsh2xonsh`), which accepts an import.\n\nIf you want to provide extra utility functions to your code, you can define `extra_builtins`.\n\n### Example\nIn my `.xonshrc`, I dynamically translate and evaluate the output of `brew shellenv`:\n````xonsh\nzsh2xonsh.translate_to_xonsh_and_eval($(/opt/homebrew/bin/brew shellenv))\n````\n\nLikewise, I do the same with my machine-specific `.config.zsh` files (in the example directory).\n\n## Motiviation\nFirst of all, I need support for `eval $(brew shellenv)` .\n\nSecond of all, I still use `zsh` as my backup shell (by the use of my [wrap-shell](https://github.com/Techcable/wrap-shell) utility).\n\nThis means I need to setup `$PATH` and other enviornment variables for both of these shells, indepenently of each other.\n\nThe natural way to set these up is by using shell scripts.\nI have a seperate one for each of my different machines (server, macbook, old lapotop, etc)\n\nFor each of these (tiny) shell scripts, `zsh2xonsh` works very well :)\n\nSo in addition to properly translating `$(brew shellenv)`,\nit also needs to translate these basic shell \"environement files\".\n\nTurns out, dealing with platform specific quirks can get pretty intense and requires things like function definitions and if/then statements.\nIn order to properly support `export`s, control flow has to be emulated in Python (can't just delegate to zsh).","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftechcable%2Fzsh2xonsh","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftechcable%2Fzsh2xonsh","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftechcable%2Fzsh2xonsh/lists"}