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

2014-04-22 Thread OSiUX
El jue, 17 abr 2014, Bastien decía:

 OSiUX xu...@osiux.com.ar writes:

  #+BEGIN_SRC sh :cmdline -i :session :results output

 From a quick look, this should rather be:

 #+BEGIN_SRC sh :cmdline -i :session session_name :results output

 Can you test this?

Don't Work :-(

** DONE test =bash -i=
   CLOSED: [2014-04-22 mar 14:56]
   :LOGBOOK:
   - State DONE   from NEXT   [2014-04-22 mar 14:56]
   CLOCK: [2014-04-22 mar 14:51]--[2014-04-22 mar 14:54] =  0:03
   :END:

   #+BEGIN_SRC sh :cmdline -i :session xyz :results output
 export | grep -i shell
 alias | wc -l
 history | wc -l
   #+END_SRC

   #+RESULTS:
   : declare -x SHELL=/bin/bash
   : 0
   : 0

   #+BEGIN_SRC sh :session :results output
 export | grep -i shell
 alias | wc -l
 history | wc -l
   #+END_SRC

   #+RESULTS:
   : export SHELL=/bin/bash
   : 0
   : 0

--

::

  Osiris Alejandro Gomez (OSiUX) os...@osiux.com.ar
  DC44 95D2 0D5D D544 FC1A F00F B308 A671 9237 D36C
  http://www.osiux.com.ar http://www.altermundi.net


signature.asc
Description: Digital signature


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

2014-04-22 Thread Nick Dokos
OSiUX xu...@osiux.com.ar writes:

 Hi, in the past I ask *How to use alias and bash builtin functions?*

 http://lists.gnu.org/archive/html/emacs-orgmode/2013-12/msg00205.html

 The solution:

   (setq org-babel-sh-command bash -i)

 But now don't work anymore :-(


Works for me:

(setq org-babel-sh-command bash -i)
bash -i

--8---cut here---start-8---
#+BEGIN_SRC sh :results output
   history | wc -l
   alias | wc -l
#+END_SRC

#+RESULTS:
: 1000
: 6
--8---cut here---end---8---

Org-mode version 8.2.6 (release_8.2.6-901-g91da1b @
/home/nick/elisp/org-mode/lisp/)

 My Org-mode version:

 8.2.5h release_8.2.5h-660-gef207f


--
Nick




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

2014-04-17 Thread Bastien
OSiUX xu...@osiux.com.ar writes:

 #+BEGIN_SRC sh :cmdline -i :session :results output

From a quick look, this should rather be:

#+BEGIN_SRC sh :cmdline -i :session session_name :results output

Can you test this?

-- 
 Bastien



[O] bash alias and history in code block (again)

2014-04-15 Thread OSiUX
Hi, in the past I ask *How to use alias and bash builtin functions?*

http://lists.gnu.org/archive/html/emacs-orgmode/2013-12/msg00205.html

The solution:

  (setq org-babel-sh-command bash -i)

But now don't work anymore :-(

My Org-mode version:

8.2.5h release_8.2.5h-660-gef207f

Looking the source:

b896bd4 2014-02-09 20:12 schulte.ericadd :cmdline support to shell code 
blocks
5f0ca0e 2014-01-31 17:02:03 +0100 theonewiththeevillook  Renaming of ob-sh to 
ob-shell: various fixes
1a9a666 2014-01-21 09:52 schulte.ericmention ob-sh renamed to ob-shell in 
ORG-NEWS
80754a8 2014-01-18 10:26 schulte.ericupdated names in test-ob-shell
2ebae7b 2014-01-18 10:25 schulte.ericrenamed test file for shell code blocks
fb09863 2013-12-13 16:04 schulte.ericmore shell names
b319475 2013-12-13 10:03 schulte.ericfix tests with the renamed ob-shell.el
583e7ab 2013-12-13 09:54 schulte.ericrename ob-sh to ob-shell
7a6c0e3 2013-12-13 09:52 schulte.ericmultiple code block types for multiple 
shells
d286d81 2013-12-13 09:18 schulte.ericRevert change default sh code block 
shell to bash
1f498c9 2013-11-23 09:14 schulte.ericchange default sh code block shell to 
bash

I change my ~/.emacs

  (setq org-babel-sh-command bash)

... and try the new :cmdline parameter:

#+BEGIN_SRC sh :cmdline -i :session :results output
   history | wc -l
   alias | wc -l
#+END_SRC

#+RESULTS:
: 0
: 0

*How to use alias and bash builtin functions?*

thanks!

--

::

  Osiris Alejandro Gomez (OSiUX) os...@osiux.com.ar
  DC44 95D2 0D5D D544 FC1A F00F B308 A671 9237 D36C
  http://www.osiux.com.ar http://www.altermundi.net


signature.asc
Description: Digital signature


[O] bash alias and history in code block

2013-12-06 Thread OSiUX
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!

--

::

  Osiris Alejandro Gomez (OSiUX) os...@osiux.com.ar
  DC44 95D2 0D5D D544 FC1A F00F B308 A671 9237 D36C
  http://www.osiux.com.ar http://www.altermundi.net


signature.asc
Description: Digital signature


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

2013-12-06 Thread Eric Schulte
OSiUX xu...@osiux.com.ar 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



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

2013-12-06 Thread Sebastien Vauban
OSiUX wrote:
 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

Just throwing an idea (as I don't know enough about that): play with the
variable `org-babel-sh-command' (default: bash) and add options such as
--login or --interactive (or stuff like that)?

Best regards,
  Seb

-- 
Sebastien Vauban




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

2013-12-06 Thread OSiUX
El vie, 06 dic 2013, Sebastien Vauban decía:

 OSiUX wrote:
  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

 Just throwing an idea (as I don't know enough about that): play with the
 variable `org-babel-sh-command' (default: bash) and add options such as
 --login or --interactive (or stuff like that)?

Ok, add a bash -i and now is working well:

   #+BEGIN_SRC sh :session :results output
 grep bash ~/.emacs
 echo $SHELL
 echo $HOME
 alias | wc
 env | grep HISTTIMEFORMAT
 echo $BASH_VERSION
 shopt -s histappend
 set -o | grep history
 history | wc
 alias dia
 alias hh
 hh | tail
 history -a
   #+END_SRC

   #+RESULTS:
   #+begin_example
   (setq org-babel-sh-command bash -i)
   /bin/bash
   /home/osiris
   5343236   29894
   HISTTIMEFORMAT=%Y-%m-%d %H:%M
   4.2.37(1)-release
   history  on
  8275   44194  338107
   alias dia='date +%Y-%m-%d'
   alias hh='history | egrep $(dia)  | cut -c 19- | sort -u'
   17:10 set -o | grep history
   17:10 shopt -s histappend
   17:10 ssh sugar-mant
   17:10 sudo chown osiris.osiris config -R
   17:10 sudo chown osiris.osiris .* -R
   17:10 sudo chown osiris.osiris /var/run/screen/S-osiris
   17:10 sudo chown osiris.osiris /var/run/screen/S-osiris.*
   17:10 sudo -s
  #+end_example

Sometimes I forget to start clock in a task,
then I use the history to know the timestamp
:-P

--

::

  Osiris Alejandro Gomez (OSiUX) os...@osiux.com.ar
  DC44 95D2 0D5D D544 FC1A F00F B308 A671 9237 D36C
  http://www.osiux.com.ar http://www.altermundi.net


signature.asc
Description: Digital signature