mirror of
https://github.com/extrawurst/gitui.git
synced 2024-11-21 15:02:40 +03:00
Support "Copy Path" operation in WSL (#2413)
This commit is contained in:
parent
8db448cab3
commit
94924db632
@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
* Set `CREATE_NO_WINDOW` flag when executing Git hooks on Windows ([#2371](https://github.com/extrawurst/gitui/pull/2371))
|
||||
|
||||
### Added
|
||||
* support for "Copy Path" action in WSL [[@johnDeSilencio](https://github.com/johnDeSilencio)] ([#2413](https://github.com/extrawurst/gitui/pull/2413))
|
||||
* help popup scrollbar [[@wugeer](https://github.com/wugeer)](https://github.com/extrawurst/gitui/pull/2388))
|
||||
* add popups for viewing, adding, updating and removing remotes [[@robin-thoene](https://github.com/robin-thoene)] ([#2172](https://github.com/extrawurst/gitui/issues/2172))
|
||||
|
||||
|
@ -49,12 +49,30 @@ fn exec_copy_with_args(
|
||||
}
|
||||
}
|
||||
|
||||
// Implementation taken from https://crates.io/crates/wsl.
|
||||
// Using /proc/sys/kernel/osrelease as an authoratative source
|
||||
// based on this comment: https://github.com/microsoft/WSL/issues/423#issuecomment-221627364
|
||||
#[cfg(all(target_family = "unix", not(target_os = "macos")))]
|
||||
fn is_wsl() -> bool {
|
||||
if let Ok(b) = std::fs::read("/proc/sys/kernel/osrelease") {
|
||||
if let Ok(s) = std::str::from_utf8(&b) {
|
||||
let a = s.to_ascii_lowercase();
|
||||
return a.contains("microsoft") || a.contains("wsl");
|
||||
}
|
||||
}
|
||||
false
|
||||
}
|
||||
|
||||
#[cfg(all(target_family = "unix", not(target_os = "macos")))]
|
||||
pub fn copy_string(text: &str) -> Result<()> {
|
||||
if std::env::var("WAYLAND_DISPLAY").is_ok() {
|
||||
return exec_copy_with_args("wl-copy", &[], text, false);
|
||||
}
|
||||
|
||||
if is_wsl() {
|
||||
return exec_copy_with_args("clip.exe", &[], text, false);
|
||||
}
|
||||
|
||||
if exec_copy_with_args(
|
||||
"xclip",
|
||||
&["-selection", "clipboard"],
|
||||
|
Loading…
Reference in New Issue
Block a user