Skip to content

Instantly share code, notes, and snippets.

@rvause
Last active July 3, 2018 09:57
Show Gist options
  • Select an option

  • Save rvause/fcad733670a42debb7c4 to your computer and use it in GitHub Desktop.

Select an option

Save rvause/fcad733670a42debb7c4 to your computer and use it in GitHub Desktop.
Put current file path in status bar relative to project directory
import os.path as op
import sublime_plugin
class CurrentFile(sublime_plugin.EventListener):
def on_activated_async(self, view):
encoding = view.encoding()
if encoding == 'Undefined':
encoding = ''
file_path = view.file_name()
window = view.window()
project_path = op.dirname(op.abspath(window.project_file_name()))
if project_path and file_path:
for folder in window.project_data()['folders']:
project_part = op.join(project_path, folder['path'])
if project_part in file_path:
file_path = file_path.replace(project_part, '').strip('/')
if not file_path:
file_path = ''
view.set_status('currentPath', file_path)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment