Skip to content

Commit

Permalink
Exclude file/folder_exclude_patterns
Browse files Browse the repository at this point in the history
If `dired_show_excluded_files` is set to `false`, it hides files and folders that match against `folder_exclude_patterns` and `file_exclude_patterns` patterns defined in the global settings.
  • Loading branch information
laggingreflex committed Jul 1, 2016
1 parent a28e4e5 commit 8e80529
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 15 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,13 @@ such patterns:
{ "dired_hidden_files_patterns": [".*", "__pycache__", "*.pyc"] }
```

It also shows all files and directories otherwise excluded by your `file_exclude_patterns` and `folder_exclude_patterns`.

To hide excluded files and folders, add the following to your settings:
``` json
{ "dired_show_excluded_files": false }
```

### VCS integration
In case `git status`(or `hg status`) returns a colorable output in current directory, the modified
and untracked files will be designated by orange and green icons respectively.
Expand Down
38 changes: 23 additions & 15 deletions common.py
Original file line number Diff line number Diff line change
Expand Up @@ -403,21 +403,29 @@ def prepare_filelist(self, names, path, goto, indent):
def is_hidden(self, filename, path, goto=''):
if not (path or goto): # special case for ThisPC
return False
tests = self.view.settings().get('dired_hidden_files_patterns', ['.*'])
if isinstance(tests, str):
tests = [tests]
if any(fnmatch.fnmatch(filename, pattern) for pattern in tests):
return True
if sublime.platform() != 'windows':
return False
# check for attribute on windows:
try:
attrs = ctypes.windll.kernel32.GetFileAttributesW(join(path, goto, filename))
assert attrs != -1
result = bool(attrs & 2)
except (AttributeError, AssertionError):
result = False
return result
show_hidden = self.show_hidden
show_excluded = self.view.settings().get('dired_show_excluded_files', True)
is_hidden = False
if not show_hidden:
test = self.view.settings().get('dired_hidden_files_patterns', ['.*'])
if isinstance(test, str):
test = [test]
if any(fnmatch.fnmatch(filename, p) for p in test):
is_hidden = True
if sublime.platform() == 'windows':
# check for attribute on windows:
try:
attrs = ctypes.windll.kernel32.GetFileAttributesW(join(path, goto, filename))
assert attrs != -1
if bool(attrs & 2):
is_hidden = True
except:
pass
if not show_excluded:
test = self.view.settings().get('folder_exclude_patterns', []) + self.view.settings().get('file_exclude_patterns', [])
if any(fnmatch.fnmatch(filename, p) for p in test):
is_hidden = True
return is_hidden

def try_listing_directory(self, path):
'''Return tuple of two element
Expand Down

0 comments on commit 8e80529

Please sign in to comment.