Ranger: Update mkcd and `A` binding with 1.7 makedirs and rename_append
parent
b7f06de62a
commit
1d4f082dcb
|
@ -101,17 +101,26 @@ class mkcd(Command):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def execute(self):
|
def execute(self):
|
||||||
from os.path import join, expanduser, lexists, basename
|
from os.path import join, expanduser, lexists
|
||||||
from os import mkdir
|
from os import makedirs
|
||||||
|
import re
|
||||||
|
|
||||||
dirname = join(self.fm.thisdir.path, expanduser(self.rest(1)))
|
dirname = join(self.fm.thisdir.path, expanduser(self.rest(1)))
|
||||||
if not lexists(dirname):
|
if not lexists(dirname):
|
||||||
mkdir(dirname)
|
makedirs(dirname)
|
||||||
|
|
||||||
if self.rest(1).startswith('.') and not self.fm.settings['show_hidden']:
|
match = re.search('^/|^~[^/]*/', dirname)
|
||||||
self.fm.cd(dirname)
|
if match:
|
||||||
else:
|
self.fm.cd(match.group(0))
|
||||||
self.fm.thisdir.load_content(schedule=False)
|
dirname = dirname[match.end(0):]
|
||||||
self.fm.execute_console('scout -ae ^{}$'.format(self.rest(1)))
|
|
||||||
|
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:
|
else:
|
||||||
self.fm.notify("file/directory exists!", bad=True)
|
self.fm.notify("file/directory exists!", bad=True)
|
||||||
|
|
|
@ -102,6 +102,12 @@ map <F5> shell -w file %s
|
||||||
map <F6> console touch
|
map <F6> console touch
|
||||||
map <F7> console mkcd
|
map <F7> console mkcd
|
||||||
|
|
||||||
|
|
||||||
|
# ===================================================================
|
||||||
|
# == Overrides
|
||||||
|
# ===================================================================
|
||||||
|
map A rename_append
|
||||||
|
|
||||||
# ===================================================================
|
# ===================================================================
|
||||||
# == Personal shorcuts
|
# == Personal shorcuts
|
||||||
# ===================================================================
|
# ===================================================================
|
||||||
|
|
|
@ -103,6 +103,9 @@ case "$mimetype" in
|
||||||
# # Use sed to remove spaces so the output fits into the narrow window
|
# # Use sed to remove spaces so the output fits into the narrow window
|
||||||
try mediainfo "$path" && { dump | trim | sed 's/ \+:/: /;'; exit 5; } || exit 1;;
|
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:
|
# Display information about media files:
|
||||||
video/* | audio/*)
|
video/* | audio/*)
|
||||||
# Use sed to remove spaces so the output fits into the narrow window
|
# Use sed to remove spaces so the output fits into the narrow window
|
||||||
|
|
Loading…
Reference in New Issue