summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--ranger/config/rc.conf3
-rw-r--r--ranger/core/actions.py11
-rw-r--r--ranger/core/loader.py6
3 files changed, 14 insertions, 6 deletions
diff --git a/ranger/config/rc.conf b/ranger/config/rc.conf
index 98a059d4..4a182f69 100644
--- a/ranger/config/rc.conf
+++ b/ranger/config/rc.conf
@@ -476,6 +476,9 @@ map pl paste_symlink relative=False
 map pL paste_symlink relative=True
 map phl paste_hardlink
 map pht paste_hardlinked_subtree
+map pd console paste dest=
+map p`<any> paste dest=%any_path
+map p'<any> paste dest=%any_path
 
 map dD console delete
 
diff --git a/ranger/core/actions.py b/ranger/core/actions.py
index ddb98d9b..3868d102 100644
--- a/ranger/core/actions.py
+++ b/ranger/core/actions.py
@@ -1559,12 +1559,17 @@ class Actions(  # pylint: disable=too-many-instance-attributes,too-many-public-m
                 link(source_path,
                      next_available_filename(target_path))
 
-    def paste(self, overwrite=False, append=False):
+    def paste(self, overwrite=False, append=False, dest=None):
         """:paste
 
-        Paste the selected items into the current directory.
+        Paste the selected items into the current directory or to dest
+        if provided.
         """
-        loadable = CopyLoader(self.copy_buffer, self.do_cut, overwrite)
+        if dest is not None:
+            if not exists(dest) and not isdir(dest):
+                self.notify('Failed to paste. The given path is invalid.', bad=True)
+                return
+        loadable = CopyLoader(self.copy_buffer, self.do_cut, overwrite, dest=dest)
         self.loader.add(loadable, append=append)
         self.do_cut = False
 
diff --git a/ranger/core/loader.py b/ranger/core/loader.py
index 9f32535f..96d000ac 100644
--- a/ranger/core/loader.py
+++ b/ranger/core/loader.py
@@ -51,11 +51,11 @@ class Loadable(object):
 class CopyLoader(Loadable, FileManagerAware):  # pylint: disable=too-many-instance-attributes
     progressbar_supported = True
 
-    def __init__(self, copy_buffer, do_cut=False, overwrite=False):
+    def __init__(self, copy_buffer, do_cut=False, overwrite=False, dest=None):
         self.copy_buffer = tuple(copy_buffer)
         self.do_cut = do_cut
         self.original_copy_buffer = copy_buffer
-        self.original_path = self.fm.thistab.path
+        self.original_path = dest if dest is not None else self.fm.thistab.path
         self.overwrite = overwrite
         self.percent = 0
         if self.copy_buffer:
@@ -102,7 +102,7 @@ class CopyLoader(Loadable, FileManagerAware):  # pylint: disable=too-many-instan
                         tag = self.fm.tags.tags[path]
                         self.fm.tags.remove(path)
                         self.fm.tags.tags[
-                            path.replace(fobj.path, self.original_path + '/' + fobj.basename)
+                            path.replace(fobj.path, path.join(self.original_path, fobj.basename))
                         ] = tag
                         self.fm.tags.dump()
                 n = 0