# libtmux.Server.show_hook

- **Module:** libtmux
- **Package:** libtmux
- **Language:** Python
- **Kind:** method
- **Source:** https://github.com/tmux-python/libtmux/blob/38e368c11117fb4aeb2f082d552cd4f210eae06a/src/libtmux/hooks.py#L371
- **Inherited from:** libtmux.hooks.HooksMixin
- **Page:** https://libtmux.org/en/py/stable/reference/libtmux-server-show_hook/

```
libtmux.Server.show_hook(
    self,
    hook: str,
    global_: bool = False,
    scope: OptionScope
    | _DefaultOptionScope
    | None = DEFAULT_OPTION_SCOPE,
) -> str | int | SparseArray[str] | None
```

Return value for a hook.

For array hooks (e.g., [`session-renamed`](/en/tmux/latest/catalog/hooks/session-renamed/)), returns a
:class:`~libtmux._internal.sparse_array.SparseArray` with hook values
at their original indices. Use ``.keys()`` for indices and ``.values()``
for values.

## Examples

```python
>>> session.set_hook('session-renamed[0]', 'display-message "test"')
Session($...)
```

```python
>>> hooks = session.show_hook('session-renamed')
>>> isinstance(hooks, SparseArray)
True
```

```python
>>> sorted(hooks.keys())
[0]
```

```python
>>> session.unset_hook('session-renamed')
Session($...)
```

## Parameters

- `hook` (`str`): Hook name to query
- `global_` (`bool`)
- `scope` (`OptionScope | _DefaultOptionScope | None`)

## Returns

str | int | SparseArray[str] | None
    Hook value. For array hooks, returns SparseArray.

## Raises

- [`exc.OptionError`](/en/py/stable/reference/libtmux-exc-optionerror/)
- [`exc.UnknownOption`](/en/py/stable/reference/libtmux-exc-unknownoption/)
- [`exc.InvalidOption`](/en/py/stable/reference/libtmux-exc-invalidoption/)
- [`exc.AmbiguousOption`](/en/py/stable/reference/libtmux-exc-ambiguousoption/)
