sublimehq / sublime_merge

Issue tracker for Sublime Merge
https://www.sublimemerge.com
273 stars 14 forks source link

Show in Terminal and Show in Finder/Explorer/etc buttons #186

Open chere005 opened 5 years ago

chere005 commented 5 years ago

A button on top to quickly navigate to the repo in terminal or file browser

jasonycw commented 5 years ago

Maybe follow the Enhancement request template? Same as #178 ?

chere005 commented 5 years ago

Maybe follow the Enhancement request template? Same as #178 ?

Maybe if the enhancement request template were useful for my requests I would

deathaxe commented 5 years ago

How about the existing: Menu > Repository > Open Containing Folder ...? It would open the file browser.

Opening Terminal is not yet available.

Remarks: The meaning of "button on top" is unclear to me. Do you want a button in the toolbar?

chere005 commented 5 years ago

@jasonycw to be more specific, I would basically be filling out this:

Problem description

There is not "A button on top to quickly navigate to the repo in terminal or file browser"

Preferred solution

Add "A button on top to quickly navigate to the repo in terminal or file browser"

Alternatives

None

Screenshots

I could draw a fake button, but the only useful info above was " Please add a button on top to quickly navigate to the repo in terminal or file browser". I thought it was best to just make my point briefly. Thanks for the comment.

chere005 commented 5 years ago

@deathaxe Thanks for pointing out this menu option. It would be good to 1) add this to the command palette, 2) add a button on the top bar (or a setting to add said button in preferences) 3) add these features for terminal as well when possible. It would help a lot, and I'm only a few features away from being able to replace my existing git workflow with Sublime Merge, thus purchasing a license.

deathaxe commented 5 years ago

Extending the Command Palette or even add key bindings is as easy as in ST, except there is no side-by-side view to see the defaults.

Just add ...

Packages/User/Default.sublime-commands

[
    {
        "caption": "Open Containing Folder…",
        "command": "open_dir",
        "args": { "dir": "$working_dir" },
    },
]

You can have a look at the different *.sublime-menu files in the Default package to get an idea about the available functions.

Note: Not all variables like $commit work in main menu or command palette.

deathaxe commented 5 years ago

I've just added the missing commands to such Packages/User/Default.sublime-commands

[
    // Start
    {
        "caption": "New Repository",
        "command": "prompt_new_repository"
    },
    {
        "caption": "Clone Repository…",
        "command": "display_clone_page"
    },
    {
        "caption": "Open Repository…",
        "command": "prompt_open_repository"
    },
    {
        "caption": "Select Repository…",
        "command": "quick_open_repository"
    },
    {
        "caption": "Switch Repository…",
        "command": "quick_switch_repository"
    },

    // Repository
    {
        "caption": "Search",
        "command": "toggle_search"
    },
    {
        "caption": "Stage All Modified\tgit stage -A --modified",
        "command": "stage_all_modified"
    },
    {
        "caption": "Repository: Edit .gitattributes…",
        "command": "open_in_editor",
        "args": {
            "path": "$working_dir/.gitattributes", "line": "$line", "col": "$col",
            "default": "# Specify filepatterns you want to assign special attributes.\n\n.git export-ignore\n.gitattributes export-ignore\n.gitignore export-ignore\n\n"
        },
    },
    {
        "caption": "Repository: Edit .gitignore…",
        "command": "open_in_editor",
        "args": {
            "path": "$working_dir/.gitignore", "line": "$line", "col": "$col",
            "default": "# Specify filepatterns you want git to ignore.\n\n"
        },
    },
    {
        "caption": "Open Containing Folder…",
        "command": "open_dir",
        "args": { "dir": "$working_dir" },
    },

    // Preferences
    {
        "caption": "Preferences: Edit Settings…",
        "command": "open_in_editor",
        "args":
        {
            "path": "${packages}/User/Preferences.sublime-settings",
            "default": "// Settings in here override those in \"Default/Preferences.sublime-settings\",\n// and are overridden in turn by syntax-specific settings.\n{\n\n}\n"
        },
    },
    {
        "caption": "Preferences: Edit Commit Message Settings…",
        "command": "open_in_editor",
        "args":
        {
            "path": "${packages}/User/Commit Message.sublime-settings",
            "default": "// Settings in here override those in \"Default/Commit Message.sublime-settings\"\n{\n\n}\n"
        },
    },
    {
        "caption": "Preferences: Browse Packages…",
        "command": "open_dir",
        "args": { "dir": "$packages" },
    }
]
chere005 commented 5 years ago

@deathaxe these are great, thanks!

Now I'm trying to figure out how to add open in terminal, which seems to involve a little python when done in SublimeText.

I still think these merit being buttons at the top similar to SourceTree

wbond commented 5 years ago

@chere005 Unfortunately the specifics of your request aren't clear to me. A screenshot would help. It appears you've used other programs that behave this way, so a screenshot of that may be helpful.

In general, "opening a terminal" isn't really very easy to implement cross-platform while supporting many popular terminal editors. The Terminal package for Sublime Text (https://github.com/wbond/sublime_terminal) does this, but from looking at issues, you can see that getting this basic task working isn't exactly trivial. Partially this is because many terminal emulators don't offer a way to just open a specific folder. This results in horrible hacks where you have to use AppleScript to tell Terminal to open a new window and then write commands including cd and clear. Then users want to customize if opening a new terminal means a new window, or a new tab in an existing window.

That said, it may be good to take a step back and understand why you want to open a terminal from Merge. Are you trying to execute git commands that aren't available in Merge, or don't work properly?

chere005 commented 5 years ago

@wbond really appreciate you taking the time to respond. Just wanted to quickly say Sublime Text is without a doubt my favorite tool.

The screenshot at the top of this page shows the buttons I'm looking for: https://www.sourcetreeapp.com/

In the top right there's "Show in Terminal" and "Show in Finder". I realize on linux this is less straightforward (with all the flavors of DEs etc), and even on windows too. Standard cmd shell usually isn't what people want. Plus, many osx folks would probably prefer that button opens iTerm2 etc. But on OS X I have become very used to hitting these buttons and getting Terminal.app to the directory. And yes, it looks like sourcetree just opens Terminal.app and calls cd, and doesn't bother to clear. I think always being a new window is a fine default behavior. These things don't bother me as a user, but I can see how maintaining it is more annoying. I'm not even convincing myself here as I type that out.. but..

This may be a little out there, but even if I could add it manually to command palette, and if Merge supported dragging commands to the top bar as buttons, then I could drag the button for my specific open a terminal command, as well as customize which other buttons I'd like to have on the top (another one I miss is a Fetch button, but that's probably not for everyone). Then the burden doesn't fall on you to come up with something general, but I realize asking for customizable buttons is a sizeable request.

I can say one of the most common things I will do is hit "show in terminal" then run subl . I just realized I can open in Sublime Text from the command palette, but I still wish it were a button out of habit. But to be quite honest I'm just more used to running a lot of git commands on the command line and I have a ton of aliases stored in my bash_profile. I primarily used SourceTree as a gui to view the graphs in the past, and for the most part I've been happy replacing it with Merge, but these small things interrupt the flow I'm used to. Another reason I may want to switch to the terminal is to run builds/ tests etc.

wbond commented 5 years ago

@chere005 Awesome, thanks for taking the time to reply with an example and info about your workflow. That helps us to think about possible solutions and also to understand if there are workarounds, or if requests are kind of foundational to workflows.

wnagrodzki commented 4 years ago

For those hoping to find here a way to launch macOS Terminal application at repository path.

  1. Create Default.sublime-commands file at ~/Library/Application Support/Sublime Merge/Packages/User/ unless you already have it.
  2. Add Open Repository in Terminal command
    [
    { 
        "caption": "Open Repository in Terminal", 
        "command": "git", 
        "args": {
            "argv": ["openterminalatpath", "$working_dir"]
        }
    }
    ]
  3. Create git alias by running following command git config --global alias.openterminalatpath '!f() { open -a Terminal "$1" ; }; f'

The new command will be present in Command Palette after restarting Sublime Merge.

iodic commented 4 years ago

Thank you, this has worked for me! I just changed the alias to open iTerm. :)

jasonycw commented 4 years ago

@wnagrodzki do you have a Windows version? After I added the alias for the git, open command is not a thing in Windows sadly

image

wnagrodzki commented 4 years ago

@jasonycw No, I am using macOS only.

stdedos commented 3 years ago

For the time being, can you add the "command": "execute" variety?

This is taking forever (since 2018!) for no reason. While this https://github.com/sublimehq/sublime_merge/issues/186#issuecomment-618228195 is somewhat okay, I don't think it's a suitable workaround for two years.

gb4711de commented 3 years ago

To launch a terminal in Windows (at repository path):

If you have Cmder installed (https://cmder.net/), you can

  1. use the following git-alias: openterminalatpath = "!f() { C:\\\\cmder\\\\cmderlauncher.bat $1 ; }; f"
  2. create the following batch-file cmderlauncher.bat:
    @echo off
    set CMDER_ROOT=%~dp0
    %CMDER_ROOT%\vendor\conemu-maximus5\ConEmu.exe /icon "%CMDER_ROOT%\cmder.exe" /title Cmder /loadcfgfile "%CMDER_ROOT%\config\ConEmu.xml" /cmd cmd /k "%CMDER_ROOT%\vendor\init.bat"

    Obviously you want to adjust the path to the batch-file in the alias accordingly

andrejohansson commented 3 years ago

With the latest fix from git team, it´s now possible to use get wt git alias in @wnagrodzki ´s solution. See https://forum.sublimetext.com/t/solution-open-repository-in-terminal-windows-terminal-and-others/56972

ratijas commented 3 years ago

Adding few cents here. It's kinda hard to believe that I have to justify the need for such a feature, but anyway. I'd like to talk about my scenario.

reason I may want to switch to the terminal is to run builds/ tests etc.

Yes and yes. Me too. I'm kinda an old fart who does things in a more traditional way. I may press some big green buttons in Qt Creator or IntelliJ CLion when I feel like it, but for the most of the time I'm chilling with ANSI xterm-256color.

However, it does not stop me from using Sublime Merge. Scrolling through history, quickly editing past commits, merging, rebasing, rearranging — it's all very nice to use. In fact, I often use SM as an entry point for a research and development. Here is my typical workflow:

And that last step is when Sublime Merge should've kicked in with a build-in command and a pre-defined shortcut to fire up the terminal in one click, to avoid unnecessary interactions and redundant opened windows.

Sometimes the workflow may be opposite though. I may start from the Konsole, navigate to the project's repo directory, and then smerge . && st . — whichever path I choose is entirely circumstantial, and most certainly depends on the current direction of wind and phase of moon. :new_moon_with_face:

nk9 commented 1 year ago

Thanks a ton to @wnagrodzki for explaining how to add this to the command palette. After adding the git global alias, you can also add a key binding this way:

{ "keys": ["super+alt+t"], "command": "git", "args": {"argv": [ "openterminalatpath", "$working_dir" ]}}
SuleymanAli commented 3 months ago

@deathaxe Thanks a million. I have been looking the prompt_open_repository for almost 3 hours