* add `set_config` method to `Context`
* Made inline comment a doc comment
* use `default_context()` for `set_config()` test
* use `set_config()` in tests for `print.rs`
* set root config w `set_config()` (`print.rs` test)
* Move PathExt::device_id() outside modules module
* Add upwards_sibling_scan-function
* Fix Fossil check-out detection in subdirectories
* Use shared upwards scanning function in hg_branch
* Let the caller specify if they're looking for a file or a folder
* fix merge
---------
Co-authored-by: David Knaack <davidkna@users.noreply.github.com>
* feat: Pijul VCS support
* Extra bits needed for new module.
* Format Markdown table.
* Fix lint.
* Don't test Pijul module so thoroughly.
Installing from source is too expensive, and compiled binaries are only
available for Windows (and unofficially as well). Perhaps once Pijul
1.0.0 comes out of beta there will be more binaries available in package
repos.
* Format!
* Bad rebase, remove Pijul install from workflow.
* Mock Pijul commands for code coverage.
* Make fake .pijul directory in fixture.
* Truly mock `pijul` command.
* Rename module from `pijul` to `pijul_channel`.
* Format!
* Fix config-schema.json.
* Missed changing module name in docs/ folder.
* refactor: replace module_config_derive with serde
Changes include:
* Removing `starship_module_config_derive` and replacing it with `serde::Deserialize`
* Removing `RootModuleConfig::load_config`. While potentially useful, it was only used in tests. And it would require something like `serde::DeserializeSeed` which is not derived by serde.
* Merging `RootModuleConfig` into `ModuleConfig`
* Implementing a `ValueDeserializer` that holds a reference to a `toml::Value` in `serde_utils.rs`
* Deserialization errors (invalid type) are now logged and include the current key and the struct names
* Unknown keys are now considered an error. "Did you mean?"-messages are still possible
* fix typo
Co-authored-by: Matan Kushner <hello@matchai.dev>
Co-authored-by: Matan Kushner <hello@matchai.dev>
* 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>
* 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: Add pipestatus display in status module
This MR is based on this one https://github.com/starship/starship/pull/370
* Documentation
* Add a test with map_symbol false
* Handle bash preexec pipestatus
* Add zsh support
* Add fish support
Thanks kidonng for the diff patch
* Rename sucess_symbol to success_symbol
On Windows when running commands with their name instead of the path with Command::new, executable with that name from the current working directory will be executed.
This PR replaces all instances of Command::new with a new create_command function which will first resolve any executable paths and avoid this issue.
* refactor(directory): Introduce `logical-path` argument which allows a shell to explicitly specify both a logical and physical filesystem path
Fix `directory::module` to consume both path and logical-path (if provided). The "logical" path is preferred when rendering the "display path", while the "physical" path is used to resolve the "read only" flag. Repo- and home-directory contraction behavior is maintained, based on the logical path if it is set, or the physical path if it is not.
The custom "get_current_dir" logic has been removed entirely, and the `directory` module now relies on `context.current_dir` / `context.logical_dir` entirely.
Changes have been made to `init/starship.ps1` to work with this new flag:
- Calculate and pass "physical" and "logical" paths explicitly (as other shells do not pass `--logical-path` that they fall back to rendering the physical path)
- Moved the "powershell provider prefix" cleanup code to the PowerShell script - this code _should_ now support any kind of powershell path prefix.
* fix(powershell): Fix an issue with trailing backslashes on file paths causing command line parsing issues.
This is a bit of a footgun!
The work-around chosen is to append a trailing space when a path string ends with a backslash, and then trim any extra whitespace away in the Context constructor.
Other alternatives considered and rejected:
1. Always trim trailing backslashes as the filesystem generally doesn't need them.
2. Escape trailing backslashes with another backslash. This proved complex as PS only quotes string args when the string includes some whitespace, and other backslashes within the string apparently don't need to be escaped.
* fix(powershell): Use Invoke-Native pattern for safely invoking native executables with strings which may contain characters which need to be escaped carefully.
* fix(context): Remove superfluous argument trims
These were in place to clean up extra whitespace sometimes injected by starship.ps1::prompt, and are no longer required with the new Invoke-Native helper in place.
* refactor(directory): Clean up the semantics of `logical_dir` defaulting it to `current_dir` but overridable by the `--logical-dir` flag.
- Restore `use_logical_path` config flag.
- Always attempt to contract repo paths from the `current_dir`.
* fix(directory) :Use logical_dir for contracting the home directory
This keeps the two calls to contract_path in sync.
* fix(directory): Remove test script
* refactor(directory): Convert current_dir to canonical filesystem path when use_logical_path = false
- This requires some clean-up to remove the extended-path prefix on Windows
- The configured logical_dir is ignored entirely in this mode - we calculate a new logical_dir by cleaning up the physical_dir path for display.
- Test coverage
* fix(directory): Use AsRef style for passing Path arguments
* fix(directory): Strip the windows extended-path prefix from the display string later in the render process
* fix(docs): Update docs/config/README.md for use_logical_path
* refactor(context): Populate `current_dir` from `--path` or `std::env::current_dir`, populate `logical_dir` from `--logical-path` or the `PWD` env var
- `current_dir` is always canonicalized
- On Windows, `current_dir` will have an extended-path prefix
- `logical_dir` is now always set
- `directory::module` now just selects between `current_dir` and `logical_dir` when picking which path to render
- Test coverage
* fix(directory): Fix path comparison operations in directory to ignore differences between path prefixes
- Added PathExt extension trait which adds `normalised_equals`, `normalised_starts_with` and `without_prefix`
* fix(path): Add test coverage for PathExt on *nix
* fix(directory): Test coverage for `contract_repo_path`, `contract_path` with variations of verbatim and non-verbatim paths
* fix(directory): Update path-slash to latest
This fixes the issue with the trailing character of some Windows paths being truncated, e.g. `\\server\share` and `C:`
* fix(powershell): Improve UTF8 output handling, argument encoding
- Use `ProcessStartInfo` to launch native executable, replacing manual UTF8 output encoding handling
- If we detect we're on PWSH6+ use the new `System.Diagnostics.ProcessStartInfo.ArgumentList` parameter, otherwise manually escape the argument string
- Move `Get-Cwd` and `Invoke-Native` into the prompt function scope so that they don't leak into the user's shell scope
* fix(path): Make PathExt methods no-ops on *nix
* fix(path): Cargo fmt
* fix(powershell): Remove typo ';'. Fix variable assignment lint.
* feat: Add computational duration to all computed modules
This also means that in case we do some computations and these end up empty, we submit an empty module
* feat: Add timings subcommand
This outputs the timings of all computed modules, sorted by the duration it took to compute the module.
Useful for debugging why the prompt takes so long.
* feat: Add timings to explain output
* fix: Ensure that even empty custom modules get timings
* format main.rs
* feat: Only show interesting timings
* fix(tests): Change tests to look for empty string instead of None
* Use proper wording in timings help
* Revert "fix(tests): Change tests to look for empty string instead of None"
This reverts commit aca5bd1b03c48e1dee1b7ca91d66e2bda2d5a97c.
* fix(tests): Returning None in case the module produced an empty string
* fix: Ensure that linebreaks (and space) make a module not-empty
* Make cargo clippy happy
* Make Module.duration a proper Duration
* Only return a module if we would report it
* Change to cleaner way to return None for empty modules
* Avoid unnecessary module creation
* Simplify a string comparison
* Add timings to trace
Co-authored-by: Thomas O'Donnell <andytom@users.noreply.github.com>
Co-authored-by: Thomas O'Donnell <andytom@users.noreply.github.com>