标签: ripgrep

最佳 GNU 查找替代品

我正在寻找更好的发现。原因是查找用户界面对我来说不直观(特别是修剪/打印样式),并且由于对参数排序的严格要求而难以包装在函数中。locate/updatedb 不够灵活,无法使用。有人愿意分享他们的示例查找包装器或查找替代方案(请仅使用命令行)吗?

这是我认为不直观的用法的示例:

find dir_a dir_b \( -path dir_a/.git -o -path dir_b/out \) -prune -o \( -type f -o -type l \)
Run Code Online (Sandbox Code Playgroud)

在选项之前指定目录对我来说很奇怪,而且修剪的语法很容易被忘记。(有些程序使用 --exclude 选项代替。)我认识到这是一个挑剔的点。

这是我在不损失太多功能的情况下指定一些默认值的最佳尝试:

f()
{
  # The trouble is that -regextype must appear after path but before expression.
  # HACK: "-D debugopts" unsupported and -[HLPO] options assumed to before dirs.
  local a=()
  while [[ -n "$1" ]] && ( [[ ! "${1:0:1}" =~ [-!(),] ]] || [[ "${1:0:2}" =~ -[HLPO] ]] )
  do
    a+=("$1")

    # Eliminate arg …
Run Code Online (Sandbox Code Playgroud)

find command-line-interface ack ag ripgrep

5
推荐指数
1
解决办法
870
查看次数

望远镜查找文件和实时 grep 不起作用

我正在尝试在 MacOS 13.2.1 上使用 nvim 设置望远镜。我是用打包机安装的。我已经安装了望远镜所需的所有依赖项。并且仍然无法显示find_fileslive_grep搜索任何结果。

\n

这是我在望远镜打包机中的配置

\n
use({ "nvim-telescope/telescope.nvim", branch = "0.1.x", \n    requires = { { "nvim-lua/plenary.nvim" } } \n}) \n
Run Code Online (Sandbox Code Playgroud)\n

这是我的望远镜配置

\n
-- import telescope plugin safely\nlocal telescope_setup, telescope = pcall(require, "telescope")\nif not telescope_setup then\n    return\nend\n\n-- import telescope actions safely\nlocal actions_setup, actions = pcall(require, "telescope.actions")\nif not actions_setup then\n    return\nend\n\n-- configure telescope\ntelescope.setup({\n    -- configure custom mappings\n    defaults = {\n        layout_config = {\n            width = 0.75,\n            prompt_position = "top",\n            preview_cutoff = 120,\n            horizontal …
Run Code Online (Sandbox Code Playgroud)

lua neovim ripgrep telescope.nvim

3
推荐指数
1
解决办法
3918
查看次数

.gitignore node_modules/ 不适用于 fd 和 ripgrep

我正在尝试在 Windows 10 上为 vim设置fzf.vim 。

您可以使用替代的 find 命令,如ripgrepfd,它应该尊重 .gitignore

我的 .gitignore 文件有这一行,对于 git 提交等工作正常:

node_modules/
Run Code Online (Sandbox Code Playgroud)

我的目录结构是

/working directory
.gitignore file
.git  dir
/node_modules dir
Run Code Online (Sandbox Code Playgroud)

当我跑步时

fd --type f
Run Code Online (Sandbox Code Playgroud)

或者

rg --files
Run Code Online (Sandbox Code Playgroud)

它列出了node_modules 中的所有文件。

我感觉这可能是windows的问题。

如何让这些程序使用 .gitignore 来忽略 node_modules?

fzf ripgrep vim-fzf

2
推荐指数
1
解决办法
2797
查看次数

python在bash和子进程上运行时的不同输出

我正在运行一个脚本,该脚本在内部调用 bash 命令并相应地解析输出。例如我正在调用这个命令

result = subprocess.check_output("rg result",shell=True)
print(output)
Run Code Online (Sandbox Code Playgroud)

我得到这个输出没有任何行号或任何东西

historyChecker.py:        result = subprocess.check_output("rg --help",shell=True)
historyChecker.py:        output = re.search(r'USAGE:',result)
Run Code Online (Sandbox Code Playgroud)

如果我在 bash 中运行相同的命令,我会得到不同的结果

[~/history_checker/code]$ rg result                                                                                                                                               
historyChecker.py
56:        result = subprocess.check_output("rg --help",shell=True)
57:        output = re.search(r'USAGE:',result) 
Run Code Online (Sandbox Code Playgroud)

知道为什么会发生这种情况以及我们如何解决这个问题。谢谢

python format bash subprocess ripgrep

2
推荐指数
1
解决办法
45
查看次数

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

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

ripgrep

2
推荐指数
1
解决办法
478
查看次数

2
推荐指数
1
解决办法
4620
查看次数

将ripgrep搜索结果传递到vim并在确切的搜索位置打开文件

rg -l "searched phrase" | xargs vim
Run Code Online (Sandbox Code Playgroud)

用搜索到的词填充vim,但是这次我需要在vim中再次搜索它们。

如何将ripgrep搜索结果传送到vim,以便在精确的搜索位置(行和列)打开搜索到的文件?

vim ripgrep

0
推荐指数
1
解决办法
278
查看次数