diff options
author | awerebea <awerebea.21@gmail.com> | 2023-03-07 22:41:51 +0400 |
---|---|---|
committer | awerebea <awerebea.21@gmail.com> | 2023-03-07 22:41:51 +0400 |
commit | aa870e9553098319091ce422937c044b85244ed9 (patch) | |
tree | 4ce357b1b061ef6fc1645b3dd0dfb95ea9991e9f | |
parent | d99cfab56c37be7488178a128085377440ade3d1 (diff) |
Skip WSL-related dirs from PATH in WSL
Change the get_executables_uncached function to ignore WSL-related
directories from PATH.
-rw-r--r-- | ranger/ext/get_executables.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/ranger/ext/get_executables.py b/ranger/ext/get_executables.py index 1646cb56..0a9a0516 100644 --- a/ranger/ext/get_executables.py +++ b/ranger/ext/get_executables.py @@ -21,6 +21,12 @@ def get_executables(): return _cached_executables +def _in_wsl(): + # Check if the current environment is Microsoft WSL instead of native Linux + with open('/proc/sys/kernel/osrelease', encoding="utf-8") as file: + return 'microsoft' in file.read().lower() + + def get_executables_uncached(*paths): """Return all executable files in each of the given directories. @@ -34,7 +40,10 @@ def get_executables_uncached(*paths): paths = unique(pathstring.split(':')) executables = set() + in_wsl = _in_wsl() for path in paths: + if in_wsl and path.startswith('/mnt/c/'): + continue try: content = listdir(path) except OSError: |