GNOME 搜索功能的一些小技巧
GNOME 搜索
![](/data/attachment/album/202112/25/115842tf8jjgn4ttz7nf4m.jpg)


你可能已经注意到，当你在 GNOME 菜单/活动区搜索某样东西时，它也会显示名称与搜索词相匹配的文件，以及已安装的应用。


![Search in GNOME activities shows installed applications and matching files](/data/attachment/album/202112/25/115909gci9w67cqq26ldri.png)


这是个很方便的功能。如果你记得文件名，甚至是它的一部分，你可以很容易地搜索到它，只需按下 `Super` 键（`Windows` 键）并输入文件名就可以打开它。


但是，围绕这个搜索功能，有一些你可能不知道或从未关心过的小问题。


在这篇文章中，我将分享你如何控制 GNOME 搜索功能，从搜索选项中添加或隐藏文件夹，以及完全禁用它。


注意：这专门针对使用 GNOME 的发行版。请 [确认你使用的是哪种桌面环境](https://itsfoss.com/find-desktop-environment/)，确保是 GNOME。


### 文件搜索的默认位置


GNOME 的搜索功能使用了一个叫做 [Tracker Miner FS](https://wiki.gnome.org/Projects/Tracker/Documentation/GettingStarted) 的工具。请不要被 “tracker” 和 “miner” 这样的术语吓到。它不是在监视你，也不是在你的系统上挖掘加密货币。它的基本功能是作为一个搜索引擎和数据库，为你提供即时搜索结果。


默认情况下，文件索引发生在元文件夹，如文档、音乐、图片和视频目录及其子目录。主页和下载文件夹中的文件也会被索引，但不包括其子目录中的文件。


![Default locations for file search](/data/attachment/album/202112/25/115910u0sgbfbs8s0ea8rh.png)


如果你在你的主文件夹中创建了一些新的目录，这些文件将不会被索引。


然而，最近访问的文件也会被自动编入索引。如果你最近打开了一个文件，它将被添加到 “最近的文件” 中，并将出现在搜索结果中，而不管它在什么地方。


如果你还不知道的话，你可以在文件管理器中看到你最近访问的文件：


![Accessing recent files in GNOME file manager](/data/attachment/album/202112/25/115911ulqql3igjxzqmt8i.png)


### 在搜索结果中添加一个文件夹的内容


假设你在你的主目录中为编码项目创建了一个文件夹。这些文件不会被索引，也不会出现在搜索结果中（除非你通过双击打开了一个文件，并且它被添加到最近的文件中）。


要在搜索结果中添加自定义文件夹中的文件，你可以将该文件夹添加到搜索位置。


通过在菜单/活动区搜索打开 “设置” 应用。


![Search for settings application](/data/attachment/album/202112/25/115912t3zv63zsd40bwnex.jpg)


从左侧边栏进入 “搜索” 选项，点击顶部的“搜索位置”选项。在弹出的窗口中，进入 “其他” 标签，点击 “+” 符号。它将打开文件浏览器，你可以添加你想要的文件夹。


![Adding a custom folder content to search](/data/attachment/album/202112/25/115913squbv3f20hrr33bo.png)


如果你在刚刚添加的文件夹中搜索一个文件名进行测试，你现在应该在搜索结果中看到它。它应该是即时的，但如果不是，请尝试注销或重启系统。


### 从搜索结果中隐藏一个文件夹


如果你不希望某个特定文件夹的文件出现在搜索结果中，你可以隐藏它。


如果你不希望在搜索中出现图片、文档、视频等元文件夹的内容，你可以从搜索位置设置中禁用它。


![Disable meta folders from the search](/data/attachment/album/202112/25/115913my4toywqt45qmitb.png)


如果你只想让文档下的某个文件夹的内容不出现在搜索结果中，你只需要在该文件夹中创建一个名为 `.nomedia` 的新文件。你也可以将该文件命名为 `.git`、`.trackerignore` 或 `.hg`。


![Hide specific folder from search results by creating file named .nomedia or .hg or .git](/data/attachment/album/202112/25/115914j4dg9ic350mu84il.png)


如果你在鼠标右键中没有看到创建新文件的选项，你必须做一些调整来增加 [在右键上下文菜单中创建新文件选项](https://itsfoss.com/add-new-document-option/)。还要注意的是，任何名称中以 `.` 开头的文件都会被隐藏起来，不能被正常查看。要 [切换显示隐藏文件](https://itsfoss.com/hide-folders-and-show-hidden-files-in-ubuntu-beginner-trick/)，按 `Ctrl+H` 键。


这种隐藏可能不会立即生效，因为该文件可能已经被索引了。你可能必须注销或重启才能看到效果。


如果你手动访问一个文件，它将被添加到最近的文件中，并且会出现在搜索结果中，尽管文件夹中的文件被忽略了。


你可以从 “设置 -> 隐私 -> 文件历史 & 垃圾箱” 删除最近的文件历史或完全禁用它（如果你想的话）。不过我认为没有必要，所以在这里你自己决定吧。


![Clear or disable file access history in GNOME](/data/attachment/album/202112/25/115916mwbwa42b7kvv0uwq.png)


### 禁用所有文件的搜索结果


如果你不希望任何文件出现在搜索结果中，你可以在搜索设置中完全禁用对文件的搜索。


![Disable search results for all files](/data/attachment/album/202112/25/115916o1p1fsalaxwwl51a.png)


你应该通过点击顶部的搜索切换按钮完全禁用搜索功能，它可能会干扰 GNOME 桌面环境的正常功能。


关于它的更多细节可以在 [项目主页] 中找到。


### 总结


这里的 *讨论的是文件搜索*。GNOME 桌面也可以在日历、字符映射和其他一些程序中进行搜索。你可以禁用或启用可用的搜索选项，但我们这篇不针对这些。


我希望你觉得这个快速提示对 [定制你的 GNOME 体验](https://itsfoss.com/gnome-tricks-ubuntu/) 有帮助。如果你知道其他一些你想让别人知道的技巧，请在评论中与我们分享。




---


via: <https://itsfoss.com/control-gnome-file-search/>


作者：[Abhishek Prakash](https://itsfoss.com/author/abhishek/) 选题：[lujun9972](https://github.com/lujun9972) 译者：[geekpi](https://github.com/geekpi) 校对：[wxy](https://github.com/wxy)


本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译，[Linux中国](https://linux.cn/) 荣誉推出


OK
You might have already noticed that when you search for something in the GNOME menu/activities area, it also shows the files with names matching the searched term along with installed applications.

![gnome file search result](https://itsfoss.com/content/images/wordpress/2021/12/gnome-file-search-result-800x355.png)

That’s a handy feature. If you remember the file name or even part of it, you can easily search for it and open it just by pressing the Super key (Windows key) and typing the name.

But there are a few nit bits around this search feature that you might not know about or never cared for.

In this article, I’ll share how you can control the GNOME search feature, add or hide folders from the search option and disable it completely.

*Note: This is exclusively for distributions using GNOME. Please verify which desktop environment you are using and ensure it is GNOME.*

## Default locations for file search

The GNOME search feature utilizes a utility called [Tracker Miner FS](https://wiki.gnome.org/Projects/Tracker/Documentation/GettingStarted). Please do not get alarmed by the terms like *tracker* and *miner*. It’s not spying on you or mining crypto on your system. It basically functions as a search engine and a database to provide you instant search results.

By default, the file indexing takes place in the meta folders like Documents, Music, Pictures and Videos directories and their sub-directories. Files in the Home and Downloads folders are also indexed but not the ones in their sub-directories.

![gnome default search location](https://itsfoss.com/content/images/wordpress/2021/12/gnome-default-search-location-800x533.png)

If you have created some new directories in your home folder, those files will not be indexed.

However, the recently accessed files are also indexed automatically. If you have opened a file recently, it is added to the ‘recent files’ and will appear in the search results irrespective of its location.

In case you didn’t know already, you can see your recently accessed files in the file manager:

![access recent files gnome linux](https://itsfoss.com/content/images/wordpress/2021/12/access-recent-files-gnome-linux.png)

## Adding a folder content to search results

Suppose you have created a folder for coding projects in your home directory. These files won’t be indexed and won’t appear in search results (unless you have opened a file by double clicking and it is added to the recent files).

To add the files from a custom folder in the search result, you can add the folder to the search locations.

Open the Settings application by searching for it in the menu/activity area:

![Settings Search Ubuntu 20 04](https://itsfoss.com/content/images/wordpress/2020/04/settings-search-ubuntu-20-04.jpg)

Go to the **Search** option from the left sidebar and click on the **Search Locations** option at the top. In the pop-up window, go to the **Other** tab and click on the **+ symbol**. It will add the file browser and you can add your desired folder.

![gnome add search location](https://itsfoss.com/content/images/wordpress/2021/12/gnome-add-search-location-800x525.png)

If you test by searching a filename in the just added folder, you should see it in the search results now. It should be instant but if it is not, try logging out or rebooting the system.

## Hide a folder from search results

If you don’t want files from a specific folder to appear in the search result, you can hide it.

If you don’t want the content of the meta folders like Pictures, Documents, Videos in search, you disable it from the Search Location settings.

![disable folders from search](https://itsfoss.com/content/images/wordpress/2021/12/disable-folders-from-search-800x533.png)

If you want the contents of only a certain folder under Documents to NOT appear in the search result, you just have to create a new file named **.nomedia** in that folder. You may also name the file .git, .trackerignore or .hg.

![hide specific folder from search results](https://itsfoss.com/content/images/wordpress/2021/12/hide-specific-folder-from-search-results.png)

If you don’t see the option to create new file in right mouse lick, you’ll have to do some tweaking to add the [create new document option in the right click context menu](https://itsfoss.com/add-new-document-option/). Also note that any files starting with a . in its name is hidden from normal view. To [toggle hidden files](https://itsfoss.com/hide-folders-and-show-hidden-files-in-ubuntu-beginner-trick/), press Ctrl+H keys.

This hiding might not work immediately because the file is probably already indexed. You may have to log out or reboot to see the effect.

If you access a file manually, it will be added to the recent files and will appear in the search result despite the ignore file in the folder.

You can delete the recent files history or disable it altogether (if you want) from **Settings-> Privacy-> File History & Trash**. I don’t see the need of it, though, so make your own decision here.

![clear or disable file history gnome linux](https://itsfoss.com/content/images/wordpress/2021/12/clear-or-disable-file-history-gnome-linux-800x389.png)

## Disable search results for all files

If you do not want any files to appear in the search results, you can disable search for Files altogether from the search settings.

![disable search for files gnome](https://itsfoss.com/content/images/wordpress/2021/12/disable-search-for-files-gnome-800x475.png)

You should disable the search functionality altogether by clicking the Search toggle button at the top as it may interfere with the normal functionality of the GNOME desktop environment.

More details on it can be found on the [project’s homepage](https://gnome.pages.gitlab.gnome.org/tracker/).

## Conclusion

The ** discussion here is about file search**. GNOME desktop also searches in Calendar, Characters and some other utilities. You can disable or enable the available search options but let’s not focus on that.

I hope you find this quick tip helpful in [customizing your GNOME experience](https://itsfoss.com/gnome-tricks-ubuntu/). If you know some other neat trick that you want others to know, please share it with us in the comments.