Introduce reveal_in_finder function

And use this function in a new Reveal in Finder option of the project panel context menu.

Co-Authored-By: Mikayla Maki <mikayla.c.maki@gmail.com>
This commit is contained in:
Petros Amoiridis 2023-02-10 21:11:05 +02:00
parent 7de04abdcb
commit a789476c95
No known key found for this signature in database
2 changed files with 19 additions and 0 deletions

View file

@ -9,6 +9,7 @@ use rand::{seq::SliceRandom, Rng};
use std::{
cmp::Ordering,
ops::AddAssign,
path::Path,
pin::Pin,
task::{Context, Poll},
};
@ -53,6 +54,15 @@ pub fn truncate_and_trailoff(s: &str, max_chars: usize) -> String {
}
}
pub fn reveal_in_finder<P: AsRef<Path>>(path: P) {
let path_to_reveal = path.as_ref().to_string_lossy();
std::process::Command::new("open")
.arg("-R") // To reveal in Finder instead of opening the file
.arg(path_to_reveal.as_ref())
.spawn()
.log_err();
}
pub fn post_inc<T: From<u8> + AddAssign<T> + Copy>(value: &mut T) -> T {
let prev = *value;
*value += T::from(1);