Home Download Buy Blog Forum Support

Add path to current file in status bar

Add path to current file in status bar

Postby willi297 on Wed Nov 18, 2009 8:32 pm

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.
Greg Williams
Atomic Embedded, USA
http://atomicembedded.com
willi297
 
Posts: 121
Joined: Wed Nov 18, 2009 8:29 pm
Location: Grand Rapids, MI, USA

Re: Add path to current file in status bar

Postby myel on Wed Nov 18, 2009 9:06 pm

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: Select all
import sublime, sublimeplugin

sublime.runCommand('CurrentPathStatus')

class CurrentPathStatusCommand(sublimeplugin.Plugin):
   def onActivated(self, view):
      view.setStatus('currentPath', view.fileName() )


(i don't know if thats the right way to do it, but it kinda works)
Attachments
CurrentPathStatus.zip
(271 Bytes) Downloaded 286 times
myel
 
Posts: 88
Joined: Sat Mar 22, 2008 11:26 pm

Re: Add path to current file in status bar

Postby willi297 on Mon Dec 14, 2009 4:12 pm

Sweet! Works great! Thanks myel!
Greg Williams
Atomic Embedded, USA
http://atomicembedded.com
willi297
 
Posts: 121
Joined: Wed Nov 18, 2009 8:29 pm
Location: Grand Rapids, MI, USA

Re: Add path to current file in status bar

Postby Binocular222 on Sat May 18, 2013 4:30 pm

Not work for me (I'm using ST3).
Any help?
Binocular222
 
Posts: 55
Joined: Sat May 18, 2013 4:10 pm

Re: Add path to current file in status bar

Postby skuroda on Sat May 18, 2013 6:35 pm

That was written for ST1. Try the following

Code: Select all
import sublime
import sublime_plugin

class CurrentPathStatusEvent(sublime_plugin.EventListener):
    def on_activated(self, view):
        view.set_status('currentPath', view.file_name())
skuroda
 
Posts: 676
Joined: Fri Oct 05, 2012 8:11 am

Re: Add path to current file in status bar

Postby Binocular222 on Sun May 19, 2013 1:17 am

It works!
Thanks
Binocular222
 
Posts: 55
Joined: Sat May 18, 2013 4:10 pm

Re: Add path to current file in status bar

Postby Binocular222 on Wed May 22, 2013 9:27 am

I modified it a bit to include "Read only" status:
Code: Select all
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)

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?
Binocular222
 
Posts: 55
Joined: Sat May 18, 2013 4:10 pm

Re: Add path to current file in status bar

Postby skuroda on Wed May 22, 2013 11:51 pm

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.
skuroda
 
Posts: 676
Joined: Fri Oct 05, 2012 8:11 am

Re: Add path to current file in status bar

Postby Binocular222 on Thu May 23, 2013 3:09 am

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
Binocular222
 
Posts: 55
Joined: Sat May 18, 2013 4:10 pm

Re: Add path to current file in status bar

Postby skuroda on Fri May 24, 2013 2:08 am

You wouldn't use the ST API to check the file permissions. Remember, plugins are just python. Quick google search pointed me to this. http://stackoverflow.com/questions/5337 ... ssion-mask
skuroda
 
Posts: 676
Joined: Fri Oct 05, 2012 8:11 am

Next

Return to Ideas and Feature Requests

Who is online

Users browsing this forum: No registered users and 8 guests