{"id":27403734,"url":"https://github.com/pmav99/fxr","last_synced_at":"2025-10-17T08:44:21.738Z","repository":{"id":57432787,"uuid":"81569246","full_name":"pmav99/fxr","owner":"pmav99","description":"An ag/sed replacement","archived":false,"fork":false,"pushed_at":"2019-04-02T13:50:44.000Z","size":81,"stargazers_count":4,"open_issues_count":2,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-09-03T06:38:47.128Z","etag":null,"topics":["find-and-replace","python","python-search","regex"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pmav99.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}},"created_at":"2017-02-10T13:46:04.000Z","updated_at":"2019-04-02T13:50:45.000Z","dependencies_parsed_at":"2022-08-27T20:51:06.970Z","dependency_job_id":null,"html_url":"https://github.com/pmav99/fxr","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/pmav99/fxr","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pmav99%2Ffxr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pmav99%2Ffxr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pmav99%2Ffxr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pmav99%2Ffxr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pmav99","download_url":"https://codeload.github.com/pmav99/fxr/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pmav99%2Ffxr/sbom","scorecard":{"id":738681,"data":{"date":"2025-08-11","repo":{"name":"github.com/pmav99/fxr","commit":"7acdc1d221eff131e1086f3b8254f3a235f91844"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":2,"checks":[{"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":"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":"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":"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":"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":"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":"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":"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":"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":"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":"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":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: BSD 2-Clause \"Simplified\" License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"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":"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"}},{"name":"Vulnerabilities","score":2,"reason":"8 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: PYSEC-2024-48 / GHSA-fj7x-q9j7-g6q6","Warn: Project is vulnerable to: PYSEC-2020-92 / GHSA-hj5v-574p-mj7c","Warn: Project is vulnerable to: PYSEC-2022-42969","Warn: Project is vulnerable to: PYSEC-2020-176 / GHSA-3pqx-4fqf-j49f","Warn: Project is vulnerable to: PYSEC-2020-96 / GHSA-6757-jp84-gxfx","Warn: Project is vulnerable to: PYSEC-2021-142 / GHSA-8q59-q68h-6hv4","Warn: Project is vulnerable to: PYSEC-2024-187 / GHSA-rqc4-2hc7-8c8v","Warn: Project is vulnerable to: GHSA-jfmj-5v4g-7637"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-22T16:41:27.840Z","repository_id":57432787,"created_at":"2025-08-22T16:41:27.840Z","updated_at":"2025-08-22T16:41:27.840Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273403949,"owners_count":25099299,"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","status":"online","status_checked_at":"2025-09-03T02:00:09.631Z","response_time":76,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["find-and-replace","python","python-search","regex"],"created_at":"2025-04-14T04:55:06.507Z","updated_at":"2025-10-17T08:44:16.697Z","avatar_url":"https://github.com/pmav99.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# fxr\n\n[![Travis](https://travis-ci.org/pmav99/fxr.svg?branch=master)](https://travis-ci.org/pmav99/fxr)\n[![coveralls](https://coveralls.io/repos/pmav99/fxr/badge.svg?branch=master\u0026service=github)](https://coveralls.io/r/pmav99/fxr)\n\n`fxr` (pronounced \"fixer\") is a CLI utility that can be used to find matching patterns in text files\nand:\n\n* append/prepend lines\n* delete lines before/after the matching line.\n* replace text\n\nIn other words, you can consider it as a replacement for `ag`, `xargs` and `sed` (with a nicer API!)\n\n**Warning**: *`fxr` currently has no dry-run mode and by default changes files inplace. If you want\nbackups, you need to explicitly enable them!\n\n## Installation\n\n### Prerequisites\n\nAll you need is Python `3.6+` and a search program like\n[`ag`](https://github.com/ggreer/the_silver_searcher):\n\n### `pipx`\n\nThe recommended installation method is [pipx](https://github.com/cs01/pipx).  More\nspecifically, you can install `fxr` for your user with:\n\n```\npipx install fxr\n```\n\nThe above command will create a virtual environment in `~/.local/pipx/venvs/fxr`\nand add the `fxr` script in `~/.local/bin`.\n\n#### `pip`\n\nAlternatively you can use good old `pip` but this is more fragile than `pipx`.\n\n``` bash\npip install --user fxr\n```\n\n## Modes of operation\n\n`fxr` has three modes of operations:\n\n* `fxr add`\n* `fxr delete`\n* `fxr replace`\n\n### `fxr add`\n\nIn this mode you search for lines matching `\u003cpattern\u003e` and you append/prepend text to them.\n\n```\nfxr add \u003cpattern\u003e \u003cadded_text\u003e              # Appends text to lines matching pattern\nfxr add --prepend \u003cpattern\u003e \u003cadded_text\u003e    # Prepends text to lines matching pattern\n```\n\n### `fxr delete`\n\nIn this mode you search for lines matching `\u003cpattern\u003e` and you can:\n\n1. delete N lines preceding the matching line\n2. delete M lines following the matching line\n3. delete the matching line itself\n4. or any combination of the above!\n\nE.g. to delete 3 lines before the line matching pattern, 2 lines after it and the matching line\nitself:\n\n```\nfxr delete --before 3 --after 2 --include_line \u003cpattern\u003e\n```\n\n### `fxr replace`\n\nIn this mode you can replace text on a single line. This is more or less equivalent to:\n\n```\nag \u003cpattern\u003e -l | xargs sed -i 's/\u003cpattern\u003e/\u003creplacement\u003e/g'\n```\n\nYou can use it like this:\n\n```\nfxr replace \u003cpattern\u003e \u003creplacement\u003e\n```\n\n## Common interface\n\nAll the above subcommands share the following flags/arguments:\n\n* `--backup`: The provided value is used as a prefix for the backup files. If it is not provided,\n  the changes are being done in-place.\n* `--literal`: When you set this flag, the pattern will not be parsed as a regex.\n* `--raise-if-no-change`: When you set this flag, an exception will be raised if there were no\n  changes in the file.\n* `--single \u003cfilename\u003e`: When you specify this argument, fxr will only try to do its magic on the\n  specified file. I.e. `ag` will not be used.\n* `--search_prog`: If you don't like `ag` you can specify  an alternate program (e.g. `rg`).\n* `--search_args`: You can specify additional arguments for the search program.\n\n## Notes\n\n### Rationale\n\nThere were two compelling arguments that made me write this:\n\n1. `sed` regex engine is quite limited. E.g. there is no support for look-aheads and other more\n   advanced features, which you don't really need, until you need them!\n   ([link](https://www.gnu.org/software/sed/manual/html_node/Regular-Expressions.html)).\n\n2. The API for combining `ag`, `sed` and `xargs` is clunky at best (e.g. repeating `\u003cpattern\u003e` both\n   in `ag` and `sed` etc). E.g.:\n   `ag \u003cpattern\u003e -l | xargs sed -i 's/\u003cpattern\u003e/\u003creplacement\u003e/g'`\n\n\n### Performance\n\nThe script has not been written with performance in mind.  Since the search for matching files is\nbeing done using `ag`, performance shouldn't be too bad, but keep in mind that the main use case\nis to make changes to source code and configuration files; not a multi-GB CSV file/database dump.\n\n### Search programs\n\nIf you wish to use a different program than `ag` you can do so by using the appropriate `CLI` argument.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpmav99%2Ffxr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpmav99%2Ffxr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpmav99%2Ffxr/lists"}