summaryrefslogtreecommitdiffstats
path: root/src/init
AgeCommit message (Collapse)Author
2021-07-13fix(pwsh): replace Get-Error with $error[0] (#2873)Chrissy LeMaire
Get-Error does not exist in all versions of PowerShell, and attempting to use it on machines where it does not exist pollutes $error. Someone may be tempted to use -ErrorAction Ignore but since the command does not exist, it still ends up in $error This is a dual bug fix because it actually gets errors on all machines now and it does not pollute $error.
2021-07-10fix(nu): use correct session key variable name (#2874)David Knaack
2021-07-04feat: add support for nu shell (#2847)David Knaack
2021-07-03fix(init): improve starship path escaping (#2848)David Knaack
2021-05-12fix(zsh): preserve zle-keymap-select (#2717)Munif Tanjim
2021-04-29fix(fish): explicitly set scope in fish init script (#2636)Kid
* fix: use correct scope in fish init script * Prefix variable names with Starship * Use `functions -e` to remove `fish_mode_prompt` * Update src/init/starship.fish Co-authored-by: Dario Vladović <d.vladimyr@gmail.com> Co-authored-by: Dario Vladović <d.vladimyr@gmail.com>
2021-04-29fix(zsh): Reverts changes to background jobs retaining improvements around ↵Felipe Seré
START_TIME (#2638) * Revert "fix(zsh): Set PROMPT just once (#2428)" This reverts commit 6fd7d7b5010c28d0557e4ff562187098abaa3bc6. * Reintroduce fixes around START_TIME * Bring back disabling virtualenv * Expand the jobstates before passing the number to starship Credit goes to @vladimyr
2021-04-05refactor(init): cleanup init stub (#2548)Dario Vladović
* refactor(init): cleanup init stub * refactor(init): use iex PowerShell alias * fix(init): prevent bash scope pollution * refactor(init): update PowerShell snippet
2021-03-25style(init): Cleanup the unknown shell message (#2444)Thomas O'Donnell
* 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.
2021-03-15fix(zsh): Set PROMPT just once (#2428)Eric Nielsen
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`.
2021-02-27feat: add support for tcsh (#2288)Vivek Malneedi
* 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>
2021-02-15fix: correct fish syntax error when setting variables (#2320)Jan Christoph Ebersbach
2021-02-14perf(init): Prefer set -x over export for fish users (#2292)Michael Sanders
2021-02-13fix(init): Quote path for elvish init (#2294)Tim Grelka
Fixes starship/starship#2293
2021-02-13fix(init): make log messages on pwsh visible again (#2295)David Knaack
2021-02-08refactor(directory): Introduce `logical-path` argument which allows a shell ↵Benjamin Fox
to explicitly specify both a logical and physical filesystem path (#2104) * 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.
2021-02-02feat: add support for elvish shell (#1725)David Knaack
* 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
2021-01-31fix(bash): Count jobs with for loop to fix MacOS count issue (#2250)Rich Lafferty
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.
2021-01-23perf: use built-in EPOCHREALTIME env-var to compute cmd_duration for ZSH5+ ↵Gautham Warrier
(#1751) 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.
2021-01-07feat: Add support for cygwin/msys2/git-bash evironment (#2020)Zoritle
* 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>
2021-01-07fix(bash): Fix broken bash init script (#2100)Thomas O'Donnell
This fixes a regression where the exit code of the most recently run command was not correctly recorded in the bash init script.
2021-01-07fix(pwsh): disable builtin venv prompt (#2090)David Knaack
2021-01-07fix(bash): bash-preexec detection and implementation (#2091)Kevin Song
* Fix bash-preexec detection and implementation * Add detection for other arrays
2021-01-04perf(init): Use random for session-key in fish (#1904)Glandos
* perf(init): Use random for session-key in fish Same as #1755 but for fish users * Update src/init/starship.fish
2020-12-19feat(init): prefix STATUS and PREEXEC_READY shell vars with STARSHIP_ (#1710)Bjørn Forsman
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.)
2020-12-02style: Add comments for bash preexec fix (#1952)Kevin Song
* Add comments for bash fix * Rewrite commend
2020-12-02fix(bash): Fix background jobs with z/autojump (#1897)Harald Hoyer
Fixes issue where having z.sh or autojump hooked in bash would cause spurious background job indicators to appear.
2020-11-12fix(pwsh): fix crash on error in shell with old pwsh (#1861)David Knaack
Handle missing Get-Error in powershell gracefully.
2020-11-08perf(init/pwsh): use get-random for session-key instead of invoking starship ↵David Knaack
session (#1860)
2020-11-07perf(init): use $RANDOM env-var instead of starship session to generate ↵Gautham Warrier
session-key (#1755)
2020-10-27fix(zsh): Ensure existing keymap change functions are not overriden (#1826)Gautham Warrier
2020-10-24fix(pwsh): Switched pwsh profile to use dollar hook for a more accurate ↵marcos-quezada
success/failure handling (#1745) * [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>
2020-10-19fix(pwsh): preserve original console encondings (#1810)David Knaack
2020-09-30fix(powershell): fix session key syntax error (#1697)Tilmann Meyer
2020-09-28feat: add error messaging (#1576)Tilmann Meyer
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.
2020-09-14fix(zsh): work when `setopt ksh_arrays` is set (#1612)David Knaack
2020-09-09fix(pwsh): update init script to propagate $LASTEXITCODE and $? Joshua Poehls
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.
2020-08-19fix(pwsh): stop paths from being interpreted as patterns (#1569)David Knaack
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.
2020-08-03fix(bash): init breaks if PROMPT_COMMAND includes starship_precmd as an ↵Jason Wang
intermediate command (#1541)
2020-06-10fix(bash): last command status and command duration (#1185)Munif Tanjim
* fix: character module last command status for bash * fix: command duration module for bash
2020-06-09fix: Retain previous command state on zsh keymap select (#958)Nemo157
2020-05-28style(init): tidy-up init scripts (#1269)Dario Vladović
* style: fix indent & spacing * chore: use consistent function definition style * chore: remove extra semicolon * chore: flip comparison expression
2020-04-30fix(directory): avoid confusing modules with PowerShell paths (#1114)Jean Gautier
* Avoid confusing modules with PowerShell paths * Avoid confusing modules with PowerShell paths Powershell supports PSDrives (https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.management/new-psdrive?view=powershell-7) that allow to create "logical" drives mapped to actual Windows drives. * Preserve Windows directories * Preserve logical paths for Powershell * Fix formating with cargo fmt * Fix directory_in_root test Co-authored-by: Jean Gautier <jean.gautier@ssi.gouv.fr>
2020-02-06fix: Change command duration variable for Ion shell to CMD_DURATION (#911)Jon Grythe Stødle
2020-01-04feat: Terminate $PROMPT_COMMAND properly (#799)InNoobWeTrust
Add trailing semicolon to end $PROMPT_COMMAND properly. This will prevent starship_precmd to accidentally mess with other hooks invoked after it.
2019-12-28fix: Remove trailing semicolon from `$PROMPT_COMMAND` (#784)InNoobWeTrust
Remove any trailing semicolon in $PROMPT_COMMAND before appending starship_precmd, to prevent syntax error.
2019-12-19feat: cmd_duration module optionally reports milliseconds (#696)Luca Rinaldi
2019-12-19fix(bash): save and restore "$_" (#753)Etienne Mabille
2019-12-13fix(powershell): Fix prompt not updating on -nix systems (#728)David Knaack
Closes #661
2019-12-11feat: Add support for the ion shell (#704)BuggStream