I like this `bin/replace` script, but I've recently switched from `ag`
to [ripgrep](https://github.com/BurntSushi/ripgrep). This checks for the
presence of `rg` and uses it in `bin/replace`, passing the correct
parameter to disable colors.
Problem:
Currently the `for` in bash will break up lists by whitespace, so if a
filename has a space in it the `for` will break it up incorrectly.
AG will separate the files with a newline character, so this temporarily
overwrites the `IFS` to be used correctly for this use case.
[Docs](https://bash.cyberciti.biz/guide/$IFS)
The existing implementation of the `replace` script does not work on
GNU/Linux due to differences in the implementation of `sed`. This change
reworks the process of the replacement to create temporary files,
apply the changes to the files, and then move them into place. It will
improve the script's portability for more OSes.
**Bring executables into better shellcheck compliance**
While evaluating linting and testing options for our shell
configuration, a run of Shellcheck against our executables turned up
some places where we could use more consistent syntax across our
executables, such as always using a shebang or quoting `$HOME` when we
build up a larger directory.
**Update syntax for zsh functions and completions**
A few changes found while linting zsh configs with shellcheck:
* thoughtbot's [style guide] [guide] calls for `$(..)` over backticks
when capturing command output
* use `-gt` to test array length in arguments
[guide]: https://github.com/thoughtbot/guides/tree/master/best-practices
https://github.com/ggreer/the_silver_searcher
* ag is faster than ack
* ag searches all files by default (but still ignores gitignored files). This
removes the need for ack's `--type-add=` options.
* The command is 33% shorter than ack!