feat(python): Configure different detect env vars
Allow the env vars that trigger the python module to be configured, if
an empty list is passed then the module will fall back to just
triggering based on the configured files, folders and extensions.
* fix(bash): quote array expansions to work around custom IFS
* fix(bash): locally set standard IFS for $(jobs -p)
* fix(bash): localize the leaked variable "job"
* chore: use current way to get max value of an integer type
The std::usize::MAX way has been obsolete for quite some time now.
Found by clippy (clippy::legacy_numeric_constants).
Signed-off-by: Lars Wirzenius <liw@liw.fi>
* chore: use helper variable for a more idiomatic pattern matching
A nested expression can be harder to understand than two simpler
expressions. (Found by clippy lint clippy::blocks_in_conditions.)
Signed-off-by: Lars Wirzenius <liw@liw.fi>
---------
Signed-off-by: Lars Wirzenius <liw@liw.fi>
Co-authored-by: Lars Wirzenius <liw@liw.fi>
* Fix config schema
* Improve performance of kubeconfig module
This module currently takes about 200 ms when using our ~10MiB
kubeconfig. This change improves its performance by:
* Only parsing the file once
* (Naively) checking if the content is yaml or json and potentially
parse as the latter, as that seems to be much faster
* Remove duplicate `v` in dotnet version
Every language version provider returns the version without a leading 'v', and the shared code then prepends the 'v'. Take a look at Python for example.
The Dotnet provider prepends a 'v' however, causing the version to be printed like 'vv8.0.203'.
* Update src/modules/dotnet.rs
* tests(dotnet): add test for obtaining version from cli
---------
Co-authored-by: Bernd Verst <github@bernd.dev>
feat(color): add prevfg,prevbg as color specifiers based on the previous foreground/background colors respectively
Co-authored-by: Vladimir Lushnikov <vladimir@solidninja.is>
* update: add purescript spago-next configuration files
in upcoming spago projects, the configuration file is changing from
spago.dhall -> spago.yaml and spago.lock. This will detect both styles
for the time being
* fix typo
did not update test. spago.yaml -> spago.lock in the spago lock file
test case
* refactor(bash): use `STARSHIP_*` for the internal variable names
The current codebase uses `dbg_trap` to save the original DEBUG trap
in bash <= 4.3. However, the variable name possibly conflicts a user
variable since it is not prefixed by `_starship` or `starship_` or
`STARSHIP_`. In this patch, we rename `dbg_trap` to
`STARSHIP_DEBUG_TRAP` following other variables of
`STARSHIP_EXIT_STATUS` and `STARSHIP_PIPE_STATUS`. We also rename the
variable `_PRESERVED_PROMPT_COMMAND` to `STARSHIP_PROMPT_COMMAND`.
* fix(bash): correctly extract DEBUG trap with spaces
* fix(bash): evaluate DEBUG trap by eval
The current code executes the saved DEBUG trap just by
$_starship_dbg_trap. This causes various problems. The content of
the variable `_starship_dbg_trap` is unexpectedly subject to the word
splitting with the pathname expansions. Also, the needed shell
expansions and quote removal are not performed. With a custom IFS,
the content of the variable will be split in an unexpected way. The
saved DEBUG trap needs to be executed by eval "$_starship_dbg_trap".
* feat(k8s): Add detect env vars option
Have added the option to trigger the k8s module based on what env vars
are set, this has been done in a backwards compatible way so if nothing
is changed from the defaults the module will still behave the same way
as before. This is similar to what I did in #4486 for the python module
and if goes well I'd like to rollout to other modules.
* Update src/modules/kubernetes.rs
Co-authored-by: David Knaack <davidkna@users.noreply.github.com>
* Update src/modules/kubernetes.rs
---------
Co-authored-by: David Knaack <davidkna@users.noreply.github.com>
* combine ANSI color codes before wrapping them
The existing code wraps each individual module's output for
`context.shell`, concatenates all that output together and passes it to
`AnsiStrings` to merge ANSI color codes. However, the wrapping obscures
ANSI color codes, meaning that no merging is possible.
This commit changes the shell-specific wrapping to happen right before
output, once all modules' output has been concatenated together. This
results in ANSI color codes being correctly merged, as well as reducing
the number of calls to `wrap_colorseq_for_shell` to one.
With a minimal `starship.toml`:
```
format = """$directory"""
[directory]
format = '[a]($style)[b]($style)'
```
The current code produces[0]:
```
\n%{\x1b[31m%}a%{\x1b[0m%}%{\x1b[31m%}b%{\x1b[0m%
```
And this commit's code:
```
\n%{\x1b[31m%}ab%{\x1b[0m%}
```
You can see that the current code emits an additional reset and repeated
color code between "a" and "b" compared to the new code.
[0] Produced in a Python shell with:
```
subprocess.check_output(
"./target/debug/starship prompt", shell=True,
env={"STARSHIP_CONFIG": "./starship.toml", "STARSHIP_SHELL": "zsh"}
)
```
* utils: return early from wrap_seq_for_shell unless wrapping required
* refactor(utils): simplify wrap_seq_for_shell
This commit modifies wrap_seq_for_shell to (a) return early for shells
with no wrapping required, and (b) determine the wrapping characters
once at the start of the function (rather than inline in the map
function for every character).
* Create place to put it in the config
* Initial functional version
* Fix grammar
* Add option documentation to README
* Add test for two aliases and emoji translation
* Remove println
* Rewrite match as iflet
* Improve converting the reference
* Format file
* Try to restore autoformat of markdown
* Replace toml:Map with concrete IndexMap
* Update schema
* Add option that got lost
* Add Odin lang module
* add utils string and remove commit number from output
* switch to new symbol because ZWJ support is rare
* add config docs
* add option to show the commit number
* fix lack of trimming
* fix formatting to comply with checks
* Add trailing newline to comply with cargo fmt
* Add new Odin test and add newline in cmd output
Resolve #5847 by initializing `$env.STARSHIP_SHELL` before calling `starship`
Most minimal change possible. Other simplification are possible but not know to be
backwards compatible. Also considered `with-env` or `STARSHIP_SHELL=nu starship` but
they'd be worse. Happy to reformat indentation if desired.
* Added the option "detect_env_vars" to the `username` module
with the same functionality as in the `hostname` module.
* Fixed logic error and added test to catch it
* build(deps): update dependency vitepress to ^1.0.0-rc.45
* build(deps): update rust crate shadow-rs to 0.27.1
* Added the option "detect_env_vars" to the `username` module
with the same functionality as in the `hostname` module.
* Fixed logic error and added test to catch it
* Removed unused gix import
* Removed unused gix import, again
* Removed unused gix import. Next try
---------
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
* feat(docs): move to vitepress
* change up hero styles to match existing site
* A bit more style tweaking
* Replace stylus with plain CSS
* improve unicode-range value for nerdfont
---------
Co-authored-by: Matan Kushner <hello@matchai.dev>