# server.Server.setHook

- **Module:** server.Server
- **Package:** libtmux
- **Language:** TypeScript
- **Kind:** method
- **Source:** https://github.com/libtmux/libtmux-ts/blob/3fe1ca654b81b8cbf4a13b777a001a3298c87a6f/packages/libtmux/src/server.ts#L693
- **Page:** https://libtmux.org/en/ts/latest/reference/server-server-sethook/

```
server.Server.setHook(name: : string, command: : string, options: : SetHookOptions) -> Promise<void>
```

Bind a tmux command to a global hook.

A hook holds a list of commands. Without `append` this writes the whole
list, so it replaces whatever the hook already ran.

## Example

```ts
await server.setHook("session-created", "display-message 'hello'");
await server.setHook("session-created", "display-message 'and this'", { append: true });
```
