nushell

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

starship.nu (2334B)


      1 # this file is both a valid
      2 # - overlay which can be loaded with `overlay use starship.nu`
      3 # - module which can be used with `use starship.nu`
      4 # - script which can be used with `source starship.nu`
      5 export-env { $env.STARSHIP_SHELL = "nu"; load-env {
      6     STARSHIP_SESSION_KEY: (random chars -l 16)
      7     PROMPT_MULTILINE_INDICATOR: (
      8         ^'C:\Program Files\starship\bin\starship.exe' prompt --continuation
      9     )
     10 
     11     # Does not play well with default character module.
     12     # TODO: Also Use starship vi mode indicators?
     13     PROMPT_INDICATOR: ""
     14 
     15     PROMPT_COMMAND: {||
     16         (
     17             # The initial value of `$env.CMD_DURATION_MS` is always `0823`, which is an official setting.
     18             # See https://github.com/nushell/nushell/discussions/6402#discussioncomment-3466687.
     19             let cmd_duration = if $env.CMD_DURATION_MS == "0823" { 0 } else { $env.CMD_DURATION_MS };
     20             ^'C:\Program Files\starship\bin\starship.exe' prompt
     21                 --cmd-duration $cmd_duration
     22                 $"--status=($env.LAST_EXIT_CODE)"
     23                 --terminal-width (term size).columns
     24                 ...(
     25                     if (which "job list" | where type == built-in | is-not-empty) {
     26                         ["--jobs", (job list | length)]
     27                     } else {
     28                         []
     29                     }
     30                 )
     31         )
     32     }
     33 
     34     config: ($env.config? | default {} | merge {
     35         render_right_prompt_on_last_line: true
     36     })
     37 
     38     PROMPT_COMMAND_RIGHT: {||
     39         (
     40             # The initial value of `$env.CMD_DURATION_MS` is always `0823`, which is an official setting.
     41             # See https://github.com/nushell/nushell/discussions/6402#discussioncomment-3466687.
     42             let cmd_duration = if $env.CMD_DURATION_MS == "0823" { 0 } else { $env.CMD_DURATION_MS };
     43             ^'C:\Program Files\starship\bin\starship.exe' prompt
     44                 --right
     45                 --cmd-duration $cmd_duration
     46                 $"--status=($env.LAST_EXIT_CODE)"
     47                 --terminal-width (term size).columns
     48                 ...(
     49                     if (which "job list" | where type == built-in | is-not-empty) {
     50                         ["--jobs", (job list | length)]
     51                     } else {
     52                         []
     53                     }
     54                 )
     55         )
     56     }
     57 }}