diff options
author | Célestin Matte <celestin.matte@gmail.com> | 2014-04-28 19:42:45 +0200 |
---|---|---|
committer | Célestin Matte <celestin.matte@gmail.com> | 2014-04-28 19:56:56 +0200 |
commit | 04681ff7ceb8a7db4111dbfac5f06477561c4c4a (patch) | |
tree | 92084599e4470814c239e18f52cb50c1164aa86a /ranger | |
parent | 3e31022b943f33f0466f9f5b7b452cf2363bfb40 (diff) | |
download | ranger-04681ff7ceb8a7db4111dbfac5f06477561c4c4a.tar.gz |
Handle CDPATH
This shell feature allows one to cd directly to remote directories located in paths defined in the variable. Allow handling of such variable in ranger. Compatible with: bash, ksh, zsh, csh, and possibly others.
Diffstat (limited to 'ranger')
-rw-r--r-- | ranger/core/actions.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/ranger/core/actions.py b/ranger/core/actions.py index ec853f1b..8424b51d 100644 --- a/ranger/core/actions.py +++ b/ranger/core/actions.py @@ -451,7 +451,19 @@ class Actions(FileManagerAware, EnvironmentAware, SettingsAware): def enter_dir(self, path, remember=False, history=True): """Enter the directory at the given path""" cwd = self.thisdir + # bash and ksh syntax + cdpath = os.environ.get('CDPATH', None) + if cdpath == "": + # zsh and csh syntax + os.environ.get('cdpath', None) + paths = cdpath.split(':') result = self.thistab.enter_dir(path, history=history) + if result == 0: + for p in paths: + curpath = p + '/' + path + if os.path.isdir(curpath): + result = self.thistab.enter_dir(curpath, history=history) + break if cwd != self.thisdir: if remember: self.bookmarks.remember(cwd) |