I never needed ranger's native move
command with being able to use the mv
command on the ranger command line, to move the selected file or directory to a given directory, e.g.:
shell -f mv %f /foo/bar
where %f
is the ranger macro for highlighted files, and %s
would be for all the selected.
The option -f
forks the operation so that the ranger session is not interrupted by a long file process.
You can summon the comand line with s, ! or @.
Another way, especially if you have many copies/moves to make, is to open another tab in ranger, with gn
and cd to the directory you want to copy/move the files to. Then return to the first tab to select files and use the ranger macro for the next tab %D
, to move files to, like,
shell -f mv %f %D
But that actually only saves you from hitting yy Tab dd Tab
. To be honest I usually switch tab and dd
.
I set up key-bindings in the rc.conf file like so,
#sync sel'd into dir on next tab
map ytt shell -f rsync -rult %s %D
#sync sel'd from dir on next tab
map yff shell -f rsync -rult %S %d
#sync sel'd into dir on next tab :incl referred files
map ytr shell -f rsync -ruLt %s %D
#sync sel'd from dir on next tab :incl referred files
map yfr shell -f rsync -ruLt %S %d
#move sel'd into dir on next tab
map dtt shell -f mv %s %D
#move sel'd from dir on next tab
map dff shell -f mv %S %d
Note that %S
is the macro for the selected files on the next tab.
%d
is the macro for the directory path of current tab.
And some others,
#copy sel'd into h'd dir
map pc shell -f rsync -rut %s %d/%f/
#move sel'd into h'd dir
map pm shell -f mv -u %s %d/%f
#copy buffer into h'd dir
map pds shell -f rsync -rult %c %d/%f/
#move buffer into h'd dir
map pdm shell -f mv -u %c %d/%f
#sync buffer'd files into curr dir :links only
map ps shell -f rsync -rult %c %d
Where %c
is the ranger macro for files held in the copy/cut buffer.
Files are easily added to the buffer with yy
, to yank, or ya
, to add to the copy buffer. Similarly, with dd
, to cut, or da
, to add to the cut buffer.
See my other key-mappings here
Best Answer
You don't need to edit the configuration for this. Just press r and then select your editor.
By default this will be
2 | ${VISUAL:-$EDITOR} -- "$@"
, so you'd just press 2 and then Enter (assuming that$VISUAL
or$EDITOR
are set to your preferred editor).See Krv Perera's answer if you'd like to change the default ("
0
") program inrifle.conf
.