unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* How to get eshell to do what I used to do with shell
@ 2024-08-10 17:00 KARR, DAVID
  2024-08-10 19:10 ` tpeplt
  2024-08-10 21:01 ` James Thomas
  0 siblings, 2 replies; 8+ messages in thread
From: KARR, DAVID @ 2024-08-10 17:00 UTC (permalink / raw)
  To: Help-gnu-emacs@gnu.org

I haven't gotten a reply from the Cygwin list yet on my shell ioctl problem.  I may get something useful from that, but I may have to consider an alternative path.  I wrote this little wrapper on "shell" a couple of decades ago, and it's worked fine since then.  I've briefly looked at "eshell", and it seems like it will do the job, but I wanted to know whether I can wrap it to do the same things my older wrapper was doing.

My old wrapper had these features:
* In a non-shell buffer, execing the main func would either create the first shell buffer, or go to the first one in the chain, perhaps called the 0th.
* In a shell buffer, execing the main func would create a new shell in the chain, using the current directory 
* In a shell buffer, execing the "goto-next-shell" func would move to the next buffer in the chain, or back to 0 if at the end
* In a shell buffer, execing the "find-shell-with-dir" func would take a string argument and find the next buffer in the chain where the pwd has that string as a substring

I think all of these are doable, but I haven't written any elisp for many years. I see that "default-directory" in each eshell buffer is set to the current directory, just like in the old shell package.  I wonder if this will work just by changing the name of the function to execute.  Could it be that simple?  I guess I'll iterate on that and come back here for question.



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: How to get eshell to do what I used to do with shell
  2024-08-10 17:00 How to get eshell to do what I used to do with shell KARR, DAVID
@ 2024-08-10 19:10 ` tpeplt
  2024-08-10 19:52   ` KARR, DAVID
  2024-08-10 21:01 ` James Thomas
  1 sibling, 1 reply; 8+ messages in thread
From: tpeplt @ 2024-08-10 19:10 UTC (permalink / raw)
  To: KARR, DAVID; +Cc: Help-gnu-emacs@gnu.org

"KARR, DAVID" <dk068x@att.com> writes:

> ... I wrote this little wrapper on "shell"
> a couple of decades ago, and it's worked fine since then.  I've
> briefly looked at "eshell", and it seems like it will do the job, but
> I wanted to know whether I can wrap it to do the same things my older
> wrapper was doing.
>
> My old wrapper had these features:
> * In a non-shell buffer, execing the main func would either create the
> first shell buffer, or go to the first one in the chain, perhaps
> called the 0th.
> * In a shell buffer, execing the main func would create a new shell in
> the chain, using the current directory
> * In a shell buffer, execing the "goto-next-shell" func would move to
> the next buffer in the chain, or back to 0 if at the end
> * In a shell buffer, execing the "find-shell-with-dir" func would take
> a string argument and find the next buffer in the chain where the pwd
> has that string as a substring
>
> I think all of these are doable, but I haven't written any elisp for
> many years. I see that "default-directory" in each eshell buffer is
> set to the current directory, just like in the old shell package.  I
> wonder if this will work just by changing the name of the function to
> execute.  Could it be that simple?  I guess I'll iterate on that and
> come back here for question.

1. In case you are unaware, there is an Info manual for eshell.  It is
   separate from the Emacs user manual and the Emacs Lisp reference
   manual.  If it is installed on your system, then you should be able
   to read it by evaluating the following expression in Emacs:

     (info "(eshell) Top")

2. One of the chapters in the Eshell manual is titled "Bugs and Ideas".
   You might find the answer to your question(s) in this chapter (over
   400 lines long), or find that the capability that you want is not yet
   supported in Eshell.

     (info "(eshell) Bugs and ideas")

-- 
The lyf so short, the craft so long to lerne.
- Geoffrey Chaucer, The Parliament of Birds.



^ permalink raw reply	[flat|nested] 8+ messages in thread

* RE: How to get eshell to do what I used to do with shell
  2024-08-10 19:10 ` tpeplt
@ 2024-08-10 19:52   ` KARR, DAVID
  2024-08-10 22:32     ` tpeplt
  2024-08-11 11:27     ` Joel Reicher
  0 siblings, 2 replies; 8+ messages in thread
From: KARR, DAVID @ 2024-08-10 19:52 UTC (permalink / raw)
  To: tpeplt; +Cc: Help-gnu-emacs@gnu.org

(Hope top post is ok, Outlook doesn’t make it easy to configure different ways to include the replying post, per mailing list.)

Yes, I’m familiar with Info, I just hadn’t read the eshell section before. I’ve only started to run through it, but I have two questions right off.

Section 1.1 mentions an obscure way of filtering ls output, using an example like “ls -lt **/*.doc(Lk+100aM+6)”. I couldn’t get any variation of that to work. It’s not clear whether it’s saying that is eshell functionality, or something about the  most common implementations of “ls”.

When I do something simple like this: “ls -l | grep "txt" | sort”, all the output lines are prefixed with “(standard input):”.  I haven’t searched through the info manual yet, but I asked github copilot about this, and it said that “eshell/grep” instead of “grep” would fix that, but that didn’t work either (I don’t expect everything from copilot to be 100% accurate).

From: tpeplt <tpeplt@gmail.com>
Sent: Saturday, August 10, 2024 12:10 PM
To: KARR, DAVID <dk068x@att.com>
Cc: Help-gnu-emacs@gnu.org
Subject: Re: How to get eshell to do what I used to do with shell

ZjQcmQRYFpfptBannerEnd

"KARR, DAVID" <dk068x@att.com<mailto:dk068x@att.com>> writes:



> ... I wrote this little wrapper on "shell"

> a couple of decades ago, and it's worked fine since then.  I've

> briefly looked at "eshell", and it seems like it will do the job, but

> I wanted to know whether I can wrap it to do the same things my older

> wrapper was doing.

>

> My old wrapper had these features:

> * In a non-shell buffer, execing the main func would either create the

> first shell buffer, or go to the first one in the chain, perhaps

> called the 0th.

> * In a shell buffer, execing the main func would create a new shell in

> the chain, using the current directory

> * In a shell buffer, execing the "goto-next-shell" func would move to

> the next buffer in the chain, or back to 0 if at the end

> * In a shell buffer, execing the "find-shell-with-dir" func would take

> a string argument and find the next buffer in the chain where the pwd

> has that string as a substring

>

> I think all of these are doable, but I haven't written any elisp for

> many years. I see that "default-directory" in each eshell buffer is

> set to the current directory, just like in the old shell package.  I

> wonder if this will work just by changing the name of the function to

> execute.  Could it be that simple?  I guess I'll iterate on that and

> come back here for question.



1. In case you are unaware, there is an Info manual for eshell.  It is

   separate from the Emacs user manual and the Emacs Lisp reference

   manual.  If it is installed on your system, then you should be able

   to read it by evaluating the following expression in Emacs:



     (info "(eshell) Top")



2. One of the chapters in the Eshell manual is titled "Bugs and Ideas".

   You might find the answer to your question(s) in this chapter (over

   400 lines long), or find that the capability that you want is not yet

   supported in Eshell.



     (info "(eshell) Bugs and ideas")



--

The lyf so short, the craft so long to lerne.

- Geoffrey Chaucer, The Parliament of Birds.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: How to get eshell to do what I used to do with shell
  2024-08-10 17:00 How to get eshell to do what I used to do with shell KARR, DAVID
  2024-08-10 19:10 ` tpeplt
@ 2024-08-10 21:01 ` James Thomas
  2024-08-10 21:06   ` KARR, DAVID
  1 sibling, 1 reply; 8+ messages in thread
From: James Thomas @ 2024-08-10 21:01 UTC (permalink / raw)
  To: Help-gnu-emacs@gnu.org

KARR, DAVID wrote:

> My old wrapper had these features:
> * In a non-shell buffer, execing the main func would either create the
> first shell buffer, or go to the first one in the chain, perhaps
> called the 0th.
> * In a shell buffer, execing the main func would create a new shell in
> the chain, using the current directory
> * In a shell buffer, execing the "goto-next-shell" func would move to
> the next buffer in the chain, or back to 0 if at the end
> * In a shell buffer, execing the "find-shell-with-dir" func would take
> a string argument and find the next buffer in the chain where the pwd
> has that string as a substring
>
> I think all of these are doable

They should be, but lemme just say that I think a better way to use
eshell is to have a single buffer: the ability to transparently 'cd' to
different remotes and selectively open async output buffers (at least
for me) makes keeping multiple buffers redundant and is more convenient:
if the user is a single person, all the commands are in a particular
sequence, after all.

Regards,
James



^ permalink raw reply	[flat|nested] 8+ messages in thread

* RE: How to get eshell to do what I used to do with shell
  2024-08-10 21:01 ` James Thomas
@ 2024-08-10 21:06   ` KARR, DAVID
  2024-08-11  9:49     ` James Thomas
  0 siblings, 1 reply; 8+ messages in thread
From: KARR, DAVID @ 2024-08-10 21:06 UTC (permalink / raw)
  To: James Thomas, Help-gnu-emacs@gnu.org

I don't understand that. I will be performing different tasks in different directories, and the output for tasks in one directory need to kept separate from the output for tasks in other directories.

By "different remotes", do you mean different hosts? I wouldn't be doing that at all.

From: help-gnu-emacs-bounces+dk068x=att.com@gnu.org <help-gnu-emacs-bounces+dk068x=att.com@gnu.org> On Behalf Of James Thomas
Sent: Saturday, August 10, 2024 2:01 PM
To: Help-gnu-emacs@gnu.org
Subject: Re: How to get eshell to do what I used to do with shell

KARR, DAVID wrote: > My old wrapper had these features: > * In a non-shell buffer, execing the main func would either create the > first shell buffer, or go to the first one in the chain, perhaps > called the 0th. > * In a shell


KARR, DAVID wrote:



> My old wrapper had these features:

> * In a non-shell buffer, execing the main func would either create the

> first shell buffer, or go to the first one in the chain, perhaps

> called the 0th.

> * In a shell buffer, execing the main func would create a new shell in

> the chain, using the current directory

> * In a shell buffer, execing the "goto-next-shell" func would move to

> the next buffer in the chain, or back to 0 if at the end

> * In a shell buffer, execing the "find-shell-with-dir" func would take

> a string argument and find the next buffer in the chain where the pwd

> has that string as a substring

>

> I think all of these are doable



They should be, but lemme just say that I think a better way to use

eshell is to have a single buffer: the ability to transparently 'cd' to

different remotes and selectively open async output buffers (at least

for me) makes keeping multiple buffers redundant and is more convenient:

if the user is a single person, all the commands are in a particular

sequence, after all.



Regards,

James




^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: How to get eshell to do what I used to do with shell
  2024-08-10 19:52   ` KARR, DAVID
@ 2024-08-10 22:32     ` tpeplt
  2024-08-11 11:27     ` Joel Reicher
  1 sibling, 0 replies; 8+ messages in thread
From: tpeplt @ 2024-08-10 22:32 UTC (permalink / raw)
  To: KARR, DAVID; +Cc: Help-gnu-emacs@gnu.org

"KARR, DAVID" <dk068x@att.com> writes:

> (Hope top post is ok, Outlook doesn’t make it easy to configure
> different ways to include the replying post, per mailing list.)
>

FYI, it is possible to read from and write to mailing lists within Emacs
using gnus, but it requires some investment in time to get started with
it and to learn the subset of commands that you would find useful.

(info "(gnus) Top")

-- 
The lyf so short, the craft so long to lerne.
- Geoffrey Chaucer, The Parliament of Birds.



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: How to get eshell to do what I used to do with shell
  2024-08-10 21:06   ` KARR, DAVID
@ 2024-08-11  9:49     ` James Thomas
  0 siblings, 0 replies; 8+ messages in thread
From: James Thomas @ 2024-08-11  9:49 UTC (permalink / raw)
  To: KARR, DAVID; +Cc: Help-gnu-emacs@gnu.org

KARR, DAVID wrote:

> By "different remotes", do you mean different hosts? I wouldn't be
> doing that at all.

All right. But this should be applicable even then:

> I don't understand that. I will be performing different tasks in
> different directories, and the output for tasks in one directory need
> to kept separate from the output for tasks in other directories.

For e.g. you could add something like this to eshell-pre-command-hook:

(lambda () (eshell-set-output-handle 1 'insert (eshell-get-buffer
(concat "output-" (eshell/pwd)))))

...if you don't want to do (info "(eshell) Redirection") manually.

Eshell is not that well documented, though. I don't know it well either.

Regards,
James



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: How to get eshell to do what I used to do with shell
  2024-08-10 19:52   ` KARR, DAVID
  2024-08-10 22:32     ` tpeplt
@ 2024-08-11 11:27     ` Joel Reicher
  1 sibling, 0 replies; 8+ messages in thread
From: Joel Reicher @ 2024-08-11 11:27 UTC (permalink / raw)
  To: KARR, DAVID; +Cc: tpeplt, Help-gnu-emacs@gnu.org

"KARR, DAVID" <dk068x@att.com> writes:

> Section 1.1 mentions an obscure way of filtering ls output, 
> using an example like “ls -lt **/*.doc(Lk+100aM+6)”. I couldn’t 
> get any variation of that to work. It’s not clear whether it’s 
> saying that is eshell functionality, or something about the 
> most common implementations of “ls”.

Why do you think ls is doing anything interesting there?

> When I do something simple like this: “ls -l | grep "txt" | 
> sort”, all the output lines are prefixed with “(standard 
> input):”.  I haven’t searched through the info manual yet, but I 
> asked github copilot about this, and it said that “eshell/grep” 
> instead of “grep” would fix that, but that didn’t work either (I 
> don’t expect everything from copilot to be 100% accurate).

Keep in mind that when you execute a command line in eshell, 
you're executing some lisp, because eshell is written in lisp.

Depending on your configuration, the behaviour might be to execute 
a lisp function (if there is one), and that's probably the case 
with grep. If eshell fails to find a lisp function matching the 
command's name, it will then attempt to find an external program 
by that name.

Also - and this is very important - that pipe is implemented in 
lisp.

Both of these things can be overridden on demand by using the '*' 
character. For example you can force grep to call the external 
program by running

*grep

instead.

Compare the output of

grep blah foo

and

*grep blah foo

(the difference is much clearer if you do not use pipe to begin 
with)

For pipes, you can do

grep blah foo *| grep something

and this will force the use of an external shell implementation of 
pipe which, as far as I know, implicitly forces an external 
program to be used for both commands too. There may be situations 
you want the in-lisp pipe (such as piping to a lisp function 
instead of an external program).

You may also find this useful.

https://www.masteringemacs.org/article/complete-guide-mastering-eshell

Cheers,

        - Joel



^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2024-08-11 11:27 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-10 17:00 How to get eshell to do what I used to do with shell KARR, DAVID
2024-08-10 19:10 ` tpeplt
2024-08-10 19:52   ` KARR, DAVID
2024-08-10 22:32     ` tpeplt
2024-08-11 11:27     ` Joel Reicher
2024-08-10 21:01 ` James Thomas
2024-08-10 21:06   ` KARR, DAVID
2024-08-11  9:49     ` James Thomas

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).