* feat(config): print a suggestion for unknown fields
* Fix typo
Co-authored-by: Thomas O'Donnell <andytom@users.noreply.github.com>
Co-authored-by: Thomas O'Donnell <andytom@users.noreply.github.com>
* style(init): Cleanup the unknown shell message
Have make a small change to the message that is printed when an unknow
shell is used. This correct the placement of the trailing `"` so that
the two training new lines are correctly printed and updates the list of
supported shells.
* refactor(init): consolidate unknown shell errors
Have consolidated the two unknown shell errors
* refactor(init): Quote the shell name in the output
Quote the shell name in the script and combined the shell_name and
shell_basename to simplify the code a little.
Previously attempting to use conditional format strings with
`$indicator` would never display an indicator, e.g.:
```toml
[shell]
fish_indicator = ""
bash_indicator = "B "
format = "($indicator )"
disabled = false
```
This would always display an empty string.
Fixes #2474.
* refactor(dotnet): ".NET" instead of "•NET"
"•NET" looks quite weird, especially since the official writing is ".NET".
* revert(docs): translated docs
Co-authored-by: Eyal Cherevatzki <eyal@hyperguest.com>
No need to forcefully set the `PROMPT` variable every time the prompt is
to be shown. Just set it once, leaving the command to be evaluated every
time the prompt is to be shown, by enabling the `promptsubst` option.
Setting it once is also friendlier to users that want to experiment with
another prompt theme by temporarily setting `PROMPT` to something else.
This would currently not be possible, because the variable is always
reset before every prompt draw (precmd) and keymap change
(zle-keymap-select).
Some other updates to take better advantage of the zsh script dialect:
* `$` is not required to read variables inside `(( ))` arithmetic
expressions.
* The zsh dialect to check if a variable is set is `${+var}`. Better
than `${var+1}`, which substitutes 1 if var is set, which is
intended for more general substitutions, not just to check if var is
set.
* The number of jobs can be read using the `%j` escape sequence, which
is expanded when the `promptpercent` option is set.
Also simplified a couple of code lines by avoiding a temporary
`STARSHIP_START_TIME` variable, since we already have
`STARSHIP_CAPTURED_TIME`.
* fix(python): Handle PyPy python version correctly
* refactor: rework Python version retrieval and formatting
Align Python version retrieval and formatting with established
Starship conventions.
* fix(java): use consistent separators for java path
This switches us from just appending `/bin/java` to `$JAVA_HOME` to
treating `$JAVA_HOME` as a path. This should fix any issues on Windows
where $JAVA_HOME might use `\` rather than `/`.
* test(java): add test for JAVA_HOME
* refactor: remove duplicate defaults
* perf: sligntly better java path perf
* Update src/modules/java.rs
Co-authored-by: Dario Vladović <d.vladimyr@gmail.com>
* Update src/modules/java.rs
Co-authored-by: Dario Vladović <d.vladimyr@gmail.com>
* Update src/modules/java.rs
Co-authored-by: Dario Vladović <d.vladimyr@gmail.com>
Co-authored-by: Dario Vladović <d.vladimyr@gmail.com>
* 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>
The unicode hexagon symbol does not actually fit into a single column with a
fixed-width font. does. As starship requires a nerd font as a prerequisite,
it's safe to assume that this symbol is available.
Symbol link: https://www.nerdfonts.com/cheat-sheet?set=nf-mdi-nodejs
In the documentation, I've left the '⬢' symbols in '#### Text Group' as
they are, as they will continue displaying correctly in a browser
without a nerd font available. I feel like readability is more important
than consistency with the new nodejs symbol, especially as this
documentation section does not actually refer to nodejs, rather it's
just a symbol.
As `⬢` has been replaced, use `⌘` instead in documentation to avoid
any possible confusion
This makes it possible to configure when the purescript module is shown
based on the contents of a directory. This should make it possible to
be a lot more granular when configuring the module.
This makes it possible to configure when the php module is shown
based on the contents of a directory. This should make it possible to
be a lot more granular when configuring the module.
This makes it possible to configure when the perl module is shown
based on the contents of a directory. This should make it possible to
be a lot more granular when configuring the module.
This makes it possible to configure when the ocaml module is shown
based on the contents of a directory. This should make it possible to
be a lot more granular when configuring the module.
This makes it possible to configure when the nodejs module is shown
based on the contents of a directory. This should make it possible to
be a lot more granular when configuring the module.
This makes it possible to configure when the nim module is shown
based on the contents of a directory. This should make it possible to
be a lot more granular when configuring the module.
* feat(erlang): Configure when the module is shown
This makes it possible to configure when the erlang module is shown
based on the contents of a directory. This should make it possible to
be a lot more granular when configuring the module.
* Update docs/config/README.md
Co-authored-by: Shu Kutsuzawa <cappyzawa@gmail.com>
Co-authored-by: Shu Kutsuzawa <cappyzawa@gmail.com>
This makes it possible to configure when the elm module is shown
based on the contents of a directory. This should make it possible to
be a lot more granular when configuring the module.
This makes it possible to configure when the elixir module is shown
based on the contents of a directory. This should make it possible to be
a lot more granular when configuring the module.
* Add the shell module
This module allows to quickly identify which shell is currently used, in case someone frequently switches between them.
* Updated documentation with shell module.
Co-authored-by: mro <mro@fedorabox.localdomain>
This makes it possible to configure when the dotnet module is shown
based on the contents of a directory. This should make it possible to be
a lot more granular when configuring the module.
This makes it possible to configure when the lua module is shown
based on the contents of a directory. This should make it possible to
be a lot more granular when configuring the module.
This makes it possible to configure when the golang module is shown
based on the contents of a directory. This should make it possible to
be a lot more granular when configuring the module.
This makes it possible to configure when the terraform module is shown
based on the contents of a directory. This should make it possible to
be a lot more granular when configuring the module.
* feat(docker_context): Configure when module is shown
This makes it possible to configure when the docker_context module is
shown based on the contents of a directory. This should make it possible
to be a lot more granular when configuring the module.
* Update docs/config/README.md
Co-authored-by: David Knaack <davidkna@users.noreply.github.com>
Co-authored-by: David Knaack <davidkna@users.noreply.github.com>
* feat(vagrant): Configure when the module is shown
This makes it possible to configure when the vagrant module is shown based on the contents of a directory.
* fix documentation
Co-authored-by: Thomas O'Donnell <andytom@users.noreply.github.com>
Co-authored-by: Thomas O'Donnell <andytom@users.noreply.github.com>
* feat(dart): Configure when the module is shown
This makes it possible to configure when the dart module is shown based
on the contents of a directory. This should make it possible to be a lot
more granular when configuring the module.
* docs(dart): add missing detected files
* removed invalid comment
* feat(crystal): Configure when the module is shown
This makes it possible to configure when the crystal module is shown
based on the contents of a directory. This should make it possible to
be a lot more granular when configuring the module.
* Update docs/config/README.md
Co-authored-by: David Knaack <davidkna@users.noreply.github.com>
Co-authored-by: David Knaack <davidkna@users.noreply.github.com>
This makes it possible to configure when the cmake module is shown
based on the contents of a directory. This should make it possible to
be a lot more granular when configuring the module.
* 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.
This makes it possible to configure when the python module is shown
based on the contents of a directory. This should make it possible to
be a lot more granular when configuring the module.
This includes a breaking change since we are removing the
`scan_for_pyfiles` configuration option in favour of setting the
`detect_extensions` to an empty array.
* fix(windows): don't inherit stdin when executing commands
On Windows, inheriting stdin from starship might lead to leaking the
console reference to the command we're executing. `id.exe` supplied with
Git has been observed to disable the ENABLE_VIRTUAL_TERMINAL_PROCESSING
console flag if it inherits stdin -- leading to Windows Terminal not
processing ANSI escape sequences.
This change fixes #2254 by explicitly disabling stdin inheritance.
The fix was suggested by David Knaack.
* fix(username): don't call `id -u` on Windows
This was done to check if user is root by comparing the UID to 0. Windows
does not have a concept of UID 0 anyway, so it's pointless to call `id.exe`
(which is installed with MSYS2 or Git, for example).
* feat: add support for elvish shell
* improve doc
* elvish 0.15 is out
* fix example init
* update systax for 0.15 stable
* udpate second init example too
* remove warning from swift module
* add warning to status module docs
* prefix elvish version with v
In #1897 we replaced a 'wc -l' with a bash-native job counter, but
subsequently discovered that bash on MacOS folds '<<<' output into
a single line, preventing line counting.
A for loop works around that problem, is still bash-native, and works
on Linux as well.
While we're at it, also removed the need for command substitution and
an echo by doing the work directly on NUM_JOBS.
Fixes #2241.
I simplified the code in the git status module by moving everything from RwLock<_> to OnceCell<_>. I think this should also get rid of any remaining race conditions that remained after #1777.
We currently invoke `starship time` in a sub-shell to compute time, which is non-performant. By using $EPOCHREALTIME,
which is an inbuilt env-var in ZSH5, we can get better performance. This commit only targets ZSH5+ and maintains the
old behaviour.
* perf(zig): evaluate version lazily
* fix(zig): update format string; update tests
* refact(zig): remove redundant clone and put everything to do with version eval into match statement
* tiny optimization
Co-authored-by: David Knaack <davidkna@users.noreply.github.com>
Co-authored-by: Moritz Vetter <mv@3yourmind.com>
Co-authored-by: David Knaack <davidkna@users.noreply.github.com>
* perf(perl): evaluate version lazily
* fix(perl): update format string; update tests
* refact(perl): run rustfmt
Co-authored-by: Moritz Vetter <mv@3yourmind.com>
* perf(utils): Add timeout to `utils::exec_cmd`
This adds a timeout to any command executed using the `utils::exec_cmd`.
The initial time limit is hard coded to 500ms but if required we can
make this configurable. Have also switched the tests to be a bit more
granular on which systems they are ignored.
* Terminate the processes if they timeout
* fix(nodejs): update format string
* test(nodejs): adjust tests to new format strings
* fix(nodejs): use once_cell's Lazy to implement hassleless lazy execution
* chore(nodejs): run rustfmt
Co-authored-by: Moritz Vetter <mv@3yourmind.com>
* perf(dart): evaluate version lazily
* fix(dart): update format string
* fix: use suggested format string
Co-authored-by: Moritz Vetter <mv@3yourmind.com>
* perf(java): evaluate version lazily
* fix(java): update format string
* fix: use suggested format string
Co-authored-by: Moritz Vetter <mv@3yourmind.com>
* perf(elm): evaluate version lazily
* fix(elm): update format string
* fix: use suggested format string
Co-authored-by: Moritz Vetter <mv@3yourmind.com>
* fix(dotnet): update dotnet format string
* fix(dotnet): update erlang format string
* fix(dotnet): update golang format string
* fix(dotnet): update helm format string
* fix(dotnet): update julia format string
* fix(dotnet): update nim format string
* fix(dotnet): update ruby format string
* fix(dotnet): update rust format string
* test: update formatted strings in unit tests
* Use suggested format strings
Co-authored-by: Thomas O'Donnell <andytom@users.noreply.github.com>
Co-authored-by: Moritz Vetter <mv@3yourmind.com>
Co-authored-by: Thomas O'Donnell <andytom@users.noreply.github.com>
* perf(python): evaluate version lazily
* fix(python): update format string
* fix: use suggested format strings
Co-authored-by: Thomas O'Donnell <andytom@users.noreply.github.com>
Co-authored-by: Moritz Vetter <mv@3yourmind.com>
Co-authored-by: Thomas O'Donnell <andytom@users.noreply.github.com>
* perf(crystal): Lazily evaluate version command
This updates the module to lazily execute the `crystal --version`
command only when the `version` variable is used in the format string.
* perf(crystal): Update format string
Update format string to handle the `$version` variable not being set.
* feat: Add support for cygwin/msys2/git-bash evironment
* Update src/init/mod.rs
Co-authored-by: David Knaack <davidkna@users.noreply.github.com>
Co-authored-by: Thomas O'Donnell <andytom@users.noreply.github.com>
Co-authored-by: David Knaack <davidkna@users.noreply.github.com>
* fix(user): Fix username detection on Windows
This switches Windows to use the env var `USERNAME` rather than `USER`
for getting the username of the current user. I have also done some minor
refactoring to simplify some of the code and make the checks to see if
the user is root or another user a bit more robust.
* Update src/modules/username.rs
Co-authored-by: David Knaack <davidkna@users.noreply.github.com>
Co-authored-by: David Knaack <davidkna@users.noreply.github.com>
Have added support to the `utils::exec_cmd` to allow it to execute
commands that are not `.exe` on Windows. Have also added a timer to
measure how long a command took to execute.
I was surprised to see these (unprefixed) variables being set in my
shell. I think it's better to have them in the STARSHIP_ "namespace".
(Actually, STATUS got the new name STARSHIP_CMD_STATUS.)
* refactor: convert some vecs to static arrays and slices
* refactor(openstack): lazy yaml file reading, skip files without expected structure, and avoid panics for some edge cases
* feat(git_branch): Show remote name in addition to remote branch
* feat(git_branch): Fix table indentation in config README
* feat(git_branch): Use a different method to fetch remote information
* feat(git_branch): Fix the Clippy issue regarding string constant
* fix(git_commit): show last created tag on current commit
* style(git_commit): fixed linter & format alerts on PR checks
* test(git_commit): added 'test_latest_tag_shown_with_tag_enabled'
* test(git_commit): add a second between tags on same commit in 'test_latest_tag_shown_with_tag_enabled'
* feat: Try harder to guess if inside ssh
* Add test for SSH_CLIENT
* Update documentation on checking ssh connection
* Update docs/config/README.md
Co-authored-by: Thomas O'Donnell <andytom@users.noreply.github.com>
Co-authored-by: Thomas O'Donnell <andytom@users.noreply.github.com>
Changes the behaviour of a bg:none color string so that
it causes the background to have no color instead of
decoloring the entire string like it did before.
Update the python module to try multiple python binaries when
determining the version. With the new logic if starship doesn't find
`python` on the `PATH`, which is the default for some Linux Distros, it
will fallback to `python3` and then `python2`.
* feat(rust): Support new rust-toolchain format
* Match file parsing with rustup and update link
* Use cargo to deserialize the rust-toolchain file
* Filter empty channel strings after extraction
* Use the option value instead of rewrapping