ranger: extracthere command and unmap q

master
Pierre Neidhardt 2013-08-04 14:06:53 +02:00
parent b0a5565eec
commit 964d1c3985
2 changed files with 41 additions and 1 deletions

View File

@ -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)

View File

@ -94,7 +94,7 @@ alias setl setlocal
# ===================================================================
# Basic
map ! console shell -w
map ! console shell -w
# For the nostalgics: Midnight Commander bindings
map <F4> bulkrename
@ -105,6 +105,10 @@ map <F6> 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