diff options
-rwxr-xr-x | ranger/config/commands.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/ranger/config/commands.py b/ranger/config/commands.py index 2656755e..27919541 100755 --- a/ranger/config/commands.py +++ b/ranger/config/commands.py @@ -927,10 +927,14 @@ class touch(Command): """ def execute(self): - from os.path import join, expanduser, lexists + from os.path import join, expanduser, lexists, dirname + from os import makedirs fname = join(self.fm.thisdir.path, expanduser(self.rest(1))) + dirname = dirname(fname) if not lexists(fname): + if not lexists(dirname): + makedirs(dirname) open(fname, 'a').close() else: self.fm.notify("file/directory exists!", bad=True) |