Core LibraryunreleasedGuides

Choose documentation 1

latest

Current version

latest
English

Unreleased libtmux-haskell has not been released. Its API may change during development. This site's structure and URLs may change too.

MoreLess about this notice

Read and change options and hooks

Needs libtmux for Haskell unreleased Install

Set a local history limit with setOption and read it with readOption. Register one indexed rename hook with setHook, inspect its definition with readHook, then observe its effect.

Run from a provisioned checkout.

Terminal window
$ cabal run --verbose=0 configure-session
local history-limit = 500
rename hook recorded the change

Select a store

StoreTarget
ServerServerOptions
Session defaultGlobalSessionOptions
Exact sessionSessionOptionsAt session
Window defaultGlobalWindowOptions
Physical windowWindowOptionsAt window
Exact panePaneOptionsAt pane

LocalOption reads the selected store. EffectiveOption includes native inheritance. An empty StringValue and an absent value are distinct. unsetOption removes an override or resets a built-in global value. User options use an at sign followed by ASCII letters, digits, hyphens, underscores or dots. Their values remain literal bytes and cannot contain NUL.

Built-in scalar operations use definitions from the pinned releases, from 3.3a through 3.8. An incompatible scope or kind raises InvalidSetting before dispatch. tmux checks its own value constraints. Option arrays are listed in the catalogue. Their mutation APIs remain open.

Hooks use session, window or pane stores according to the event’s native scope. setHook replaces one numeric entry. tmux parses its command source when registering it. readHook returns the local native listing, keeping keys and line endings. unsetHook clears the local override. Custom hook operations and writing named keys remain open.

Reads are bounded to 64 KiB. A failed after-hook raises SettingReadHookFailed; the reader does not use hook output as a value. See mutation recovery for command outcomes and deadlines.

Find a built-in name

Use serverCapabilities to read the version of the daemon you opened. Pass those capabilities to lookupOption or lookupHook. Use the full native name, such as history-limit or after-new-session. The creation example prints the option’s value kind and the hook’s scope.

knownOptions lists names, types, supported scopes, array shape and named choices. knownHooks lists events and their scopes. Both report when each entry became available within the pinned releases.

The catalogue selects the latest pinned table at or below the daemon’s reported release. The pins span tmux 3.3a through 3.8. Entries already available at 3.3a report that release as their first qualified version. A newer daemon can have additional entries. See the tmux source pins and table digests.

Complete program

{-# LANGUAGE OverloadedRecordDot #-}
{-# LANGUAGE OverloadedStrings #-}
module Main (main) where
import Control.Exception (bracket)
import Control.Monad (unless)
import LibTmux qualified as Tmux
import LibTmux.Creation qualified as Creation
import System.Exit (die)
main :: IO ()
main = do
let options = Creation.defaultSessionOptions {Creation.process = Creation.ShellCommand "exec /bin/cat"}
Tmux.withOwnedServer Tmux.defaultOwnedServerConfig $ \server ->
bracket (Tmux.createSession server options) (Tmux.killSession server . (.session)) $ \created -> do
let local = Tmux.SessionOptionsAt created.session
event = "after-rename-window"
Tmux.setOption server local "history-limit" (Tmux.NumberValue 500)
stored <- Tmux.readOption server local Tmux.LocalOption "history-limit"
case stored of
Just (Tmux.NumberValue rows) -> putStrLn ("local history-limit = " <> show rows)
_ -> die "Expected a local numeric history limit"
Tmux.setHook server local event 0 "set-option @last-rename seen"
hook <- Tmux.readHook server local event
unless (hook == Just "after-rename-window[0] set-option @last-rename seen\n")
(die "Expected one entry in the local rename hook")
Tmux.renameWindow server created.window "review"
observed <- Tmux.readOption server local Tmux.LocalOption "@last-rename"
unless (observed == Just (Tmux.StringValue "seen")) (die "The rename hook did not run")
putStrLn "rename hook recorded the change"
Esc
Search in

Type to search.

Reference previewOpen reference