Make 'copy names to clipboard' more versatile and more prominent (like in Total Commander)

961 views
Skip to first unread message

CrucialKrusader

unread,
Oct 11, 2016, 8:20:39 AM10/11/16
to krusader-users


In File Managers like Total Commander for Windows, some of the most important use cases for me is 'copy names to clipboard' and its variants:




When you choose the menu item shown on this screenshot, the following information is copied into the clipboard (consider that these are (1) multiple items and (2) files and folders):

f:\cygwin64\etc\apache2\conf.d\
f:\cygwin64\etc\apache2\extra\
f:\cygwin64\etc\apache2\original\
f:\cygwin64\etc\apache2\magic
f:\cygwin64\etc\apache2\httpd.conf
f:\cygwin64\etc\apache2\mime.types


In the current version of Krusader, these important use cases seem to be neglected.

What I could find out so far is that there's a sample User Action named "filename_to_clipboard" contained in
~/.kde/share/apps/krusader/useractions.xml and available either via Menu (User Actions > Samples) or via shortcut (Ctrl+Alt+C).

<action name="filename_to_clipboard">
 <title>&amp;Copy current item to clipboard</title>
 <tooltip>Copy current item to clipboard</tooltip>
 <icon>editpaste</icon>
 <category>Samples</category>
 <command>%_Clipboard("%aCurrent%")%</command>
 <defaultshortcut>Ctrl+Alt+C</defaultshortcut>
</action>

But this (slightly hidden) User Action seems to work only with single files or folders.

Besides, the desciption "Copy current item to clipboard" is mistakable: Will the files/folder be copied into the clipboard or just the name?

I would like to ask for a hint and to make a suggestion. :)

1.) Question: Is there a way to make a User Action behave like Total Commander's Use Cases 'Copy Selected Names To Clipboard' and 'Copy Names With Path To Clipboard', i.e. to copy the names of one or multiple files or folders into the clipboard (either with path or without)?

2.) Suggestion: Please add to the default Krusader distribution more versatile versions of these these Use Cases and make them more prominent by rising them up to default menu entries.

Thanks and keep up the good work!
Johannes

A. Bikadorov

unread,
Oct 11, 2016, 9:08:22 AM10/11/16
to krusade...@googlegroups.com

Create a new user action with this command:

%_Clipboard("%aList("Selected", " ", "", "")%")%

However, the delimiter is a space here, I don't think newlines are supported. You can find
more information in the handbook and play with the parameters.

Cheers
Alex


On 11.10.2016 14:20, CrucialKrusader wrote:
>
> In File Managers like Total Commander for Windows, some of the most important use cases
> for me is 'copy names to clipboard' and its variants:
>
>
> <https://lh3.googleusercontent.com/-JK4YXlf1--k/V_zTzmsGd3I/AAAAAAAAUCY/pmqL1mdPCuoZdxTyZG76xjKfpR6yZ9ITgCLcB/s1600/TotalCommander_CopyToClipboard_UseCases.jpg>

Steven P. Ulrick

unread,
Oct 11, 2016, 9:57:54 AM10/11/16
to krusade...@googlegroups.com
Hello, Johannes
Unless I misread your message, I thought that Krusader already did what
you ask, without any "Useractions"

As an experiment, I went to a directory that contains Krusader's source
code, and I did the following:
1. Selected all the directories and files.
2. Right click and select "Copy to Clipboard" from the context menu.
3. Paste the results directly into this email. See below...

file:///home/steve/CVS/Assorted-CVS-Modules/k/krusader/build
file:///home/steve/CVS/Assorted-CVS-Modules/k/krusader/doc
file:///home/steve/CVS/Assorted-CVS-Modules/k/krusader/doc-extras
file:///home/steve/CVS/Assorted-CVS-Modules/k/krusader/iso
file:///home/steve/CVS/Assorted-CVS-Modules/k/krusader/krArc
file:///home/steve/CVS/Assorted-CVS-Modules/k/krusader/krusader
file:///home/steve/CVS/Assorted-CVS-Modules/k/krusader/pics
file:///home/steve/CVS/Assorted-CVS-Modules/k/krusader/AUTHORS
file:///home/steve/CVS/Assorted-CVS-Modules/k/krusader/ChangeLog
file:///home/steve/CVS/Assorted-CVS-Modules/k/krusader/CMakeLists.txt
file:///home/steve/CVS/Assorted-CVS-Modules/k/krusader/COPYING
file:///home/steve/CVS/Assorted-CVS-Modules/k/krusader/createdist.sh
file:///home/steve/CVS/Assorted-CVS-Modules/k/krusader/CREDITS
file:///home/steve/CVS/Assorted-CVS-Modules/k/krusader/FAQ
file:///home/steve/CVS/Assorted-CVS-Modules/k/krusader/INSTALL
file:///home/steve/CVS/Assorted-CVS-Modules/k/krusader/Krusader.kdevelop
file:///home/steve/CVS/Assorted-CVS-Modules/k/krusader/krusader.lsm
file:///home/steve/CVS/Assorted-CVS-Modules/k/krusader/Messages.sh
file:///home/steve/CVS/Assorted-CVS-Modules/k/krusader/porting_todo.txt
file:///home/steve/CVS/Assorted-CVS-Modules/k/krusader/README
file:///home/steve/CVS/Assorted-CVS-Modules/k/krusader/SVNNEWS
file:///home/steve/CVS/Assorted-CVS-Modules/k/krusader/TODO

This is with Krusader version "2.5.0-beta "Clear Skies""

Now, is the menu option "Copy to Clipboard" as clear as the option in
Total Commander? My opinion is that it is not...

I just tried changing
"addAction(i18n("Copy to Clipboard"))->setData(QVariant(COPY_CLIP_ID));"

to

"addAction(i18n("Copy Names With Path To
Clipboard"))->setData(QVariant(COPY_CLIP_ID));"

in the source code file "krusader/krusader/Panel/krpopupmenu.cpp"

I then recompiled and installed Krusader. The result was the menu
option now reads "Copy Names With Path To Clipboard"

I am NOT a developer or programmer, but if you are able to compile
Krusader from source, I can help you do what I did.


I put a screenshot here:
<http://www.afolkey2.us/gallery3/index.php/Assorted/Krusader-CopyNamesWithPathToClipboard>

to show you the results.

Keep in mind that this does not involve "Useractions"

If I totally misunderstood your request, I do apologize.

Steven P. Ulrick

On 10/11/2016 07:20 AM, CrucialKrusader wrote:
>
> In File Managers like Total Commander for Windows, some of the most
> important use cases for me is 'copy names to clipboard' and its variants:
>
>
> <https://lh3.googleusercontent.com/-JK4YXlf1--k/V_zTzmsGd3I/AAAAAAAAUCY/pmqL1mdPCuoZdxTyZG76xjKfpR6yZ9ITgCLcB/s1600/TotalCommander_CopyToClipboard_UseCases.jpg>
> --
> You received this message because you are subscribed to the Google
> Groups "krusader-users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to krusader-user...@googlegroups.com
> <mailto:krusader-user...@googlegroups.com>.
> To post to this group, send email to krusade...@googlegroups.com
> <mailto:krusade...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/krusader-users/99cfce1e-8ff6-4c50-8ce8-c2ffbfc84574%40googlegroups.com
> <https://groups.google.com/d/msgid/krusader-users/99cfce1e-8ff6-4c50-8ce8-c2ffbfc84574%40googlegroups.com?utm_medium=email&utm_source=footer>.
> For more options, visit https://groups.google.com/d/optout.

CrucialKrusader

unread,
Oct 11, 2016, 3:21:12 PM10/11/16
to krusader-users, alex.bi...@kdemail.net
For quite a while now I've played around with the User Action commands, but did not get it to work.

There is a posting of 2006 in the Krusader forum about How to introduce a new line as separator in %aList?

Based on that I experimented with constructs like

%_Clipboard($(echo -e "%aList("Selected", "\n", "", "")%"))%

but I didn't manage to get the expansion precedence of the Krusader placeholders and the Linux $(...) construct in the right order. That is totally conform with what is explained here:

"There is one more important thing to know: All placeholders that interact with Krusader internal functions are called at expand time (meaning directly when the placeholders are replaced). External programs are called at execution time (meaning after all placeholders are replaced)."


Does anyone have an idea on how to use a new line as separator in %aList and(!) copy the result into the clipboard afterwards?

If not, I'd propose to create the possibility of using escape-sequences (like \n for 'new line') within placeholders to make things easier :)

Thanks
Johannes


Am Dienstag, 11. Oktober 2016 15:08:22 UTC+2 schrieb A. Bikadorov:


    Create a new user action with this command:

    %_Clipboard("%aList("Selected", " ", "", "")%")%

    However, the delimiter is a space here, I don't think newlines are supported. You can find
    more information in the handbook and play with the parameters.



    On 11.10.2016 14:20, CrucialKrusader wrote:
    ...

    > 1.) Question: Is there a way to make a User Action behave like Total Commander's Use Cases
    > 'Copy Selected Names To Clipboard' and 'Copy Names With Path To Clipboard', i.e. to copy
    > the names of one or multiple files or folders into the clipboard (either with path or
    > without)?
    >
    ...

CrucialKrusader

unread,
Oct 11, 2016, 3:23:08 PM10/11/16
to krusader-users
Hi Steven,

what you are proposing is to copy files (not names) into the clipboard and then pasting them into a text editor (field). It's the window manager that transforms the files into their names while pasting, as some kind of fallback.

And it's not exactly the needed result, because what is needed are fully qualified file paths corresponding to the file system, not URLs, e.g.

  /home/steve/CVS/Assorted-CVS-Modules/k/krusader/build

instead of

  file:///home/steve/CVS/Assorted-CVS-Modules/k/krusader/build

What you are doing in the next step is to rename a correctly named menu option into something misleading (because it won't be only names that will be copied into the clipboard).

Nevertheless, changing and compiling the Krusader sourcecode myself is an interesting option that I did not have in mind before. Maybe I'll try this just as an experiment. Thanks for that!

Regards
Johannes



Am Dienstag, 11. Oktober 2016 15:57:54 UTC+2 schrieb StevenPUlrick:

    Hello, Johannes
    Unless I misread your message, I thought that Krusader already did what
    you ask, without any "Useractions"

    As an experiment, I went to a directory that contains Krusader's source
    code, and I did the following:
    1. Selected all the directories and files.
    2. Right click and select "Copy to Clipboard" from the context menu.
    3. Paste the results directly into this email.  See below...

    file:///home/steve/CVS/Assorted-CVS-Modules/k/krusader/build
    ...


    Now, is the menu option "Copy to Clipboard" as clear as the option in
    Total Commander?  My opinion is that it is not...

    I just tried changing
    "addAction(i18n("Copy to Clipboard"))->setData(QVariant(COPY_CLIP_ID));"

    to

    "addAction(i18n("Copy Names With Path To
    Clipboard"))->setData(QVariant(COPY_CLIP_ID));"

    in the source code file "krusader/krusader/Panel/krpopupmenu.cpp"

    I then recompiled and installed Krusader...
    ...


    Steven P. Ulrick

    On 10/11/2016 07:20 AM, CrucialKrusader wrote:
    >
    > In File Managers like Total Commander for Windows, some of the most
    > important use cases for me is 'copy names to clipboard' and its variants

    ...
    > Johannes

Victoria Stuart

unread,
Nov 24, 2016, 7:07:46 PM11/24/16
to krusader-users
Krusader has changed! :-/

On a recent Arch Linux system update (1 month or so ago; ~Oct. 2016), Krusader was replaced with a totally brand-new install: my current version is Krusader v.2.5.0.

Among the changes -- now missing -- was the ability to simply right-click a selection of files and directly paste those paths into a text editor: Geany or equivalent.

Per the responses here, I managed to create a satisfactory User Action (Krusader >> Settings menu >> Configure Krusader ...):

%_Clipboard("%aList("Selected", "``", "", "", "No")%")%

Then, after I paste the paths into Geany, I do a regex-based find/replace on that seperator ( ` : backtick), equivalent to

s'/`/\n/'

Note that "No" disables \-escaping of whitespace in the paths (my preference): see documentation, here:

https://krusader.org/documentation/useractions.html

Here is the iterative approach leading to my solution -- "Copy selected files to clipboard" :


%_Clipboard("%aList("Selected", " ", "", "")%")%

%_Clipboard("%aList("Selected", " || ")%")%

%_Clipboard("%aCurrent("", "No")%")%

%_Clipboard("%aList("Selected", " || ", "", "", "No")%")%

%_Clipboard("%aList("Selected", "``", "", "", "No")%")%

Chosen solution:
------------------------

%_Clipboard("%aList("Selected", "`", "", "", "No")%")%

Implementation:
-----------------------

%_Clipboard("%aList("Selected", "`", "", "", "No")%")%

Example:
-------------

/mnt/Vancouver/byzanz capture 2016-11-24 (09:27:22).gif`/mnt/Vancouver/byzanz capture 2016-11-24 (09:26:20).gif`/mnt/Vancouver/_Victoria - installation.txt

Geany >> regex on selection >> 's/`/\n/'      ## note: separator is a backtick ( ` ):

/mnt/Vancouver/byzanz capture 2016-11-24 (09:27:22).gif
/mnt/Vancouver/byzanz capture 2016-11-24 (09:26:20).gif
/mnt/Vancouver/_Victoria - installation.txt

My rationale for using a backtick as a separator is that it is rarely-used, and I don't need to escape it in a regex expression.  ;-)

Victoria Stuart

unread,
Nov 24, 2016, 7:21:50 PM11/24/16
to krusader-users
oops: ignore misspelling seperator [sic] >> separator

CrucialKrusader

unread,
Nov 25, 2016, 2:48:32 AM11/25/16
to krusader-users
Thank you for sharing this.

However, this approach also is a quite circumstantial two-step approach. In the first step, you use the limited power of %aList. And in the second step, you fix this insufficiency by using a text editor (e.g. Geany).

I therefore want to repeat the proposal that has been made 10 years ago already in the old Krusader forum: Please introduce a new line as separator in %aList !

That shouldn't be too complicated.

By the way: What happened to the old Krusader forum? In September 2016 it still was online, read-only:

http://forum.krusader.org/index.php - "Forum has been closed due to ongoing spam issues. It is kept search- and read-able as a reference. Registrations and logins are disabled. Please use the mailing lists instead."

Now the forum is completely offline. If it should be online again in the future, you can read the proposal "How to introduce a new line as separator in %aList?" from 2006 in this thread. ( http://forum.krusader.org/viewtopic.php?p=7308 )

Am Freitag, 25. November 2016 01:07:46 UTC+1 schrieb Victoria Stuart:
...

Example:
-------------

/mnt/Vancouver/byzanz capture 2016-11-24 (09:27:22).gif`/mnt/Vancouver/byzanz capture 2016-11-24 (09:26:20).gif`/mnt/Vancouver/_Victoria - installation.txt

Geany >> regex on selection >> 's/`/\n/'      ## note: separator is a backtick ( ` ):

/mnt/Vancouver/byzanz capture 2016-11-24 (09:27:22).gif
/mnt/Vancouver/byzanz capture 2016-11-24 (09:26:20).gif
/mnt/Vancouver/_Victoria - installation.txt

...

A. Bikadorov

unread,
Nov 25, 2016, 1:34:37 PM11/25/16
to krusade...@googlegroups.com
On 25.11.2016 08:48, CrucialKrusader wrote:
> I therefore want to repeat the proposal that has been made 10 years ago already in the old
> Krusader forum: *Please introduce a new line as separator in %aList* !

Please create new bug report.

> By the way: What happened to the old Krusader forum? In September 2016 it still was
> online, read-only:

The website was moved from privately operated (by the old authors of Krusader) to the KDE
organization but without the forum.
Migrating the 10+ years old forum with all its dependencies was a bit out of scope. We
could ask the former devs. to make it available again but they have to run a domain and
server.
And instead the KDE forum can be used: https://forum.kde.org/viewforum.php?f=225

Cheers
Alex

CrucialKrusader

unread,
Nov 26, 2016, 5:00:42 AM11/26/16
to krusader-users, alex.bi...@kdemail.net
Although it seems more like a feature request than a bug, I followed your proposal and created a ticket in the Krusader Bugtracking System.

( https://bugs.kde.org/show_bug.cgi?id=372944 )

Thanks for the hint, Alex.

CrucialKrusader

unread,
Nov 27, 2016, 5:46:35 AM11/27/16
to krusader-users, alex.bi...@kdemail.net
That bugfix was quick! Thanks, Alex!

BTW: Don't you write Unit Tests? ;)

> https://bugs.kde.org/show_bug.cgi?id=372944#c1
> Modified: 2016-11-26 18:31 UTC
> Status: RESOLVED FIXED

Piotr Dobrogost

unread,
May 2, 2017, 9:22:57 AM5/2/17
to krusader-users
It's good that the versatile part of the request was taken care of but what about the second part; making this feature more prominent?
I think this feature should really be placed in the "File" menu making it much easier to find.
I don't remember for sure but I think I saw it there in the past...
Reply all
Reply to author
Forward
0 new messages