diff --git a/CHANGELOG b/CHANGELOG index 84297d9..41307b4 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,7 +1,9 @@ # Offpunk History ## 1.1 - Unreleased +- Perfect rendering of pictures with chafa 1.8+ and compatible terminal - "cp cache" put the path of the cached content in clipboard +- "cp url X" will copy the URL of link X (suggested by Eoin Carney) - HTML renderering of
 has been improved
 - "fold" has been removed as it doesn’t work well anyway with our width.
 - Fixed crash when chafa is not installed (Thanks Xavier Hinault for the report)
diff --git a/offpunk.py b/offpunk.py
index 8a2cb10..ae84a1a 100755
--- a/offpunk.py
+++ b/offpunk.py
@@ -2589,15 +2589,21 @@ class GeminiClient(cmd.Cmd):
         else:
             print("Already online. Try offline.")
 
-    def do_copy(self, *args):
+    def do_copy(self, arg):
         """Copy the content of the last visited page as gemtext in the clipboard.
 Use with "url" as argument to only copy the adress.
 Use with "raw" to copy ANSI content as seen in your terminal (not gemtext).
 Use with "cache" to copy the path of the cached content."""
         if self.gi:
             if _HAS_XSEL:
+                args = arg.split()
                 if args and args[0] == "url":
-                    subprocess.call(("echo %s |xsel -b -i" % self.gi.url), shell=True)
+                    if len(args) > 1 and args[1].isdecimal():
+                        gi = self.index[int(args[1])-1]
+                        url = gi.url
+                    else:
+                        url = self.gi.url
+                    subprocess.call(("echo %s |xsel -b -i" % url), shell=True)
                 elif args and args[0] == "raw":
                     subprocess.call(("cat %s |xsel -b -i" % self.gi.get_temp_filename()), shell=True)
                 elif args and args[0] == "cache":