{"id":20230832,"url":"https://github.com/sharkdp/pysh","last_synced_at":"2025-04-10T18:05:18.743Z","repository":{"id":65984778,"uuid":"83895999","full_name":"sharkdp/pysh","owner":"sharkdp","description":"Python-enhanced bash scripts","archived":false,"fork":false,"pushed_at":"2018-10-19T19:03:10.000Z","size":9,"stargazers_count":61,"open_issues_count":0,"forks_count":6,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-03-24T15:47:27.568Z","etag":null,"topics":["bash","python","shell-script"],"latest_commit_sha":null,"homepage":null,"language":"Python","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/sharkdp.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}},"created_at":"2017-03-04T13:39:53.000Z","updated_at":"2025-03-10T06:25:17.000Z","dependencies_parsed_at":"2023-02-19T18:35:20.078Z","dependency_job_id":null,"html_url":"https://github.com/sharkdp/pysh","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/sharkdp%2Fpysh","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sharkdp%2Fpysh/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sharkdp%2Fpysh/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sharkdp%2Fpysh/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sharkdp","download_url":"https://codeload.github.com/sharkdp/pysh/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248265837,"owners_count":21075051,"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","python","shell-script"],"created_at":"2024-11-14T07:43:53.047Z","updated_at":"2025-04-10T18:05:18.711Z","avatar_url":"https://github.com/sharkdp.png","language":"Python","readme":"# pysh\nPython-enhanced bash scripts.\n\n[![Build Status](https://travis-ci.org/sharkdp/pysh.svg?branch=master)](https://travis-ci.org/sharkdp/pysh)\n\n`pysh` allows you to write bash scripts that include short snippets of Python\ncode with a local environment that is shared between bash and Python.\n\n## Example\nLines that start with `#\u003e ` are evaluated as Python:\n```bash\n##### From bash to python #####\n\nbashVariable=\"Hello world\"\n#\u003e print(\"{} from python!\".format(bashVariable))\n\n\n##### From python to bash #####\n\n#\u003e pythonVariable = \" \".join([\"Hello\", \"world\"])\necho \"$pythonVariable from bash!\"\n\n\n######## Back and forth #######\n\nfor file in *.csv; do\n    echo\n    echo \"before: $file\"\n\n    #\u003e base, ext = os.path.splitext(file)\n    #\u003e file = base.upper() + ext\n\n    echo \"after:  $file\"\ndone\n```\n\nRun it:\n```\n\u003e ls\ndummy.csv  important.csv  example.sh\n\n\u003e pysh example.sh\nHello world from python!\nHello world from bash!\n\nbefore: dummy.csv\nafter:  DUMMY.csv\n\nbefore: important.csv\nafter:  IMPORTANT.csv\n```\n\n## Caveats\n\nThis is only supported for Python 3.4 and above due to [`redirect_stdout`](https://docs.python.org/3/library/contextlib.html#contextlib.redirect_stdout).\n\n## Disclaimer / warning\nThis is a prototype implementation with lots of evil hacks.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsharkdp%2Fpysh","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsharkdp%2Fpysh","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsharkdp%2Fpysh/lists"}