* 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"
* 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".
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.
* Support right prompt in bash
* Docs for transience in bash
* Apply suggestions from review
* Simplify conditional
* Use ble.sh hooks, if available
* Properly quote args
* Use BLE_PIPESTATUS
* Update starship.bash
* Update src/init/starship.bash
Co-authored-by: Koichi Murase <myoga.murase@gmail.com>
---------
Co-authored-by: Koichi Murase <myoga.murase@gmail.com>
Skip unnecessary indirection in starship init zsh
The installation instructions indicate that one should add this snippet
to zsh's configuration:
eval "$(starship init zsh)"
The command `starship init zsh` prints a little shell script for zsh to
execute:
> starship init zsh
source <(/usr/bin/starship init zsh --print-full-init)%
Running `starship init zsh --print-full-init` prints yet another script
that zsh executes. There is an intermediate step that seems redundant;
starship prints a script for zsh to execute, and this script prints
another script for zsh to execute.
This commit skips the intermediate execution and prints the final script
in `starship init`. This is backwards compatible and does not require
any changes in the installation instructions, so it could be release
without a major version bump.
Note that it would still be possible to update the installation
instructions to `source <(starship init zsh)`; this patch works with
both `source` and `eval`. Picking the most performant one is beyond this
scope of this commit.
See: https://github.com/starship/starship/issues/2637
* break long commands into multiple lines for readability
* fix the format of closures
We generally write `{|| ...}` instead of `{ || ...}`.
* remove the `$"--opt=(val)"` structure when possible
`starship` does not require to use `--opt=val` and so we do not
need to do that with Nushell :)
the only place where this is required is with `--status` because
`$env.LAST_EXIT_CODE` can be negative and `starship` does not
appear to *like* values of the form `-2`...
so i left this line as it was.
on the other hand, `$env.CMD_DURATION_MS` and `(term size).columns`
should be fine 😌
* simplify the `config` mutation with new `?` syntax
This is a new very handy feature of Nushell which gives a much
simpler command combined with `default` and `merge`.
* put all `let-env`s inside an `export-env` with `load-env`
This commit has two reasons of existing:
- i think it makes it a bit easier to read with less `let-env`s
- it transforms the *script* into both a valid module and a valid
overlay
* bump the version to `0.78` in to docs
* add a note about the init file being also a module to all docs
* tweak the documentation
* update the Nushell part of the install script
* format the vuepress config file
as previous commit 117580136d3da5e00a4ccb7ada508c8510a2e50e was
not successful, let's try to make the CI happy manually 😌
* remove code quotes in the `config_cmd` of Nushell
* format the style in the Nushell `warning` section
Update starship.nu to conform to Nushell changes
Nushell recently made a change to require that all closures have an explicit parameter list, even if it's empty, in https://github.com/nushell/nushell/pull/8290.
This updates starship.nu to conform to this requirement.
I have casually tested this against both the latest released version of Nushell, and the latest version on HEAD; the changed code works well (for me) on both.
Fixed a startup error, when using nushell.
The nushell warns about not using `let-env` for configuring `config`. I have removed the `load-env` and just added a `let-env` for the `config` as the documentation recommends: https://www.nushell.sh/book/environment.html#let-env
This patch uses the which crate to resolve the starship path, replacing the
current_exe() mechanism.
Co-authored-by: Kevin Song <chips@ksong.dev>
Co-authored-by: David Knaack <davidkna@users.noreply.github.com>
Co-authored-by: Dario Vladović <d.vladimyr@gmail.com>
* Use global:error[0] for most recent error
The current version use $error[0], which is for the module instead of the global status and is always $null, so the $lastExitCodeForPrompot is always $origLastExitCode (see https://github.com/starship/starship/issues/3485 for a related bug).
It should be replaced with $global:error[0]
Comments are also updated
* fix(pwsh): make Semantic PR bot happy
The `$PWD` environment variable used by starship is not updated on startup by `elvish`. `elvish` also provides a separate `$pwd` variable that does get updated and seems to be be a better indicator for the current logical path.
* 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>