Question

I've got a script in my ~/.bin directory that changes iTerm's background before starting an SSH session (as detailed here, script slightly modified from this version).

If I start a regular login session and run my command, sshb servername, it works fine! The background image loads and the SSH session starts.

However, if I set up a profile to start a session with that same command, it errors out and says it can't find sshb. If I make my command ~/.bin/sshb servername, it runs the command, but says it can't find the ImageMagick convert command used in that script.

It seems as though the command shell command doesn't know about my $PATH. I suppose I could figure out where convert lives and edit the script to use the full path, but that seems to be treating symptoms, not the problem. Is there a way to make the command shell load my environment variables before it runs that command?

Was it helpful?

Solution

Environment variables like PATH and TERM are normally inherited from the shell. When you run the script directly, they are unset.

You can run the script as a child process of a login shell by setting the command to bash -lc "~/.bin/sshb servername".

Licensed under: CC-BY-SA with attribution
Not affiliated with apple.stackexchange
scroll top