obsidian-execute-code icon indicating copy to clipboard operation
obsidian-execute-code copied to clipboard

[FR] Does not take in account the .*rc file for Shell commands

Open bachrc opened this issue 3 years ago • 9 comments

I want to execute a shell command (here, zsh), but I have path and environment variables defined in my .zshrc. Though, when I execute my command, the plgin doesn't read them ! Any ideas ?

bachrc avatar Aug 08 '22 09:08 bachrc

The plugin doesn't read them in. I will add this to future work.

twibiral avatar Aug 08 '22 11:08 twibiral

Should be easy to implement. spawn function from child_process does accept optional argument. We can give a shell here. It would automatically source it's .rc file. Documentation here

pspiagicw avatar Sep 20 '22 12:09 pspiagicw

I think the shell option is already used for groovy. We can add it for shell/bash/powershell too. Maybe even add it in general for every language.

twibiral avatar Sep 20 '22 12:09 twibiral

@bachrc it should work now. Can you test it and give me feedback?

twibiral avatar Sep 20 '22 15:09 twibiral

Did you released an update on Obsidian or should I build the plugin ?

bachrc avatar Sep 21 '22 10:09 bachrc

An update in Obsidian

twibiral avatar Sep 21 '22 10:09 twibiral

I consider this as resolved, please reopen this issue otherwise.

twibiral avatar Oct 13 '22 19:10 twibiral

This doesn't seem to work for me, doing echo $ZSHCONFIG returns nothing whilst doing it in a terminal returns the path to my .zshrc as expected.

mayurankv avatar Dec 02 '22 20:12 mayurankv

That is for a shell language block with zsh (my default shell). I can circumvent this by pre-executing source but this becomes an issue when using python blocks because variables for settings files like MATPLOTLIBRC are not respected in the python blocks.

mayurankv avatar Dec 02 '22 20:12 mayurankv