Tools

The Tools preferences settings allow you to define external tools to assist you when using SmartGit:

You can share the external tools list with Export… and Import…. Export saves the selected entries to a .yml file. Import adds entries to the current list. It skips matching command lines and keeps existing default tools, including your customizations. Alternatively, the configuration is stored in tools.yml file in the settings directory.

A leading * marks a tool that can be used by Open.

  • Add… creates a tool.
  • Copy… creates a tool using the selected entry’s settings.
  • Edit… changes the selected tool.
  • Remove removes selected entries from the configuration.
  • Move Up and Move Down change the order used in the Tools menu. You can also drag entries to reorder them.

Default Tools

When first installed, SmartGit will configure a set of default tools:

  • The Open File tool will invoke the system’s default open command, e.g. to launch a browser for .html files.
  • The Open in Terminal tool will open the selected directory in the terminal application.
  • The Open Git-Shell tool will open the repository in the Git shell.

If the Tool setup is not to your liking, you can restore missing default tools by clicking the Re-Add Defaults button.

During automatic setup on Linux, SmartGit removes recognized default tools whose configured executable is missing. Use an absolute executable path when customizing the Command of these tools.

Reveal files on Linux

If /usr/bin/gdbus is available, you can use it for Reveal in File Manager on Linux. Edit the entry in Preferences -> Tools and set Command to /usr/bin/gdbus. Use these Arguments:

call --session --dest org.freedesktop.FileManager1 --object-path /org/freedesktop/FileManager1 --method org.freedesktop.FileManager1.ShowItems "['${fileUri}']" ""

Note

SmartGit adds a reveal tool for each supported file manager it detects. The generic Reveal in File Manager tool uses /usr/bin/gdbus when available, otherwise /usr/bin/dbus-send. This improves compatibility with Flatpak installations. An existing dbus-send entry can remain alongside the new gdbus entry.

Open files and terminals on Linux

New Open File defaults use /usr/bin/xdg-open with the file URI when available. If it is absent, SmartGit uses /usr/bin/gio with open and the file path when available. Existing Open File entries keep their configured command.

SmartGit adds an entry for each supported terminal it detects, including Open Terminal (Ptyxis) when /usr/bin/ptyxis is available.

Note

On SmartGit 22.1 and later, default tools have been cleaned up. The Git version is now displayed in the preferences, Fast-forward Merge has been implemented as SmartGit command.

If you are missing further tools from SmartGit version before 22.1 (e.g. Set Executable Flag, Format Patch, Apply Patch, Verify Database or Git Config), please download this file for Windows or Linux/macOS and Import that in SmartGit.

Configure a Tool

Use Add… or Copy… to create a new tool. Menu Item Name sets its name in the Tools menu.

The Command means just the executable file without any argument. The Arguments can contain the following variables, accessible from the Variables menu at the right:

  • ${filePath} = the path of the selected file or directory, e.g. C:\repository\readme.txt
  • ${fileName} = the name of the selected file or directory, e.g. readme.txt
  • ${fileUri} = the URI of the selected file or directory, e.g. file://C:/repository/readme.txt
  • ${repositoryRootPath} = the root path of the repository, e.g. C:\repository
  • ${selectionFile} = the path of a temporary file containing all selected file paths, one file per line, e.g. C:\temp\selected-91235
  • ${remoteUrl} = the remote (push) URL of the repository, e.g. https://github.com/user/project.git
  • ${encoding} = the configured text file encoding, e.g. UTF-8
  • ${commit} = the (single or first) selected commit or ref (depending on the Handles: Refs, Commits, Both option), e.g. feature/new-layout
  • ${commit2} = the second selected commit or ref, e.g. feature/old-layout
  • ${fileOpen} = the path of a existing file that the user will have to select when invoking the tool, e.g. D:\download\my-patch.txt
  • ${fileSave} = the path of a file that the user will have to select when invoking the tool; if existing, the user needs to confirm the overwrite
  • ${dirSelect} = the path of a directory that the user will have to select when invoking the tool, e.g. D:\export
  • ${git} = the path of the configured Git executable, e.g. C:\Program Files\SmartGit\git\bin\git.exe
  • ${gitDir} = the (root) path configured Git installation, e.g. C:\Program Files\SmartGit\git
  • ${smartGitDir} = the (root) path of the SmartGit installation, e.g. C:\Program Files\SmartGit

If space-separated options should be one argument, you need to use double quotes (") to surround this argument. If you need to use a double-quote in the output, use two double quotes ("").

The working directory when launching the tool will be the root directory of the corresponding repository (which may also be a submodule). When launching a tool on a set of files which belong to different repositories, it will be the closest common directory of all affected repositories.

The variables in Arguments determine which selection settings are available:

  • File variables such as ${filePath} enable Handles with Files, Directories, and Both. Use Applies To to match file or directory names with ? for one character or * for any number of characters. Separate multiple patterns with commas.
  • ${commit} enables Handles with Refs, Commits, and Both. Choose whether the tool accepts named refs, commit IDs, or either.
  • Tools without selection-specific variables can operate on the repository itself.

Enable Can be used by the Open command to make a file tool available to Open and Open from Working Tree in the Files view. Its arguments must contain ${filePath}, ${fileName}, or ${fileUri}. This option cannot be combined with Show output and wait until finished.

Note

When the selected directory is the root of an open repository, its name is empty and only * matches it. For a closed repository in the Repositories View, Applies To matches its folder name.

Enable Request confirmation before invoking and enter a confirmation message to ask before running the tool. The message can use variables that are also present in Arguments. Enable Show output and wait until finished to display the tool’s output and wait for it to finish.

For tools with Show output and wait until finished enabled, the low-level property tools.prependGitBinToPath controls whether SmartGit adds its configured Git executable directory to the front of PATH. It defaults to true; set it to false to keep the tool’s existing PATH.

Note

For perl.exe commands with Show output and wait until finished enabled, SmartGit searches the tool’s original PATH, without prepending Git’s executable directories. Use an absolute path in Command if you need a specific Perl installation.

Example Tools

Format Patch

Save this content to a file format-patch.yml and use the Import button on the Tools page of the preferences to restore the Format Patch feature from SmartGit versions < 22.1.

tools:
- name: Format Patch
  fileStarter: {command: '${git}', parameters: 'format-patch -o "${dirSelect}" -1 ${commit}'}
  useForOpen: false
  waitUntilFinished: true
  filePattern: '*'
- name: Format Patch
  fileStarter: {command: '${git}', parameters: 'format-patch -o "${dirSelect}" ${commit}..${commit2}'}
  useForOpen: false
  waitUntilFinished: true
  filePattern: '*'

Open top-most Visual Studio solution from current repository

This PowerShell script can be used to open a solution file .sln inside a repository, in Visual Studio. The script iterates through the repository folders and looks for a .sln file. It stops at the first match and then launches Visual Studio.

External tool configuration for opening a Visual Studio solution

PowerShell script C:\SmartGit-Scripts\openVS.ps1

Install-Module VSSetup -Scope CurrentUser
$slnname = Get-ChildItem -Path $args[0] -Filter *.sln -Recurse -ErrorAction SilentlyContinue -Force | Select-Object -First 1 | Select-Object -ExpandProperty FullName

switch ( $args[1] )
{
    2017
    {
        $ver = '[15.0,16.0)'
    }

    2019
    {
        $ver = '[16.0,17.0)'
    }

    default
    {
        $ver = '[1.0,1000.0)'
    }
}

$devenv = Get-VSSetupInstance | Select-VSSetupInstance -Version $ver -Latest | Select-Object -ExpandProperty InstallationPath
$devenv = $devenv + "\Common7\IDE\devenv.exe"
Start-Process -FilePath $devenv -ArgumentList $slnname