I'm not a ranger user, but I saw an entry in the ranger wiki that seems to be helpful : https://github.com/ranger/ranger/wiki/Commands.
TL;DR : edit the file ~/.config/ranger/commands.py
from ranger.api.commands import Command
class move_to_path(Command):
"""
:move_to_path
Move file to a directory
"""
def execute(self):
import shutil # for shutil.copy, os.rename works fine too
shutil.move(self.fm.thisfile.path, "/your/directory/" + self.fm.thisfile.basename)
You now have your command that you can launch with :move_to_path. You could write python code to know where to get the directory name : fixed, in a configuration file of your choice, etc.
Now, to add a keybinding, let's have a look at : https://github.com/ranger/ranger/wiki/Keybindings or at : http://ranger.nongnu.org/ranger.1.html#KEY-BINDINGS
If I'm not wrong, you can edit the ~/.config/ranger/config/rc.conf and add a keybinding here.
For instance, you can add a line :
map mf move_to_path
I think this should do the trick.
And thank you for making me discover ranger, I'll try it tomorrow :)
Edit :
To move multiple selected files, you could do :
def execute(self):
import shutil # for shutil.copy, os.rename works fine too
from os import basename
for file in self.fm.thistab.get_selection():
shutil.move(file, "/your/directory/" + basename(file))