# session.Session.rename

- **Module:** session.Session
- **Package:** libtmux
- **Language:** Rust
- **Kind:** method
- **Source:** https://github.com/libtmux/libtmux-rs/blob/8a648c0894dfffc9303583f753b6c8ae01f2fe76/crates/libtmux/src/session.rs#L540
- **Page:** https://libtmux.org/reference/rs/session-session-rename/

```
session.Session.rename(mut, name: impl Into<OsString>) -> Result<&mut Self, Error>
```

Rename the session and update this handle.

# Errors

Returns an error when tmux refuses the name, which includes one that
is empty or already taken.
tmux expands the name as a format before it checks it, so `#(command)`
in one runs a shell command. See [the crate documentation][crate#a-name-reaches-tmux-as-a-format]
before passing text a caller supplied.
