Ranger: Update mkcd and `A` binding with 1.7 makedirs and rename_append

master
Pierre Neidhardt 2015-04-14 23:36:13 +02:00
parent b7f06de62a
commit 1d4f082dcb
3 changed files with 26 additions and 8 deletions

View File

@ -101,17 +101,26 @@ class mkcd(Command):
"""
def execute(self):
from os.path import join, expanduser, lexists, basename
from os import mkdir
from os.path import join, expanduser, lexists
from os import makedirs
import re
dirname = join(self.fm.thisdir.path, expanduser(self.rest(1)))
if not lexists(dirname):
mkdir(dirname)
makedirs(dirname)
if self.rest(1).startswith('.') and not self.fm.settings['show_hidden']:
self.fm.cd(dirname)
else:
self.fm.thisdir.load_content(schedule=False)
self.fm.execute_console('scout -ae ^{}$'.format(self.rest(1)))
match = re.search('^/|^~[^/]*/', dirname)
if match:
self.fm.cd(match.group(0))
dirname = dirname[match.end(0):]
for m in re.finditer('[^/]+', dirname):
s = m.group(0)
if s == '..' or (s.startswith('.') and not self.fm.settings['show_hidden']):
self.fm.cd(s)
else:
## We force ranger to load content before calling `scout`.
self.fm.thisdir.load_content(schedule=False)
self.fm.execute_console('scout -ae ^{}$'.format(s))
else:
self.fm.notify("file/directory exists!", bad=True)

View File

@ -102,6 +102,12 @@ map <F5> shell -w file %s
map <F6> console touch
map <F7> console mkcd
# ===================================================================
# == Overrides
# ===================================================================
map A rename_append
# ===================================================================
# == Personal shorcuts
# ===================================================================

View File

@ -103,6 +103,9 @@ case "$mimetype" in
# # Use sed to remove spaces so the output fits into the narrow window
try mediainfo "$path" && { dump | trim | sed 's/ \+:/: /;'; exit 5; } || exit 1;;
# Image preview for videos, disabled by default:
# video/*)
# ffmpegthumbnailer -i "$path" -o "$cached" -s 0 && exit 6 || exit 1;;
# Display information about media files:
video/* | audio/*)
# Use sed to remove spaces so the output fits into the narrow window