# Default terminal

Vaultport can stand in for your system terminal: other programs can open a tab with a command, in a folder, or connected to a server from an `ssh://` link. Turn the integrations on in **Settings → Terminal → Default terminal**. Every change is made for your user only (no administrator rights), and switching an option off removes it again.

## Command line

```text
vaultport [-e | --command | -x | -- <program> [args…]] [--working-directory <dir>] [--title <title>]
vaultport ssh://user@host:port
vaultport <directory>
```

| Option                                                   | What it does                                                                                                                                                                  |
| -------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `-e <program> [args…]`                                   | Runs the program in a new local tab instead of your shell; the tab ends when it exits. Everything after `-e` belongs to the command. `--command`, `-x` and `--` are the same. |
| `-e "<program> <args>"`                                  | One string is split into words (with shell quoting, but no shell runs), as many `x-terminal-emulator` callers pass it. A path that exists is never split.                     |
| `--working-directory <dir>`, `--working-directory=<dir>` | Starts the tab in this directory. A directory as a plain argument does the same.                                                                                              |
| `--title <title>`, `--title=<title>`, `-T`               | Names the tab.                                                                                                                                                                |
| `ssh://user@host:port`                                   | Opens the [saved host](http://vaultport.niessen.dev/guide/hosts-and-groups.md) with that address, port and user (the most recently used one if there are several), or else a quick connection.               |

If Vaultport is already running, a second `vaultport …` hands its arguments to the running app, which opens the tabs and comes to the front. Requests made while the vault is locked wait until you unlock it: the lock screen covers every tab, so nothing opens behind it. That includes local terminals, although they need no secrets.

> **What a link can do**
>
> An `ssh://` link only ever connects: the user name, host and port are used, and everything else in the link — a password, a path, a query — is ignored. Host keys are checked as usual, and nothing is run on the server. Only `-e`, which you type yourself or which a program on your computer passes, runs a command, and only in a local terminal. Arguments handed over by a second launch are length-limited and checked before anything opens.

## Windows

| Setting                         | What it registers (in `HKEY_CURRENT_USER`)                                                                                                    |
| ------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------- |
| "Open in Vaultport" for folders | `Software\Classes\Directory\shell`, `Directory\Background\shell` and `Drive\shell` → `vaultport --working-directory "<folder>"`               |
| Handle ssh:// links             | The `Vaultport.ssh` ProgID, Vaultport's capabilities in `Software\RegisteredApplications`, and the `ssh` scheme if no other app registered it |
| Start from Run                  | `Software\Microsoft\Windows\CurrentVersion\App Paths\vaultport.exe`, so <kbd>Win</kbd>+<kbd>R</kbd> → `vaultport` and `start vaultport` work  |

- On Windows 11 the folder entry is in the classic menu: right-click → **Show more options**, or <kbd>Shift</kbd>+right-click. The compact Windows 11 menu only shows entries of packaged apps.
- If another app is already chosen for `ssh://` links, Windows keeps using it. Vaultport then says so and opens **Settings → Apps → Default apps → Vaultport**, where you pick it for `SSH`.
- Uninstalling with the setup `.exe` removes the entries. With the `.msi`, switch the options off first.

### Why Vaultport is not in "Default terminal application"

Windows 11 (and Windows 10 since KB5026435) lets you choose a **Default terminal application** under **Settings → System → For developers** or in Windows Terminal's settings. That list is not open to ordinary programs:

- It only contains packaged apps. Windows reads it from the app extension catalog: a terminal must be an MSIX package that declares the `com.microsoft.windows.terminal.host` app extension, and the list pairs it with a `com.microsoft.windows.console.host` extension from the same package ([`DelegationConfig.cpp`](https://github.com/microsoft/terminal/blob/main/src/propslib/DelegationConfig.cpp)).
- The console host hands a new console over through COM: it creates the terminal's out-of-process server and calls `ITerminalHandoff3::EstablishPtyHandoff` ([`ITerminalHandoff.idl`](https://github.com/microsoft/terminal/blob/main/src/host/proxy/ITerminalHandoff.idl)). Marshalling that interface needs the `OpenConsoleProxy.dll` proxy that Windows Terminal registers in its package manifest ([`Package.appxmanifest`](https://github.com/microsoft/terminal/blob/main/src/cascadia/CascadiaPackage/Package.appxmanifest)).

Vaultport is installed with an NSIS setup or an MSI, not as an MSIX package, so it cannot register these extensions. Writing the delegation CLSIDs into `HKEY_CURRENT_USER\Console\%%Startup` by hand would depend on Windows Terminal's own console host and proxy and is not something Vaultport does. Windows Terminal stays your default for console programs; use the options above to open Vaultport from Explorer, links and Run.

## macOS

macOS has no system-wide default terminal. Like other Terminal alternatives, Vaultport declares in its `Info.plist` that it can open `ssh://` links, shell scripts and folders, and can make itself the default through Launch Services:

| Setting             | What it does                                                                                                                            |
| ------------------- | --------------------------------------------------------------------------------------------------------------------------------------- |
| Handle ssh:// links | Makes Vaultport the default app for `ssh://` (switching it off gives the links back to Terminal).                                       |
| Open shell scripts  | Makes Vaultport the default app for `.command` and `.tool` (`com.apple.terminal.shell-script`) and `.sh` (`public.shell-script`) files. |

- Double-clicking an executable script runs it in a new tab in your home folder, as Terminal does. A script that is not executable opens a shell in its folder instead, and a script downloaded from the internet (it carries the quarantine flag) asks before it runs.
- Drag a folder onto Vaultport in the Dock, or run `open -a Vaultport ~/projects`, to open a tab there.
- For a Finder menu entry, create a **Quick Action** in Automator or Shortcuts that receives folders in Finder and runs the shell script `open -a Vaultport "$@"`.

## Linux

The packages (`.deb`, `.rpm`, AppImage) ship a desktop entry, `Vaultport.desktop`, that declares Vaultport a terminal emulator and `ssh://` handler:

```ini
Exec=vaultport %U
Categories=System;TerminalEmulator;
MimeType=x-scheme-handler/ssh;
X-TerminalArgExec=-e
X-TerminalArgDir=--working-directory=
X-TerminalArgTitle=--title=
```

| Setting                             | What it does                                                                                                                                                                                                                                                                                         |
| ----------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Make Vaultport the default terminal | Puts `Vaultport.desktop` first in `~/.config/xdg-terminals.list` (and in a desktop-specific list such as `gnome-xdg-terminals.list` if you have one), the [xdg-terminal-exec](https://gitlab.freedesktop.org/terminal-wg/specifications) choice used by launchers and file managers that support it. |
| Handle ssh:// links                 | Runs `xdg-mime default Vaultport.desktop x-scheme-handler/ssh` (or edits `~/.config/mimeapps.list`). Switching it off gives the previous handler back.                                                                                                                                               |

Without an installed desktop entry (an AppImage, a source build), Vaultport writes one for itself to `~/.local/share/applications/Vaultport.desktop` and removes it again when both options are off.

### x-terminal-emulator (Debian, Ubuntu)

Many programs on Debian and Ubuntu start `x-terminal-emulator`, which the alternatives system points at one terminal. Changing it needs root, so Vaultport leaves it to you. Vaultport accepts the `-e` and `-T` options that callers use, in both the `-e cmd args…` and `-e "cmd args"` forms:

```bash
sudo update-alternatives --install /usr/bin/x-terminal-emulator x-terminal-emulator /usr/bin/vaultport 20
sudo update-alternatives --config x-terminal-emulator
```

### Desktop environments

- **GNOME** has no setting for the default terminal. Where xdg-terminal-exec is installed (for example on recent Ubuntu releases), GNOME uses it to start programs that need a terminal, so the first option applies. A file manager's own "Open in Terminal" entry may still open the terminal that provides it.
- **KDE Plasma**: choose Vaultport in **System Settings → Default Applications → Terminal Emulator**; it is listed because of `TerminalEmulator` in its desktop entry.

## Phones and tablets

Android, iOS and iPadOS have no default terminal, so the section is hidden there.
