Last active
July 3, 2018 09:57
-
-
Save rvause/fcad733670a42debb7c4 to your computer and use it in GitHub Desktop.
Put current file path in status bar relative to project directory
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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