I recently wrote:

>> My org documents include lots of source code blocks, in a variety of
>> languages. I use the listings package to give each language a
>> distinctive look.
>> Lately, my work has involved using shell commands on different machines,
>> as different users. I'd like to give each shell environment (e.g., local
>> user, normal user on remote host, root on remote host) a different look.
>> At the moment, I'm doing this by specifying different shells (bash,
>> dash, sh) for each. This works, especially since I'm not executing the
>> commands from emacs, so it doesn't matter which shell I specify.
>> Is there a better way to do this?
I've found that #+ATTR_LATEX: :options language=.... does exactly what I
was looking for. The attached example may be useful to others.
#+LATEX_HEADER: \lstset{frame=shadowbox}
#+LATEX_HEADER: \lstdefinelanguage{bash-local}{rulesepcolor=\color{cyan}}
#+LATEX_HEADER: \lstdefinelanguage{bash-remote}{rulesepcolor=\color{yellow}}
#+PROPERTY: header-args :eval never

#+ATTR_LATEX: :options language=bash-local
#+BEGIN_SRC bash :results output :eval ask
  # Run this script on the local host
  # Install the key in the VM:
  ssh-copy-id -i ~/.ssh/vm \
              -p 3022 user@ 


#+ATTR_LATEX: :options language=bash-remote-root
#+BEGIN_SRC bash
  # Run this as root on the remote host
  apt-get update
  apt-get -y install  git 

#+ATTR_LATEX: :options language=bash-remote
#+BEGIN_SRC bash :results output :eval ask
  # Run this as a normal user on the remote host
  cd project
  git pull

Reply via email to