summaryrefslogtreecommitdiffstats
path: root/src/utils.rs
diff options
context:
space:
mode:
authorqkzk <qu3nt1n@gmail.com>2023-02-26 12:15:20 +0100
committerqkzk <qu3nt1n@gmail.com>2023-02-26 12:15:20 +0100
commitdce565d0d7613967f71ea3aec961366e636eeca2 (patch)
tree9d545de85a883b55c7fafb9ff90c78fc73ddc823 /src/utils.rs
parented7a644f233ecaffc32bc5b20a2fdd8f62c85019 (diff)
read current terminal from env, if it doesn't exists use config one
Diffstat (limited to 'src/utils.rs')
-rw-r--r--src/utils.rs12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/utils.rs b/src/utils.rs
index 355c86b..490e961 100644
--- a/src/utils.rs
+++ b/src/utils.rs
@@ -105,3 +105,15 @@ pub fn current_username() -> FmResult<String> {
.ok_or_else(|| FmError::custom("username", "couldn't read username"))?
.to_owned())
}
+
+pub fn is_program_in_path(program: &str) -> bool {
+ if let Ok(path) = std::env::var("PATH") {
+ for p in path.split(':') {
+ let p_str = format!("{p}/{program}");
+ if std::fs::metadata(p_str).is_ok() {
+ return true;
+ }
+ }
+ }
+ false
+}