|
7 | 7 | """
|
8 | 8 |
|
9 | 9 | import os
|
10 |
| -from typing import List |
| 10 | +from typing import List, Iterable |
11 | 11 |
|
12 | 12 | from vimiv.qt.core import QDateTime
|
13 | 13 | from vimiv.qt.gui import QGuiApplication, QClipboard
|
@@ -64,25 +64,33 @@ def toggle(mode: str) -> None:
|
64 | 64 | api.modes.get_by_name(mode).toggle()
|
65 | 65 |
|
66 | 66 |
|
67 |
| -@api.keybindings.register("yA", "copy-name --abspath --primary") |
68 |
| -@api.keybindings.register("yY", "copy-name --primary") |
69 |
| -@api.keybindings.register("ya", "copy-name --abspath") |
70 |
| -@api.keybindings.register("yy", "copy-name") |
| 67 | +@api.keybindings.register("yA", "copy-name % --abspath --primary") |
| 68 | +@api.keybindings.register("yY", "copy-name % --primary") |
| 69 | +@api.keybindings.register("ya", "copy-name % --abspath") |
| 70 | +@api.keybindings.register("yy", "copy-name %") |
| 71 | +@api.keybindings.register("ymA", "copy-name %m --abspath --primary") |
| 72 | +@api.keybindings.register("ymY", "copy-name %m --primary") |
| 73 | +@api.keybindings.register("yma", "copy-name %m --abspath") |
| 74 | +@api.keybindings.register("ymy", "copy-name %m") |
71 | 75 | @api.commands.register()
|
72 |
| -def copy_name(abspath: bool = False, primary: bool = False) -> None: |
73 |
| - """Copy name of current path to system clipboard. |
| 76 | +def copy_name( |
| 77 | + paths: Iterable[str], abspath: bool = False, primary: bool = False |
| 78 | +) -> None: |
| 79 | + """Copy file name or full path of provided paths(s) to system clipboard. |
| 80 | +
|
| 81 | + **syntax:** ``:copy-name path [path ...] [--abspath] [--primary]`` |
74 | 82 |
|
75 |
| - **syntax:** ``:copy-name [--abspath] [--primary]`` |
| 83 | + positional arguments: |
| 84 | + * ``paths``: The path(s) to copy. |
76 | 85 |
|
77 | 86 | optional arguments:
|
78 | 87 | * ``--abspath``: Copy absolute path instead of basename.
|
79 | 88 | * ``--primary``: Copy to primary selection.
|
80 | 89 | """
|
81 | 90 | clipboard = QGuiApplication.clipboard()
|
82 | 91 | mode = QClipboard.Mode.Selection if primary else QClipboard.Mode.Clipboard
|
83 |
| - path = api.current_path() |
84 |
| - name = path if abspath else os.path.basename(path) |
85 |
| - clipboard.setText(name, mode=mode) |
| 92 | + text = " ".join(path if abspath else os.path.basename(path) for path in paths) |
| 93 | + clipboard.setText(text, mode=mode) |
86 | 94 |
|
87 | 95 |
|
88 | 96 | @api.keybindings.register("yi", "copy-image")
|
|
0 commit comments