From 04681ff7ceb8a7db4111dbfac5f06477561c4c4a Mon Sep 17 00:00:00 2001 From: CĂ©lestin Matte Date: Mon, 28 Apr 2014 19:42:45 +0200 Subject: 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. --- ranger/core/actions.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) 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) -- cgit 1.4.1-2-gfad0