Giter Club home page Giter Club logo

Comments (11)

Learath2 avatar Learath2 commented on May 24, 2024

I took a quick look at the git blame and it seems the -l is needed to keep the current directory. I guess passing -f to zsh is the way to go.

from alacritty.

nixpulvis avatar nixpulvis commented on May 24, 2024

This has nothing to do with alacritty, I recommend playing with your shell until it behaves as expected.

from alacritty.

Learath2 avatar Learath2 commented on May 24, 2024

This has nothing to do with alacritty, I recommend playing with your shell until it behaves as expected.

I respectfully disagree. This has something to do with alacritty as alacritty's choice to invoke the user login shell through zsh is what pollutes the environment. It's not expected behaviour that your terminal emulator runs an extra shell. Especially a shell that is not the login shell you picked with no recourse but to fork and compile your own.

from alacritty.

nixpulvis avatar nixpulvis commented on May 24, 2024

That’s not alacritty doing that, I believe this was a choice macOS made recently. Feel free to change your shell invocation in the alacritty config to get around it though, or write your own wrapper shell as your default shell.

from alacritty.

Learath2 avatar Learath2 commented on May 24, 2024

I even linked the line where alacritty starts the login shell through zsh -c how is that a choice by macOS? The only reason alacritty uses zsh there seems to be the fact that it needs exec -a. zsh -fc would be the correct way to abuse zsh there without polluting the environment.

from alacritty.

nixpulvis avatar nixpulvis commented on May 24, 2024

Apologies. I forgot all about that logic and was assuming that something changed when macOS defaulted to ZSH somewhat recently.

from alacritty.

nixpulvis avatar nixpulvis commented on May 24, 2024

@Learath2 perhaps reading over #6426 will shed some light on this issue. I vaguely recall being a bit confused about this myself a while ago now that I’m thinking more about it. Though I assume you have at this point.

from alacritty.

nixpulvis avatar nixpulvis commented on May 24, 2024

So now I'm curious and I'm trying running the suggested change here:

diff --git a/alacritty_terminal/src/tty/unix.rs b/alacritty_terminal/src/tty/unix.rs
index a4b07b74..d559a4e4 100644
--- a/alacritty_terminal/src/tty/unix.rs
+++ b/alacritty_terminal/src/tty/unix.rs
@@ -162,21 +162,12 @@ fn default_shell_command(shell: &str, _user: &str) -> Command {
 
 #[cfg(target_os = "macos")]
 fn default_shell_command(shell: &str, user: &str) -> Command {
-    let shell_name = shell.rsplit('/').next().unwrap();
-
     // On macOS, use the `login` command so the shell will appear as a tty session.
     let mut login_command = Command::new("/usr/bin/login");
 
-    // Exec the shell with argv[0] prepended by '-' so it becomes a login shell.
-    // `login` normally does this itself, but `-l` disables this.
-    let exec = format!("exec -a -{} {}", shell_name, shell);
-
     // -f: Bypasses authentication for the already-logged-in user.
-    // -l: Skips changing directory to $HOME and prepending '-' to argv[0].
     // -p: Preserves the environment.
-    //
-    // XXX: we use zsh here over sh due to `exec -a`.
-    login_command.args(["-flp", user, "/bin/zsh", "-c", &exec]);
+    login_command.args(["-fp", user, shell]);
     login_command
 }

Seems to work for me, so I'm not sure why things are as they are. Also, it's worth noting that having your shell.program set to something without the login call also results in a terminal without a registered session, which I suspect many people have. I don't honestly know what the consequences of not being a registered session are, but all my alacritty instances don't show up when I call who.

Hope this helps a bit.

from alacritty.

kchibisov avatar kchibisov commented on May 24, 2024

You can look into the git history to figure out why the changes are like that, but most likely because of some macOS bug.

PR that added that is also relatively new thing.

Also, none of that triggers if you run the command on your own iirc.

from alacritty.

nixpulvis avatar nixpulvis commented on May 24, 2024

It just surprised me that all this special logic is skipped if you choose your own shell in the config. Shouldn’t it be applied to custom shells too?

from alacritty.

Learath2 avatar Learath2 commented on May 24, 2024

Careful. Removing the -l isn't correct. It'll switch directories to home. I'm running with -f added to the zsh invocation, and that has been working fine for me, albeit only tested for a week or so.

from alacritty.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.