about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--ranger/commands.py31
1 files changed, 27 insertions, 4 deletions
diff --git a/ranger/commands.py b/ranger/commands.py
index 411408eb..07c0a8d7 100644
--- a/ranger/commands.py
+++ b/ranger/commands.py
@@ -264,11 +264,34 @@ class mkdir(Command):
 	"""
 
 	def execute(self):
+		from os.path import join, expanduser, lexists
+		from os import mkdir
+
 		line = parse(self.line)
-		try:
-			self.fm.mkdir(line.rest(1))
-		except IndexError:
-			pass
+		dirname = join(self.fm.env.pwd.path, expanduser(line.rest(1)))
+		if not lexists(dirname):
+			mkdir(dirname)
+		else:
+			self.fm.notify("file/directory exists!", bad=True)
+
+
+class touch(Command):
+	"""
+	:touch <fname>
+
+	Creates a file with the name <fname>.
+	"""
+
+	def execute(self):
+		from os.path import join, expanduser, lexists
+		from os import mkdir
+
+		line = parse(self.line)
+		fname = join(self.fm.env.pwd.path, expanduser(line.rest(1)))
+		if not lexists(fname):
+			open(fname, 'a')
+		else:
+			self.fm.notify("file/directory exists!", bad=True)
 
 
 class edit(Command):