{"id":13478651,"url":"https://github.com/ms-jpq/sad","last_synced_at":"2025-05-14T03:10:40.688Z","repository":{"id":37828419,"uuid":"262460365","full_name":"ms-jpq/sad","owner":"ms-jpq","description":"CLI search and replace | Space Age seD","archived":false,"fork":false,"pushed_at":"2025-04-08T22:53:30.000Z","size":39511,"stargazers_count":1875,"open_issues_count":27,"forks_count":22,"subscribers_count":10,"default_branch":"senpai","last_synced_at":"2025-04-11T14:17:51.727Z","etag":null,"topics":["cli","command-line","diff","editing","fzf","rust","sed","terminal","tui"],"latest_commit_sha":null,"homepage":"","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/ms-jpq.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":"2020-05-09T01:04:12.000Z","updated_at":"2025-04-08T18:03:50.000Z","dependencies_parsed_at":"2024-01-06T13:18:09.274Z","dependency_job_id":"ba3b0e2a-621a-4a78-be53-76150c5e15a4","html_url":"https://github.com/ms-jpq/sad","commit_stats":{"total_commits":1716,"total_committers":14,"mean_commits":"122.57142857142857","dds":0.5023310023310024,"last_synced_commit":"3b5d67a086bc258dae62cec2523fa348b67db583"},"previous_names":[],"tags_count":55,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ms-jpq%2Fsad","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ms-jpq%2Fsad/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ms-jpq%2Fsad/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ms-jpq%2Fsad/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ms-jpq","download_url":"https://codeload.github.com/ms-jpq/sad/tar.gz/refs/heads/senpai","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254059512,"owners_count":22007769,"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":["cli","command-line","diff","editing","fzf","rust","sed","terminal","tui"],"created_at":"2024-07-31T16:01:59.882Z","updated_at":"2025-05-14T03:10:35.671Z","avatar_url":"https://github.com/ms-jpq.png","language":"Rust","readme":"# [SAD!](https://ms-jpq.github.io/sad)\n\n**Space Age seD**\n\n## What does it do?\n\nBasically `sad` is a **Batch File Edit** tool.\n\nIt will show you a really nice diff of proposed changes _before_ you commit them.\n\nUnlike `sed`, you can double check before you fat finger your edit.\n\n## Preview (with fzf)\n\nSelectively replace `std` -\u003e `joseph joestar` in the `sad` repo.\n\nYou can pick and choose which changes to apply.\n\nYou can also choose the clustering factor for changes using `--unified=\u003cn\u003e`. (Same as in GNU diff)\n\n![preview1](https://github.com/ms-jpq/sad/raw/senpai/previews/preview1.gif)\n\n**If you have `delta` installed, try `--pager 'delta -s'` for side by side view**\n\n## Preview (no fzf)\n\nReplace all`'\"(\\d+)\"'` -\u003e `'🌈$1🌈'` in the `chromium` repo.\n\nuse `--commit` or `-k` to commit changes all at once.\n\n`-c` is taken because `sad` has to trick `fzf` into thinking it's `bash` :)\n\n![preview2](https://github.com/ms-jpq/sad/raw/senpai/previews/preview2.gif)\n\n## How to use sad?\n\n**with fzf**\n\n```bash\nexport GIT_PAGER='\u003chighlighter-of-your-choice\u003e'\n# ^ can be done in your bash/zsh/rc file.\nfind \"$FIND_ARGS\" | sad '\u003cpattern\u003e' '\u003creplacement\u003e'\n```\n\nNote: `--multi` is passed to fzf so you can select multiple files with `Shift+tab`\n\n**without fzf**\n\n```bash\nfind \"$FIND_ARGS\" | sad '\u003cpattern\u003e' '\u003creplacement\u003e' | highlighter-of-your-choice\n```\n\nor\n\n```bash\nfind \"$FIND_ARGS\" | sad '\u003cpattern\u003e' '\u003creplacement\u003e' --pager=\u003chighlighter-of-your-choice\u003e\n```\n\nor\n\n```bash\nexport GIT_PAGER='\u003chighlighter-of-your-choice\u003e'\nfind \"$FIND_ARGS\" | sad '\u003cpattern\u003e' '\u003creplacement\u003e'\n```\n\n**gotta go fast**\n\nIf you wanna go fast.\n\n- preview to verify you really want the changes.\n\n- run with `--commit`, and redirect `stdout` to a file or `/dev/null`\n\n---\n\n## Requirements\n\nTechnically none of these are \"required\", but they make `sad` so much happier.\n\nIf you install the things below, `sad` will automatically use them. It's progressive enhancement!\n\n### Commandline fuzzer\n\n[**fzf**](https://github.com/junegunn/fzf)\n\n`sad` does not come with a UI, it uses `fzf` to perform selection.\n\n### Diff Colorizer\n\nAny `git` compatible colourizer would work. I prefer these two:\n\n[**delta**](https://github.com/dandavison/delta)\n\n`fd \u003cfiles\u003e | sad \u003cpattern\u003e \u003creplacement\u003e | delta`\n\n[**diff-so-fancy**](https://github.com/so-fancy/diff-so-fancy)\n\n`fd \u003cfiles\u003e | sad \u003cpattern\u003e \u003creplacement\u003e | diff-so-fancy | less`\n\n## Environmental Variables\n\n| Name        | Function                               |\n| ----------- | -------------------------------------- |\n| `GIT_PAGER` | `sad` will use the same pager as `git` |\n\n## Flags\n\n| Name             | Function                                  |\n| ---------------- | ----------------------------------------- |\n| `-f` `--flags`   | Regex flags, see below                    |\n| `-k` `--commit`  | No preview, write changes to file         |\n| `-0` `--read0`   | Use `\\x00` as stdin delimiter             |\n| `-e` `--exact`   | String literal mode                       |\n| `-p` `--pager`   | Colourizing program, disable = `never`    |\n| `--fzf`          | Additional Fzf options, disable = `never` |\n| `-u` `--unified` | Same as in GNU `diff`, affects hunk size  |\n\n## Regex Flags\n\nBy default, `sad` uses smartcase, and multiline matching.\n\nFor each options, lowercase toggles on and uppercase toggles off.\n\nie. `i` =\u003e on, `I` =\u003e off\n\n| Name | Function                                                                             |\n| ---- | ------------------------------------------------------------------------------------ |\n| `i`  | case insensitive (works for `--exact` mode as well)                                  |\n| `m`  | multiline: `^` `$` match each line                                                   |\n| `s`  | allow `.` match `\\n`                                                                 |\n| `u`  | swap the meaning of `*` and `*?` patterns, (normally `*` is lazy and `*?` is greedy) |\n| `x`  | ignore whitespace and allow `#` comments                                             |\n\n## Exit Codes\n\n| Code  | Meaning                                                                                                                |\n| ----- | ---------------------------------------------------------------------------------------------------------------------- |\n| `0`   | Good                                                                                                                   |\n| `1`   | Bad                                                                                                                    |\n| `130` | Interrupted (ie. user cancel), or if using `fzf`, [it will always exit `130`](https://github.com/ms-jpq/sad/issues/5). |\n\n## GET SAD NOW!\n\nFor scripting, use the following format:\n\n```bash\n# replace `x86_64-unknown-linux-gnu.deb` with your desired package\nwget 'https://github.com/ms-jpq/sad/releases/latest/download/x86_64-unknown-linux-gnu.deb'\n```\n\n### Homebrew:\n\n```bash\nbrew install sad\n```\n\n### Scoop:\n\n```bash\nscoop install sad\n```\n\n### Snap Store:\n\ncoming soon...\n\n### Distribution packages:\n\n##### Debian/Ubuntu:\n\nYou can download `sad` deb packages from the [github release page](https://github.com/ms-jpq/sad/releases/latest).\n\n##### Arch Linux:\n\nThere is an official Arch Linux package that can be installed via `pacman`:\n\n```\npacman -Syu sad\n```\n\n##### Other:\n\nMissing a package for your favourite distribution? Let us know!\n\n### Compile from source:\n\n##### Requirements:\n\nTo compile sad yourself you'll have to make sure you have\n[Rust](https://www.rust-lang.org/) and `cargo` installed.\n\n##### Install instructions:\n\nTo install cargo from source you can run the following commands:\n\n```bash\ncargo install --locked --all-features \\\n  --git https://github.com/ms-jpq/sad --branch senpai\n```\n\nIf you want to install it in a specific directory you can provide the `--root`\nflag, like so:\n\n```bash\ncargo install --locked --all-features --root=\"/usr/bin/\" \\\n  --git https://github.com/ms-jpq/sad --branch senpai\n```\n\n## What about stdin -\u003e stdout\n\nIf you just want to edit the shell stream, I would recommend [`sd`](https://github.com/chmln/sd), it uses the same concept, but its more for in stream edits. `sad` was inspired by my initial usage of `sd`.\n\n```bash\ncommand1 | sd '\u003cpattern\u003e' '\u003creplacement\u003e' | command2\n```\n\n[`ripgrep`](https://github.com/BurntSushi/ripgrep) with `--replace` also works\n\n```bash\ncommand1 | rg --passthru --replace '\u003creplacement\u003e' -- '\u003cpattern\u003e' | command2\n```\n\nTake note however, `rg` will `exit 1`, it it finds no matches.\n\n## Thank yous\n\nSpecial thanks to [MadeOfMagicAndWires](https://github.com/MadeOfMagicAndWires) for their generous contribution for maintaining the AUR package.\n\n## Bugs\n\nPlease file an issue if you see one `\u003c3`\n","funding_links":[],"categories":["Rust","cli","Applications","Sed Replacement","Other","\u003ca name=\"git\"\u003e\u003c/a\u003eGit and accessories"],"sub_categories":["System tools","Open USP Tsukubai"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fms-jpq%2Fsad","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fms-jpq%2Fsad","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fms-jpq%2Fsad/lists"}