From f0df02e997dec212228f507179b17ef847425087 Mon Sep 17 00:00:00 2001 From: everpcpc Date: Tue, 25 Apr 2023 12:58:48 +0800 Subject: [PATCH] fix(cli): use first two segments of domain for prompt --- cli/src/session.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/cli/src/session.rs b/cli/src/session.rs index c47872b8e..880819fec 100644 --- a/cli/src/session.rs +++ b/cli/src/session.rs @@ -60,7 +60,13 @@ impl Session { let mut prompt = settings.prompt.clone(); { - prompt = prompt.replace("{host}", &info.host); + let tokens = info.host.split('.').collect::>(); + let host = if tokens.len() >= 2 { + tokens[..2].join(".") + } else { + info.host + }; + prompt = prompt.replace("{host}", &host); prompt = prompt.replace("{user}", &info.user); prompt = prompt.replace("{port}", &info.port.to_string()); }