We're losing the art of bash ``` find -type f -iname '*.go' | xargs -r -n1 sed -i 's,foo,foobar,g' ```
Show HN: Scooter – Interactive find and replace in the terminal
71–80 of 81 posts
Re: Show HN: Scooter – Interactive find and replace in the terminal
#72Since we're all giving replacements to this, nobody's mentioned my preferred one, so: use git add's patch mode. On a clean worktree, do the search/replace in bulk. Then use `git add --patch` to selectively add the good replacements and skip the bad ones. Finally, `git checkout -- .` to throw away all the bad ones. The nice part about this is that it's not much to remember. If you can make a global search and replace,…
git checkout .
it will eat your changes changes if you yolo it.Re: Show HN: Scooter – Interactive find and replace in the terminal
#73We're losing the art of bash ``` find -type f -iname '*.go' | xargs -r -n1 sed -i 's,foo,foobar,g' ```
The problem is... if you use these on rare occasions it gets frustrating, because you have to read the manual or google everything or ask the llm again and again. noone can remember these abbreviations
Re: Show HN: Scooter – Interactive find and replace in the terminal
#74Re: Show HN: Scooter – Interactive find and replace in the terminal
#75Since we're all giving replacements to this, nobody's mentioned my preferred one, so: use git add's patch mode. On a clean worktree, do the search/replace in bulk. Then use `git add --patch` to selectively add the good replacements and skip the bad ones. Finally, `git checkout -- .` to throw away all the bad ones. The nice part about this is that it's not much to remember. If you can make a global search and replace,…
But it only works in git repositories. Sometimes you need to search and replace on non-git repositories, for those cases Scooter might be the answer
Re: Show HN: Scooter – Interactive find and replace in the terminal
#76We're losing the art of bash ``` find -type f -iname '*.go' | xargs -r -n1 sed -i 's,foo,foobar,g' ```
The problem is... if you use these on rare occasions it gets frustrating, because you have to read the manual or google everything or ask the llm again and again. noone can remember these abbreviations
noone except your shell! Fish is perfect and very very often can guess what I want using pwd, file existence, current prompt, etc...
Re: Show HN: Scooter – Interactive find and replace in the terminal
#77A useful feature of bash and zsh is the "edit command". The standard shortcut is "ctrl-x ctrl-e". It opens the current command line in $EDITOR, which often defaults to vim.
Re: Show HN: Scooter – Interactive find and replace in the terminal
#78Since we're all giving replacements to this, nobody's mentioned my preferred one, so: use git add's patch mode. On a clean worktree, do the search/replace in bulk. Then use `git add --patch` to selectively add the good replacements and skip the bad ones. Finally, `git checkout -- .` to throw away all the bad ones. The nice part about this is that it's not much to remember. If you can make a global search and replace,…
Re: Show HN: Scooter – Interactive find and replace in the terminal
#79Am I the only one who thought this could alsop work lik "just" a find tool, only to discover it silently erased that word from all files in the directory without asking for confirmation? This felt riskier than rm -rf.
Re: Show HN: Scooter – Interactive find and replace in the terminal
#80Main change I would need I think: to assume that if no replacement if provided, the user wants to edit each instance individually "inline" (or dropping into vim, not sure what works best - this model breaks once you want to swap lines, replace 1 word with multiple lines etc).
And ofc accept command line args for the initial search string (and optionally replacement) from command line so the first screen is skipped! (I think folder could be optional)
(I also tried to undo my changes after deleting words by accident but thats a hard ask! :D)