# LibTmux::Configuration::Hooks.set

- **Module:** LibTmux::Configuration
- **Package:** LibTmux
- **Language:** Raku
- **Kind:** method
- **Source:** https://github.com/libtmux/libtmux-raku/blob/0b5dd3d32e20f83a0069874e33eab0eb48f55962/lib/LibTmux/Configuration.rakumod#L494
- **Page:** https://libtmux.org/en/raku/latest/reference/libtmux-configuration-hooks-set/

```
method set(Str:D $name, Invocation:D $command, Count:D :$index = 0 --> Result:D)
```

Set one hook index to a validated tmux command; the command is deferred.

Set one hook index to a validated tmux command; the command is deferred.

## Parameters

- `$name` (`Str:D`)
- `$command` (`Invocation:D`)
- `$index?` (`Count:D`)

## tmux command

The tmux commands behind `set`.

- [`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 global hook

| Language | Equivalent |
| --- | --- |
| Python | [`libtmux.Server.set_hook`](/en/py/latest/reference/libtmux-server-set_hook/) (method) |
| Lua | [`libtmux.Server:set_hook`](/en/lua/latest/reference/libtmux-server-set_hook/) (method) |
| Haskell | No public Haskell equivalent is implemented; the current modules expose scalar values and version parsing. |
| TypeScript | [`server.Server.setHook`](/en/ts/latest/reference/server-server-sethook/) (method) |
| Rust | [`server.Server.set_hook`](/en/rs/latest/reference/server-server-set_hook/) (method) |
| Go | no equivalent on `Server` |
| Java | reached through `Server.hooks`, whose `Hooks` carries the write |
| C# | reached through `Server.Hooks`, whose `TmuxHooks` carries the write |
| C++ | no equivalent on `Server` |
| Swift | [`Server.setHook(_:to:at:in:)`](/en/swift/latest/reference/server-sethook(_-to-at-in-)/) (method) |
| OCaml | [`Libtmux_unix.Client.set_hook`](/en/ocaml/latest/reference/libtmux_unix-client-set_hook/) (function) |
| Perl | [`LibTmux::Server::set_hook`](/en/perl/latest/reference/libtmux-server-set_hook/) (method). Use global => true; command is an explicit native tmux command string. |

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

Bind a command to a session hook

| Language | Equivalent |
| --- | --- |
| Python | [`libtmux.Session.set_hook`](/en/py/latest/reference/libtmux-session-set_hook/) (method) |
| Lua | [`libtmux.Session:set_hook`](/en/lua/latest/reference/libtmux-session-set_hook/) (method) |
| Haskell | No public Haskell equivalent is implemented; the current modules expose scalar values and version parsing. |
| 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) |
| OCaml | [`Libtmux_unix.Client.set_hook`](/en/ocaml/latest/reference/libtmux_unix-client-set_hook/) (function) |
| Perl | [`LibTmux::Server::set_hook`](/en/perl/latest/reference/libtmux-server-set_hook/) (method). Use an explicit session target ID; command is an explicit native tmux command string. |

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

Bind a command to a window hook

| Language | Equivalent |
| --- | --- |
| Python | [`libtmux.Window.set_hook`](/en/py/latest/reference/libtmux-window-set_hook/) (method) |
| Lua | [`libtmux.Window:set_hook`](/en/lua/latest/reference/libtmux-window-set_hook/) (method) |
| Haskell | No public Haskell equivalent is implemented; the current modules expose scalar values and version parsing. |
| TypeScript | [`window.Window.setHook`](/en/ts/latest/reference/window-window-sethook/) (method) |
| Rust | [`window.Window.set_hook`](/en/rs/latest/reference/window-window-set_hook/) (method) |
| Go | [`tmux.Window.SetHook`](/en/go/latest/reference/tmux-window-sethook/) (method) |
| Java | reached through `Window.hooks`, whose `Hooks` carries the write |
| C# | reached through `Window.Hooks`, whose `TmuxHooks` carries the write |
| C++ | no equivalent on `Window` |
| Swift | [`Server.setHook(_:to:at:in:)`](/en/swift/latest/reference/server-sethook(_-to-at-in-)/) (method) |
| OCaml | [`Libtmux_unix.Client.set_hook`](/en/ocaml/latest/reference/libtmux_unix-client-set_hook/) (function) |
| Perl | No dedicated equivalent in the selected Perl surface. Explicit Server::cmd remains available for native tmux commands. |

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

Bind a command to a pane hook

| Language | Equivalent |
| --- | --- |
| Python | [`libtmux.Pane.set_hook`](/en/py/latest/reference/libtmux-pane-set_hook/) (method) |
| Lua | [`libtmux.Pane:set_hook`](/en/lua/latest/reference/libtmux-pane-set_hook/) (method) |
| Haskell | No public Haskell equivalent is implemented; the current modules expose scalar values and version parsing. |
| TypeScript | [`pane.Pane.setHook`](/en/ts/latest/reference/pane-pane-sethook/) (method) |
| Rust | [`pane.Pane.set_hook`](/en/rs/latest/reference/pane-pane-set_hook/) (method) |
| Go | [`tmux.Pane.SetHook`](/en/go/latest/reference/tmux-pane-sethook/) (method) |
| Java | reached through `Pane.hooks`, whose `Hooks` carries the write |
| C# | reached through `Pane.Hooks`, whose `TmuxHooks` carries the write |
| C++ | no equivalent on `Pane` |
| Swift | [`Server.setHook(_:to:at:in:)`](/en/swift/latest/reference/server-sethook(_-to-at-in-)/) (method) |
| OCaml | [`Libtmux_unix.Client.set_hook`](/en/ocaml/latest/reference/libtmux_unix-client-set_hook/) (function) |
| Perl | No dedicated equivalent in the selected Perl surface. Explicit Server::cmd remains available for native tmux commands. |

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