Terminal

Terminal Emulator

Konsole is KDE’s trusty default terminal emulator. It is highly configurable and works flawlessly. I’ve been using Konsole ever since I started using Linux.

Then, Alacritty came out. It runs in your GPU, rather than your CPU. It is much faster than any terminal emulator running on the CPU.

Shortly after that, Kitty came out. It’s like a terminal emulator, with the multiplexor Tmux built-into it. KiTTY also runs on the GPU.

I’ve switched over to using Kitty as my default terminal. I recently switched back to Konsole, because I like the KDE applications, which integrate very well with the KDE Plasma desktop. Then, I was wondering why one particular operation was taking so long to execute. I switched back to Kitty.

Once you settle on using a particular terminal as your default terminal, your shell is what you will be interacting with. You still have to figure out how to split the screen and move around from one window to another. Use <ctrl><shft><enter> to split the screen horizontally. Then use <ctrl><shft><l>, that is a lower case el, to shift the split to vertical. You can be working with multiple windows and multiple sessions in Kitty. There are many other features and plugins and extensions you can use. You can even write your own extensions. Extensions are called kittens. KiTTY is the official spelling of Kitty. TTY being the ancient acronym for Teletype.

While you are working in your terminal you will be switching back and forth between Zsh and Neovim a lot. Work with these tools a lot. Get familiar with them. At first, you will be clumsy and slow. Eventually, as you develop your muscle memory, you will develop yourself into a very high performance computer programmer.

WezTerm

WezTerm is a cross-platform terminal emulator and multiplexer written in Rust by Wez Furlong. It aims to provide a modern, GPU-accelerated environment for interacting with the command line, offering features like multiplexing, ligature support and dynamic color schemes.

WezTerm is compatible with Windows, macOS, Linux, and FreeBSD, ensuring a consistent user experience across these environments. It uses the GPU for rendering, which can lead to smoother scrolling and better performance, especially when dealing with complex text rendering like ligatures or color emojis.

Built-in terminal multiplexing allows for managing multiple terminal sessions, panes, tabs and windows, both locally and remotely. This reduces the need for additional tools like tmux or screen for some users. It supports ligatures, color emojis and font fallback, enhancing the visual quality of text in the terminal. It also supports true color (24-bit color) for more vibrant display options.

Configuring Wezterm with Lua scripts, enables extensive customization options. The configuration can dynamically react to system settings or user preferences, like changing color schemes based on the time of day.

Features like shell integration with OSC (Operating System Command) escape sequences enables better interaction with modern shells, improving the user experience with tools like zsh or bash. Searchable scrollback, quick copy mode and custom hyperlink highlighting rules make it user-friendly. You can automatically adjust themes based on system appearance settings or time of day, providing a seamless experience with the user’s environment.

At its core, WezTerm acts as a terminal emulator, which means it spawns a pseudo-terminal (PTY) for each session. It interprets escape sequences from the shell or applications to display text, colors and manage cursor behavior. It handles input from the keyboard, converting it into appropriate escape sequences or commands for the shell or application running in the terminal.

WezTerm multiplexing manages multiple terminal sessions in one application instance. Panes split the terminal window into multiple regions, each running its own shell or application. Tabs allow switching between different terminal sessions within the same window. Multiple instances of WezTerm can be opened, with each individual window, potentially holding multiple tabs or panes.

The Lua-based configuration allows for defining key bindings for actions like pane splitting, tab navigation or custom commands. Setting up dynamic behaviors like changing the theme based on system settings. Configuring appearance, including fonts, colors and padding.

For remote work, WezTerm can use SSH directly from within the application for connecting to remote hosts. Connect to a remote WezTerm mux server to manage sessions over a network. By leveraging Rust for its implementation and GPU acceleration for rendering, WezTerm aims to provide a responsive and efficient terminal experience.

WezTerm can handle mouse interactions for selecting text, clicking on hyperlinks or manipulating panes/tabs/windows with intuitive shortcuts or clicks.

WezTerm represents a modern approach to terminal emulation, focusing on both functionality for developers and aesthetics, leveraging Rust’s performance benefits and Lua’s flexibility for configuration.

WezTerm mux Server

The WezTerm Mux Server is an integral part of WezTerm that enables multiplexing terminal sessions across multiple connections, including local and remote setups. It allows users to manage multiple terminal sessions, panes, and windows in a centralized manner, similar to how tmux or screen work but integrated directly into WezTerm.

When WezTerm starts, it can optionally spawn a mux server which manages all the sessions. This server runs in the background and can continue to manage sessions even if all client windows are closed. The WezTerm GUI clients connect to this server. This model allows for multiple clients (different WezTerm windows or even remote connections) accessing the same sessions. Sessions persist beyond the lifetime of a single client.

Sessions are collections of windows, tabs and panes. Each session is managed by the mux server. Sessions can be saved and restored, meaning you can close WezTerm and later reopen it to find your previous work environment intact.

You can configure WezTerm to connect to a mux server running on a remote machine via SSH. This allows you to interact with your terminal sessions on that machine from anywhere, with the same interface you use locally. The mux server uses a network protocol to communicate with clients, allowing for secure, encrypted communication over SSH.

You can issue commands to manipulate sessions, like splitting panes, creating new tabs or closing windows, which are then handled by the server. Changes made in one client (like adding a new pane) are reflected in all connected clients viewing the same session.

The state of the mux server, including all sessions, is stored in a file system (in a directory like ~/.local/share/wezterm/mux-server-state). This allows for recovery if WezTerm crashes or is forcibly closed, the server can potentially recover the state from this storage. You can back up these files for session preservation.

Since the server can run on a network, there’s a focus on ensuring only authorized access. This typically involves SSH for remote setups, where SSH keys or passwords secure the connection. By centralizing session management, the mux server aims to provide efficiency in handling complex terminal setups without the need for multiple separate applications or tools.

Simply running WezTerm with multiplexing enabled will start a local mux server, and all windows/tabs/panes you create are managed by this server. Configure WezTerm to connect to a remote mux server by specifying the host in your wezterm.lua configuration. When you connect to this host, you’re interacting with the sessions managed by the server on that machine. Use built-in commands or shortcuts to interact with the mux server, like CTRL+Shift+N for new tab, CTRL+Shift+W for closing current tab, etc., with actions propagated through the server.

The WezTerm Mux Server thus enhances the utility of WezTerm by providing a robust framework for managing terminal sessions, making it particularly appealing to users who frequently work with multiple terminal environments or need persistent, accessible sessions across different devices.

SSH Integration

SSH Integration with WezTerm

WezTerm’s SSH integration allows for seamless management and interaction with remote terminal sessions directly from the WezTerm interface. This integration leverages SSH (Secure Shell) protocols for secure remote access, providing a user-friendly experience for connecting to and managing remote systems.

You can initiate SSH connections from within WezTerm without needing to open another terminal or SSH client. This is done via command line, by launching WezTerm with wezterm ssh user@hostname.

Adding SSH connections in the wezterm.lua configuration file, allowing for easy access via shortcuts or menu items. WezTerm can connect to a mux server running on a remote machine over SSH. This means you can log into a remote machine, join existing sessions, or start new ones that persist even after you disconnect. Different clients (local or remote) can connect to the same session managed by the mux server on the remote host.

WezTerm respects your SSH configuration file (~/.ssh/config), allowing you to use aliases, custom ports or specific keys for different hosts. In (wezterm.lua), you can define:

lua

return {
  ssh_domains = {
    {
      name = "myserver",
      remote_address = "user@example.com",
      multiplexing = "WezTerm",
    },
  },
}

This setup allows launching connections with (wezterm connect myserver).

WezTerm uses SSH keys for authentication if configured in your SSH setup. It will attempt to use any SSH agent or keys defined in your SSH config. It falls back to password authentication if key-based authentication fails or isn’t configured.

All connections are encrypted by SSH, ensuring that your session data is secure during transit. WezTerm does not store passwords but relies on SSH’s mechanisms for key management and authentication. By connecting to a remote mux server, you can share sessions across multiple windows or devices.

Leave processes running on the remote machine without keeping an SSH connection open continuously. Once connected, a remote session behaves much like a local one within WezTerm, with all features like pane splitting, tab management, etc., available. WezTerm handles SSH connection details, including forwarding control sequences for better shell integration.

Users can customize how SSH connections look or behave through WezTerm’s config, like setting different color schemes for different hosts.

Launching from cli:

wezterm ssh user@hostname

From WezTerm (if configured) use a shortcut or select from a dropdown list of SSH domains.

Edit wezterm.lua to define ssh_domains. This allows for pre-configured, named connections that can be easily accessed.

Remote Mux Server: Ensure WezTerm is set to run a mux server on the remote machine (default behavior if multiplexing is enabled). Use wezterm connect with the domain name to connect to this server remotely.

SSH integration reduces context switching by keeping your workflow within one application. It provides an enhanced, feature-rich remote terminal experience with WezTerm’s capabilities like GPU-accelerated rendering and multiplexing.

Wezterm requires some setup for full feature utilization, particularly for remote mux server connections. Users must be familiar with SSH keys and configuration to get the best experience.

WezTerm’s SSH integration aims to make working with remote systems as seamless as local work, leveraging the strengths of both SSH and WezTerm’s interface to provide an efficient, secure and user-friendly experience.

Sources: Grok