diff options
author | hut <hut@lavabit.com> | 2010-01-14 19:32:02 +0100 |
---|---|---|
committer | hut <hut@lavabit.com> | 2010-01-14 19:32:02 +0100 |
commit | 301b488b987b629add14c8a4831d237387ac5d28 (patch) | |
tree | 139b39c0b95c82fa0fc23e3ff7f13b1a05e9d824 /ranger | |
parent | c0280bc867aecc29d8f72fbbd637133ea88729ba (diff) | |
download | ranger-301b488b987b629add14c8a4831d237387ac5d28.tar.gz |
commands: added touch, improved mkdir
Diffstat (limited to 'ranger')
-rw-r--r-- | ranger/commands.py | 31 |
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): |