Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

5
  • 2
    doesn’t work in remote tmux sessions and also has issues if logged in via IPv6 and no DNS reverse name exists. Commented Feb 10, 2013 at 16:58
  • @bene: what doesn't work? The regular expression, or does who am i not show your IPv6 address? Commented Feb 10, 2013 at 19:08
  • 1) who am i doesn’t return anything in a remote tmux session. 2) IPv6 address might contain colons which your regex doesn’t allow. This might be tricky since who am i contains (:0.0) in X sessions for me (xterm). Commented Feb 11, 2013 at 15:05
  • @bene: The alternative solution which I just added should also work with IPv6. I don't know about tmux, but it does also work in screen. Commented Dec 15, 2013 at 14:54
  • 1
    I found it's easier to test with [[ $(pstree -s $$) = *sshd* ]] if the parent is a SSH connection. See here for details. Commented Nov 29, 2022 at 17:57