Windows support (#754)
* adds support for getting home dir in windows * fixes bug * adds windows server support + build for linux ^| todo: test server on linux * improvements to redability * removes comment * returns if windows when importing auto * this should be here, to prevent double inputs * adds explanation to why we have to throw away 1 event in the tui * better message when running atuin import on windows + spell fix
This commit is contained in:
parent
df16a03cb6
commit
e9c5e1d85c
3 changed files with 20 additions and 1 deletions
|
@ -10,11 +10,19 @@ pub fn uuid_v4() -> String {
|
|||
// TODO: more reliable, more tested
|
||||
// I don't want to use ProjectDirs, it puts config in awkward places on
|
||||
// mac. Data too. Seems to be more intended for GUI apps.
|
||||
|
||||
#[cfg(not(target_os = "windows"))]
|
||||
pub fn home_dir() -> PathBuf {
|
||||
let home = std::env::var("HOME").expect("$HOME not found");
|
||||
PathBuf::from(home)
|
||||
}
|
||||
|
||||
#[cfg(target_os = "windows")]
|
||||
pub fn home_dir() -> PathBuf {
|
||||
let home = std::env::var("USERPROFILE").expect("%userprofile% not found");
|
||||
PathBuf::from(home)
|
||||
}
|
||||
|
||||
pub fn config_dir() -> PathBuf {
|
||||
let config_dir =
|
||||
std::env::var("XDG_CONFIG_HOME").map_or_else(|_| home_dir().join(".config"), PathBuf::from);
|
||||
|
|
|
@ -45,6 +45,11 @@ impl Cmd {
|
|||
|
||||
match self {
|
||||
Self::Auto => {
|
||||
if cfg!(windows) {
|
||||
println!("This feature does not work on windows. Please run atuin import <SHELL>. To view a list of shells, run atuin import.");
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
let shell = env::var("SHELL").unwrap_or_else(|_| String::from("NO_SHELL"));
|
||||
if shell.ends_with("/zsh") {
|
||||
if ZshHistDb::histpath().is_ok() {
|
||||
|
|
|
@ -475,6 +475,13 @@ pub async fn history(
|
|||
let initial_input = app.input.as_str().to_owned();
|
||||
let initial_filter_mode = app.filter_mode;
|
||||
|
||||
{
|
||||
// We do this because windows does double inputs and captures the `Enter` when running a
|
||||
// command
|
||||
#[cfg(target_os = "windows")]
|
||||
let _ = event::read();
|
||||
};
|
||||
|
||||
let event_ready = tokio::task::spawn_blocking(|| event::poll(Duration::from_millis(250)));
|
||||
|
||||
tokio::select! {
|
||||
|
@ -499,7 +506,6 @@ pub async fn history(
|
|||
results = app.query_results(settings.search_mode, db).await?;
|
||||
}
|
||||
};
|
||||
|
||||
if index < results.len() {
|
||||
// index is in bounds so we return that entry
|
||||
Ok(results.swap_remove(index).command)
|
||||
|
|
Loading…
Reference in a new issue