* feat(nim): add support for nimble project package version
* Replace find_file with context scanner. Fixes the failing tests.
* Replace `utils::exec_cmd` with `context.exec_cmd` so that it uses
global timeout
* Add tests for nimble project version
* Add docs for nimble in package version module for english language
* Update docs/config/README.md
Co-authored-by: David Knaack <davidkna@users.noreply.github.com>
* Add test for a case when nimble is not available
* Remove extract_vlang_version
I don't know why it did not come up while I was fixing merge conflicts
on rebase.
Co-authored-by: David Knaack <davidkna@users.noreply.github.com>
* format crystal version with VersionFormatter
* update crystal dosc
* format crystal module
* fix typos
* format dart version with VersionFormatter
* fix dart malformed test
* update dart docs
* format cmake version with VersionFormatter
* update cmake docs
* format deno version with VersionFormatter
* update deno docs
* remove Version type
* format dotnet version with VersionFormatter
* update dotnet docs
* format erlang version with VersionFormatter
* update erlang docs
* format golang version with VersionFormatter
* refactor formatting in my modules
* format helm version with VersionFormatter
* format julia version with VersionFormatter
* format kotlin version with VersionFormatter
* format lua version with VersionFormatter
* format nim version with VersionFormatter
* format perl version with VersionFormatter
* format php version with VersionFormatter
* format purescript version with VersionFormatter
* format scala version with VersionFormatter
* format swift version with VersionFormatter
* format terraform version with VersionFormatter
* format vagrant version with VersionFormatter
* format zig version with VersionFormatter
* format elixir version with VersionFormatter
* format ocaml version with VersionFormatter
* update elixir docs
* update golang docs
* update helm docs
* update julia docs
* update kotlin docs
* update lua docs
* update nim docs
* update ocaml docs
* update perl docs
* update php docs
* update purescript docs
* update scala docs
* update swift docs
* update terraform docs
* update vagrant docs
* update zig docs
* format elm version with VersionFormatter
* update elm docs
* pass module_name as &str to format_module_version
* Revert "fix(zsh): Set PROMPT just once (#2428)"
This reverts commit 6fd7d7b501.
* Reintroduce fixes around START_TIME
* Bring back disabling virtualenv
* Expand the jobstates before passing the number to starship
Credit goes to @vladimyr
* Add support for `reverse` keyword in style strings
* Duplicate test case and keep original
* Rename keyword to `inverted`
* Add explanatory sentence in readme
* feat: Add a symbol option to `battery.display`
* feat: Add a symbol option to `battery.display`
* use `impl defaulat` instead of `RootModuleConfig`
* edit the code according to clippy's linting
* change variable type to `Option<'a str>`
* update the documentation on the battery module
* updated documentation and source code according to review comment
* remove the unnecessary method and write the default value of BatteryDisplayConig to the document
* add 'charging_symbol' option to battery.display
* 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
* feat(git_branch): add remote branch name if different than local branch
* feat(git_branch): Implement a more customizable remote branch
* feat(git_branch): Use more explicit API function name
* feat(git_branch): Remove forgotten draft documentation
* feat(git_branch): Set less verbose defaults
* feat(git_branch): Handle case to always display remote
* feat(git_branch): Fix error in rebase operation
* feat(git_branch): add 'only_attached' config bool
This adds a new boolean, `only_attached`, to the configuration for
the `git_branch` module. This mirrors the `only_detached` config
value for the `git_commit` module: setting the value to true causes
the module to suppress its output when the user is not on a branch.
This allows users to have either a branch name or a commit hash in
their prompt, as opposed to having either a branch name or the
overly-wordy "HEAD (sha1)".
* Fix formatting
* Add CMakeCache.txt to cmake module
* Remove trailing whitespace
* Apply fixes by @andytom
* Add CMakeCache.txt to docs
* Revert documentation for languages other than en
* [f]Use_global_dollar_hook_for_lastExitCodeForPrompt Switched to use the dollar hook, as source of truth for exit code of las command, included comments to clarify.
* fix: Adjusted accordingly to comments on PR.
* fix: Moved last exit code handling inside if to reuse that variable.
Co-authored-by: Marcos Quezada Perez <marcos.quezadaperez@peakwork.com>
Have refactored the kubernetes module to better support stacked
kubeconfigs. Rather than trying to grab both the current-context and
namespace on a single pass we now do two passes. These changes should
fix the problems where the current-context is defined in one file but
the context and the namespace are defined in a different file.
Have switched to use a monotonic clock for calculating the timeout when
indexing the current directory for the context to avoid any issues with
calculating the timeout when the systems clock might change.
* fix: rust modules are compiled twice
The modules being declared both in the _library_ crate and the _binary_
crate made cargo compile everything twice:
1. for the library
2. for the binary
What happened was:
1. The library "starship" was compiled.
2. The binary "starship" (and all its modules) were compiled.
* fix: stop compiling every rust module twice
restrict visibility
* Run cargo fmt
* Add bug_report module
Co-authored-by: Matan Kushner <hello@matchai.dev>
Co-authored-by: Kevin Song <chips@ksong.dev>
When running the AWS module it will parse the AWS config found in
`~/.aws/config` to get the region. This means that tests that expect no
region to be set will fail if there exists a default profile with a
region set, which is probably true for most AWS users. To avoid this
have set the AWS tests that depend on the non-existance of a
`.aws/config` to be ignored.
Have added a little bit more context to the error messages that occur
when if starship is unable to setup the logger. This should hopefully
make it a bit easier to work out why starship can't setup the logger.
* ✨ Add --prompt rendering to python virtualenv
* Use pyvenv.cfg to find prompt
* Remove usage of VIRTUAL_ENV_PROMPT variable
Seeing how both venv and virtualenv set a pyvenv.cfg, this isn't needed.
Additionally pyvenv.cfg is set in earlier versions than VIRTUAL_ENV_PROMPT,
which at this moment is in the unrelased python 3.10
* Smarter result unwrapping thanks to clippy
Some users have commit.gpgSign set to true in their global git config,
causing tests which run `git commit` to fail if the configured
user.signingKey is not present (as is often the case with PGP smart
cards). Passing this flag overrides the global git configuration,
preventing git from attempting sign the specified commit. This change
has no effect on users who haven't set commit.gpgSign to true.
Have reduced the log level when we fail to execute a command since this
is happening a lot more that expected, for example if a user checks out
a repo that contains a `.js` file but they don't have node installed.
The tests for git-state assume the default branch is `master`.
In git 2.28 support for a global option, `init.defaultBranch`, to
change the default branch name which causes git-state tests to fail.
This creates a custom logger for the log crate which logs everything to a file (/tmp/starship/session_$STARSHIP_SESSION_KEY.log) and it logs everything above Warn to stderr, but only if the log file does not contain the line that should be logged resulting in an error or warning to be only logged at the first starship invocation after opening the shell.
The default `disabled: true` is actually only available within the module (when the config struct is used and not the user toml) but not all (the hg_branch) modules checked it there again.
Document this in all places and add the check (+ test) to the hg_branch module.
* add the exit code module
this allows to display more precisely the last command exit code
and to configure starship to not change the last charcter of the
prompt even in case of failure. It is disabled by default, because
it seems a bit redundant with the character module in its default
configuration.
* rename exit_code module to status
* Enforce a default disabled=true
In the outer places, we only check for the disabled flag in the config toml file, only when this is loaded into the real config struct, we see the default. And if the default is true, we have to abort at that place. For status and hg_branch that wasn't so. I also commented the rest
* fix spaces in markdown table for status module
* Add a tip that status module is disabled by default
Co-authored-by: Thomas O'Donnell <andytom@users.noreply.github.com>
* Remove unrelated changes for default disabled=true
Co-authored-by: Gaëtan Lehmann <gaetan.lehmann@gmail.com>
Co-authored-by: Thomas O'Donnell <andytom@users.noreply.github.com>
* 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>
Have restored the `pyenv_prefix` option to the python module. This is
added as a new variable that will only be shown if `pyenv` is being used
to determine the version of python that is being used.
Previously the prompt function used in PowerShell would overwrite the $LASTEXITCODE and $? automatic variables that were set by the previous command run the user in the shell. This results in surprising behavior for the user if they inspect those variables looking for the result of the command they last ran.
This fixes the bug reported here: https://github.com/starship/starship/issues/1051
And goes further to also propagate the $? automatic variable which is not mentioned in that bug.
Previously, all modules would have prefixes, which lead to the first
module having a dangling prefix. This change ensures that the first
few modules would instead have suffixes so that we don't start or
end with a prefix or suffix.
* docs: Clarify that commands will be passed in on stdin
* docs: Clearer instruction how to include individual custom modules
* docs: Include link to #1252 in docs for custom modules
That issue is used to share custom modules.
* docs: Remove reference to prompt_order
Co-authored-by: Thomas O'Donnell <andytom@users.noreply.github.com>
Co-authored-by: Thomas O'Donnell <andytom@users.noreply.github.com>
Convert-Path in the powershell prompt script works with -Path,
which interprets paths as wildcard patterns.
Not all valid paths are also valid wildcard patterns, possibly causing
the prompt to error (eg []*).
Replace it with -LiteralPath that makes Convert-Path use the path as-is.
Often it is handy to get notified when the execution of a command finished.
This commit includes notify-rust in order to generate a desktop notification
when a command execution finished.
* fix(explain): align table correctly
* iterate over lines directly
* calculate desc_width with the actual space available
* custom unicode-aware textwrapping
* fix clippy error
* better width estimination
* explain +6
* move padding width into a constant
* initial commit of support for shlvl
* documentation for shlvl
* use a symbol instead
* test coverage for shlvl
* actually disable when the config says to
* fix docs
* tweak defaults some
* refactor from pr comments
* redisable
* return early to avoid indenting
* make default suffix empty space
* fixing tests after suffix change
* updating docs for format
* making shlvl compatible with formatting
* adding variables table for shlvl
* removing extra line
* doc clarity