diff options
| author | Waldir Pimenta <waldyrious@gmail.com> | 2025-12-03 23:13:05 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-12-03 15:13:05 -0800 |
| commit | 011fe31c84d40d8b738183c6d65ab8973d08fc0a (patch) | |
| tree | e514a55d427ec63a965b66141ae8a65c7ef4aa04 /crates/atuin-client/src/import/replxx.rs | |
| parent | build(nix): prevent deprecation warning on evaluation (#3006) (diff) | |
| download | atuin-011fe31c84d40d8b738183c6d65ab8973d08fc0a.zip | |
feat: support additional history filenames in replxx importer (#3005)
<!-- Thank you for making a PR! Bug fixes are always welcome, but if
you're adding a new feature or changing an existing one, we'd really
appreciate if you open an issue, post on the forum, or drop in on
Discord -->
The original implementation of the `replxx` importer, from PR #2024,
only supported `.histfile` as a filename for the history file, since
there is no default filename. However, the replxx codebase does use
`replxx_history.txt` as an example history filename (see
[here](https://github.com/AmokHuginnsson/replxx/blob/release-0.0.4/examples/c-api.c#L183)
and
[here](https://github.com/AmokHuginnsson/replxx/blob/release-0.0.4/examples/cxx-api.cxx#L383)),
so this patch adds support for that as an alternative filename.
The implementation was modeled after [the
one](https://github.com/atuinsh/atuin/blob/v18.10.0/crates/atuin-client/src/import/zsh.rs#L29-L44)
currently used for the `zsh` history file importer, which also means the
`replxx` importer now produces a human-friendly error if no history file
is found in the expected path(s).
## Checks
- [x] I am happy for maintainers to push small adjustments to this PR,
to speed up the review cycle
- [x] I have checked that there are no existing pull requests for the
same thing
/cc @amosbird who introduced this importer in #2024.
Diffstat (limited to 'crates/atuin-client/src/import/replxx.rs')
| -rw-r--r-- | crates/atuin-client/src/import/replxx.rs | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/crates/atuin-client/src/import/replxx.rs b/crates/atuin-client/src/import/replxx.rs index dd7030ad..47d566cf 100644 --- a/crates/atuin-client/src/import/replxx.rs +++ b/crates/atuin-client/src/import/replxx.rs @@ -19,8 +19,23 @@ fn default_histpath() -> Result<PathBuf> { let home_dir = user_dirs.home_dir(); // There is no default histfile for replxx. - // For simplicity let's use the most common one. - Ok(home_dir.join(".histfile")) + // Here we try a couple of common names. + let mut candidates = ["replxx_history.txt", ".histfile"].iter(); + loop { + match candidates.next() { + Some(candidate) => { + let histpath = home_dir.join(candidate); + if histpath.exists() { + break Ok(histpath); + } + } + None => { + break Err(eyre!( + "Could not find history file. Try setting and exporting $HISTFILE" + )); + } + } + } } #[async_trait] |
