Skip to content

Commit 7a2d6c2

Browse files
committed
make shell detection more reliable. sometimes it's under /usr/bin/zsh
1 parent 3812f99 commit 7a2d6c2

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

scripts/setup.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,16 +51,17 @@ if (import.meta.main) {
5151
// detect shell type and inject `wql` alias
5252
try {
5353
const shell = detectDefaultShell();
54+
const shellName = path.basename(shell);
5455

5556
// TODO: other shell types?
56-
if (shell === "/bin/bash" || shell === "/bin/zsh") {
57+
if (shellName === "bash" || shellName === "zsh") {
5758
const rcFile = (() => {
5859
const zDotDir = Deno.env.get("ZDOTDIR");
59-
if (shell === "/bin/zsh" && zDotDir) {
60+
if (shellName === "zsh" && zDotDir) {
6061
return path.join(zDotDir, ".zshrc");
6162
}
6263

63-
const rc = shell === "/bin/bash" ? ".bashrc" : ".zshrc";
64+
const rc = shellName === "bash" ? ".bashrc" : ".zshrc";
6465
return path.join(homedir(), rc);
6566
})();
6667

@@ -83,7 +84,7 @@ if (import.meta.main) {
8384
await writer.ready;
8485
await writer.close();
8586

86-
updatedShell = shell === "/bin/bash" ? "bash" : "zsh";
87+
updatedShell = shellName === "bash" ? "bash" : "zsh";
8788
}
8889
}
8990
} catch (_error) {

0 commit comments

Comments
 (0)