LibTmux.Watch-TmuxEvent
LibTmux\Watch-TmuxEvent Stream native tmux events with bounded delivery and explicit ownership.
Source and package
- Declared in
- LibTmux
- Package
- LibTmux
- Source
- src/LibTmux.PowerShell/WatchTmuxEventCommand.cs
- Connection (default): Watch-TmuxEvent [-Connection] <Lib
Tmux > [-Max.IControl Mode Session Event <SystemBytes .Int32 >] [-MaxEvents <System.Int64 >] [-MaxOutput <SystemBytes .Int64 >] [-WhatIf ] [-Confirm] [<CommonParameters >] Server: Watch-TmuxEvent [-Server] <LibTmux > [-Target] <System.Server .String > [-MaxEvent <SystemBytes .Int32 >] [-MaxEvents <System.Int64 >] [-MaxOutput <SystemBytes .Int64 >] [-WhatIf ] [-Confirm] [<CommonParameters >] -
Description#
Emit native
TmuxEventvalues in stream order. A supplied Connection is borrowed and remains usable after cancellation or early pipeline exit. WithServerand Target, the command owns a new control client and closes it before returning. Both forms borrow the daemon and its sessions.Outputcount and byte budgets reset for each input connection or server; piping N owners can emit N times MaxEvents.There is one acknowledged handoff slot. The reader does not fetch the next event until downstream processing returns. PowerShell output runs only on the active pipeline callback; native command replies continue independently, so downstream code may send through the same connection.
Only one
Watch-TmuxEventconsumer may read a connection at a time. Direct nativeEventsreaders remain the caller's responsibility: the stream is not broadcast. Event output is decoded text fragments, not rendered pane contents, lines, byte-exact output or a durable log. Loss and exit events are forwarded.Notes
Tmux.WatchFailedpreserves the native exception and supplied owner. Buffered events precede a terminal stream error. A byte-budget failure preserves earlier output and reports that the consumed oversized event was not emitted.Byte accounting includes decoded UTF-8 text in pane IDs, output data, notification names and arguments, and exit reasons.
Numericloss counts add no text bytes. This bounds text payload, not object overhead or serialized PowerShell Job data. Set BOTH MaxEvents and MaxOutputBytes for unattended jobs. The native upstream queue separately defaults to 512 events and 4 MiB of decoded UTF-8 payload. Configure its positiveControlModeEventBufferCapacityandControlModeEventBufferMaxBytesthroughServerConnectionOptionsbefore connecting. Queue bytes include output data, notification names and arguments, and exit reasons, excluding pane IDs and object overhead. Oldest events are discarded until both queue limits hold. An oversized event is dropped; an oversized exit reason is omitted while the exit event remains. Loss is reported byTmuxEventsDroppedEventwithout blocking command replies.Ctrl+C, pipeline early exit and module removal stop the reader and await its disposal. Module removal cancels active watches only in the importing runspace; it does not dispose supplied clients. Cancellation may consume an event that has not reached the pipeline. Resnapshot after loss when current state matters. The foreground pipeline remains occupied while watching; use a bounded ThreadJob to make the prompt available.
Command details#
- Command type
cmdlet- Default parameter set
- Connection
- Confirmation
- Supports
-WhatIfand-Confirm; confirm impact: Medium. - Positional binding
- Enabled.
- Pipeline inputs
-
LibTmux.IControlModeSession: A borrowed native control client.;LibTmux.Server: An endpoint on which to create an owned control client. - Outputs
-
LibTmux.TmuxEvent
Examples#
Example 1 Observe the first notification on fixture using a previously selected
$server. The command closes its new control client when the count limit is reached. View sourceTerminal window $server |LibTmux\Watch-TmuxEvent -Target 'fixture' -MaxEvents 1 -MaxOutputBytes 1MB- Parameters
-
-
-Connection(LibTmux ) (for.IControl Mode Session Connection) #The borrowed native client. No other consumer may read its
Eventsstream while this watch is active.- Required
- Yes
- Position
- 0
- Pipeline input
- By value
- Validation
ValidateNotNull()
-
-MaxEventBytes(System.Int32 ) #Positive maximum UTF-8 text bytes in the one-event handoff. Default: 1048576. An oversized event fails before output.
- Required
- No
- Position
- Named
- Pipeline input
- No
- Default
1048576- Validation
ValidateRange(1, 2147483647)
-
Positive maximum emitted event count. Default: Int64.MaxValue. Reaching the limit ends the watch normally.
- Required
- No
- Position
- Named
- Pipeline input
- No
- Default
9223372036854775807- Validation
ValidateRange(1, 9223372036854776000)
-
-MaxOutputBytes(System.Int64 ) #Positive maximum cumulative emitted UTF-8 text bytes. Default: Int64.MaxValue. Reaching it exactly ends normally; an event too large for the remaining budget emits an error before that event.
- Required
- No
- Position
- Named
- Pipeline input
- No
- Default
9223372036854775807- Validation
ValidateRange(1, 9223372036854776000)
-
-WhatIf(System.Management ) #.Automation .Switch Parameter Show the operation without attaching a client or consuming events.
- Required
- No
- Position
- Named
- Pipeline input
- No
- Switch
- Yes
- Aliases
wi
-
-Confirm(System.Management ) #.Automation .Switch Parameter Ask before attaching or consuming the event stream.
- Required
- No
- Position
- Named
- Pipeline input
- No
- Switch
- Yes
- Aliases
cf
-
-Server(LibTmux ) (for.Server Server) #The borrowed endpoint on which this command creates and owns one control client.
- Required
- Yes
- Position
- 0
- Pipeline input
- By value
- Validation
ValidateNotNull()
-
-Target(System.String ) (forServer) #The explicit raw tmux target to attach to. It has no captured session identity guard.
- Required
- Yes
- Position
- 1
- Pipeline input
- No
- Validation
ValidateNotNullOrEmpty()- Validation
ValidatePattern("\\A[^\\x00]*[^\\s\\x00][^\\x00]*\\z")
Common parameters 12
PowerShell supplies these parameters. See common parameter behavior for their effects.
-
-Verbose(System.Management ) #.Automation .Switch Parameter Display verbose messages produced by this command.
Aliases:vbMicrosoft Learn reference -
-Debug(System.Management ) #.Automation .Switch Parameter Display debug messages produced by this command.
Aliases:dbMicrosoft Learn reference -
-ErrorAction(System.Management ) #.Automation .Action Preference Choose how this command responds to non-terminating errors.
Aliases:eaMicrosoft Learn reference -
-WarningAction(System.Management ) #.Automation .Action Preference Choose how this command responds to warning messages.
Aliases:waMicrosoft Learn reference -
-InformationAction(System.Management ) #.Automation .Action Preference Choose how this command handles information messages.
Aliases:infaMicrosoft Learn reference -
-ProgressAction(System.Management ) #.Automation .Action Preference Choose how this command handles progress updates.
Aliases:progaMicrosoft Learn reference -
-ErrorVariable(System.String ) #Store the command's error records in the named variable.
Aliases:evMicrosoft Learn reference -
-WarningVariable(System.String ) #Store the command's warning records in the named variable.
Aliases:wvMicrosoft Learn reference -
-InformationVariable(System.String ) #Store the command's information records in the named variable.
Aliases:ivMicrosoft Learn reference -
-OutVariable(System.String ) #Save output in the named variable while passing it down the pipeline.
Aliases:ovMicrosoft Learn reference -
Buffer output before passing it to the next pipeline command.
Aliases:obMicrosoft Learn reference -
-PipelineVariable(System.String ) #Make the most recent output object available through a named variable within the pipeline.
Aliases:pvMicrosoft Learn reference
-
- Returns
-
LibTmux.TmuxEvent: Native output, notification, loss, pane-gone or exit events.
Discussed in Getting started , Watch events and use runspaces · Watching output and state , Ownership and cleanup