All Projects → ms-jpq → Sad

ms-jpq / Sad

Licence: mit
CLI search and replace | Space Age seD

Programming Languages

rust
11053 projects

Projects that are alternatives of or similar to Sad

Nnn
n³ The unorthodox terminal file manager
Stars: ✭ 13,138 (+3653.71%)
Mutual labels:  cli, terminal, command-line, tui
Zoxide
A smarter cd command. Supports all major shells.
Stars: ✭ 4,422 (+1163.43%)
Mutual labels:  fzf, cli, terminal, command-line
Mandown
man-page inspired Markdown viewer
Stars: ✭ 173 (-50.57%)
Mutual labels:  cli, terminal, command-line, tui
Jquery.terminal
jQuery Terminal Emulator - JavaScript library for creating web-based terminals with custom commands
Stars: ✭ 2,623 (+649.43%)
Mutual labels:  cli, terminal, command-line, tui
Goaccess
GoAccess is a real-time web log analyzer and interactive viewer that runs in a terminal in *nix systems or through your browser.
Stars: ✭ 14,096 (+3927.43%)
Mutual labels:  cli, terminal, command-line, tui
Go Termd
Package termd provides terminal markdown rendering, with code block syntax highlighting support.
Stars: ✭ 223 (-36.29%)
Mutual labels:  cli, terminal, command-line
Peaclock
A responsive and customizable clock, timer, and stopwatch for the terminal.
Stars: ✭ 314 (-10.29%)
Mutual labels:  cli, terminal, tui
Fd
A simple, fast and user-friendly alternative to 'find'
Stars: ✭ 19,851 (+5571.71%)
Mutual labels:  cli, terminal, command-line
Cmd2
cmd2 - quickly build feature-rich and user-friendly interactive command line applications in Python
Stars: ✭ 342 (-2.29%)
Mutual labels:  cli, terminal, command-line
Saldl
A lightweight well-featured CLI downloader optimized for speed and early preview.
Stars: ✭ 203 (-42%)
Mutual labels:  cli, terminal, command-line
S Tui
Terminal-based CPU stress and monitoring utility
Stars: ✭ 2,825 (+707.14%)
Mutual labels:  cli, terminal, tui
Caporal.js
A full-featured framework for building command line applications (cli) with node.js
Stars: ✭ 3,279 (+836.86%)
Mutual labels:  cli, terminal, command-line
Kmdr Cli
🧠 The CLI tool for learning commands from your terminal
Stars: ✭ 218 (-37.71%)
Mutual labels:  cli, terminal, command-line
Csview
📠 A high performance csv viewer with cjk/emoji support.
Stars: ✭ 208 (-40.57%)
Mutual labels:  cli, terminal, command-line
Stonky
A command line dashboard for monitoring stocks
Stars: ✭ 208 (-40.57%)
Mutual labels:  cli, terminal, command-line
Laravel Zero
A PHP framework for console artisans
Stars: ✭ 2,821 (+706%)
Mutual labels:  cli, terminal, command-line
Ytfzf
A posix script to find and watch youtube videos from the terminal. (Without API)
Stars: ✭ 2,212 (+532%)
Mutual labels:  fzf, cli, terminal
Tmux Fzf Url
🚀 Quickly open urls on your terminal screen!
Stars: ✭ 227 (-35.14%)
Mutual labels:  fzf, cli, tui
Spotui
Spotify in the terminal 💻🎶
Stars: ✭ 302 (-13.71%)
Mutual labels:  cli, terminal, tui
Qrc
QR code generator for text terminals (ASCII art, Sixel)
Stars: ✭ 200 (-42.86%)
Mutual labels:  cli, terminal, tui

SAD!

Space Age seD

What does it do?

Basically sad is a Batch File Edit tool.

It will show you a really nice diff of proposed changes before you commit them.

Unlike sed, you can double check before you fat finger your edit.

Preview (with fzf)

Selectively replace std -> joseph joestar in the sad repo.

You can pick and choose which changes to apply.

You can also choose the clustering factor for changes using --unified=<n>. (Same as in GNU diff)

preview1

Preview (no fzf)

Replace all'"(\d+)"' -> '🌈$1🌈' in the chromium repo.

use --commit or -k to commit changes all at once.

-c is taken because sad has to trick fzf into thinking it's bash :)

preview2

How to use sad?

with fzf

export GIT_PAGER='<highlighter-of-your-choice>'
# ^ can be done in your bash/zsh/rc file.
find "$FIND_ARGS" | sad '<pattern>' '<replacement>'

without fzf

find "$FIND_ARGS" | sad '<pattern>' '<replacement>' | highlighter-of-your-choice

or

find "$FIND_ARGS" | sad '<pattern>' '<replacement>' --pager=<highlighter-of-your-choice>

or

export GIT_PAGER='<highlighter-of-your-choice>'
find "$FIND_ARGS" | sad '<pattern>' '<replacement>'

gotta go fast

If you wanna go fast.

  • preview to verify you really want the changes.

  • run with --commit, and redirect stdout to a file or /dev/null


Requirements

Technically none of these are "required", but they make sad so much happier.

If you install the things below, sad will automatically use them. It's progressive enhancement!

Commandline fuzzer

fzf

sad does not come with a UI, it uses fzf to perform selection.

Diff Colorizer

Any git compatible colourizer would work. I perfer these two:

delta

fd <files> | sad <pattern> <replacement> | delta

diff-so-fancy

fd <files> | sad <pattern> <replacement> | diff-so-fancy | less

Environmental Variables

Name Function
GIT_PAGER sad will use the same pager as git

Flags

Name Function
-f --flags Regex flags, see below
-k --commit No preview, write changes to file
-0 --read0 Use \x00 as stdin delimiter
-e --exact String literal mode
-p --pager Colourizing program, disable = never
--fzf Additional Fzf options, disable = never
-u --unified Same as in GNU diff, affects hunk size

Regex Flags

By default, sad uses smartcase, and multiline matching.

Name Function
i case insensitive (works for --exact mode as well)
I case sensitive (works for --exact mode as well)
m multiline: ^ $ match each line
M singleline: ^ $ match entire document
s allow . match \n
x ignore whitespace and allow # comments

Exit Codes

Code Meaning
0 Good
1 Bad
130 Interrupted (ie. user cancel), or if using fzf, it will always exit 130.

GET SAD NOW!

Homebrew:

brew install ms-jpq/sad/sad

Snap Store:

coming soon...

Distribution packages:

Debian/Ubuntu:

You can download sad deb packages from the github release page.

Arch Linux:

You can find the PKGBUILD on the AUR.

Other:

Missing a package for your favourite distribution? Let us know!

Compile from source:

Requirements:

To compile sad yourself you'll have to make sure you have Rust and cargo installed.

Install instructions:

To install cargo from source you can run the following commands:

cargo install --locked --all-features --path .

If you want to install it in a specific directory you can provide the --root flag, like so:

cargo install --locked --all-features --root="/usr/bin/" --path .

What about stdin -> stdout

If you just want to edit the shell stream, I would recommand sd, it uses the same concept, but its more for in stream edits. sad was inspired by my initial useage of sd.

command1 | sd '<pattern>' '<replacement>' | command2

ripgrep with --replace also works

command1 | rg --passthru --replace '<replacement>' -- '<pattern>' | command2

Take note however, rg will exit 1, it it finds no matches.

Thank yous

Special thanks to MadeOfMagicAndWires for their generous contribution for maintaining the AUR package.

Bugs

Please file an issue if you see one <3

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].