0

In order to launch a new terminal and run a zsh function on it, I am trying to run the following command from within an urxvtc terminal (the urxvtd is running as a systemd service)

     urxvtc -e zsh -c "my-zsh-defined-function"

which doesn't work as the function is unknown. I need to explicitly source my zshrc to make it work

     urxvtc -e zsh -c "source ~/.zshrc; my-zsh-defined-function"

The problem is, I don't understand why. Shouldn't zsh source .zshrc as when I run urxvtc, and then I type my-zsh-defined-function ?

1 Answer 1

2

It shouldn't, since you're not running zsh interactively. Quoting man zsh (section STARTUP/SHUTDOWN FILES):

[I]f the shell is interactive, commands are read from /etc/zshrc and then $ZDOTDIR/.zshrc.

You could try using -i:

-i     Force  shell to be interactive.  It is still possible to specify
       a script to execute.
1
  • Well, doing urxvtc -e zsh -c 'zsh -i -c my-zsh-defined-function' works fine, thanks
    – csantosb
    Commented Dec 30, 2014 at 15:14

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .