8000 [FEATURE] Per-note/dir/block environments · Issue #412 · twibiral/obsidian-execute-code · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

[FEATURE] Per-note/dir/block environments #412

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
jbschooley opened this issue Mar 19, 2025 · 1 comment
Open

[FEATURE] Per-note/dir/block environments #412

jbschooley opened this issue Mar 19, 2025 · 1 comment
Labels
features request Request for a new feature.

Comments

@jbschooley
Copy link

Is your feature request related to a problem? Please describe.
I'd like to be able to specify an environment for a language inside a directory or individual note. Any code in that language inside that note would use that environment, but notes outside of that would either use their own environments or the default environment.

Describe the solution you'd like
Something that allows me to define an environment for that individual note or any notes in the current directory and its children. For example with SQL, I could define a server to connect to (possibly pulling credentials from a .env file that may or may not be in the current dir or even in the vault) and any SQL blocks in that note or dir would connect to that host.

Maybe even an option to specify it per code block:

```sql {env='prod'}

or in a file

```sql {env='./prod.env'}
```sql {env='~/envs/prod.env'}

prod.env:

path: psql
# path: docker run -it --rm postgres psql
args: -d <database> -U <user> -f

Maybe something like {pre, env='~/really/long/path/prod.env'} to apply that env to everything in the note. Or {label='prod', env='~/really/long/path/prod.env'} and use an import to reuse that env without having to rewrite the path for each block.

Or even {env=[dev='./dev.env', prod='./prod.env']} and the Run button in that block (and anything that imports it) would change to 2 buttons labeled dev and prod

Describe alternatives you've considered
Right now I don't know of anything like this. I just copy-paste my code into terminal in a dir where I use direnv to set up environments

Additional context
I'm looking for a place to keep all my snippets for all my projects and be able to easily run them. I think this is the last piece of the puzzle.

@jbschooley jbschooley added the features request Request for a new feature. label Mar 19, 2025
@jbschooley jbschooley changed the title [FEATURE] Per-note/dir environments [FEATURE] Per-note/dir/block environments Mar 19, 2025
@jbschooley
Copy link
Author

Another possible solution: wrappers. In fact, this might be better, and more flexible as you could run custom languages with it. Similar to pre/post blocks but with more options.

```run-shell {label='prod'}
docker run -it --rm postgres psql -d <database> -U <user> -c '@wrapped_str'
# or
docker run -it --rm postgres psql -d <database> -U <user> -f @wrapped_file
```

```run-sql {wrap='prod'}
SELECT * FROM table;
```

Or wrap with a template script:

#!/bin/bash
docker run -it --rm postgres psql -d <database> -U <user> -c '@wrapped_str'
```run-sql {wrap='./prod.sh'}
SELECT * FROM table;
```

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
features request Request for a new feature.
Projects
None yet
Development

No branches or pull requests

1 participant
0