Sublime Forum

File Name and Full Path to Clipboard

#1

I’m often in need of either the full path+filename or just the filename for copy/pasting. I see that full path is available via right click in the document body. I’d love to see both of these options added to the file name in the Side Bar, file name in the tabs AND in the body (or at least one of the three).

Brilliant app btw…

1 Like

#2

It is available when you right click inside the view as “Copy File Path”

2 Likes

#3

As I said, full path is available; I want full path AND just the filename as I use both often. It would be nice if they were both available via right click anywhere the name of the file is. Eg. in the sidebar and on the tab when the file is open.

Thanks.
Brian

1 Like

#4

Why not make it yourself? Sounds simple enough. Just create a small plugin the copies the filename to the clipboard and add it to the context menu.

  • set_clipboard(string)
  • file_name() #returns full path, just parse to get the filename
  • Create a file named: Context.sublime-menu to add an option the the context menu

sublimetext.com/docs/2/api_reference.html

1 Like

#5

COOL, what i am locking for, thanks.

sublimetext.com/docs/menus

1 Like

#6

SideBarEnhancements package already add the menus to the sidebar. And now these are available via: Tools -> Commands Palette or via the shortcut which is faster.

1 Like

#7

If you still want these in some menu, with that package installed, you can copy the file

“…/Packages/SideBarEnhancements/Commands.sublime-commands”

to

“…/Packages/User/Context.sublime-menu”
“…/Packages/User/Tab Context.sublime-menu”

and customize the entries ( deleting these you don’t use).
( notice these files ends with “sublime-menu” instead of “sublime-commands”

1 Like

#8

Thanks Tito… that did the trick.

[size=150]Solution:[/size]
First install SideBarEnhancements

Then copy:
“…/Packages/SideBarEnhancements/Commands.sublime-commands”
to
“…/Packages/User/Context.sublime-menu”
“…/Packages/User/Tab Context.sublime-menu”

1 Like

#9

Just made a plugin command for this in case it helps anyone else.

{ "keys": "ctrl+alt+c"], "command": "filename_to_clipboard" }, { "keys": "ctrl+alt+shift+c"], "command": "path_to_clipboard" },

[code]import sublime, sublime_plugin, os

class FilenameToClipboardCommand(sublime_plugin.TextCommand):
def run(self, edit):
sublime.set_clipboard(os.path.basename(self.view.file_name()))

class PathToClipboardCommand(sublime_plugin.TextCommand):
def run(self, edit):
sublime.set_clipboard(self.view.file_name())
[/code]

2 Likes

#10

[quote=“robertcollier4”]Just made a plugin command for this in case it helps anyone else.

{ "keys": "ctrl+alt+c"], "command": "filename_to_clipboard" }, { "keys": "ctrl+alt+shift+c"], "command": "path_to_clipboard" },

[code]import sublime, sublime_plugin, os

class FilenameToClipboardCommand(sublime_plugin.TextCommand):
def run(self, edit):
sublime.set_clipboard(os.path.basename(self.view.file_name()))

class PathToClipboardCommand(sublime_plugin.TextCommand):
def run(self, edit):
sublime.set_clipboard(self.view.file_name())
[/code][/quote]

just found this http://superuser.com/questions/636057/how-to-set-shortcut-for-copy-file-path-in-sublime-text-3/636175#636175, the code for copy file path is “copy_path”

1 Like

#11

The copy-file-name plugin does the job very nicely, as long as you install it “properly”, as described in this issue: github.com/nwjlyons/copy-file-name/issues/3

1 Like

#12

On Right Click on the file not on the title of file.

you will get pop up like this

2 Likes