microsoft / terminal

The new Windows Terminal and the original Windows console host, all in the same place!
MIT License
94.36k stars 8.17k forks source link

Ability to identify pane ids #10708

Open Rosefield opened 2 years ago

Rosefield commented 2 years ago

Description of the new feature/enhancement

If features are going to be added that rely on the user providing a pane id, e.g. focus-pane $id or swap-panes -s $sid -t $tid it would be helpful to have a command (perhaps identify-pane) that identifies what the ids of each pane are. This would require making the currently internal _id public, or choosing some other method of identifying each pane.

This might look like (briefly?) showing the id centered in each pane (excuse the paint mockup)

image

Proposed technical implementation details (optional)

zadjii-msft commented 2 years ago

you know, we've got this as a sub-point in #8592, but I guess it deserves it's own specific tracking task. Thanks!

noheromen commented 1 year ago

Hi, any update here? It would be perfect to see list of all tabs and panes, and perhaps see which shell, what process is running in them?

I want to be able to jump to specific tab or pane, depending on the app (lets say I have nvim open in tab 3, pane 2). I could get ID of process, but I have no way to match it to that tab 3, pane 2... I would have to myself keep track what is where open....

Would it be possible to have command like: "wt list tabs and panes" output:

  1. pwsh process ID 10456/pwsh process ID 10452 (here are two panes)
  2. mingw process ID 10534
  3. wsl proces ID 102345 eg...
woodda commented 3 months ago

I would be immensely interested in this too. It would also be especially useful to expose the specific Window/Tab/Pane IDs for each of the Windows Terminal "viewports" within the env vars of its contained Bash shell, Command Window or Power Shell window for easy retrieval. This way, the values could be used to essentially track a specific "viewport" between re-launches of Windows Terminal, after it re-renders its layout.

I have a S.O. question opened about this, but I fear it is not currently possible to access the window/tab/pane IDs within a Linux shell environment running within Windows Terminal (specifically, within WSL2+Ubuntu). And the existing "WT_SESSION" and WSL_INTEROP bash shell environment variables are different each time a Bash shell is created when Windows Terminal restarts (i.e., those values don't persist after pre-rendering the layout).

The specific use case I have is to use Windows Terminal as my primary terminal multiplexer, but reconnect individually persisted Gnu Screen sessions to each re-opened bash shell in the Windows Terminal layout, no matter what the dynamic layout is. Then, with the window/tab/pane IDs exposed in the env vars of the shell, one could have their .bashrc file construct a unique name to assign to the individual Gnu Screen session associated with that specific Bash shell instance running on that particular WT viewport. The ID values (or indexes) would be the same after a Window Terminal restart and re-layout, and thus the same Gnu Screen session IDs could be reconstructed in .bashrc in order to reattached the original Screen session to the same viewport.

This doesn't seem to be a particularly difficult ask. Yet myriad benefits could arise from having these values exposed in the environment of the command process running in the viewport. One could write a command to display the unique viewport ID or number (or a "tuple" of window/tab/pane index values), have Bash scripts restart specific actions based on which viewport they start in, etc.