{"id":13551257,"url":"https://github.com/lovesegfault/beautysh","last_synced_at":"2026-03-17T21:36:08.622Z","repository":{"id":4172688,"uuid":"52216487","full_name":"lovesegfault/beautysh","owner":"lovesegfault","description":"A Bash beautifier for the masses.","archived":false,"fork":false,"pushed_at":"2025-05-01T00:08:24.000Z","size":360,"stargazers_count":485,"open_issues_count":41,"forks_count":45,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-05-13T09:08:53.677Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://pypi.python.org/pypi/beautysh","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/lovesegfault.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,"zenodo":null}},"created_at":"2016-02-21T16:46:12.000Z","updated_at":"2025-05-03T23:46:08.000Z","dependencies_parsed_at":"2023-07-05T20:16:41.762Z","dependency_job_id":"984120b4-d30e-43bf-b9a7-31b8e132cdeb","html_url":"https://github.com/lovesegfault/beautysh","commit_stats":{"total_commits":257,"total_committers":19,"mean_commits":"13.526315789473685","dds":"0.43190661478599224","last_synced_commit":"9845efc3ea3e86cc0d41465d720a47f521b2799c"},"previous_names":["bemeurer/beautysh"],"tags_count":24,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lovesegfault%2Fbeautysh","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lovesegfault%2Fbeautysh/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lovesegfault%2Fbeautysh/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lovesegfault%2Fbeautysh/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lovesegfault","download_url":"https://codeload.github.com/lovesegfault/beautysh/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254159194,"owners_count":22024558,"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":[],"created_at":"2024-08-01T12:01:45.146Z","updated_at":"2025-10-18T07:01:29.131Z","avatar_url":"https://github.com/lovesegfault.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"# Beautysh [![CI](https://github.com/lovesegfault/beautysh/actions/workflows/ci.yaml/badge.svg)](https://github.com/lovesegfault/beautysh/actions/workflows/ci.yaml)\n\nThis program takes upon itself the hard task of beautifying Bash scripts\n(yeesh). Processing Bash scripts is not trivial, they aren't like C or Java\nprograms — they have a lot of ambiguous syntax, and (shudder) you can use\nkeywords as variables. Years ago, while testing the first version of this\nprogram, I encountered this example:\n\n```shell\ndone=0;while (( $done \u003c= 10 ));do echo done=$done;done=$((done+1));done\n```\nSame name, but three distinct meanings (sigh). The Bash interpreter can sort out\nthis perversity, but I decided not to try to recreate the Bash interpreter to\nbeautify a script. This means there will be some border cases this Python\nprogram won't be able to process. But in tests with large Linux system\nBash scripts, its error-free score was ~99%.\n\n## Installation\n\nIf you have `pip` set up you can do\n\n```shell\npip install beautysh\n```\n\nor clone the repo and install:\n\n```shell\ngit clone https://github.com/lovesegfault/beautysh\ncd beautysh\npoetry install\n```\n\n## Usage\n\nYou can call Beautysh from the command line such as\n\n```shell\nbeautysh file1.sh file2.sh file3.sh\n```\n\nin which case it will beautify each one of the files.\n\nAvailable flags are:\n\n```\n  --indent-size INDENT_SIZE, -i INDENT_SIZE\n                        Sets the number of spaces to be used in indentation.\n  --backup, -b          Beautysh will create a backup file in the same path as\n                        the original.\n  --check, -c           Beautysh will just check the files without doing any\n                        in-place beautify.\n  --tab, -t             Sets indentation to tabs instead of spaces.\n  --force-function-style FORCE_FUNCTION_STYLE, -s FORCE_FUNCTION_STYLE\n                        Force a specific Bash function formatting. See below\n                        for more info.\n  --version, -v         Prints the version and exits.\n  --help, -h            Print this help message.\n\nBash function styles that can be specified via --force-function-style are:\n  fnpar: function keyword, open/closed parentheses, e.g.      function foo()\n  fnonly: function keyword, no open/closed parentheses, e.g.  function foo\n  paronly: no function keyword, open/closed parentheses, e.g. foo()\n```\n\nYou can also call beautysh as a module:\n\n```python3\nfrom beautysh import Beautify\n\nsource = \"my_string\"\n\nresult, error = Beautify().beautify_string(source)\n```\n\nAs written, beautysh can beautify large numbers of Bash scripts when called\nfrom a variety of means,including a Bash script:\n\n```shell\n#!/bin/sh\n\nfor path in `find /path -name '*.sh'`\ndo\n   beautysh $path\ndone\n```\n\nAs well as the more obvious example:\n\n```shell\n$ beautysh *.sh\n```\n\n\u003e **CAUTION**: Because Beautysh overwrites all the files submitted to it, this\n\u003e could have disastrous consequences if the files include some of the\n\u003e increasingly common Bash scripts that have appended binary content (a regime\n\u003e where Beautysh has undefined behaviour ). So please — back up your files,\n\u003e and don't treat Beautysh as a harmless utility. Even if that is true\n\u003e most of the time.\n\nBeautysh handles Bash here-docs with care(and there are probably some\nborder cases it doesn't handle). The basic idea is that the originator knew what\n format he wanted in the here-doc, and a beautifier shouldn't try to outguess\nhim. So Beautysh does all it can to pass along the here-doc content\nunchanged:\n\n```shell\nif true\nthen\n\n   echo \"Before here-doc\"\n\n   # Insert 2 lines in file, then save.\n   #--------Begin here document-----------#\nvi $TARGETFILE \u003c\u003cx23LimitStringx23\ni\nThis is line 1 of the example file.\nThis is line 2 of the example file.\n^[\nZZ\nx23LimitStringx23\n   #----------End here document-----------#\n\n   echo \"After here-doc\"\n\nfi\n```\n\nSpecial comments `@formatter:off` and `@formatter:on` are available to disable formatting around a block of statements.\n\n```shell\n# @formatter:off\ncommand \\\n    --option1 \\\n        --option2 \\\n            --option3 \\\n# @formatter:on\n\n```\nThis takes inspiration from the Eclipse feature.\n\n## Contributing\n\nContributions are welcome and appreciated, however test cases must be added to\nprevent regression. Adding a test case is easy, and involves the following:\n\n1. Create a file `tests/fixtures/my_test_name_raw.sh` containing the unformatted version\n   of your test case.\n1. Create a file `tests/fixtures/my_test_name_formatted.sh` containing the formatted version\n   of your test case.\n1. Register your test case in `tests/test_integration.py`, It should look\n   something like this:\n  ```python3\n  def test_my_test_name(self):\n      self.assert_formatting(\"my_test_name\")\n  ```\n\n________________________________________________________________________________\n\nOriginally written by [Paul Lutus](http://arachnoid.com/python/beautify_bash_program.html)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flovesegfault%2Fbeautysh","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flovesegfault%2Fbeautysh","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flovesegfault%2Fbeautysh/lists"}