Skip to content

lordkrandel/lsub

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

lsub

Combines the powers of:

to replace occurrences of specified regex needle with a replacement. Asks confirm for each replacement.

Example:

  1. Create three files

$ echo "Hello world!" > anyfile.txt
$ echo "The world is not enough" > anyfile2.txt
$ echo "The wooooorld's on fire!" > anyfile3.txt

  1. Find the w*rld inside of it
$ rg "w\w+rld"
anyfile3.txt
1:The wooooorld's on fire!

anyfile.txt
1:Hello world!

anyfile2.txt
1:The world is not enough

  1. Replace the w*rld with the whole universe
$ lsub "w\w+rld" "universe"

./anyfile2.txt
000001:The world is not enough
Replace with "universe"? (n)ext/next (f)ile/(r)eplace/replace (a)ll/(q)uit > r

./anyfile3.txt
000001:The wooooorld's on fire!
Replace with "universe"? (n)ext/next (f)ile/(r)eplace/replace (a)ll/(q)uit > r

./anyfile.txt
000001:Hello world!
Replace with "universe"? (n)ext/next (f)ile/(r)eplace/replace (a)ll/(q)uit > n
  1. See the changes you want, reflected in the filesystem!
$ rg "w\w+rld"
anyfile.txt
1:Hello world!

$ rg "universe"
anyfile2.txt
1:The universe is not enough

anyfile3.txt
1:The universe's on fire!

Help message:

$ lsub --help
Usage: lsub [OPTIONS] NEEDLE REPLACEMENT

Arguments:
  NEEDLE       [required]
  REPLACEMENT  [required]

Options:
  --path TEXT  [default: .]
  --help       Show this message and exit.

About

Replace in files with confirm

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages