use std null_device export-env { load-env { PROMPT_COMMAND: {|| let exit_code = $env.LAST_EXIT_CODE let jj_root = try { ^jj root err> $null_device } catch { "" } $env.LAST_EXIT_CODE = 0 let vcs_root = if not ($jj_root | is-empty) { $jj_root } else { "" } mut path_segment = "" if not (($vcs_root | is-empty) or ($env.PWD == $vcs_root)) { # vcs_root is not empty, we're not in the vcs_root of the project $path_segment = [($vcs_root | path basename) ($env.PWD | path basename)] | str join " @ " } else { $path_segment = $env.PWD | path basename } let exit_code_segment = if ($exit_code == 0) { "" } else { $"(ansi yellow)━┫(ansi red)($exit_code)(ansi yellow)┣━" } [$"(ansi yellow)┏" $exit_code_segment "━ " $path_segment "\n"] | str join } TRANSIENT_PROMPT_COMMAND: {|| let path_segment = $env.PWD | path basename let exit_code_segment = if ($env.LAST_EXIT_CODE == 0) { "" } else { $"(ansi yellow)━┫(ansi red)($env.LAST_EXIT_CODE)(ansi yellow)┣━" } [$"(ansi yellow)━" $exit_code_segment "━ " $path_segment] | str join } PROMPT_INDICATOR_VI_INSERT: $"(ansi yellow)┃ " PROMPT_INDICATOR_VI_NORMAL: $"(ansi yellow)┋ " # PROMPT_MULTILINE_INDICATOR: "::: " PROMPT_MULTILINE_INDICATOR: $"(ansi yellow)┃ " TRANSIENT_PROMPT_INDICATOR_VI_INSERT: " " TRANSIENT_PROMPT_INDICATOR_VI_NORMAL: " " TRANSIENT_PROMPT_MULTILINE_INDICATOR: $"(ansi yellow)┃ " config: ( $env.config? | default {} | merge { render_right_prompt_on_last_line: true } ) PROMPT_COMMAND_RIGHT: {|| let jj_status = try { jj --quiet --color always --ignore-working-copy log --no-graph --revisions @ --template ' separate( " ", if(empty, label("empty", "(empty)")), coalesce( surround( "\"", "\"", if( description.first_line().substr(0, 24).starts_with(description.first_line()), description.first_line().substr(0, 24), description.first_line().substr(0, 23) ++ "…" ) ), label(if(empty, "empty"), description_placeholder) ), bookmarks.join(", "), change_id.shortest(), commit_id.shortest(), if(conflict, label("conflict", "(conflict)")), if(divergent, label("divergent prefix", "(divergent)")), if(hidden, label("hidden prefix", "(hidden)")), ) ' err> $null_device } catch { "" } $jj_status } } }