Home Download Buy Blog Forum Support

Relative Path in Title Bar

Relative Path in Title Bar

Postby hyphenistic on Sun Nov 25, 2012 6:31 pm

Is it possible to show the relative path to a file in the title bar? Showing only the file name can be confusing when working with similarly named files in different folders and showing the full path seems to be a waste of when I only care about the end.
hyphenistic
 
Posts: 3
Joined: Thu Oct 04, 2012 3:58 pm

Re: Relative Path in Title Bar

Postby skuroda on Mon Nov 26, 2012 12:03 am

As far as I know this isn't possible. One issue with attempting to implement something like this (that I could think of) is relative to what? Though not in the title bar, a plugin to display some subsection of the path in the status bar is doable. Maybe that would suffice for what you need?
skuroda
 
Posts: 676
Joined: Fri Oct 05, 2012 8:11 am

Re: Relative Path in Title Bar

Postby hyphenistic on Tue Nov 27, 2012 12:32 pm

It could be relative to the folder that has been added to the project.
hyphenistic
 
Posts: 3
Joined: Thu Oct 04, 2012 3:58 pm

Re: Relative Path in Title Bar

Postby robertcoaster on Tue Nov 27, 2012 3:18 pm

skuroda wrote:As far as I know this isn't possible. One issue with attempting to implement something like this (that I could think of) is relative to what? Though not in the title bar, a plugin to display some subsection of the path in the status bar is doable. Maybe that would suffice for what you need?


It ain't impossible. I've had "Subethaedit + Transmit" working this way.
I'm searching for this aswell... There is a possibility to "activate" the path but what you get is something like this;
"~/Library/Caches/Cleanup At Startup/Transmit/BAE7A76C-116F-644F-8487-7B381FB6FFCF/file.php"

While in the previous situation (Subethaedit + Transmit) it was something like this;
"ftp://domain-name.com:21//domains/domain-name.com/public_html/path/file.php"

I hope a developer reads this, because this extra feature will be so helpful. I've had a few encounters where i accidentally edited the wrong website :mrgreen:
robertcoaster
 
Posts: 1
Joined: Tue Nov 27, 2012 3:09 pm

Re: Relative Path in Title Bar

Postby qgates on Thu Nov 29, 2012 4:00 pm

Yes, part of the issue is that sublime doesn't have or expose the notion of current working directory (CWD). That notion partially conflicts with the idea of "project folders"; since you can have >1 project folder, which is the CWD? One solution would be to have the CWD for a buffer's editing session to be it's containing project folder, but that has issues when the file is in >1 project folder, or one project folder is nested in another.

Another option is to have the CWD as the directory that sublime is launched from. Some editors have the notion of CWD, and some have a console/commandline which allows it to be changed with a CD command.

In Sublime's "intuitive-land", I would favour the approach of the CWD being containing project folder, with some caveats for the multiple project folder scenario above. The CWD for a file that doesn't belong to a project folder would be the launch dir, and it would be nice to have a Sublime console command to change/show the CWD as well.

S
qgates
 
Posts: 205
Joined: Mon Nov 05, 2012 4:33 pm

Re: Relative Path in Title Bar

Postby jbjornson on Thu Nov 29, 2012 4:58 pm

Something like this?

Code: Select all
import sublime, sublime_plugin
import os

class ExampleCommand(sublime_plugin.TextCommand):
    def run(self, edit):
        # check if the current path is in one of the project folders.
        # If yes, then return the relative path of the current file.
        for path in sublime.active_window().folders():
            project_path = os.path.normpath(path)
            file_path = os.path.normpath(sublime.active_window().active_view().file_name())

            relative_path = file_path
            if file_path.startswith(project_path):
                relative_path = file_path.replace(project_path, '...')
                break

        print 'relative_path = %s' % (relative_path)


This just prints out the relative path of the active view, so it would need some work to display it somewhere (not sure where ). It also isn't correctly using self.view but I couldn't be bothered to change it (this was more of a proof of concept).
jbjornson
 
Posts: 347
Joined: Tue Oct 27, 2009 4:25 pm
Location: Zurich, Switzerland

Re: Relative Path in Title Bar

Postby bronson on Thu Nov 29, 2012 5:12 pm

jbjornson, that's excellent and exactly what I would expect. (well, almost: I would replace $HOME with ~/ and leave relative paths relative instead of adding .../. Like you say, proof of concept)

There's TONS of room in the window title bar. It would be excellent to put this info up there. +1!
bronson
 
Posts: 38
Joined: Wed Nov 28, 2012 8:52 pm

Re: Relative Path in Title Bar

Postby jbjornson on Fri Nov 30, 2012 9:23 am

Unfortunately I'm not aware of anything in the API that allows you to change the window title bar text...

@jps Jon, if you are reading this, maybe this could be a candidate for inclusion in the API?
jbjornson
 
Posts: 347
Joined: Tue Oct 27, 2009 4:25 pm
Location: Zurich, Switzerland

Re: Relative Path in Title Bar

Postby logangreer on Tue Feb 19, 2013 3:31 am

logangreer
 
Posts: 1
Joined: Tue Feb 19, 2013 3:29 am


Return to Technical Support

Who is online

Users browsing this forum: No registered users and 10 guests