tmux/screen alternative for powershell

It's not precisely analogous to tmux or screen, but PowerShell has a facility for managing remote sessions. Ed Wilson wrote a blog post about it entitled Learn How to Manage Remote PowerShell Sessions, which might help. Also see the about_PSSessions PowerShell help topic.

Can you say more about what you're trying to accomplish?


Try Cmder. It's awesome! It even bundled with git for windows. http://cmder.net/


Although it wasn't possible when this question was originally asked, with Windows Subsystem for Linux, it's now possible to use a "real" tmux to manage PowerShell windows.

Short-version

In a WSL instance with tmux installed, set up your ~/.tmux.conf with:

set -g default-command "cd $(pwsh.exe -c 'Write-Host -NoNewLine \$env:userprofile' | xargs -0 wslpath); exec pwsh.exe --nologo"
set-window-option -g automatic-rename off
bind c new-window -n "PowerShell"

Benefits and Features

Most of the features you'd normally expect from tmux, including:

  • Full (?) hotkeys support
  • Scrollback / Copy mode for PowerShell
  • And many more

Limitations

  • If the original session is disconnected, re-attaching will result in a broken pipe. However, you can attach multiple clients at once, as long as the original remains open.

More details

There are several ways to set this up, but here's how I'm doing it at the moment:

  • Install Windows Subsystem for Linux. You don't have to enable WSL2; just WSL v1 will work fine for this (and perhaps better than WSL2).

  • Install the Alpine Linux distribution. I use this as the base for the tmux feature, since it has very low overhead (less than 12MB, including tmux).

  • The next few steps are optional. I create a new, cloned WSL instance for PowerShell tmux. You could just use the default Alpine instance, but I like to have single-purpose WSL instances, similar to Docker containers.

    mkdir $env:userprofile\Documents\WSL\instances # Or wherever you want to set this up
    mkdir $env:userprofile\Documents\WSL\images
    cd $env:userprofile\Documents\WSL
    wsl --export Alpine .\images\alpine_base.tar
    mkdir .\instances\posh_tmux
    wsl --import posh_tmux .\instances\posh_tmux .\images\alpine_base.tar --version 1 
    
  • Launch the WSL instance as root with wsl -d posh_tmux -u root

  • adduser tmux, and give it a password.

  • Set the default user for the instance by creating /etc/wsl.conf with the following contents:

    [user]
    default = tmux
    
  • apk add tmux to install tmux

  • Exit the session, relaunch with wsl ~ -d tmux (omitting the username, since it will now default to the tmux user)

  • Create a ~/.tmux.conf with the following:

    set -g default-command "cd $(pwsh.exe -c 'Write-Host -NoNewLine \$env:userprofile' | xargs -0 wslpath); exec pwsh.exe --nologo"
    set-window-option -g automatic-rename off
    bind c new-window -n "PowerShell"
    
    # Give this tmux a "PowerShell blue" color to differentiate it
    set -g status-bg blue
    
    # Use UTF8
    set -qg utf8
    set-window-option -qg utf8 on
    
    # Recommended, to avoid the Ctrl+B finger-gymnastics
    # Change default prefix to Screen's
    unbind C-b
    set-option -g prefix C-a
    bind-key C-a send-prefix
    bind-key -n C-b send-prefix
    bind C-a last-window
    
    # Optional
    # split panes using - and |
    bind | split-window -h
    bind - split-window -v
    unbind '"'
    unbind %
    
    set -g history-limit 10000
    
    set -g default-terminal "screen-256color"
    
  • Create a ~/.profile with the following:

    if tmux has-session -t=posh; then
      exec tmux attach-session -t posh
    else
      exec tmux new-session -s posh -n PowerShell
    fi
    
  • Set up a PowerShell Core tmux profile in Windows Terminal, ConEmu, or however you prefer. The launch command is simply wsl -d tmux_posh

  • If you need to access the instance without entering tmux/PowerShell (for instance, to sudo apk upgrade or to edit the config), launch instead with wsl ~ -d tmux_posh -e sh (or wsl ~ -d tmux_posh -u root).

  • You can access tmux commands from within PowerShell by wsl -d tmux_posh -e tmux <tmux_command. For instance, wsl -d tmux_posh -e tmux rename-window host1. TODO: Create a tmux wrapper PowerShell function for this.

  • TODO: PowerShell prompt function to set the window name dynamically to the last executed command


You don't specify your requirements, so it's somewhat hard to answer your post.

You could try the free Console, which can incorporate PowerShell tabs :

Console is a Windows console window enhancement. Console features include: multiple tabs, text editor-like text selection, different background types, alpha and color-key transparency, configurable font, different window styles.

For details see this article : Console – Windows Command Prompt alternative for Windows and PowerShell.

image

(Note: Remember that this answer is from 2012.)


it's been a while since I've used Windows but just came across https://wezfurlong.org/wezterm/features.html which would fit my requirements quite well

among other things it has tabs and vertical/horizontal splits