0

Short description

  • Same .zshrc file in both Operating Systems
  • Most things work fine in Arch, only some don't
  • Command: echo $? Output: 0
  • PS1="%(?.▶.✘)" shows the while starting new pts
  • With source ~/.zshrc everything works suddenly

Long description

Okay I am not sure if anyone can help me with this, because I can't even identify the problem exactly. I am just gonna describe what is going on:

So I have the absolutely identical .zshrc on both my ubuntu-computer and on my arch-computer. When I start a terminal-emulator, zsh gets loaded and everything goes fine.

When I do it on my arch-computer tho, it fails. But here comes the thing, it doesn't fail completely. Let me explain:

Most of the aliases, functions and options work perfectly fine. But some don't. Even weirder is, that after I type in

source ~/.zshrc

everything works perfectly fine. It is just at the start.

And the weirdness just continues: I use something like this in my prompt:

PS1="%(?.%(!.%{$fg[yellow]%}▶.%{$fg[cyan]%}▶).%{$fg[red]%}✘)"

In short explained: If the last command failed, it shows the cross, and if everything went fine, it shows the right arrow. As soon as I start the terminal it shows the cross, so something went wrong. But no error messages are shown...

And last, if I use this command:

echo $?

In short, this shows the exit status code of the last command.

It shows the Error-Code of 0. So it should be all fine right? But no. How can the Prompt see that something went wrong but not $? or anything else?

I am just so confused and I have no Idea how to debug something like this. If you have any Ideas, please please please let me know.

It isn't the worst thing on earth, it is just annoying. And for the sake of learning it would be interesting, to find out where the problem lies, because this seems rather unusual to me.

(My .zshrc is over 400 lines of code, I think there is no point in showing it here since it has no errors in itself. If you think otherwise, let me know and I am gonna edit the question)



Thanks for your help :)

Pixelbog
  • 236
  • 1
  • 8
  • 1
    [unix.se] is a better place for questions about shell/environment customization as opposed to software development. – Charles Duffy Feb 20 '23 at 16:00
  • 1
    As for losing your `$?` values, though -- use `set -x` to enable trace logging, and see what all's running between shell commands. I'll bet you there'll be a fair bit more going on than just printing your prompt unmodified. – Charles Duffy Feb 20 '23 at 16:01
  • 1
    Also, keep the distinction between _login_ shells and _interactive_ shells in mind. In the former, you have `.zprofile` executed. If your zprofile isn't in turn sourcing .zshrc (caveat: this comment is assuming that zsh behaves similarly to more standard-compliant shells, which is not always a safe assumption), that can lead to having a shell where your zshrc hasn't been executed. – Charles Duffy Feb 20 '23 at 16:02
  • 1
    While `bash` uses `.bash_profile` *instead* of `.bashrc` for login shells, `zsh` sources `.zprofile` as an *additional* configuration file to `.zshrc` (which is sourced for all interactive shells, whether or not it is also a login shell). That said, any configuration file can set and unset options that control whether later files in the process get sourced or not. – chepner Feb 20 '23 at 20:18

0 Answers0