Sublime Forum

Add path to current file in status bar

#1

I LOVE using the full-screen view, but then I have no feedback as to the path of the current file. I would suggest that it be added to the status bar at the bottom. Current path would also be nice as well, but not as necessary.

0 Likes

#2

hi,

that is possible via the api.

unzip and put the attached file into your …\Application Data\Sublime Text\Packages\Default folder and restart sublime.

[code]import sublime, sublimeplugin

sublime.runCommand(‘CurrentPathStatus’)

class CurrentPathStatusCommand(sublimeplugin.Plugin):
def onActivated(self, view):
view.setStatus(‘currentPath’, view.fileName() )
[/code]

(i don’t know if thats the right way to do it, but it kinda works)
CurrentPathStatus.zip (271 Bytes)

0 Likes

#3

Sweet! Works great! Thanks myel!

0 Likes

#4

Not work for me (I’m using ST3).
Any help?

0 Likes

#5

That was written for ST1. Try the following

[code]import sublime
import sublime_plugin

class CurrentPathStatusEvent(sublime_plugin.EventListener):
def on_activated(self, view):
view.set_status(‘currentPath’, view.file_name())[/code]

0 Likes

#6

It works!
Thanks

0 Likes

#7

I modified it a bit to include “Read only” status:

[code]import sublime_plugin

class StatusBar(sublime_plugin.EventListener):
def on_activated_async(self, view):
if view.is_read_only():
Status = “ReadOnly”
else:
Status = “Full”
view.set_status(‘encoding’, view.encoding())
view.set_status(‘currentPath’, view.file_name())
view.set_status(‘lineending’, view.line_endings())
view.set_status(‘readonly’, Status)[/code]
However, view.is_read_only() always return true even when I open a Read-only file.
Is this a bug or is there something wrong in my code?

0 Likes

#8

Do you define it as read only within the editor or is it defined as read only on the file system? If it’s the latter, ST doesn’t automatically apply the read only setting. You may want to use the “on_load(view)” method to check the permissions of the file, then set read_only to true if necessary.

0 Likes

#9

I set read-only status by system (latter case).
I read the View Class in API reference http://www.sublimetext.com/docs/3/api_reference.html but still don’t know how to get file attribute.
Sorry that I’m totally new to ST

0 Likes

#10

You wouldn’t use the ST API to check the file permissions. Remember, plugins are just python. Quick google search pointed me to this. stackoverflow.com/questions/5337 … ssion-mask

0 Likes

#11

Could it be possible to add this as a plugin and add it to the package repository?

I would really like to see this as a package there. :smile:

0 Likes

#12

I prefer working in full screen and shift desktop views, but I also miss the file path since it is only displayed in the title bar. I use ST3 on Linux.

I don’t have a Packages/Default directory, so I tried putting the snippet which was posted by skuroda.

I placed it in ./config/sublime-text-3/Packages/User, but I don’t see anything. I tried plaving it in Packages as well, but no result. Does anyone know how to get this working in ST3 on Linux?

0 Likes

#13

I found a solution that works for me: github.com/shyam-habarakada/sub … namestatus

0 Likes