{"id":13579389,"url":"https://github.com/dalance/amber","last_synced_at":"2025-05-14T03:08:40.361Z","repository":{"id":3550605,"uuid":"50120013","full_name":"dalance/amber","owner":"dalance","description":"A code search / replace tool","archived":false,"fork":false,"pushed_at":"2025-03-24T21:28:08.000Z","size":874,"stargazers_count":878,"open_issues_count":20,"forks_count":27,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-04-02T01:11:47.451Z","etag":null,"topics":["command-line-tool","grep","replace-text","rust","search"],"latest_commit_sha":null,"homepage":null,"language":"Rust","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/dalance.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","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},"funding":{"github":"dalance"}},"created_at":"2016-01-21T16:21:46.000Z","updated_at":"2025-03-24T21:28:05.000Z","dependencies_parsed_at":"2023-01-13T12:36:25.289Z","dependency_job_id":"e18a1040-4608-4ed4-8d73-6f96889a8c47","html_url":"https://github.com/dalance/amber","commit_stats":{"total_commits":412,"total_committers":12,"mean_commits":"34.333333333333336","dds":0.558252427184466,"last_synced_commit":"fb823b925c9abd612068a3adc28964b18694e59c"},"previous_names":[],"tags_count":31,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dalance%2Famber","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dalance%2Famber/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dalance%2Famber/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dalance%2Famber/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dalance","download_url":"https://codeload.github.com/dalance/amber/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247962594,"owners_count":21024870,"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":["command-line-tool","grep","replace-text","rust","search"],"created_at":"2024-08-01T15:01:38.985Z","updated_at":"2025-04-09T02:13:25.712Z","avatar_url":"https://github.com/dalance.png","language":"Rust","readme":"# amber\r\n\r\n[![Actions Status](https://github.com/dalance/amber/workflows/Regression/badge.svg)](https://github.com/dalance/amber/actions)\r\n[![Crates.io](https://img.shields.io/crates/v/amber.svg)](https://crates.io/crates/amber)\r\n\r\n**amber** is a code search and replace tool written by [Rust](https://www.rust-lang.org/).\r\nThis tool is inspired by [ack](http://beyondgrep.com/),\r\n[ag](https://github.com/ggreer/the_silver_searcher), and other grep-like tools.\r\n\r\n## Features\r\n\r\n### Useful default settings\r\n- Recursively search from the current directory\r\n- Ignore VCS directories (.git, .hg, .svn, .bzr)\r\n- Ignore binary files\r\n- Output by the colored format\r\n\r\n### Multi-threaded searching\r\nLarge files ( \u003e 1MB by default) are divided and searched in parallel.\r\n\r\n### Interactive replacing\r\n**amber** can replace a keyword over directories (traditionally by `find ... | xargs sed -i '...'`) .\r\nYou can decide to do replacing or not interactively.\r\n\r\n## Installation\r\n\r\n### Arch Linux\r\nInstall the `amber-search-git` package from AUR.\r\n\r\n```\r\nyay -S amber-search-git\r\n```\r\n\r\n### Cargo\r\n\r\nYou can install with [cargo](https://crates.io/crates/amber).\r\n\r\n```\r\ncargo install amber\r\n```\r\n\r\n### Manual\r\nDownload from [release page](https://github.com/dalance/amber/releases/latest), and extract to the directory in PATH.\r\n\r\n## Usage\r\nTwo commands (`ambs`/`ambr`) are provided. `ambs` means \"amber search\", and `ambr` means \"amber replace\".\r\nThe search keyword is not regular expression by default. If you want to use regular expression, add `--regex`.\r\n\r\n```\r\nambs keyword                  // recursively search 'keyword' from the current directory.\r\nambs keyword path             // recursively search 'keyword' from 'path'.\r\nambr keyword replacement      // recursively search 'keyword' from the current directory, and replace to 'replacement' interactively.\r\nambr keyword replacement path // recursively search 'keyword' from 'path', and replace to 'replacement' interactively.\r\n```\r\n\r\n**amber** replace interactively by default. If the keyword is found, the following prompt is shown, and wait.\r\nIf you input 'y', 'Y', 'Yes', the keyword is replaced. 'a', 'A', 'All' means replacing all keywords non-interactively.\r\n\r\n```\r\nReplace keyword? ( Yes[Y], No[N], All[A], Quit[Q] ):\r\n```\r\n\r\nIf `--regex` option is enabled, regex captures can be used in `replacement` of `ambr`.\r\n\r\n```\r\n$ cat text.txt\r\naaa bbb\r\n$ ambr --no-interactive --regex '(aaa) (?\u003cpat\u003ebbb)' '$1 $pat ${1} ${pat}' test.txt\r\n$ cat text.txt\r\naaa bbb aaa bbb\r\n```\r\n\r\n## Configuration\r\n\r\n### Configuration path\r\n\r\nYou can change configuration by writing a configuration file.\r\nThe locations of the configuration file is OS-specific:\r\n\r\n * Linux: `~/.config/amber/ambs.toml`, `/etc/amber/ambs.toml`\r\n * macOS: `~/Library/Preferences/com.github.dalance.amber/ambs.toml`, `/etc/amber/ambs.toml`\r\n * Windows: `~/AppData/Roaming/dalance/amber/config/ambs.toml`\r\n\r\nFor compatibility, if `~/.ambs.toml` exists, it will be preferred to\r\nthe OS-specific locations.\r\n\r\nThe above paths are examples for the configuration of `ambs` command.\r\n`ambr.toml` in the same directory is used for `ambr` command.\r\n\r\n### Configurable value\r\n\r\nAvailable entries and default values are below:\r\n\r\n```toml\r\nregex          = false\r\ncolumn         = false\r\nrow            = false\r\nbinary         = false\r\nstatistics     = false\r\nskipped        = false\r\ninteractive    = true\r\nrecursive      = true\r\nsymlink        = true\r\ncolor          = true\r\nfile           = true\r\nskip_vcs       = true\r\nskip_gitignore = true\r\nfixed_order    = true\r\nparent_ignore  = true\r\nline_by_match  = false\r\n```\r\n\r\nYou can choose some entries to override like below:\r\n\r\n```toml\r\ncolumn = true\r\n```\r\n\r\n## Benchmark\r\n\r\n### Environment\r\n\r\n- CPU: Intel(R) Xeon(R) Gold 6134 CPU @ 3.20GHz\r\n- MEM: 1.5TB\r\n- OS : CentOS 7.5\r\n\r\n### Target Data\r\n\r\n- source1: https://github.com/torvalds/linux ( 52998files, 2.2GB )\r\n- source2: https://dumps.wikimedia.org/jawiki/latest/jawiki-latest-pages-articles.xml.bz2 ( 1file, 8.5GB )\r\n\r\n### Pattern\r\n\r\n- pattern1( many files with many matches ) : 'EXPORT_SYMBOL_GPL' in source1\r\n- pattern2( many files with few matches  ) : 'irq_bypass_register_producer' in source1\r\n- pattern3( a large file with many matches ) : '検索結果' in source2\r\n- pattern4( a large file with few matches  ) : '\"Quick Search\"' in source2\r\n\r\n### Comparison Tools\r\n\r\n- amber (v0.5.1)\r\n- [ripgrep](https://github.com/BurntSushi/ripgrep) (v0.10.0)\r\n- [grep](https://www.gnu.org/software/grep/) (v2.20)\r\n- [fastmod](https://github.com/facebookincubator/fastmod) (v0.2.0)\r\n- [find](https://www.gnu.org/software/findutils/)/[sed](https://www.gnu.org/software/sed/) (v4.5.11/v4.2.2)\r\n\r\n### Benchmarking Tool\r\n\r\n[hyperfine](https://github.com/sharkdp/hyperfine) with the following options.\r\n\r\n- `--warmup 3`: to load all data on memory.\r\n\r\n### Result\r\n\r\n- search ( `compare_ambs.sh` )\r\n\r\n| pattern | amber            | ripgrep          | grep             |\r\n| ------- | ---------------- | ---------------- | ---------------- |\r\n| 1       | 212.8ms ( 139% ) | 154.1ms ( 100% ) | 685.2ms ( 448% ) |\r\n| 2       | 199.7ms ( 132% ) | 151.6ms ( 100% ) | 678.7ms ( 448% ) |\r\n| 3       | 1.068s  ( 100% ) | 4.642s  ( 434% ) | 3.869s  ( 362% ) |\r\n| 4       | 1.027s  ( 100% ) | 4.409s  ( 429% ) | 3.118s  ( 304% ) |\r\n\r\n- replace ( `compare_ambr.sh` )\r\n\r\n| pattern | amber            | fastmod          | find/sed            |\r\n| ------- | ---------------- | ---------------- | ------------------- |\r\n| 1       | 792.2ms ( 100% ) | 1231ms  ( 155% ) | 155724ms ( 19657% ) |\r\n| 2       | 418.1ms ( 119% ) | 352.4ms ( 100% ) | 157396ms ( 44663% ) |\r\n| 3       | 18.390s ( 100% ) | 74.282s ( 404% ) | 639.740s ( 3479% )  |\r\n| 4       | 17.777s ( 100% ) | 74.204s ( 417% ) | 625.756s ( 3520% )  |\r\n","funding_links":["https://github.com/sponsors/dalance"],"categories":["Rust","rust","Other","\u003ca name=\"text-search-replace\"\u003e\u003c/a\u003eText search and replace (alternatives to sed)"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdalance%2Famber","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdalance%2Famber","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdalance%2Famber/lists"}