[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Beginning with org-babel.

From: William Denton
Subject: Re: Beginning with org-babel.
Date: Thu, 24 Feb 2022 21:08:35 -0500 (EST)
User-agent: Alpine 2.22 (DEB 394 2020-01-19)

On 25 February 2022, Steven Harris wrote:

The current problem is that I have a config file that I want to substitute
a value into.  I want the conf-mode highlighting.  Conf is not a
programming language of course, just a text format.

I'm trying something like

#+begin_src conf :tangle yes :noweb yes
 private_key_file = <<ssh_private_key_file>>

I have tried something similar to the SQL comment example in the
documentation to no avail and also setting :var headers. How can I
substitute a value here?

I think there are a few different ways, but they depend on Org knowing about the language of the source block (as I realized after writing most of this, and deciding I'd send it along anyway in case it's helpful):

One way I do it is like so, first with defining a variable.

| 3.1.1 |

Then, in a source block, call in the variable with :var, like so:

#+begin_src shell :tangle conforg/scripts/ruby-install-personal.sh :shebang 
"#!/bin/bash" :var RUBY_VERSION=RUBY_VERSION
rbenv install --verbose $RUBY_VERSION
rbenv global $RUBY_VERSION ~/conforg/scripts/ruby-install-gems.sh
echo "Now run bundle install where needed."

I'm using the RUBY_VERSION variable name in two places: first on its own in Org, then in the shell script as an environment variable that is set to the value of the Org variable. No point in using two different variable names for this, I thought. But in other cases one would want to.

(This is from Conforguration,¹ my system for setting up my dot files and some languages or services I want to run from source.)

But Org knows about shell scripts and can pass variables in to them (like it can with SQL), and Org doesn't know about INI files or other config files the same way. So (unless I'm mistaken) this method won't work.

However, surely there's another way ...


¹ https://github.com/wdenton/conforguration

William Denton
Librarian, artist and licensed private investigator.
Toronto, Canada

reply via email to

[Prev in Thread] Current Thread [Next in Thread]