1
Fork 0
mirror of https://github.com/RGBCube/ncc synced 2025-07-28 10:37:44 +00:00

nushell: add remote hostname to prompt if we are in ssh

This commit is contained in:
RGBCube 2025-07-17 03:38:46 +03:00
parent 34f1f5b383
commit 7446c09c73
Signed by: RGBCube
SSH key fingerprint: SHA256:CzqbPcfwt+GxFYNnFVCqoN5Itn4YFrshg1TrnACpA5M

View file

@ -185,13 +185,25 @@ do --env {
""
}
let hostname = if ($env.SSH_CONNECTION? | is-not-empty) {
let hostname = try {
hostname
} catch {
"remote"
}
$"(ansi light_green_bold)@($hostname)(ansi reset) "
} else {
""
}
let body = if ($jj_workspace_root | is-not-empty) {
let subpath = pwd | path relative-to $jj_workspace_root
let subpath = if ($subpath | is-not-empty) {
$"(ansi magenta_bold) → (ansi reset)(ansi blue)($subpath)"
}
$"(ansi light_yellow_bold)($jj_workspace_root | path basename)($subpath)(ansi reset)"
$"($hostname)(ansi light_yellow_bold)($jj_workspace_root | path basename)($subpath)(ansi reset)"
} else {
let pwd = if (pwd | str starts-with $env.HOME) {
"~" | path join (pwd | path relative-to $env.HOME)
@ -199,7 +211,7 @@ do --env {
pwd
}
$"(ansi cyan)($pwd)(ansi reset)"
$"($hostname)(ansi cyan)($pwd)(ansi reset)"
}
let command_duration = ($env.CMD_DURATION_MS | into int) * 1ms