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

Re: pasting text into bash without use of mouse



on Thu, Apr 05, 2001 at 06:47:53AM +0800, csj (csj@mindgate.net) wrote:
> On Wednesday 04 April 2001 09:41, Karsten M. Self wrote:
> > csj (csj@mindgate.net) wrote:
> > > Is there a way to copy or paste text into bash without the use of
> > > a mouse? I'm thinking of a text file "file.txt" which contains
> > > command sequences which I would like to touch up before running.
> > >
> > > I don't want to use an editor for this. Just the line editing
> > > functions of bash. Offhand the only (untested) solution I can
> > > think of is something like "cat file.txt >> .bash_history",
> > > subsequently invoking another bash session. Is this stupid
> > > (dangerous)? Does someone have a better solution?
> >
> > Just posted here this week.  If you have wmaker installed, wxpaste
> > and wxcopy do what you'd expect them to.
> 
> It looks interesting. But I forgot to add: --without-X. For those 
> dire moments when X crashes.

I'm no longer clear on what it is you're hoping to accomplish.  More
below.

> On Wednesday 04 April 2001 09:49, Karsten M. Self wrote:
> > ...another option.  If you're just trying to execute a set of
> > commands through bash:
> >
> >     $ . <file>		# "source" commands in file, current shell
> >     $ bash -f <file>	# run commands in file (subshell)
> >     $ bash  < <file>	# run commands in file (subshell)
> 
> My version is something like "cat file.txt | bash". Is this a bad 
> idea.

That's fine.

> > If you want to compose multi-line commands to run in bash without
> > creating an explicit file:
> >
> >     $ set -o vi		# set 'vi' mode
> >     $ <esc>-v		# invoke 'vi' editor
> >     # edit file, 'ZZ' or ':wq' when done.  Commands execute.
> 
> Hmm, does this really mean I have to really vi? 

I believe you'll invoke whatever editor is specified as $EDITOR or
$VISUAL.   What is your specific objection to invoking vi?  Is it that
you don't want to use vi, or you don't want to invoke *any* editor?

> Actually I was thinking of something like "cat file.txt > /dev/ttyX"
> which however pastes the thing not just on the screen but on the
> command line itself. Is there such a linuxian function?

There isn't, AFAIK, a concept of "pasting to the command line".  You can
pass stdin to a process via several routes.  You can send data directly
to a terminal (if you have write access to it), including /dev/tty, the
controlling terminal of the current process.  You can create what's
essentially a shell script by any number of means.

I think there's a disconnect here -- your request is either so simple
that I don't understand what the problem is, or is fundamentally at odds
with the GNU/Linux process/data/stream model.  Are you familiar with the
fundamental concepts of streams, pipes, stdin, stdout, and input/output
redirection?  As far as I can understand, you're simply looking for a
method to invoke bash on a command stream.

Why don't you step back, take a breath, describe your situation, what
you hope to accomplish, and what specific options are ruled out.

-- 
Karsten M. Self <kmself@ix.netcom.com>    http://kmself.home.netcom.com/
 What part of "Gestalt" don't you understand?       There is no K5 cabal
  http://gestalt-system.sourceforge.net/         http://www.kuro5hin.org

Attachment: pgpw6R4mpgWlS.pgp
Description: PGP signature


Reply to: