Ghostty doesn't source files like .zshrc when launched from a .command file #3030
Replies: 7 comments 8 replies
-
Converted to a discussion to get more details here. My first question is: do other terminals also do this? I assume so but good to verify. If they do, I'm curious how they do it. I think some research is required to provide some input on this. |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
Temporary workaround for your if [[ $TERM_PROGRAM == "ghostty" ]]; then
if [[ $SHELL =~ "/zsh" ]]; then
[[ -e ~/.zprofile ]] && source ~/.zprofile
[[ -e ~/.zshrc ]] && source ~/.zshrc
elif [[ $SHELL =~ "/bash" ]]; then
[[ -e ~/.bash_profile ]] && source ~/.bash_profile
[[ -e ~/.bashrc ]] && source ~/.bashrc
fi
fi |
Beta Was this translation helpful? Give feedback.
-
I'm also seeing a strange related bug. After the
Maybe related to #3998 ? |
Beta Was this translation helpful? Give feedback.
-
I don't think it make sense to speak of what shell configuration files Ghostty does or does not source given that Ghostty isn't a shell. By default, Ghostty seems to execute the user's login shell as a login shell, presumably by prepending a On macOS, Terminal can also be configured to execute an alternative command at start up, but crucially, besides accepting the alternative command, Terminal also has an option as to whether or not that command is "run inside [a] shell." When this option is not selected, Terminal either executes the command directly or perhaps indirectly via It would be fantastic if Ghostty had an option for executing an alternative command which worked the same way as "run inside [a] shell" does with Terminal. One nicety of the method Terminal uses is that it's not necessary to know how to pass a command to a shell (although My login shell is First, configure Ghostty:
Then, provide the command wrapper:
If I don't involve the intermediate login shell, Ghostty won't be able to find The work-around I'm using isn't quite the same as what Terminal does, but it's good enough for now. A work-around involving |
Beta Was this translation helpful? Give feedback.
-
Could this be a case some env vars are defined in terminal-specifc rc-files which
and
(Took me a while to figure nix was configured in |
Beta Was this translation helpful? Give feedback.
-
Ghostty also fails to handle spaces in paths and filenames when wrapping the launch command for the OPEN Apple Event. If the file you have set Ghostty as the handler for or drop on the Ghostty application is named "Launch Me.command" or "Run Me.sh" then Ghostty will throw an error that there is no file named "Launch" or "Run." |
Beta Was this translation helpful? Give feedback.
-
When launched from a .command file on macOS (.sh equivalent), Ghostty doesn't source files like .zshrc before executing the command file. This is a bug because the default Terminal app on macOS does so, and this behavior might break some people's files
Beta Was this translation helpful? Give feedback.
All reactions