When editing a remote file with tramp, I want org-babel source blocks to source the remote machine's .bashrc.
I found this workaround that does what I want:
#+BEGIN_SRC bash :preamble ". ~/.bashrc"
echo $PATH
#+END_SRC
I can save a bit of typing by adding this to the top of the file, so it applies to all bash
blocks in the file:
:PROPERTIES:
:HEADER-ARGS:bash: :prologue ". ~/.bashrc"
:END:
However, what I really want is for the combination of tramp + org-babel to treat a shell source block as if I've started bash interactively on the remote machine.
Is there a way to configure this as the default, or is my hacky solution the best/only way to achieve my goal?
I tried the following suggestions, with no noticeable effect:
- https://emacs.stackexchange.com/a/62427/10036
- https://emacs.stackexchange.com/a/31624/10036
- https://emacs.stackexchange.com/a/46200/10036
[edit]
Based on one of the comments, I also tried adding this to my init file:
(add-to-list 'tramp-connection-properties
(list (regexp-quote "/sshx:ibp2-admin:")
"remote-shell" "/bin/bash"
"sh-extra-args" "-l -i"))
This makes the remote shell /bin/bash instead of /bin/sh, but did not source the ~/.bashrc file.
C-h i g(tramp)Remote shell setup hints
. It mentions thattramp-shell-extra-args
are applied, so you might want to try adding-i
to that.-i
or-l
seems to have no effect.tramp-sh-extra-args
. Still untested, so I don't know if it'll work or not (you may have tried it already if you read the doc, rather than going by my erroneous comment), but a variable that is used by somebody has a better chance of working !-)tramp-sh-extra-args
. According to the Tramp manual 4.14, setting a property using tramp-connection-properties prepends "tramp-" to the property name. To be thorough, I also tried usingtramp-sh-extra-args
instead, with no noticeable effect.