Prevent hostname from showing up in local X sessions (#398)
Prevent hostname from showing up in local X sessions (#398)

* Prevent hostname from showing up in local X sessions

This change prevents the hostname from showing up when a terminal is
opened inside a local X session (displayed as (:1)).

Fixes a regression introduced in #393.

* Implement a more robust remote connection detection (who)

First, we switch from `who am i` to `who -m` because this is the POSIX
way and macOS supports it as well.

Second, if the above fails, we fall back to using just `who` and grep
the line that represents our TTY. This works e.g. with busybox systems.

Finally, we use (extremely) simplified regular expressions for detecting
IPv4, IPv6 and hostname. This is a best-effort attempt at detecting the
remote connections when SSH_CONNECTION is not set.

* Inherit SSH connection detection inside tmux or other subshells

* Store match and use upper case export for consistency

This will also help with debugging if a user ever runs into a problem
where the user/host is shown when it should not be:

	# typeset -p PROMPT_PURE_SSH_CONNECTION
	export PROMPT_PURE_SSH_CONNECTION='(::1)'

kgrz/pure,joshuarubin/dotfiles,joshuarubin/dotfiles,joshuarubin/dotfiles,forivall/pure,jaredru/zsh-pure,joshuarubin/dotfiles,sindresorhus/pure