iTerm2 Build 3.0.13 show current hostname/IP of a server

4,005 views
Skip to first unread message

Kaushal Shriyan

unread,
Jan 9, 2017, 10:47:47 AM1/9/17
to iterm2-discuss
Hi,

I am using iTerm2 Build 3.0.13 on macos sierra 10.12.2. I usually have more than 15 tabs at a given point in time. Is there a way to display in bold colour to show the server hostname/IP which i am currently working on. something like pop up.... just to be sure that i am working on the right server for example on server A running commands like for example "service httpd status/restart/stop/start.... and so on and so forth so that i do not accidentally run the same command on a different server(for example server B)

Please let me know if i am not clear in my explanation.

Regards,

Kaushal


Kaushal Shriyan

unread,
Jan 11, 2017, 9:29:20 AM1/11/17
to iterm2-discuss
Hi,

I will appreciate if anyone can pitch in for my earlier question to this google group.

Thanks in Advance.

Regards,

Kaushal 

George Nachman

unread,
Jan 14, 2017, 1:53:05 PM1/14/17
to iterm2-...@googlegroups.com
Sorry for the slow response. I think badges are probably the feature you're looking for. https://www.iterm2.com/documentation-badges.html


--
You received this message because you are subscribed to the Google Groups "iterm2-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to iterm2-discuss+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Kaushal Shriyan

unread,
Jan 16, 2017, 1:31:47 PM1/16/17
to iterm2-discuss, gnac...@llamas.org


Hi George,

I have the below setup in .bash_profile

# This will set your window title
export PROMPT_COMMAND='echo -ne "\033]0;${PWD##*/}\007"'

source ~/.iterm2_shell_integration.`basename $SHELL`

test -e "${HOME}/.iterm2_shell_integration.bash" && source "${HOME}/.iterm2_shell_integration.bash"
 
and i have set Badge :- \(session.username)@\(session.hostname) in Iterm2 profiles. The issue is that when i login to the remote server, i do not see the remote hostname (for example tomcat01.testchat.com) that appears in the top right of a terminal session instead i see kaushal...@kaushalshriyan.Home which is my laptop desktop name.

Any help will be highly appreciable. Thanks in Advance

Regards,

Kaushal


On Wed, Jan 11, 2017 at 6:29 AM, Kaushal Shriyan <kaushal...@gmail.com> wrote:


On Monday, 9 January 2017 21:17:47 UTC+5:30, Kaushal Shriyan wrote:
Hi,

I am using iTerm2 Build 3.0.13 on macos sierra 10.12.2. I usually have more than 15 tabs at a given point in time. Is there a way to display in bold colour to show the server hostname/IP which i am currently working on. something like pop up.... just to be sure that i am working on the right server for example on server A running commands like for example "service httpd status/restart/stop/start.... and so on and so forth so that i do not accidentally run the same command on a different server(for example server B)

Please let me know if i am not clear in my explanation.

Regards,

Kaushal

Hi,

I will appreciate if anyone can pitch in for my earlier question to this google group.

Thanks in Advance.

Regards,

Kaushal 

--
You received this message because you are subscribed to the Google Groups "iterm2-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to iterm2-discus...@googlegroups.com.

Kaushal Shriyan

unread,
Jan 18, 2017, 11:57:35 AM1/18/17
to iterm2-discuss, gnac...@llamas.org


On Tuesday, 17 January 2017 00:01:47 UTC+5:30, Kaushal Shriyan wrote:


Hi George,

I have the below setup in .bash_profile

# This will set your window title
export PROMPT_COMMAND='echo -ne "\033]0;${PWD##*/}\007"'

source ~/.iterm2_shell_integration.`basename $SHELL`

test -e "${HOME}/.iterm2_shell_integration.bash" && source "${HOME}/.iterm2_shell_integration.bash"
 
and i have set Badge :- \(session.username)@\(session.hostname) in Iterm2 profiles. The issue is that when i login to the remote server, i do not see the remote hostname (for example tomcat01.testchat.com) that appears in the top right of a terminal session instead i see kaushalshriyan@kaushalshriyan.Home which is my laptop desktop name.

Any help will be highly appreciable. Thanks in Advance

Regards,

Kaushal


Hi,

Thanks for the reply and I have the below setup in .bash_profile

# This will set your window title
export PROMPT_COMMAND='echo -ne "\033]0;${PWD##*/}\007"'

source ~/.iterm2_shell_integration.`basename $SHELL`

test -e "${HOME}/.iterm2_shell_integration.bash" && source "${HOME}/.iterm2_shell_integration.bash"
 
and i have set Badge :- \(session.username)@\(session.hostname) in Iterm2 profiles. The issue is that when i login to the remote server, i do not see the remote hostname (for example tomcat01.testchat.com) that appears in the top right of a terminal session instead i see kaushalshriyan@kaushalshriyan.Home which is my laptop desktop name.

Any help will be highly appreciable and once again thanks in Advance. 

Regards,

Kaushal 

George Nachman

unread,
Jan 18, 2017, 1:02:58 PM1/18/17
to iterm2-...@googlegroups.com
Do you have this set up in the remote host as well, or only locally? You must load shell integration on every host you log in to, or else set up triggers to emulate the shell integration scripts as described here: https://www.iterm2.com/documentation-shell-integration.html

To unsubscribe from this group and stop receiving emails from it, send an email to iterm2-discuss+unsubscribe@googlegroups.com.

Kaushal Shriyan

unread,
Jan 19, 2017, 2:14:53 PM1/19/17
to iterm2-discuss, gnac...@llamas.org


On Wednesday, 18 January 2017 23:32:58 UTC+5:30, George Nachman wrote:
Do you have this set up in the remote host as well, or only locally? You must load shell integration on every host you log in to, or else set up triggers to emulate the shell integration scripts as described here: https://www.iterm2.com/documentation-shell-integration.html

Hi George,

Thanks a lot and it is working as expected using shell integration. The only challenge is i have to set it for more than 300 servers. I did used the triggers to emulate the shell integration scripts

Triggers

Regular expresssions                 Action                              Parameters             Instant

^(\w+)@([\w.]+):.+%                  Report User & Host           `user@host`            Checkbox ticked.

when i login to the remote server, i do not see the remote hostname (for example tomcat01.testchat.com) that appears in the top right of a terminal session.

Any help will be highly appreciable. Thanks in Advance. Please let me know if the above settings for triggers is incorrect.

George Nachman

unread,
Jan 19, 2017, 6:11:35 PM1/19/17
to iterm2-...@googlegroups.com
Given your regex I'd expect the Parameters column to have a value like:

\1@\2

That'll substitute the username and hostname you captured in the regular expression.

A few debugging tips:

1. Ensure your trigger is firing by changing it to an Alert trigger
2. You can get useful debugging info about automatic profile switching by creating a debug log. Select iTerm2 > Toggle Debug Logging to begin debug logging, then log into a remote host, then select the same menu item to disable debug logging. Next, do:

grep -i automatic /tmp/debuglog.txt

It'll tell you what it thinks the current hostname and username are in lines like:

1483862997.033284 iTermAutomaticProfileSwitcher.m:93 (-[iTermAutomaticProfileSwitcher setHostname:username:path:]): APS: hostname=iterm2.com, username=gnachman, path=/home/gnachman




To unsubscribe from this group and stop receiving emails from it, send an email to iterm2-discuss+unsubscribe@googlegroups.com.

Kaushal Shriyan

unread,
Jan 20, 2017, 2:02:24 PM1/20/17
to iterm2-discuss, gnac...@llamas.org


On Friday, 20 January 2017 04:41:35 UTC+5:30, George Nachman wrote:
Given your regex I'd expect the Parameters column to have a value like:

\1@\2

That'll substitute the username and hostname you captured in the regular expression.

A few debugging tips:

1. Ensure your trigger is firing by changing it to an Alert trigger
2. You can get useful debugging info about automatic profile switching by creating a debug log. Select iTerm2 > Toggle Debug Logging to begin debug logging, then log into a remote host, then select the same menu item to disable debug logging. Next, do:

grep -i automatic /tmp/debuglog.txt

It'll tell you what it thinks the current hostname and username are in lines like:

1483862997.033284 iTermAutomaticProfileSwitcher.m:93 (-[iTermAutomaticProfileSwitcher setHostname:username:path:]): APS: hostname=iterm2.com, username=gnachman, path=/home/gnachman



Hi George,

I did set the below triggers settings.

Triggers

Regular expresssions                 Action                              Parameters             Instant

^(\w+)@([\w.]+):.+%                  Report User & Host          \1@\2           Checkbox ticked.

Please find my pastebin here -> http://sprunge.us/VhFH 
I did grep -i automatic /tmp/debuglog.txt it did not returned anything. 

Please suggest. Thanks in Advance

Kaushal Shriyan

unread,
Jan 23, 2017, 10:06:43 AM1/23/17
to iterm2-discuss, gnac...@llamas.org


On Saturday, 21 January 2017 00:32:24 UTC+5:30, Kaushal Shriyan wrote:


On Friday, 20 January 2017 04:41:35 UTC+5:30, George Nachman wrote:
Given your regex I'd expect the Parameters column to have a value like:

\1@\2

That'll substitute the username and hostname you captured in the regular expression.

A few debugging tips:

1. Ensure your trigger is firing by changing it to an Alert trigger
2. You can get useful debugging info about automatic profile switching by creating a debug log. Select iTerm2 > Toggle Debug Logging to begin debug logging, then log into a remote host, then select the same menu item to disable debug logging. Next, do:

grep -i automatic /tmp/debuglog.txt

It'll tell you what it thinks the current hostname and username are in lines like:

1483862997.033284 iTermAutomaticProfileSwitcher.m:93 (-[iTermAutomaticProfileSwitcher setHostname:username:path:]): APS: hostname=iterm2.com, username=gnachman, path=/home/gnachman



Hi George,

I did set the below triggers settings.

Triggers

Regular expresssions                 Action                              Parameters             Instant

^(\w+)@([\w.]+):.+%                  Report User & Host          \1@\2           Checkbox ticked.

Please find my pastebin here -> http://sprunge.us/VhFH 
I did grep -i automatic /tmp/debuglog.txt it did not returned anything. 

Please suggest. Thanks in Advance

Regards,

Kaushal

Hi George,

I will appreciate if you get a chance to look at my issue. Please let me know if you need any configs related to iterm2.

George Nachman

unread,
Jan 27, 2017, 5:50:31 PM1/27/17
to iterm2-...@googlegroups.com
This looks right to me. If you're sure the regular expression is correct, please open an issue and include a debug log as described in the issue template. Go to https://iterm2.com/bugs to file an issue.


To unsubscribe from this group and stop receiving emails from it, send an email to iterm2-discuss+unsubscribe@googlegroups.com.

Kaushal Shriyan

unread,
Jan 31, 2017, 12:46:28 PM1/31/17
to iterm2-discuss, gnac...@llamas.org


On Saturday, 28 January 2017 04:20:31 UTC+5:30, George Nachman wrote:
This looks right to me. If you're sure the regular expression is correct, please open an issue and include a debug log as described in the issue template. Go to https://iterm2.com/bugs to file an issue.

Hi George


Regards,

Kaushal
Reply all
Reply to author
Forward
0 new messages