Badge does not appear in iterm2 after logging to remote GCP GCE VM Instance.

61 बार देखा गया
नहीं पढ़े गए पहले मैसेज पर जाएं

Kaushal Shriyan

नहीं पढ़ी गई,
19 नव॰ 2022, 6:15:48 am19/11/22
ईमेल पाने वाला iterm2-discuss
Hi,

I have the below server hosted in GCP ( Google Cloud Platform) https://cloud.google.com/compute/docs/instances

$gcloud compute ssh jenkins-test to login to the remote server I get the below prompt

[kaushal@jenkins-test ~]$

[kaushal@jenkins-test ~]$ hostname
jenkins-test
[kaushal@jenkins-test ~]$
I have set badge and trigger to display text label that appears in the top right of a terminal session to provide dynamic status the current host name

Badge
\(session.username)@\(session.hostname)

Trigger
^\[(\w+)@(\w+) [~\w_.-]+\]\$    Report User & Host     \1@\2
^\[(\w+)@(\w+) [~\w_.-]+\]#    Report User & Host      \1@\2
^(\w+)@([\w]+):[\w+~_/]+\$    Report User & Host      \1@\2

But I do not see the badge as kaushal@jenkins-test appearing when i login using the below gcloud command

$gcloud compute ssh jenkins-test

Please guide me. Am I missing anything? Thanks in Advance.

Best Regards,

Kaushal

Adrian Bool

नहीं पढ़ी गई,
19 नव॰ 2022, 8:55:28 am19/11/22
ईमेल पाने वाला iterm2-discuss
Hi Kaushal,

It may be down the hostname of your GCP server.

Your regex is trying to match the hostname with \w+ (one or more word characters) but the '-' in 'jenkins-test' isn't counted as a word character; so no match:

>>> re.match(r'^\w+$', 'jenkins')
<re.Match object; span=(0, 7), match='jenkins'>
>>> re.match(r'^\w+$', 'jenkins-test')
>>>

Try a trigger of:

^\[(\S+)@(\S+) .*\]    Report User & Host     \1@\2


This seems to match your prompt:

>>> match = re.match(r'^\[(\S+)@(\S+) .*\]', '[kaushal@jenkins-test ~]')
>>> match.group(0)
'[kaushal@jenkins-test ~]'
>>> match.group(1)
'kaushal'
>>> match.group(2)
'jenkins-test'


Good luck!

aid


--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/iterm2-discuss/45ed4f69-b7a4-4f71-aa68-4c50f360970bn%40googlegroups.com.

Kaushal Shriyan

नहीं पढ़ी गई,
19 नव॰ 2022, 11:33:14 am19/11/22
ईमेल पाने वाला iterm2-discuss
On Saturday, 19 November 2022 at 19:25:28 UTC+5:30 a...@logic.org.uk wrote:
Hi Kaushal,

It may be down the hostname of your GCP server.

Your regex is trying to match the hostname with \w+ (one or more word characters) but the '-' in 'jenkins-test' isn't counted as a word character; so no match:

>>> re.match(r'^\w+$', 'jenkins')
<re.Match object; span=(0, 7), match='jenkins'>
>>> re.match(r'^\w+$', 'jenkins-test')
>>>

Try a trigger of:

^\[(\S+)@(\S+) .*\]    Report User & Host     \1@\2


This seems to match your prompt:

>>> match = re.match(r'^\[(\S+)@(\S+) .*\]', '[kaushal@jenkins-test ~]')
>>> match.group(0)
'[kaushal@jenkins-test ~]'
>>> match.group(1)
'kaushal'
>>> match.group(2)
'jenkins-test'


Good luck!

aid


Thanks a lot aid and it worked perfectly. Appreciate it.

Best Regards,

Kaushal

Adrian Bool

नहीं पढ़ी गई,
20 नव॰ 2022, 10:50:07 am20/11/22
ईमेल पाने वाला iterm2-discuss

Hi,


Here's an updated regex that should match on username, hostname and directory for a number of different hosts/shells:

^\[?(\w+)@([\w\d-]+)[:\s]([\w~/ ]*[\w~/]+)\]?(?:\s%|\s#|\$|#)\s

(If you're using it for Report Directory; be sure to use "\3" as the substitution.)

I've created some test cases for it; which is now sitting on github at:


Cheers,

aid
सभी प्रषकों को उत्तर दें
लेखक को उत्तर दें
आगे भेजें
0 नया मैसेज