我的机器上经常有同一个 Git 存储库的多个副本。我通常打开多个 Sublime Text 窗口,每个窗口都打开一个 Git 存储库副本的项目。
是否有任何设置可以在状态或标题栏上显示项目文件的路径,或者其他一些可以轻松区分其他相似项目的方式?事实上,我没有简单的方法来区分哪个 Sublime Text 窗口正在使用哪个项目文件。
Sublime 的标题栏会默认显示当前与窗口关联的项目的文件名部分;它是圆括号内当前选定文件名称右侧的文本。例如,这里我有OverrideAudit
当前打开的项目:
没有办法(当前)在标题栏中显示其他信息,但是使用一些插件代码可以在状态栏中显示文本。
[编辑]问题跟踪器上有一个开放的功能请求,可以添加配置标题栏的功能,您可能想要权衡。[/编辑]
这是一个插件示例,它复制了将项目名称从窗口标题放入状态栏的过程。如果需要,您可以修改show_project
仅隔离项目名称的代码,例如,如果需要包含路径。
要使用它,您可以Tools > Developer > New Plugin...
从菜单中选择并使用此代码替换默认存根,根据需要进行修改。
此代码也可在 GitHub 上找到。
import sublime
import sublime_plugin
import os
# Related Reading:
# https://forum.sublimetext.com/t/displaying-project-name-on-the-rite-side-of-the-status-bar/24721
# This just displays the filename portion of the current project file in the
# status bar, which is the same text that appears by default in the window
# caption.
def plugin_loaded ():
"""
Ensure that all views in all windows show the associated project at startup.
"""
# Show project in all views of all windows
for window in sublime.windows ():
for view in window.views ():
show_project (view)
def show_project(view):
"""
If a project file is in use, add the name of it to the start of the status
bar.
"""
if view.window() is None:
return
project_file = view.window ().project_file_name ()
if project_file is not None:
project_name = os.path.splitext (os.path.basename (project_file))[0]
view.set_status ("00ProjectName", "[" + project_name + "]")
class ProjectInStatusbar(sublime_plugin.EventListener):
"""
Display the name of the current project in the status bar.
"""
def on_new(self, view):
show_project (view)
def on_load(self, view):
show_project (view)
def on_clone(self, view):
show_project (view)
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句