Skip to content

Commit

Permalink
Windows bugfixes
Browse files Browse the repository at this point in the history
  • Loading branch information
htngr committed Oct 11, 2024
1 parent cd28439 commit 993d396
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 12 deletions.
2 changes: 1 addition & 1 deletion codchi/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion codchi/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "codchi"
build = "build/main.rs"
version = "0.2.2"
version = "0.2.3"
edition = "2021"
rust-version = "1.80.0"
resolver = "2"
Expand Down
2 changes: 2 additions & 0 deletions codchi/src/module.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use crate::cli::{InputOptions, ModuleAttrPath, ModuleName, NixpkgsLocation, RelativePath};
use crate::config::git_url::{GitUrl, Scheme};
use crate::consts;
use crate::consts::user::DEFAULT_HOME;
use crate::logging::{log_progress, set_progress_status};
use crate::platform::{nix::NixDriver, *};
use crate::progress_scope;
Expand Down Expand Up @@ -664,6 +665,7 @@ nix run nixpkgs#git -- checkout {commit}
.cmd()
.script(cmd)
.with_user(platform::LinuxUser::Default)
.with_cwd(DEFAULT_HOME.clone())
.output_ok_streaming(channel().1, |line| {
log_progress("git clone", log::Level::Info, &line)
})?;
Expand Down
4 changes: 0 additions & 4 deletions codchi/src/platform/host.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,6 @@ pub trait Host: Sized {
use windows::Win32::System::Threading::*;
cmd.creation_flags(CREATE_NEW_PROCESS_GROUP.0 | CREATE_NO_WINDOW.0);
}
// #[cfg(target_family = "unix")]
// {
// cmd.creation_flags();
// }
cmd.spawn()?;
anyhow::Ok(())
}
Expand Down
4 changes: 2 additions & 2 deletions codchi/src/platform/windows/host.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use mslnk::ShellLink;
use std::{env, fs, os::windows::process::CommandExt, process::Command};
use sysinfo::System;
use windows::Win32::System::Threading::{
CREATE_NEW_CONSOLE, CREATE_NEW_PROCESS_GROUP, CREATE_NO_WINDOW,
CREATE_NEW_PROCESS_GROUP, CREATE_NO_WINDOW, DETACHED_PROCESS,
};
// use winreg::{enums::HKEY_CURRENT_USER, RegKey};

Expand Down Expand Up @@ -154,7 +154,7 @@ impl Host for HostImpl {
if let Some((cmd, args)) = cmd.split_first() {
Command::new(cmd)
.args(args)
.creation_flags(CREATE_NEW_CONSOLE.0)
.creation_flags(DETACHED_PROCESS.0)
.spawn()?;
} else {
anyhow::bail!("Failed to open terminal with an empty command");
Expand Down
19 changes: 15 additions & 4 deletions docs/src/docs/start/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,25 @@ download and install a newer codchi.msix at any time.

### Shell Completions

On some Windows Systems running PowerShell scripts is considered a security vulnerability and often completely disabled. Therefore Codchi doesn't try to automatically run PowerShell Scripts and you have to manually add the completions:
On some Windows Systems running PowerShell scripts is considered a security vulnerability and often completely disabled. Therefore Codchi doesn't try to automatically run PowerShell scripts and you have to manually add the following to the end of your PowerShell configuration (find it by running `$PROFILE` in PowerShell):

```ps1
# In PowerShell:
mkdir $env:USERPROFILE\Documents\WindowsPowerShell
echo 'codchi completion powershell | invoke-expression' >> $PROFILE
Invoke-Expression (& codchi completion powershell | Out-String)
```

#### Further Recommendations

- For better tab complete and history search:
```ps1
# Shows navigable menu of all options when hitting tab
Set-PSReadlineKeyHandler -Key Tab -Function MenuComplete
# Autocompletion for arrow keys (when something was already typed)
Set-PSReadlineKeyHandler -Key UpArrow -Function HistorySearchBackward
Set-PSReadlineKeyHandler -Key DownArrow -Function HistorySearchForward
```
- Install [Starship.rs](https://starship.rs/) for a better prompt


## Linux

Expand Down

0 comments on commit 993d396

Please sign in to comment.