* test that we can match a multi-part file extension such as in foo.tar.gz
* now we can match multi-part file extensions like on foo.tar.gz
* add a test that a !ext is a negative match and over-rides any positive match
* test that negative extensions that don't match any file have no effect
* fail the match if any negative extensions exist
* cargo fmt
I'm not happy with this, in particular it's made the structures of has_any_positive_extension and has_no_negative_extension look different, and the logic in is_match is harder to follow
* placate clippy
* documentation for multi-part extensions and negative extensions
* get rid of an unnecessary .to_string() and comment the necessary but weird-looking invocations of .to_string_lossy().to_string()
* tests for negative matching of files and folders
* fail the match is any negative files/folders match
* document file/folder negative matching; be less prolix
* suppress Nodejs if Deno files are present (#2627)
* Revert "suppress Nodejs if Deno files are present (#2627)"
This reverts commit c1394fd7b37bb0bf06b1449e074020a2e16bfa04.
This was a terrible way of doing this, there's got to be a better way!
* perf(package): only try to read files that exist
Have refactored the package module to improve performance. Before this
change the module would try to open every single file that could contain
some package information until it found a valid version. This resulted
in a lot of unneeded disk IO. Have added a new fn, `read_file_from_pwd`
that uses the current context to check if that file already exists and
fast failing if it doesn't. From my local testing this speeds up the
package module from taking ~1ms to ~50µs in an empty directory.
* refactor: move read_file_from_pwd to context
* refactor(haskell): use read_files_from_pwd
* refactor(nodejs): use read_files_from_pwd
* 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(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>
* 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>
Add `terminal-width` argument to explicitly define terminal's width
Update pwsh,bash,zsh,fish init scripts with `terminal-width` argument
Co-authored-by: Kevin Song <chips@ksong.dev>
Co-authored-by: Kevin Song <4605384+chipbuster@users.noreply.github.com>
Changes the parsing for pipestatus to allow for multiple arguments, a
single argument of space-separated values, or any mix of the two. All
inputs are flattened into a single array where no elements have spaces
in them.
Changes the initscripts to no longer fail when an empty pipestatus
is passed as an argument by quoting and changing expansions.
* 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
* feat: add support for xonsh
* xonsh: add STARSHIP_SESSION_KEY
* xonsh: implement STARSHIP_SESSION_KEY in xonsh
* docs: mention tcsh, elvish, and nu in more places
* xonsh: change STARSHIP_SESSION_KEY implementation
See https://github.com/starship/starship/pull/2807#discussion_r667064149
* xonsh: fix jobs implementation
* xonsh: do not silently discard stderr from starship
* feat: add support for tcsh
* add tcsh to install.sh install message
* list tcsh in bug_report.rs and main.rs
* quote starship path
Co-authored-by: David Knaack <davidkna@users.noreply.github.com>
* fix job count
* add tcsh support to shell module
* fix STARSHIP_START_TIME undefined error
* preserve existing user precmd and postcmd, remove jobs support
* remove unnecessary parentheses
* minor script improvement
* removes parens from install script message
* Update docs/config/README.md
Co-authored-by: Thomas O'Donnell <andytom@users.noreply.github.com>
Co-authored-by: David Knaack <davidkna@users.noreply.github.com>
Co-authored-by: Thomas O'Donnell <andytom@users.noreply.github.com>
* 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.