help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: Bash Script Editing Mode?


From: formido
Subject: Re: Bash Script Editing Mode?
Date: Thu, 7 Aug 2008 14:59:34 -0700 (PDT)
User-agent: G2/1.0

On Aug 7, 2:20 pm, p...@informatimago.com (Pascal J. Bourguignon)
wrote:
> formido <form...@gmail.com> writes:
> > There's a shell mode, but it has a prompt and doesn't help you
> > incrementally create a shell script as efficiently as it could, unless
> > I'm missing something. Is there any shell script mode that works more
> > like the elisp, python, or erlang repls, where you can execute your
> > choice of several lines at once and you can go back and edit and
> > execute the lines in situ? If I write a bash function, editing and
> > reloading the function is a painful process. I'm looking for something
> > a little bit like the Mac's BBEdit shell worksheets (only better).
>
> First, try to get your terminology straight.

Heh. I've noticed that no matter with what care one designs his query,
a novice will invariably run afoul of the idioms or conventions of the
new culture...

<snip>

> > I considered altering the usual shell mode, but it would take more
> > than slight edits, so I'm hoping something's already out there. For
> > example, one should be able to go back to a function, tweak it, and
> > reload with a minimum of keyboard fuss.
>
> Well, if you consider the shell mode, there's an easy way to get what
> you want:  just edit your commands, one by one, and type RET to try
> them.  When you're happy with the result, type: history RET and
> copy-and-paste all the commands to a shell script buffer, add some
> minor edits, including a #!/bin/bash on the first line, and voilà.

This does not work very well with loops and functions and is more
cumbersome than necessary besides, avoiding which is the whole point
of learning Emacs.

> But really, I would rather start from the shell-script-mode.

<snip>

> Once you have implemented a pair of functions forward-shell-expression
> and backward-shell-expression, you can easily implement a function
> such as eval-last-shell-expression:
>
> (defun eval-last-shell-expression (point)
>   (interactiev "P")
>   (let ((start (progn (backward-shell-expression) (point)))
>         (end   (progn (forward-shell-expression)  (point))))
>     (comint-send-string (inferior-shell-proc)
>                         (buffer-substring start end))
>     (comint-send-string (inferior-shell-proc) "\n")))
>
> There remains only to bind these commands to C-M-f, C-M-b and C-x C-e.

Yes, I think this and shell-script-mode should put me well on my way.

> But if you're as lazy as me, perhaps the best option would be to use
> scsh.  You get a shell, but it's really a scheme, and there is already
> all you need to edit scheme scripts, and C-x C-e already works.

That does look really cool. I only hesitate because obviously regular
shells are installed everywhere. This is probably not as great an
advantage as it seems in my mind, though.

> --
> __Pascal Bourguignon__                    http://www.informatimago.com/
>

Michael


reply via email to

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