* Use global:error[0] for most recent error
The current version use $error[0], which is for the module instead of the global status and is always $null, so the $lastExitCodeForPrompot is always $origLastExitCode (see https://github.com/starship/starship/issues/3485 for a related bug).
It should be replaced with $global:error[0]
Comments are also updated
* fix(pwsh): make Semantic PR bot happy
* fix(#3554): Print the command line argv on clap error
This is a very bare implementation that just prints the error
and then a note with the arguments passed, it does this manually
and doesn't use clap. I've also chosen to use `Vec`'s `Debug`
implementation instead of rolling my own one because I thought it was
good enough, but there might be a better way of doing all this.
Altogether, I think this will be very useful to help in the diagnostic
of other bugs :)
* fix(#3554): Print the command line argv on clap error
This is a very bare implementation that just prints the error
and then a note with the arguments passed, it does this manually
and doesn't use clap. I've also chosen to use `Vec`'s `Debug`
implementation instead of rolling my own one because I thought it was
good enough, but there might be a better way of doing all this.
Altogether, I think this will be very useful to help in the diagnostic
of other bugs :)
EDIT: removed `dbg!`, set it to exit always.
* correctness(exit): don't print argv / exit with error on help and
version error kinds
* fix: Avoid panicking when stdout/stderr closing unexpectedly
* refactor(cli): use `use_stderr` instead of manual match for error kinds
`clap` uses `use_stderr` to reliably check whether the error given is
actually an error coming from user input or rather a hint to display
other info (version, help, etc.)
Also reworded/moved a couple of comments so that they explain better
what is the thought process behind the code
* fix(status): Enable to convert from i64 to hex_status by casting instead of parsing status.
* Apply comment to src/context.rs
Co-authored-by: David Knaack <davidkna@users.noreply.github.com>
* Update README.md in configuration
Co-authored-by: David Knaack <davidkna@users.noreply.github.com>
In #1019 the undistract feature has been added to starship without
enabling it by default due to the system dependency on libdbus. With
recent versions of notify-rust the dependency is no longer required and
the feature can be enabled by default.
* fix: use e718 as the default of symbol in node configuration
* wip: change nodejs symbol in docs/config & add a nodejs symbol configuration in docs/presets
* wip: update CONTRIBUTING.md
* Allow customization of notification timeout
* Document new notification duration option
* Check for out-of-bounds timeout and correct it
* Implement ModuleConfig for u32
* Revert "Check for out-of-bounds timeout and correct it"
This reverts commit 52109ab5f7c336b55c81bccafb3adbfc81514553.
* Switch notification_timeout to u32
* Note notification_daemons might not honor timout
* Notification timeout defaults to daemon timeout
* Leave default value of notification_timeout blank in docs
The `$PWD` environment variable used by starship is not updated on startup by `elvish`. `elvish` also provides a separate `$pwd` variable that does get updated and seems to be be a better indicator for the current logical path.
* ci: Fix aws::expiration_date_set_from_file race
While aws::expiration_date_set_from_file will almost-always work
perfectly locally, it is theoretically possible for the thread running
the test to be scheduled away betwen writing the file with timing
information and then actually reading it, resulting in a
shorter-than-expected time appearing in the module. This can also happen
if the test triggers right at the very end of a second (e.g. at
10:45:47.999995).
This appears to actually happen sometimes on heavily-loaded GitHub
Actions runners. To fix this issue, we allow for up to a two-second
delay between when the file is written and when the test actually fires
(allowing "30m", "29m59s", and "29m58s" as possible values).
* Fix typo
* test: add mock method for absolute files
Signed-off-by: Harald Hoyer <harald@hoyer.xyz>
* feat(module): add a container indicator module
Adds a container type indicator, if inside a container,
detected via the presence of some marker files.
E.g. inside a podman container entered with `toolbox enter`
the prompt changes to the container name and version.
```
starship on container_rebased [$!] is 📦 v1.0.0 via 🦀 v1.56.1
❯ toolbox enter
starship on container_rebased [$!] is 📦 v1.0.0 via 🦀 v1.56.1
⬢ [fedora-toolbox:35] ❯
```
Signed-off-by: Harald Hoyer <harald@hoyer.xyz>
* feat(pwsh): Set STARSHIP_SHELL to pwsh ON PS >5
This is needed for the custom module to use the correct shell.
Closes #3376
* Update src/context.rs
Co-authored-by: David Knaack <davidkna@users.noreply.github.com>
Co-authored-by: David Knaack <davidkna@users.noreply.github.com>
* fix(pwsh): Avoid polluting the global function namespace
This is an alternative to #3386
* Review changes
* Move continuation prompt after setting starship env
* feat: add support for cmd
* add preprompt and precmd support
* add keymap support
* add info about minimum Clink version
* simplify escaping
* add handling for cmd custom commands
* add support for transient_prompt and transient_rprompt
* Revert 914057952508e81e20086fcb707ba2a0be85fdd3
This reverts commit "add support for transient_prompt and transient_rprompt"
* Apply suggestions from code review
* disable cmd shell custom commands
* any shell other than cmd can be used
* better error and correct script location
* move shell check in `map_no_escaping`
* feat: set a continuation prompt for supporting shells (#3134)
* docs: fixed wording of documentation
* fix: continuation prompt is now only set once
* fix(docs): fixed typo in advanced-config/README.md
Co-authored-by: Segev Finer <segev208@gmail.com>
* fix: update --continuation argument
Co-authored-by: David Knaack <davidkna@users.noreply.github.com>
* fix: updated continuation prompt
- PROMPT2 was fixed to be set only once in zsh.
- `continuation_symbol` and `continuation_format` were removed in
place of a single variable; `continuation_prompt`.
- The continuation prompt was moved out of the character module.
* fix: ran rustfmt
* docs: updated continuation prompt docs
Co-authored-by: Segev Finer <segev208@gmail.com>
Co-authored-by: David Knaack <davidkna@users.noreply.github.com>
* perf(git_status): tweak flags to omit extra info
`git status` can be prohibitively slow on some repos, so allow the
config to influence what flags are passed to git. For instance, if there
is no configured symbol for untracked files, tell git to omit them from
its output. This can easily result in a 2~10x speedup in many cases, but
requires the user to opt-in to hiding information from the prompt.
* docs(git_status): add ignore_submodules option
* feat: Experimental Windows path formatting via path_slash::PathBufExt
* Rework the slash path conversion into a real PR
* Add a test for convert_slash = false
* Attempt fixing CI failures
* Fix lint and fmt
* Fix docs/config/README.md getting messed up
* Rename convert_slash/from_slash
* Move convert_path_sep calls in tests
* Keep path_vec immutable
* Run rustfmt
* perf(rust): additionally check `rustup default` for faster result.
After checking directory overrides we were directly falling back to the
relatively slow call to `rustc --version`.
Inserting a call to `rustup default` leads to a quicker response.
* use `context.exec_cmd` instead of `create_command`
Previous code would render all components as empty, resulting
in an empty string even if min_time was 0. This adds a special
case which forces prompt to render "0ms"
When opening a directory as a file the intial open works, while
subsequent line-reads will fail with _is a directory_.
Since erroring line-reads were just skipped this lead to an
endless loop.
These need to be stored before calling any PowerShell function or executable.
Otherwise the values will be overwritten and cannot be properly restored
or passed to starship.
Fixes: #3315