Skip to content

Commit

Permalink
fix: support not-mac for default shell (#1960)
Browse files Browse the repository at this point in the history
  • Loading branch information
ellie authored Apr 19, 2024
1 parent 00dfc03 commit 98350f5
Showing 1 changed file with 14 additions and 15 deletions.
29 changes: 14 additions & 15 deletions crates/atuin-common/src/shell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 98350f5

Please sign in to comment.