Copy path to file (on right-click)


#1

Something I really miss from my old IDE is that you could right click on a file in the file tree, the drop down menu would appear, and you would see a keyword stating “Copy file reference”. This would copy the path to that file, and you could paste that path into another file for access to its contents.

  • Seth

#2

I was also looking for this feature and it’s apparently not yet (or not anymore) there. I would certainly like this.

Thanks in advance!


#3

Sure agree here man!


#4

Do they do any sort of upvoting on feature request. This would get my vote.


#5

I believe this is what this forum is for, you should see an option to upvote my request.


#6

Well, I clicked the heart which just said ‘like’ I didn’t see a specific button labeled upvote.


#7

Liking the post itself is sufficient for voting :thumbsup:


#8

I need it too :slight_smile:

for example like this :


#9

Is this a feature we could add by contributing to the C9 SDK?

I came here to request this exact feature. I want it all the time. I would also like this to be in the context-menu that appears when right clicking on an open file tab.


#10

sdk or init script can be used to implement this.

in init script it would look something like

var tree = services.tree;
var ui = services.ui;
var clipboard = services.clipboard;
tree.getElement("mnuCtxTree", function(mnuCtxTree) {
    ui.insertByIndex(mnuCtxTree, new ui.item({
        caption: "Copy file path",
        onclick: function() {
            var text = tree.selectedNodes.map(function(n) {
                return n.path;
            }).join("\n");
            clipboard.clipboardData.setData("text/plain", text);
        }
    }), 650, plugin);
});

var tabbehavior = services.tabbehavior;
var menus = services.menus;
tabbehavior.once("load", function() {
    menus.addItemByPath("Copy file path", new ui.item({
        onclick: function() {
            var text = tabbehavior.contextMenu.$tab.path;
            clipboard.clipboardData.setData("text/plain", text);
        }
    }), 800, tabbehavior.contextMenu, plugin);
});

#11

Nice, and with keyboard combination shortcut ? Is it available too ?


#12

https://github.com/c9/c9.ide.behaviors/commit/80127cb74aef35cfdd5499d00f74e90555e4f57e#diff-ec5ea27453d7d50256af39f79b37d588R186 adds a command which can be used with keyboard


#13

Thank you! Any idea when it will be released? I don’t see it yet.


#14

@justincy just saw this oldy but goody and noticed we never followed up on this (better late than never :grin:). This is now in place:

It’s also available to assign a keybinding to. This command is titled copyFilePath.