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