# libtmux.options._unescape_user_option_value

- **Module:** libtmux.options
- **Package:** libtmux
- **Language:** Python
- **Kind:** function
- **Source:** https://github.com/tmux-python/libtmux/blob/efdbb5637666b166358772ecc737b3807beab21e/src/libtmux/options.py#L394
- **Page:** https://libtmux.org/en/py/latest/reference/libtmux-options-_unescape_user_option_value/

```
libtmux.options._unescape_user_option_value(raw: str) -> str
```

Decode a user-option value formatted by tmux ``args_escape`` (``#{q/a:...}``).

tmux formats string options in [`show-options`](/en/tmux/latest/manual/show-options/) through ``args_escape``
(``arguments.c``), which encodes tabs, newlines, backslashes, and control
bytes with ``utf8_strvis`` even when no outer quotes are added. Passing
unquoted ``a\nb`` to :func:`shlex.split` would strip the backslash and
return ``"anb"``.

In ``args_escape``, ``$`` is in ``dquoted``, so any multi-character value
containing ``$`` sets ``VIS_DQ`` and emits ``2k + 1`` (odd) backslashes
before ``$[A-Za-z_{]``. tmux 3.4's ``server_client_print`` omits ``VIS_DQ``
and adds one more backslash there (``2k + 2``, nonzero even); dropping one
backslash on an even run of length ``>= 2`` before ``$[A-Za-z_{]`` decodes
both losslessly.

## Parameters

- `raw` (`str`)

## Examples

```python
>>> _unescape_user_option_value("''")
''
>>> _unescape_user_option_value(r"a\nb")
'a\nb'
>>> _unescape_user_option_value('"both\\"and\'"')
'both"and\''
>>> _unescape_user_option_value(r'"\$HOME"')
'$HOME'
>>> _unescape_user_option_value(r'"\\$HOME"')
'$HOME'
>>> _unescape_user_option_value(r'"\\\$HOME"')
'\\$HOME'
>>> _unescape_user_option_value(r'"\\\\$HOME"')
'\\$HOME'
```
