https://github.com/dalance/amber Skip to content Navigation Menu Toggle navigation Sign in * Product + Actions Automate any workflow + Packages Host and manage packages + Security Find and fix vulnerabilities + Codespaces Instant dev environments + Copilot Write better code with AI + Code review Manage code changes + Issues Plan and track work + Discussions Collaborate outside of code Explore + All features + Documentation + GitHub Skills + Blog * Solutions For + Enterprise + Teams + Startups + Education By Solution + CI/CD & Automation + DevOps + DevSecOps Resources + Learning Pathways + White papers, Ebooks, Webinars + Customer Stories + Partners * Open Source + GitHub Sponsors Fund open source developers + The ReadME Project GitHub community articles Repositories + Topics + Trending + Collections * Pricing Search or jump to... Search code, repositories, users, issues, pull requests... Search [ ] Clear Search syntax tips Provide feedback We read every piece of feedback, and take your input very seriously. [ ] [ ] Include my email address so I can be contacted Cancel Submit feedback Saved searches Use saved searches to filter your results more quickly Name [ ] Query [ ] To see all available qualifiers, see our documentation. Cancel Create saved search Sign in Sign up You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session. Dismiss alert {{ message }} dalance / amber Public * * Notifications * Fork 17 * Star 594 * A code search / replace tool License MIT license 594 stars 17 forks Branches Tags Activity Star Notifications * Code * Issues 20 * Pull requests 0 * Actions * Projects 0 * Security * Insights Additional navigation options * Code * Issues * Pull requests * Actions * Projects * Security * Insights dalance/amber This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository. master BranchesTags Go to file Code Folders and files Name Name Last commit message Last commit date Latest commit History 731 Commits .github .github benches benches src src test test .gitignore .gitignore Cargo.lock Cargo.lock Cargo.toml Cargo.toml LICENSE LICENSE Makefile Makefile README.md README.md compare_ambr.sh compare_ambr.sh compare_ambs.sh compare_ambs.sh rustfmt.toml rustfmt.toml View all files Repository files navigation * README * MIT license amber Actions Status Crates.io codecov amber is a code search and replace tool written by Rust. This tool is inspired by ack, ag, and other grep-like tools. Features Useful default settings * Recursively search from the current directory * Ignore VCS directories (.git, .hg, .svn, .bzr) * Ignore binary files * Output by the colored format Multi-threaded searching Large files ( > 1MB by default) are divided and searched in parallel. Interactive replacing amber can replace a keyword over directories (traditionally by find ... | xargs sed -i '...') . You can decide to do replacing or not interactively. Installation Arch Linux Install the amber-search-git package from AUR. yaourt -S amber-search-git Cargo You can install with cargo. cargo install amber Manual Download from release page, and extract to the directory in PATH. Usage Two commands (ambs/ambr) are provided. ambs means "amber search", and ambr means "amber replace". The search keyword is not regular expression by default. If you want to use regular expression, add --regex. ambs keyword // recursively search 'keyword' from the current directory. ambs keyword path // recursively search 'keyword' from 'path'. ambr keyword replacement // recursively search 'keyword' from the current directory, and replace to 'replacement' interactively. ambr keyword replacement path // recursively search 'keyword' from 'path', and replace to 'replacement' interactively. amber replace interactively by default. If the keyword is found, the following prompt is shown, and wait. If you input 'y', 'Y', 'Yes', the keyword is replaced. 'a', 'A', 'All' means replacing all keywords non-interactively. Replace keyword? ( Yes[Y], No[N], All[A], Quit[Q] ): If --regex option is enabled, regex captures can be used in replacement of ambr. $ cat text.txt aaa bbb $ ambr --no-interactive --regex '(aaa) (?bbb)' '$1 $pat ${1} ${pat}' test.txt $ cat text.txt aaa bbb aaa bbb Configuration Configuration path You can change configuration by writing a configuration file. The locations of the configuration file is OS-specific: * Linux: ~/.config/amber/ambs.toml, /etc/amber/ambs.toml * macOS: ~/Library/Preferences/com.github.dalance.amber/ambs.toml, /etc/amber/ambs.toml * Windows: ~/AppData/Roaming/dalance/amber/config/ambs.toml For compatibility, if ~/.ambs.toml exists, it will be preferred to the OS-specific locations. The above paths are examples for the configuration of ambs command. ambr.toml in the same directory is used for ambr command. Configurable value Available entries and default values are below: regex = false column = false row = false binary = false statistics = false skipped = false interactive = true recursive = true symlink = true color = true file = true skip_vcs = true skip_gitignore = true fixed_order = true parent_ignore = true line_by_match = false You can choose some entries to override like below: column = true Benchmark Environment * CPU: Intel(R) Xeon(R) Gold 6134 CPU @ 3.20GHz * MEM: 1.5TB * OS : CentOS 7.5 Target Data * source1: https://github.com/torvalds/linux ( 52998files, 2.2GB ) * source2: https://dumps.wikimedia.org/jawiki/latest/ jawiki-latest-pages-articles.xml.bz2 ( 1file, 8.5GB ) Pattern * pattern1( many files with many matches ) : 'EXPORT_SYMBOL_GPL' in source1 * pattern2( many files with few matches ) : 'irq_bypass_register_producer' in source1 * pattern3( a large file with many matches ) : 'Jian Suo Jie Guo ' in source2 * pattern4( a large file with few matches ) : '"Quick Search"' in source2 Comparison Tools * amber (v0.5.1) * ripgrep (v0.10.0) * grep (v2.20) * fastmod (v0.2.0) * find/sed (v4.5.11/v4.2.2) Benchmarking Tool hyperfine with the following options. * --warmup 3: to load all data on memory. Result * search ( compare_ambs.sh ) pattern amber ripgrep grep 1 212.8ms ( 139% ) 154.1ms ( 100% ) 685.2ms ( 448% ) 2 199.7ms ( 132% ) 151.6ms ( 100% ) 678.7ms ( 448% ) 3 1.068s ( 100% ) 4.642s ( 434% ) 3.869s ( 362% ) 4 1.027s ( 100% ) 4.409s ( 429% ) 3.118s ( 304% ) * replace ( compare_ambr.sh ) pattern amber fastmod find/sed 1 792.2ms ( 100% ) 1231ms ( 155% ) 155724ms ( 19657% ) 2 418.1ms ( 119% ) 352.4ms ( 100% ) 157396ms ( 44663% ) 3 18.390s ( 100% ) 74.282s ( 404% ) 639.740s ( 3479% ) 4 17.777s ( 100% ) 74.204s ( 417% ) 625.756s ( 3520% ) About A code search / replace tool Topics search rust replace-text command-line-tool grep Resources Readme License MIT license Activity Stars 594 stars Watchers 6 watching Forks 17 forks Report repository Releases 29 v0.6.0 Latest Dec 27, 2023 + 28 releases Sponsor this project Sponsor Learn more about GitHub Sponsors Packages 0 No packages published Contributors 11 * @dalance * @dependabot[bot] * @github-actions[bot] * @dependabot-preview[bot] * @frazar * @Stebalien * @pickfire * @bdesham * @serprex * @loyd * @peamaeq Languages * Rust 96.0% * Shell 3.2% * Other 0.8% Footer (c) 2024 GitHub, Inc. Footer navigation * Terms * Privacy * Security * Status * Docs * Contact * Manage cookies * Do not share my personal information You can't perform that action at this time.