summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorCélestin Matte <celestin.matte@gmail.com>2014-04-28 19:42:45 +0200
committerCélestin Matte <celestin.matte@gmail.com>2014-04-28 19:56:56 +0200
commit04681ff7ceb8a7db4111dbfac5f06477561c4c4a (patch)
tree92084599e4470814c239e18f52cb50c1164aa86a
parent3e31022b943f33f0466f9f5b7b452cf2363bfb40 (diff)
downloadranger-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.
-rw-r--r--ranger/core/actions.py12
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)
='#n158'>158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258