diff --git a/.config/ranger/commands.py b/.config/ranger/commands.py index b37ef052..0a5eccc2 100644 --- a/.config/ranger/commands.py +++ b/.config/ranger/commands.py @@ -57,3 +57,38 @@ class bulkrename(Command): self.fm.execute_file([File(cmdfile.name)], app=local_ed) self.fm.run(['/bin/sh', cmdfile.name], flags='w') cmdfile.close() + + + +import os +from ranger.core.loader import CommandLoader +class extracthere(Command): + def execute(self): + """ Extract copied files to current directory """ + copied_files = tuple(self.fm.env.copy) + + if not copied_files: + return + + def refresh(_): + cwd = self.fm.env.get_directory(original_path) + cwd.load_content() + + one_file = copied_files[0] + cwd = self.fm.env.cwd + original_path = cwd.path + au_flags = ['-X', cwd.path] + au_flags += self.line.split()[1:] + au_flags += ['-e'] + + self.fm.env.copy.clear() + self.fm.env.cut = False + if len(copied_files) == 1: + descr = "extracting: " + os.path.basename(one_file.path) + else: + descr = "extracting files from: " + os.path.basename(one_file.dirname) + obj = CommandLoader(args=['aunpack'] + au_flags \ + + [f.path for f in copied_files], descr=descr) + + obj.signal_bind('after', refresh) + self.fm.loader.add(obj) diff --git a/.config/ranger/rc.conf b/.config/ranger/rc.conf index b11590ad..de379c39 100644 --- a/.config/ranger/rc.conf +++ b/.config/ranger/rc.conf @@ -94,7 +94,7 @@ alias setl setlocal # =================================================================== # Basic -map ! console shell -w +map ! console shell -w # For the nostalgics: Midnight Commander bindings map bulkrename @@ -105,6 +105,10 @@ map console touch # == Personal shorcuts # =================================================================== +## Prevent accidental exit when using programs that also uses this key to quit. +unmap q +map Q quit + ## Move to trash (without Trash-CLI) # map DD shell mv -t ~/.local/share/Trash/files %s @@ -114,6 +118,7 @@ map DD shell trash-put -- %s ## Extraction using atools. map ex shell aunpack -e %s map eeg shell aunpack -e %s -X "$HOME/games/" +map pe extracthere ## Git map ega shell -w git add %f %s