From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric Schulte Subject: Re: bash alias and history in code block Date: Fri, 06 Dec 2013 11:34:31 -0700 Message-ID: <87txel6b40.fsf@gmail.com> References: <20131206175855.GA32108@localhost> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:50452) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vp0wn-00046K-TK for emacs-orgmode@gnu.org; Fri, 06 Dec 2013 14:20:26 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Vp0wj-0007eQ-E6 for emacs-orgmode@gnu.org; Fri, 06 Dec 2013 14:20:21 -0500 Received: from mail-pb0-x22c.google.com ([2607:f8b0:400e:c01::22c]:41638) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vp0wj-0007eG-64 for emacs-orgmode@gnu.org; Fri, 06 Dec 2013 14:20:17 -0500 Received: by mail-pb0-f44.google.com with SMTP id rq2so1599415pbb.17 for ; Fri, 06 Dec 2013 11:20:15 -0800 (PST) List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: OSiUX Cc: emacs-orgmode@gnu.org OSiUX 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