由於側邊欄不在官方的API中,我不認爲這是可能的,或者至少這不容易。
但是,將信息轉化爲崇高的文字很容易。您可以使用視圖對其進行歸檔。只需執行ls
命令並將結果寫入視圖。
我寫了一個小(ST3)插件用於此目的:
import subprocess
import sublime
import sublime_plugin
# change to whatever command you want to execute
commands = ["ls", "-a", "-s", "-1", "-h"]
# the update interval
TIMEOUT = 2000 # ms
def watch_folder(view, watch_command):
"""create a closure to watch a folder and update the view content"""
window = view.window()
def watch():
# stop if the view is not longer open
open_views = [v.id() for v in window.views()]
if view.id() not in open_views:
print("closed")
return
# execute the command and read the output
output = subprocess.check_output(watch_command).decode()
# replace the view content with the output
view.set_read_only(False)
view.run_command("select_all")
view.run_command("insert", {"characters": output})
view.set_read_only(True)
# call this function again after the interval
sublime.set_timeout(watch, TIMEOUT)
return watch
class WatchFolderCommand(sublime_plugin.WindowCommand):
def run(self):
folders = self.window.folders()
if not folders:
sublime.error_message("You don't have opened any folders")
return
folder = folders[0] # get the first folder
watch_command = commands + [folder]
# create a view and set the desired properties
view = self.window.new_file()
view.set_name("Watch files")
view.set_scratch(True)
view.set_read_only(True)
view.settings().set("auto_indent", False)
# create and call the watch closure
watch_folder(view, watch_command)()
只要打開User
文件夾(或包中的任何其他子文件夾),創建一個Python文件(例如:watch_folder.py
)並粘貼源代碼。
可以通過粘貼它綁定到一個鍵綁定以下到您的鍵盤佈局
{
"keys": ["ctrl+alt+shift+w"],
"command": "watch_folder",
},
有了'SideBarEnhancements'有可能選擇一個文件時,在狀態欄中顯示_FILE_大小。但是我不知道顯示文件夾的大小。 – Karlek