如何将 ripgrep 配置为始终从我的主目录进行搜索?

gar*_*ing 2 ripgrep

如何将我的~/.ripgreprcglob 配置为始终从主目录进行搜索,无论我rg从何处运行?

And*_*ter 5

我很确定您无法配置 ripgrep 来执行此操作,如果可以的话,这样做将是一个坏主意,但您可以创建一个 shell 函数来执行您想要的操作。

将其放入 ~/.bashrc 中:

function rgh()
{
    rg "$@" ~/
}
Run Code Online (Sandbox Code Playgroud)

然后你只需rgh whatever将其扩展为rg whatever ~/.

(我选择rgh了“ripgrep home”,但你可以随意称呼它。)