Detects whether the current shell is running under mosh or not.
It even works in a shell running inside tmux sessions, when attached from a mosh session.
Important
mosh 1.4+ now supports 24-bit color support (since October 2022) so you will probably no longer need this.
This project is archived, but is_mosh
would still work as designed.
You can either source the script or execute it as a sub-shell.
if is_mosh; then
echo 'running under mosh'
else
echo 'It is not under mosh'
fi
Try is_mosh -v
or is_mosh --verbose
to see messages printed to stdout (mosh
or not mosh
).
NOTE: pstree
and tmux 2.1+ are required (#1).
mosh
is awesome, but didn't support 24-bit true color until mosh 1.4.0.
I needed a way to detect and disable true color feature on mosh environments.
To see an example of vimrc to automatically turn on/off termguicolors, see my vimrc.
Please see a stackexchange thread for the discussion.
The MIT License (c) 2017-2020 Jongwook Choi (@wookayin)