Sublime Forum

File features badly needed: refresh files from SAMBA share

#1

Hi all,

I badly need the following features. Hopefully not complicated to implement:

  1. The upper file tab needs to have a “copy folder path” command added to its right-click menu. Very important if I want to copy the file name to an external tool. Would be nice to also have a “open containing folder …” similar with the one on file tree on the left.
  2. The right-click for the left directory tree needs to have a “Refresh” command. Sometimes I open files from SMB network shares and these do not get updated when the SMB directory contents is changing. Currently I need to close and reopen Sublime Text to refresh the folder/file list as a workaround, but it’s inconvenient.

Thanks!

0 Likes

#2

Replication path: ctrl+shift+c

This plugin has more features you want, Include copy folder path, and refresh.
https://packagecontrol.io/packages/SideBarEnhancements

Make a quick script yourself.

0 Likes

#3

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.

0 Likes

Reveal in Sidebar, Copy File Path misplaced
#4

Thanks.

The “Refresh Folders” doesn’t seem to work when folders are added from a remote SAMBA share. Contents are not updated even if I clearly added some files over there.

  • Sublime Text version: 3.0 (registered) build 3143
  • Client machine running Windows 10 version 1703, build 15063.608
  • File server machine holding the files: Ubuntu 16.04.3 LTS
  • Samba version 4.3.11-Ubuntu
0 Likes

#5

(renamed thread title as the copy file path was addressed above = thanks!)

0 Likes