Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hide specified files or directories #694

Closed
1 task done
grig-iv opened this issue Feb 18, 2024 · 15 comments · May be fixed by #2089
Closed
1 task done

Hide specified files or directories #694

grig-iv opened this issue Feb 18, 2024 · 15 comments · May be fixed by #2089
Labels
feature New feature request good first issue Good for newcomers

Comments

@grig-iv
Copy link
Contributor

grig-iv commented Feb 18, 2024

Is your feature request related to a problem? Please describe

It's nice to have control over file/folder visibility, e.g. folders like Desktop, go and steam in my home directory are an eyesore for me, I would like to hide them, and some people may want to treat their .config as visible folder****

Will you be willing to contribute this feature?

  • Yes, I'll give it a shot

Describe the solution you'd like

There should be an option in yazi.toml where the user can add rules for how to treat certain files and folders. It probably should resides under the [manager] category alongside with show_hidden.

Which is a more intuitive way to represent this option?

  1. An array of patterns with a specification how to treat them
[manager]
visibility_rules = [
    { pattern = "~/.config", visible = true,  }
    { pattern = "~/Desktop", visible = false, }
    { pattern = "~/go"     , visible = false, }
]
  1. Two arrays - one for visible entries, one for hidden entries
[manager]
treat_as_visible = [ "~/.config", ]
treat_as_hidden = [ "~/Desktop", "~/go", ]

Describe alternatives you've considered

No response

Additional context

Requested by @5ouma, #51 (comment)

@grig-iv grig-iv added the feature New feature request label Feb 18, 2024
@grig-iv
Copy link
Contributor Author

grig-iv commented Feb 18, 2024

Also is there already a function for checking url for a pattern?

@sxyazi
Copy link
Owner

sxyazi commented Feb 18, 2024

I think this is a bit too complicated, it's a performance challenge

If there are 10,000 files in the directory and there are 5 rules like this, it will need to match 50,000 times. My idea is that it should just be a simple regular expression, not a set of rules.

@grig-iv
Copy link
Contributor Author

grig-iv commented Feb 18, 2024

Just to be clear, should regex be checked upon filename or full path? And what config type should I use?

@sxyazi
Copy link
Owner

sxyazi commented Feb 19, 2024

Maybe we can have:

[manager]
visibility_rules = [
    { dir = "~/", hide = "go|\.git" },
    { dir = "*/", hide = "\.git" }  # fallback
]

Different hiding patterns (regular expressions) can be set for different directories, and the first matching rule will be applied.

Not quite sure, I need to think about it some more. BTW, are there any other file managers that support configuring this? Maybe we can refer to them.

@jmlucjav
Copy link

Total commander does support this, it's called Ignore list

@sxyazi
Copy link
Owner

sxyazi commented Feb 20, 2024

@jmlucjav Sorry could you be more specific? How does it support it - like, what does the configuration file look like? I haven't used it.

@jmlucjav
Copy link

the easiest would be to paste the help contents...

Configuration - Ignore list Back

Ignore specific files/folders: They will be neither displayed nor copied. Only files in the file system can be ignored. Files on ftp servers, within archives, plugins or virtual folders like the desktop cannot be ignored.

Ignore (don't show) the following files and folders:
Master switch to turn option on and off.
List files and folders which you want to ignore. The following entry types are supported:

  1. Full path to file. Example: c:\config.sys
  2. Path relative to the root of ALL drives. Example: \RECYCLER
  3. Name which will be hidden in all paths. Example: descript.ion
    Notes:
  • All 3 options above also support the wildcards * and ?, e.g. *.br1
  • Multiple names with wildcards can be put on 1 line, separated by space or ";", e.g. *.bak *.old
  • Relative or absolute path items must be put on a separate line each.
  • When a name is ended with a backslash, it will match only directories
  • Attention: If a name contains both spaces and wildcards, it must be written in double quotes the following way: "System Volume*" or c:\path"long name*"

Save in: Location and name where the ignore list will be stored. Default is tcignore.txt

Add selected names with full path
Enabled only when some files are selected in the last active panel of Total Commander. Allows you to add these files/dirs with full path to the above list.

Add selected names Enabled only when some files are selected in the last active panel of Total Commander. Allows you to add these files/dirs without path, which means that they will be hidden in ALL directories.

Note: Use the internal command cm_SwitchIgnoreList to turn this option on and off via a button, menu item, or hotkey.

image

image

@LGraz
Copy link

LGraz commented Jul 25, 2024

I was just looking for this feature I missed from ranger.

There it is implemented with the following defaults in the rc.conf file (in case this serves as useful inspiration):

# Which files should be hidden? (regular expression)
set hidden_filter ^\.|\.(?:pyc|pyo|bak|swp)$|^lost\+found$|^__(py)?cache__$

c.f. source

@sxyazi
Copy link
Owner

sxyazi commented Jul 26, 2024

Anyone want to give #694 (comment) a go?

@sxyazi sxyazi added the good first issue Good for newcomers label Jul 26, 2024
@pawel-szopinski
Copy link

lf file manager also has this feature implemented. It's just one line in the config file, e.g.:

set hiddenfiles .DS_Store:.localized:.sync_*

It would be awesome to have this feature in yazi, especially on macOS, since most directories are polluted by files like .DS_Store.

@DirkFi
Copy link
Contributor

DirkFi commented Aug 28, 2024

Anyone want to give #694 (comment) a go?

Hi, there. I'm interested in solving this issue but i'm new to this project's code base.
I tried to read and understand how this hidden attribute works in the code. Currently, my idea is to refactor the struct Manager in yazi-config with new visibility_rules attribute added and modify the is_hidden() function of Url in yazi-shared/fs to implement the rule.
Do you think it's a good way to go? Is there a better way for it?

@LGraz
Copy link

LGraz commented Aug 29, 2024

What are your thoughts on adding the option ignorefile? Like:

[manager]
visibility_rules = [
    { dir = "~/", hide = "go|\.git", ignorefile = ".gitignore|.stignore"},
    { dir = "*/", hide = "\.git", ignorefile = ".gitignore" }  # fallback
]

just a brainstorm idea :)

@DirkFi
Copy link
Contributor

DirkFi commented Aug 31, 2024

I haven't thought about ignorefile yet. I think it can still be implemented with Regx in hide.

@sxyazi
Copy link
Owner

sxyazi commented Oct 16, 2024

Tracked by #51

@sxyazi sxyazi closed this as completed Oct 16, 2024
Copy link

I'm going to lock this issue because it has been closed for 30 days. ⏳
This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please file a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 16, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature New feature request good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants