This functionality is already available from the context menu of the edit view itself, just not from its tab. If you want to add that functionality, you can do so by creating the following named files in your User
package (use Preferences > Browse Packages...
if you don’t know where that is):
Tab Context.sublime-menu
[
{ "command": "open_dir_tab", "caption": "Open Containing Folder…", "args": {"group": -1, "index": -1} },
{ "command": "copy_path_tab", "caption": "Copy File Path", "args": {"group": -1, "index": -1} },
]
custom_tab_commands.py
import sublime
import sublime_plugin
import os
def view_target(view, group=-1, index=-1):
window = view.window()
return view if group == -1 else window.views_in_group(group)[index]
class CopyPathTabCommand(sublime_plugin.TextCommand):
def run(self, edit, group, index):
target = view_target(self.view, group, index)
sublime.set_clipboard(target.file_name())
sublime.status_message("Copied file path")
def is_enabled(self, group, index):
target = view_target(self.view, group, index)
return target.file_name() is not None
class OpenDirTabCommand(sublime_plugin.TextCommand):
def run(self, edit, group, index):
target = view_target(self.view, group, index)
path, file = os.path.split(target.file_name())
target.window().run_command("open_dir", {"dir": path, "file": file})
def is_enabled(self, group, index):
target = view_target(self.view, group, index)
return target.file_name() is not None
I believe that this is already a menu item under the project menu, as Project > Refresh Folders
, although I don’t need to use that command so I’m not 100% sure that it does what you want. Assuming that it is, you can use it from there, but if desired you can also create the following file (also in your User
package as above):
Side Bar.sublime-menu
[
{ "caption": "-", "id": "folder_commands" },
{ "caption": "Refresh Folders", "command": "refresh_folder_list" },
]
This will put the command as it exists in the Project
menu into the context menu on all of the sidebar items. If desired you can use the filename Side Bar Mount Point.sublime-menu
instead, in which case the menu will only appear on the context menu for folders.
I haven’t done that here because as far as I’m aware the command refreshes all folders and not just a particular folder, so it may fool you into thinking that it’s only refreshing the selected folder if it only appears on mount points.