microsoft / microsoft/terminal

A way to get the currently selected tab index

Open
#18,692 3 comments 4 reactions 0 assignees View on GitHub
Area-Commandline Area-Remoting Issue-Feature Product-Terminal
Dominant language
C++
Stars
105k
Forks
9.6k
Avg merge
3d 17h
Merged PRs (30d)
29

Description

### Description of the new feature

The action `focus-tab` with `--target` takes a tab index to switch to.
But since one does not know which tab is selected or how many are present, this is only useful when one is creating ALL the tabs in a window manually.

If one knows the current tab index OR have a way to specify this instead of an index to `--target` the feature would be more useful.

For example, one could spawn a tab with a long running command in the background.

Currently i have resorted to using ReadProcessMemory on a running WindowsTerminal to get at the index, not exactly ideal ;)

### Proposed technical implementation details

Either `--target prev` for selecting previously selected tab, or an action for `wt` which only prints the current tab index `wt selected-tab`.

Background spawn examples:
`wt -w last new-tab "long-running-command" \; focus-tab -t prev`
OR
`wt -w last new-tab "long-running-command" \; focus-tab -t $(wt selected-tab)`

Contributor guide

Open the contributing guide

Research direction

Start with the existing focus-tab action and its --target handling, then review how wt actions expose tab state and process command sequences. Decide whether the supported behavior is a prev target, a selected-tab action, or both; done means background spawn examples can identify or return to the intended tab reliably.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
cli
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.