Search code examples
ripgrep

How can I configure ripgrep to always search from my home directory?


How can I configure my ~/.ripgreprc glob(s) to always search from the home directory regardless of where I run rg from?


Solution

  • I'm pretty sure you can't configure ripgrep to do that, and it would be a bad idea to do that if you could, but you can make a shell function to do what you want.

    Put this in your ~/.bashrc:

    function rgh()
    {
        rg "$@" ~/
    }
    

    Then you just rgh whatever and it will expand to rg whatever ~/.

    (I chose rgh for "ripgrep home" but you can call it whatever you want.)