Commit Graph

113 Commits

Author SHA1 Message Date
Ohad Lutzky 7b851fc30e
feat(scanner): add option not to follow symlinks (#5325)
Add follow_symlinks option

Settings this to false can fix hanging on symlinks to slow/inaccessible
filesystems.
2023-11-02 09:01:09 +01:00
Mick Hohmann 43b2d42cd5
feat(hostname): add detect_env_vars as option (#5196)
* Added hostname.detect_env_vars

based on the newly added context::detect_env_vars

- extended context::detect_env_vars to check for negated environment
  variables as well, analogous to the other detect modules
- made hostname.detect_env_vars only active if ssh_only is set to false
  for backwards compatibility

Co-authored-by: Dominik Sander <dsander@users.noreply.github.com>

* added clippy recommendations, removed unneeded comments

* Added new logic (suggested in https://github.com/starship/starship/pull/5196#issuecomment-1566228913)

The new `detect_env_vars` now requires either SSH_ONLY to be false or the
environment variable SSH_CONNECTION to be set, so that is will be used

* Fixed typo

* Refactored the detect_env_vars function for early returns and better readability

* Change boolean logic for better readability

Co-authored-by: David Knaack <davidkna@users.noreply.github.com>

* Apply suggestions from code review to `detect_env_vars` method.

Co-authored-by: David Knaack <davidkna@users.noreply.github.com>

* Fixed bracket error & updated comments

- fixed bracket error in hostname.rs, after changes
- updated comments for context.rs, for the suggested changes

* Removed obsolete warning from docs/config/README.md

Co-authored-by: David Knaack <davidkna@users.noreply.github.com>

---------

Co-authored-by: Dominik Sander <dsander@users.noreply.github.com>
Co-authored-by: David Knaack <davidkna@users.noreply.github.com>
2023-09-16 16:42:13 +02:00
David Knaack 03278e4de4
fix(git): prevent `core.fsmonitor` from executing external commands (#3981) 2023-07-31 21:44:31 +02:00
Denis Cornehl d07a8e3668
feat(gcloud): add `detect_env_vars` option (#5166)
* feat(gcloud): add `detect_env_vars` option

* regenerate config schema
2023-05-09 07:55:49 +02:00
Sebastian Thiel 8884bd1fd0
build(deps): upgrade gitoxide to v0.44 for performance improvements during discovery (#5141)
upgrade gitoxide to v0.44 for performance improvements during discovery

Please note that there is a new `dot_git_only` option which would further
speedup discovery. On even moderatly fast disks that probably not going
to make a difference, but it will on incredibly slow (networked) disks.

See https://github.com/helix-editor/helix/issues/6867 for reference.
2023-04-27 21:14:34 +02:00
marcybell b8a167db57
refactor(Context): `set_config` method for `Context` (#5079)
* add `set_config` method to `Context`

* Made inline comment a doc comment

* use `default_context()` for `set_config()` test

* use `set_config()` in tests for `print.rs`

* set root config w `set_config()` (`print.rs` test)
2023-04-24 16:03:47 +02:00
Dom Slee ce7f984932
fix(config): Make print-config not panic without a config (#5001) 2023-04-13 19:29:21 -05:00
Vegard Skui 4bca74eca2
feat(fossil): detection of Fossil check-outs in subdirectories (#4910)
* Move PathExt::device_id() outside modules module

* Add upwards_sibling_scan-function

* Fix Fossil check-out detection in subdirectories

* Use shared upwards scanning function in hg_branch

* Let the caller specify if they're looking for a file or a folder

* fix merge

---------

Co-authored-by: David Knaack <davidkna@users.noreply.github.com>
2023-04-02 16:37:27 +02:00
David Knaack d1891de638
chore: use updated gitoxide crate names (#4913) 2023-02-21 13:03:17 +09:00
David Knaack 5e123fcbce
chore: fix clippy warnings for rust 1.67 (#4855) 2023-01-27 18:33:24 +09:00
Florent Vilmart 10433e31ef
feat(config): Adds support for --profile <custom profile name> (#3467)
Co-authored-by: Kevin Song <chips@ksong.dev>
Co-authored-by: David Knaack <davidkna@users.noreply.github.com>
2023-01-11 21:25:36 -06:00
David Knaack 5d4cb6ff8f
feat(env_var): Add support for env_var.VAR in format (#4497)
Co-Authored-By: Segev Finer <24731903+segevfiner@users.noreply.github.com>

Co-authored-by: Segev Finer <24731903+segevfiner@users.noreply.github.com>
2022-12-28 21:00:49 +01:00
Sebastian Thiel a53f681e3c
build(deps): upgrade to git-repository v0.27 (#4588)
* upgrade to git-repository v0.27

* thanks clippy
2022-11-12 17:07:49 +01:00
David Knaack 6e38683c89
chore: fix new clippy lints (#4557) 2022-11-05 12:40:46 +01:00
David Knaack c69fe4a644
build: bump git-repository from 0.23.1 to 0.24.0 (#4393)
* build: bump git-repository from 0.23.1 to 0.24.0

Bumps [git-repository](https://github.com/Byron/gitoxide) from 0.23.1 to 0.24.0.
- [Release notes](https://github.com/Byron/gitoxide/releases)
- [Changelog](https://github.com/Byron/gitoxide/blob/main/CHANGELOG.md)
- [Commits](https://github.com/Byron/gitoxide/compare/git-repository-v0.23.1...git-repository-v0.24.0)

---
updated-dependencies:
- dependency-name: git-repository
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* add new member to `git::permissions::Config`

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-09-22 16:34:50 +02:00
Sebastian Thiel dd918296e4
build: gitoxide upgrade (#4319)
adjustments to upgrade to gitoxide v0.22.1
2022-08-27 14:24:18 +02:00
David Knaack 98089bf005
chore(git): improve logging (#4273) 2022-08-18 07:25:11 +01:00
David Knaack ac55a01d0f
feat(git): replace `git2` with `git-repository` (#3883) 2022-08-08 22:33:00 -04:00
David Cantrell dd73447329
feat: Add the ability to have some file extensions *prevent* a module from triggering (#4043)
* test that we can match a multi-part file extension such as in foo.tar.gz

* now we can match multi-part file extensions like on foo.tar.gz

* add a test that a !ext is a negative match and over-rides any positive match

* test that negative extensions that don't match any file have no effect

* fail the match if any negative extensions exist

* cargo fmt

I'm not happy with this, in particular it's made the structures of has_any_positive_extension and has_no_negative_extension look different, and the logic in is_match is harder to follow

* placate clippy

* documentation for multi-part extensions and negative extensions

* get rid of an unnecessary .to_string() and comment the necessary but weird-looking invocations of .to_string_lossy().to_string()

* tests for negative matching of files and folders

* fail the match is any negative files/folders match

* document file/folder negative matching; be less prolix

* suppress Nodejs if Deno files are present (#2627)

* Revert "suppress Nodejs if Deno files are present (#2627)"

This reverts commit c1394fd7b37bb0bf06b1449e074020a2e16bfa04.

This was a terrible way of doing this, there's got to be a better way!
2022-07-31 16:29:48 +02:00
David Knaack eb67534ac9
chore: fix new clippy lints (#4136) 2022-06-30 16:18:29 -04:00
Kian-Meng Ang 018b077630
chore: fix typos in comments (#4122) 2022-06-28 14:19:17 -04:00
yutotnh e7c1976528
docs: fix some typos in comments (#4069)
fix: some typos
2022-06-15 19:55:10 -05:00
David Knaack 009eb93c83
build: bump clap crates to v3.2 (#4067) 2022-06-15 23:31:12 +02:00
David Knaack 0ae61c7758
chore(clippy): fix new lints (#4002) 2022-05-23 06:58:27 -04:00
Noa 81a696a914
fix: Use git2::Repository::open_ext() instead of discover() (#3591)
This lets starship respect the $GIT_CEILING_DIRECTORIES env var.
2022-05-05 11:43:03 -05:00
Thomas O'Donnell 2a650bfd14
perf(package): only try to read files that exist (#3904)
* perf(package): only try to read files that exist

Have refactored the package module to improve performance. Before this
change the module would try to open every single file that could contain
some package information until it found a valid version. This resulted
in a lot of unneeded disk IO. Have added a new fn, `read_file_from_pwd`
that uses the current context to check if that file already exists and
fast failing if it doesn't. From my local testing this speeds up the
package module from taking ~1ms to ~50µs in an empty directory.

* refactor: move read_file_from_pwd to context

* refactor(haskell): use read_files_from_pwd

* refactor(nodejs): use read_files_from_pwd
2022-04-25 16:18:01 +02:00
David Knaack 2d4b183fce
refactor: replace module_config_derive with serde (#3786)
* refactor: replace module_config_derive with serde

Changes include:
* Removing `starship_module_config_derive` and replacing it with `serde::Deserialize`
* Removing `RootModuleConfig::load_config`. While potentially useful, it was only used in tests. And it would require something like `serde::DeserializeSeed` which is not derived by serde.
* Merging `RootModuleConfig` into `ModuleConfig`
* Implementing a `ValueDeserializer` that holds a reference to a `toml::Value` in `serde_utils.rs`
* Deserialization errors (invalid type) are now logged and include the current key and the struct names
* Unknown keys are now considered an error. "Did you mean?"-messages are still possible

* fix typo

Co-authored-by: Matan Kushner <hello@matchai.dev>

Co-authored-by: Matan Kushner <hello@matchai.dev>
2022-03-26 10:42:19 +01:00
David Cantrell 0863146f07
feat: Add a module for C projects (#3631)
Co-authored-by: David Knaack <davidkna@users.noreply.github.com>
2022-03-25 00:10:19 -04:00
David Knaack 1745392909
refactor: fix new clippy/compiler warnings (#3656) 2022-02-24 23:31:01 -05:00
David Knaack 1a8aa96b7f
fix(windows): avoid verbatim paths (#3638) 2022-02-23 18:32:35 -05:00
David Knaack 0ea16e2641
fix: ignore empty `--jobs` argument (#3593) 2022-02-14 13:12:31 +01:00
moko256 bbdb584f45
fix(status): Enable to convert from i64 to hex_status by casting instead of parsing status. (#3462)
* fix(status): Enable to convert from i64 to hex_status by casting instead of parsing status.

* Apply comment to src/context.rs

Co-authored-by: David Knaack <davidkna@users.noreply.github.com>

* Update README.md in configuration

Co-authored-by: David Knaack <davidkna@users.noreply.github.com>
2022-02-05 21:13:42 +01:00
Harald Hoyer 4f46411403
feat: add a container indicator (#3304)
* test: add mock method for absolute files

Signed-off-by: Harald Hoyer <harald@hoyer.xyz>

* feat(module): add a container indicator module

Adds a container type indicator, if inside a container,
detected via the presence of some marker files.

E.g. inside a podman container entered with `toolbox enter`
the prompt changes to the container name and version.

```
starship on  container_rebased [$!] is 📦 v1.0.0 via 🦀 v1.56.1
❯ toolbox enter

starship on  container_rebased [$!] is 📦 v1.0.0 via 🦀 v1.56.1
⬢ [fedora-toolbox:35] ❯
```

Signed-off-by: Harald Hoyer <harald@hoyer.xyz>
2022-01-21 09:44:46 -06:00
Segev Finer 7e32fd952e
feat(pwsh): Set STARSHIP_SHELL to pwsh on PS >5 (#3443)
* 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>
2022-01-16 20:28:26 +01:00
David Knaack 0fd6f05da4
fix(properties): fix regressions in `status`, `pipestatus` and `terminal-width` handling (#3399) 2022-01-15 04:21:38 -05:00
David Knaack 8985499c95
fix: allow compilation without battery feature (#3435) 2022-01-14 22:12:10 +01:00
Rashil Gandhi c335b4267b
feat: add support for cmd (#3277)
* feat: add support for cmd

* add preprompt and precmd support

* add keymap support

* add info about minimum Clink version

* simplify escaping

* add handling for cmd custom commands

* add support for transient_prompt and transient_rprompt

* Revert 914057952508e81e20086fcb707ba2a0be85fdd3

This reverts commit "add support for transient_prompt and transient_rprompt"

* Apply suggestions from code review

* disable cmd shell custom commands

* any shell other than cmd can be used

* better error and correct script location

* move shell check in `map_no_escaping`
2022-01-09 23:47:53 -06:00
David Knaack 20cf200c3a
refactor: update clap to v3 (#3370) 2022-01-04 12:49:42 +03:00
Ryan Cohen 4deaa02d6f
feat: set a continuation prompt for supporting shells (#3322)
* feat: set a continuation prompt for supporting shells (#3134)

* docs: fixed wording of documentation

* fix: continuation prompt is now only set once

* fix(docs): fixed typo in advanced-config/README.md

Co-authored-by: Segev Finer <segev208@gmail.com>

* fix: update --continuation argument

Co-authored-by: David Knaack <davidkna@users.noreply.github.com>

* fix: updated continuation prompt

- PROMPT2 was fixed to be set only once in zsh.
- `continuation_symbol` and `continuation_format` were removed in
  place of a single variable; `continuation_prompt`.
- The continuation prompt was moved out of the character module.

* fix: ran rustfmt

* docs: updated continuation prompt docs

Co-authored-by: Segev Finer <segev208@gmail.com>
Co-authored-by: David Knaack <davidkna@users.noreply.github.com>
2022-01-01 14:12:11 +01:00
David Knaack af98f5b8ce
fix: set cwd for command execution (#3309) 2021-12-27 23:56:06 -06:00
arcnmx e3a88a6ec1
fix(git_branch): more robust handling of .git (#3290) 2021-12-03 15:15:31 -05:00
David Knaack 6e6ab9f212
fix: ignore scan_dir timeout in tests (#3184) 2021-10-30 10:52:48 +02:00
David Knaack c4439531d3
fix: only print root level config logs a single time (#3132) 2021-10-27 15:13:17 +02:00
Rashil Gandhi 6464693165
fix(fill): Add `terminal-width` argument to explicitly define terminal's width (#3090)
Add `terminal-width` argument to explicitly define terminal's width
Update pwsh,bash,zsh,fish init scripts with `terminal-width` argument

Co-authored-by: Kevin Song <chips@ksong.dev>
Co-authored-by: Kevin Song <4605384+chipbuster@users.noreply.github.com>
2021-10-06 16:36:28 -05:00
Kevin Song 190743e4e0
fix: pipestatus quoting on Zsh/Bash (#3088)
Changes the parsing for pipestatus to allow for multiple arguments, a
single argument of space-separated values, or any mix of the two. All
inputs are flattened into a single array where no elements have spaces
in them.

Changes the initscripts to no longer fail when an empty pipestatus
is passed as an argument by quoting and changing expansions.
2021-10-05 18:19:55 -05:00
David Knaack b22c54fccc
refactor: replace `term_size` with `terminal_size` (#3087) 2021-09-23 17:52:51 +02:00
Matthew (Matt) Jeffryes 5d0a38aca3
feat: Add a fill module to pad out the line (#3029) 2021-09-12 19:59:15 -04:00
Matthew (Matt) Jeffryes 79585dcb17
feat: Add support for RPROMPT (right prompt) (#3026)
Adds support for zsh, fish, and elvish.

Co-authored-by: Matan Kushner <hello@matchai.dev>
2021-09-08 15:45:27 -04:00
David Knaack 9d3ec93d82
refactor: allow passing OsStr as-is to `exec_cmd` (#2997) 2021-08-23 18:49:30 +02:00
filip 3139c6b8a3
feat(git_status): dont render module output if not in git repository (#2897)
* refactor get_repo method to not swallow error

* module git status don't render if not in git repository
2021-08-14 15:19:43 +02:00