For years, I have used a snippet named Folder Hider
that does basically this:
.nav-file [data-path="path/to/file.md"],
.nav-folder-title[data-path^="path/to/folder"],
.nav-folder-title[data-path^="path/to/folder"] + .nav-folder-children {
display: none;
}
This snippet hides files I don't want to see.
However, managing a snippet has some caveats:
So, I decided to create a plugin to manage this for me!
To hide a file or folder, you can right-click on the file/folder in the explorer and select Hide << name >>
.
If Always hide in bookmark
is enabled, the file/folder will also be hidden in the bookmarks when the command is used from the explorer.
[!TIP] For folders, the rule will be
^=
(starts with) and for files=
(exact match).
See Experimental for more information about the bookmarks panel and shortcuts.
Using the "eye" ribbon button, you can enable or disable all the rules.
The settings are divided into two parts:
It also displays a list of all the rules, with the option to:
For string
rules, you can also edit the attribute selector and the rule itself.
You can choose to save the CSS in a snippet (in your .obsidian/snippets
folder) or directly inject it into the page. Use this if, for example, you want to keep the folder hidden without using the plugin (for instance, when disabling or uninstalling it).
You can also choose to automatically hide excluded files (obsidian files & folder settings).
[!NOTE] If you add files in the filter, you need to reload the hidden files to apply the changes.
[!warning] This option will be disabled if the bookmarks plugin is not enabled.
You can choose to hide files in the bookmarks panel too. This will hide the file in the bookmarks panel when the command is used from the explorer.
It is possible to add a button in the file-menu of the bookmarks panel that allows hiding files from bookmarks. However, this feature has some caveats and bugs.
string
and not a file (this mostly appears if the file is registered under a group). Consequently, it won't be followed if the bookmark is renamed or moved.Using attribute selectors, you can hide multiple files or folders at once. For example, to hide all the files in a folder, you can set [startswith] <path>
. See CSS attribute selectors for more information.
Each attribute corresponds to:
Attribute | CSS | Description |
---|---|---|
Exact | = |
Exact match with the string |
Contains | *= |
Contains the string |
Ends with | $= |
Ends with the string (suffix) |
Starts with | ^= |
Starts with the string (prefix) |
List | ~= |
String is a whitespace-separated list of words, one of which matches exactly |
Text followed by hyphen | \|= |
The match can be on exactly the value or can begin with the value immediately followed by a hyphen (- ) |
The result will be:
.tree-item [data-path{selector}="path"] { /* Notice the space between the class and the attribute */
display: none;
}
.tree-item[data-path{selector}="path"] {
display: none;
}
[!Note] If the tree for bookmarks and explorer is changed by the Obsidian team, the plugin/snippets will break. I will try to keep it updated, but I can't guarantee it.
https://github.com/Mara-Li/obsidian-explorer-hider
obsidian://brat?plugin=https://github.com/Mara-Li/obsidian-explorer-hider
explorer-hider.zip
in the .obsidian/plugins/
pathTo add a translation:
src/i18n/locales
folder with the name of the language (e.g., fr.json
).
<% tp.obsidian.moment.locale() %>
en.json
file into the new file.i18n/i18next.ts
:
import * as <lang> from "./locales/<lang>.json";
resources
part by adding: <lang>: {translation: <lang>}