Skip to content

Detect whether the current shell is running under mosh

Notifications You must be signed in to change notification settings

wookayin/is_mosh

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 

Repository files navigation

is_mosh

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.

Usage

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).

Why did you make this?

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.

LICENSE

The MIT License (c) 2017-2020 Jongwook Choi (@wookayin)

About

Detect whether the current shell is running under mosh

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages