emacs-orgmode
[Top][All Lists]
Advanced

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

Re: [O] bash alias and history in code block


From: Eric Schulte
Subject: Re: [O] bash alias and history in code block
Date: Fri, 06 Dec 2013 11:34:31 -0700
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux)

OSiUX <address@hidden> writes:

> How to use alias and bash builtin functions?
>
>  #+BEGIN_SRC sh :session :results output
>    echo $SHELL
>    echo $HOME
>    source ~/.bashrc
>    alias | wc
>    env | grep HISTTIMEFORMAT
>    history | wc
>  #+END_SRC
>
>  #+RESULTS:
>  : /bin/bash
>  : /home/osiris
>  :       0       0       0
>  : HISTTIMEFORMAT=%Y-%m-%d %H:%M
>  :       0       0       0
>
> Thanks!
>

I get the following.  Note that I define my alia in a separate file
which I had to load explicitly for the alia to be defined (it should be
sourced from my ~/.bashrc, but shells can be weird about loading things
they think might be profile related when you're not logging in).

#+BEGIN_SRC sh :session :results output
  echo $SHELL
  echo $HOME
  source ~/.bashrc
  alias | wc
  env | wc
  history | wc
#+END_SRC

#+RESULTS:
: /bin/zsh
: /home/eschulte
:       0       0       0
:      28      28     715
:       0       0       0

#+BEGIN_SRC sh :session :results output
  echo $SHELL
  echo $HOME
  source ~/.alia
  source ~/.bashrc
  alias | wc
  env | wc
  history | wc
#+END_SRC

#+RESULTS:
: /bin/zsh
: /home/eschulte
:      19      99     814
:      28      28     715
:       0       0       0

My guess with the empty history is that bash can tell it isn't an
interactive session, which you might be able to fake with tty pipe STDIN
and STDOUT nonsense in ob-sh.  But in general I don't see the utility of
history in a code block.

Best,

-- 
Eric Schulte
https://cs.unm.edu/~eschulte
PGP: 0x614CA05D



reply via email to

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