# server.Server.setHook

- **Module:** server.Server
- **Package:** @libtmux/libtmux
- **Language:** TypeScript
- **Kind:** method
- **Source:** https://github.com/libtmux/libtmux-ts/blob/2cb93308200da38a26b59876618116850f110607/packages/libtmux/src/server.ts#L647
- **Page:** https://libtmux.org/reference/ts/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 });
```
