summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEllie Huxtable <ellie@elliehuxtable.com>2024-04-19 09:58:25 +0100
committerGitHub <noreply@github.com>2024-04-19 09:58:25 +0100
commit98350f52df1d783886313682a5eada8a729cbaed (patch)
tree9339049d23e967c20d4ed499eff9e056ac2b0e98
parent00dfc034ed8c816de97824b510f3849420893555 (diff)
fix: support not-mac for default shell (#1960)
-rw-r--r--crates/atuin-common/src/shell.rs29
1 files changed, 14 insertions, 15 deletions
diff --git a/crates/atuin-common/src/shell.rs b/crates/atuin-common/src/shell.rs
index 42e32f72..afdccea7 100644
--- a/crates/atuin-common/src/shell.rs
+++ b/crates/atuin-common/src/shell.rs
@@ -67,26 +67,25 @@ impl Shell {
// TODO: Support Linux
// I'm pretty sure we can use /etc/passwd there, though there will probably be some issues
- if sys.contains("darwin") {
+ let path = if sys.contains("darwin") {
// This works in my testing so far
- let path = Shell::Sh.run_interactive([
+ Shell::Sh.run_interactive([
"dscl localhost -read \"/Local/Default/Users/$USER\" shell | awk '{print $2}'",
- ])?;
-
- let path = Path::new(path.trim());
-
- let shell = path.file_name();
+ ])?
+ } else {
+ Shell::Sh.run_interactive(["getent passwd $LOGNAME | cut -d: -f7"])?
+ };
- if shell.is_none() {
- return Err(ShellError::NotSupported);
- }
+ let path = Path::new(path.trim());
+ let shell = path.file_name();
- Ok(Shell::from_string(
- shell.unwrap().to_string_lossy().to_string(),
- ))
- } else {
- Err(ShellError::NotSupported)
+ if shell.is_none() {
+ return Err(ShellError::NotSupported);
}
+
+ Ok(Shell::from_string(
+ shell.unwrap().to_string_lossy().to_string(),
+ ))
}
pub fn from_string(name: String) -> Shell {