# libtmux.Session:set_hook

- **Module:** libtmux
- **Package:** libtmux
- **Language:** Lua
- **Kind:** method
- **Source:** https://github.com/libtmux/libtmux-lua/blob/d68f829fe097e38dcbbf7147e276666fe615f0cf/lua/libtmux/_internal/entity.lua#L411
- **Inherited from:** libtmux.Configurable
- **Page:** https://libtmux.org/en/lua/v0.1.1/reference/libtmux-session-set_hook/

```
set_hook: fun(
  self: libtmux.Configurable<libtmux.SnapshotSession>,
  name: string,
  value: libtmux.HookProgram,
  options?: libtmux.SettingSetOptions,
):libtmux.Request<boolean>
```

## Parameters

- `name` (`string`)
- `value` (`libtmux.HookProgram`)
- `options` (`libtmux.SettingSetOptions?`)

## tmux command

The tmux commands behind `set_hook`.

- [`set-hook`](/en/tmux/latest/manual/set-hook/)

## tmux C API

The C declarations in tmux that implement these commands.

- [`cmd_set_hook_entry`](/en/tmux/latest/reference/c-variable-cmd_set_hook_entry/) (attribute)
- [`cmd_set_option_exec`](/en/tmux/latest/reference/c-function-cmd-set-option-c-cmd_set_option_exec/) (function)

## tmux hooks

Events that run tmux commands, with the scope each hook belongs to and where tmux fires it.

- [Hooks](/en/tmux/latest/catalog/hooks/) (hook)

## In other ports

Bind a command to a session hook

| Language | Equivalent |
| --- | --- |
| Python | [`libtmux.Session.set_hook`](/en/py/latest/reference/libtmux-session-set_hook/) (method) |
| TypeScript | [`session.Session.setHook`](/en/ts/latest/reference/session-session-sethook/) (method) |
| Rust | [`session.Session.set_hook`](/en/rs/latest/reference/session-session-set_hook/) (method) |
| Go | [`tmux.Session.SetHook`](/en/go/latest/reference/tmux-session-sethook/) (method) |
| Java | reached through `Session.hooks`, whose `Hooks` carries the write |
| C# | reached through `Session.Hooks`, whose `TmuxHooks` carries the write |
| C++ | [`libtmux::Session::set_hook`](/en/cxx/latest/reference/libtmux-session-set_hook/) (method) |
| Swift | [`Server.setHook(_:to:at:in:)`](/en/swift/latest/reference/server-sethook(_-to-at-in-)/) (method) |

No equivalent is recorded in Ruby, PowerShell, Julia, Elixir, Kotlin, Scala or F#.
