sublimehq / sublime_text

Issue tracker for Sublime Text
https://www.sublimetext.com
809 stars 39 forks source link

+ Copy Relative File Path #5399

Open thoran opened 2 years ago

thoran commented 2 years ago

Problem description

When working in a container, say running specs from the command line, I don't want the full path, I just want the path from the root of the project so as I can copy and paste that to the container console.

Preferred solution

Add a "Copy Relative File Path" menu option.

Alternatives

Have it configurable, such that one may choose either "Copy File Path" or "Copy Relative File Path". Actually, I'm not sure which I prefer. I might get annoyed if I select the wrong one, much in the same way as when I accidentally select "Reveal in Finder" instead of "Reveal in Side Bar"!

Additional Information

No response

BenjaminSchaaf commented 2 years ago

Sublime Text doesn't provide any "Copy File Path" menu item.

UltraInstinct05 commented 2 years ago

Sublime Text doesn't provide any "Copy File Path" menu item.

Actually it does provide it in the context menu for files (implemented via Default/copy_path.py).

image

BenjaminSchaaf commented 2 years ago

Ah thanks, missed that one.

deathaxe commented 2 years ago

Added it to my fork of FileManager:

grafik

see: https://github.com/deathaxe/FileManager/blob/master/Tab%20Context.sublime-menu

thoran commented 2 years ago

I just noticed that Merge has an item under '...' alongside each file which is called "Copy File Path", but supplies a relative path, so works differently from Text. Should they work the same?

UltraInstinct05 commented 2 years ago

I just noticed that Merge has an item under '...' alongside each file which is called "Copy File Path", but supplies a relative path, so works differently from Text. Should they work the same?

I believe it supplies the repository relative path whereas ST's variant gives the absolute path. Whether they should work the same, I don't know.

thoran commented 2 years ago

On a slightly different, but related note... It would be good if I have the cursor on a line or if the line is highlighted, that a menu item will add :123 to the end for running a subset of specs.

mrx23dot commented 1 month ago

This should be added on right click on Tab, not bloating text's context menu.

VScode has these on Tab: image

Would be great if it had "explore directory" (open dir in OS) too.

Also what's the command for this that I could use for a binding?

the documentation https://www.sublimetext.com/docs/key_bindings.html says Currently there is no compiled list of all built-in commands. The names of many commands can be found by looking at the Default ({PLATFORM_NAME}).sublime-keymap files in the Default/ package. but there is no link to that file in documentation.

And that file is not in "C:\Program Files\Sublime Text"

deathaxe commented 1 month ago

This should be added on right click on Tab, not bloating text's context menu.

Agree. My screenshot actually shows tab context menu for exactly this reason.

Would be great if it had "explore directory" (open dir in OS) too.

Can be added by https://github.com/deathaxe/sublime-commands/blob/8aac85bcddb38a591a4fc36ea2e02af4fd3e6e71/Tab%20Context.sublime-menu#L103-L108

Also what's the command for this that I could use for a binding?

Easiest way to examine existing commands is

  1. via https://packagecontrol.io/packages/CommandsBrowser
  2. via auto-completions provided by https://packagecontrol.io/packages/PackageDev

Alternatively View Package File command from command palette to open any file from loaded packages to examine its content.

Otherwise C:\Program Files\Sublime Text\Packages contains all bundled packages in ZIP format. The most relevant one to lookup built-in commands is Default.sublime-package

mrx23dot commented 1 month ago

+1 for Renaming in Tab's menu

And showing a lock icon on Tab when write protected file, (currently only gives warning on save, which is too late)

deathaxe commented 1 month ago

It would require ST to provide a "readonly" attribute for themes to be able to treat read-only files different. I could imagine an alternative "close button" being used for read-only file.

With ST's minimalistic UI design guidelines in mind a dedicated "lock" icon is however rather unlikely to happen. Same as users might wait forever for file icons in tabs.

A currently available opportunity was a little plugin printing a "readonly" to statusbar.

mrx23dot commented 1 month ago

Or simply append xxx.txt [RO] to file name on Tab, seen it on some other sw.

Also there is no read only flag in linux, but there is for file on read only partition.