twibiral / obsidian-execute-code

Obsidian Plugin to execute code in a note.
MIT License
1.15k stars 68 forks source link

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

Open bachrc opened 2 years ago

bachrc commented 2 years ago

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 ?

twibiral commented 2 years ago

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

pspiagicw commented 2 years ago

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

twibiral commented 2 years ago

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 commented 2 years ago

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

bachrc commented 2 years ago

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

twibiral commented 2 years ago

An update in Obsidian

twibiral commented 2 years ago

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

mayurankv commented 1 year ago

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 commented 1 year ago

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.