diff options
author | hut <hut@lavabit.com> | 2010-01-10 22:54:04 +0100 |
---|---|---|
committer | hut <hut@lavabit.com> | 2010-01-10 22:54:04 +0100 |
commit | 277ecc9ea7110b79ea0d6c0e25804ea2b218287f (patch) | |
tree | b487d5c2b366ee209ec58cddaaafb5a60a4f3671 /ranger | |
parent | 8757f653918eb6ccfc5ec6715957e6cd04a2ff3f (diff) | |
download | ranger-277ecc9ea7110b79ea0d6c0e25804ea2b218287f.tar.gz |
added chmod command
Diffstat (limited to 'ranger')
-rw-r--r-- | ranger/commands.py | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/ranger/commands.py b/ranger/commands.py index 7fb3a62c..8d71b3eb 100644 --- a/ranger/commands.py +++ b/ranger/commands.py @@ -280,6 +280,37 @@ class rename(Command): return self._tab_directory_content() +class chmod(Command): + """ + :chmod <octal number> + + Sets the permissions of the selection to the octal number. + """ + def execute(self): + line = parse(self.line) + mode = line.rest(1) + + try: + mode = int(mode, 8) + if mode < 0 or mode > 511: + raise ValueError + except ValueError: + self.fm.notify("Need an octal number between 0 and 777!", bad=True) + return + + for file in self.fm.env.get_selection(): + try: + os.chmod(file.path, mode) + except Exception as ex: + self.fm.notify(str(ex), bad=True) + + try: + # reloading directory. maybe its better to reload the selected + # files only. + self.fm.env.pwd.load_content() + except: + pass + class filter(Command): """ :filter <string> |