Alias to start application in background

Alias to start application in background

am 15.08.2006 22:31:12 von Anand

I am trying to define an alias for my editor (nedit).

alias n "nedit"

Problem is when I type

n it starts the nedit app in the foreground, whereas I want
to start it in the background, equivalent to

nedit FILENAME &

How do I change my alias to start this app in the background instead of
foreground?


Thanks

Re: Alias to start application in background

am 15.08.2006 22:35:56 von Sashi

anand wrote:
> I am trying to define an alias for my editor (nedit).
>
> alias n "nedit"
>
> Problem is when I type
>
> n it starts the nedit app in the foreground, whereas I want
> to start it in the background, equivalent to
>
> nedit FILENAME &
>
> How do I change my alias to start this app in the background instead of
> foreground?
>
>
> Thanks
Just create a script with the name 'n' somewhere in your path with the
contents "nedit $0 &" and make it executable.
I'd also recommend that you get familiar with a better editor such as
vi or emacs.
Sashi

Re: Alias to start application in background

am 15.08.2006 22:39:34 von Anand

Yes, I use emacs regularly, and nedit from time to time.
How do I do this if I dont want to write a script? I know one of my
friends used something like

alias n "nedit <&0" or something like that. I am just looking for the
syntax




Sashi wrote:
> anand wrote:
> > I am trying to define an alias for my editor (nedit).
> >
> > alias n "nedit"
> >
> > Problem is when I type
> >
> > n it starts the nedit app in the foreground, whereas I want
> > to start it in the background, equivalent to
> >
> > nedit FILENAME &
> >
> > How do I change my alias to start this app in the background instead of
> > foreground?
> >
> >
> > Thanks
> Just create a script with the name 'n' somewhere in your path with the
> contents "nedit $0 &" and make it executable.
> I'd also recommend that you get familiar with a better editor such as
> vi or emacs.
> Sashi

Re: Alias to start application in background

am 15.08.2006 23:01:06 von Glenn Jackman

At 2006-08-15 04:31PM, anand wrote:
> I am trying to define an alias for my editor (nedit).
>
> alias n "nedit"
>
> Problem is when I type
>
> n it starts the nedit app in the foreground, whereas I want
> to start it in the background, equivalent to
>
> nedit FILENAME &
>
> How do I change my alias to start this app in the background instead of
> foreground?

Use a function instead:
n () { nedit ${1+"$@"} &; }

--
Glenn Jackman
Ulterior Designer

Re: Alias to start application in background

am 15.08.2006 23:06:32 von Chris Mattern

anand wrote:
> I am trying to define an alias for my editor (nedit).
>
> alias n "nedit"
>
> Problem is when I type
>
> n it starts the nedit app in the foreground, whereas I want
> to start it in the background, equivalent to
>
> nedit FILENAME &
>
> How do I change my alias to start this app in the background instead of
> foreground?
>
>
> Thanks
>

Type:

n FILENAME &


Chris Mattern

Re: Alias to start application in background

am 15.08.2006 23:45:21 von dfeustel

anand wrote:
> I am trying to define an alias for my editor (nedit).
>
> alias n "nedit"
>
> Problem is when I type
>
> n it starts the nedit app in the foreground, whereas I want
> to start it in the background, equivalent to

Just out of curiosity, why do you want to start the editor
in the background?

Thanks.

Re: Alias to start application in background

am 16.08.2006 00:10:26 von Anand

If I have one xterm open, and I start it in the background, then I can
continue using my command prompt without opening another XTERM.

Do you have the command line?


dfeustel@mindspring.com wrote:
> anand wrote:
> > I am trying to define an alias for my editor (nedit).
> >
> > alias n "nedit"
> >
> > Problem is when I type
> >
> > n it starts the nedit app in the foreground, whereas I want
> > to start it in the background, equivalent to
>
> Just out of curiosity, why do you want to start the editor
> in the background?
>
> Thanks.

Re: Alias to start application in background

am 16.08.2006 04:33:31 von Bruce Barnett

"anand" writes:

> Yes, I use emacs regularly, and nedit from time to time.
> How do I do this if I dont want to write a script? I know one of my
> friends used something like
>
> alias n "nedit <&0" or something like that. I am just looking for the
> syntax

What shell do you want this to work in?

For csh/tcsh:

alias n "nedit \!* &"

Glenn suggested a function for the POSIX shells.


You can also launch a new terminal instead of runing the editor in
the background. Or use emacs/xemacs in X window mode.



--
Sending unsolicited commercial e-mail to this account incurs a fee of
$500 per message, and acknowledges the legality of this contract.

Re: Alias to start application in background

am 16.08.2006 07:40:10 von Bill Marcum

On 15 Aug 2006 21:01:06 GMT, Glenn Jackman
wrote:
> At 2006-08-15 04:31PM, anand wrote:
>> I am trying to define an alias for my editor (nedit).
>>
>> alias n "nedit"
>>
>> Problem is when I type
>>
>> n it starts the nedit app in the foreground, whereas I want
>> to start it in the background, equivalent to
>>
>> nedit FILENAME &
>>
>> How do I change my alias to start this app in the background instead of
>> foreground?
>
> Use a function instead:
> n () { nedit ${1+"$@"} &; }
>

The syntax 'alias n "nedit"' without an = sign implies that the OP is
using csh or tcsh, which don't have functions.

Re: Alias to start application in background

am 17.08.2006 23:30:46 von brian_hiles

anand wrote:
> alias n "nedit"
> ... start this app in the background instead of foreground?

(1) Use can use ^Z (and "fg") to put a foreground task into
the background. These Job Control commands are the same
in t/csh(1) as they are in ksh(1).

(2) You could make a hardlink or symlink to "rename" "nedit"
as filename "n":

/bin/ln [-s] /path/to/nedit n

(3) As discussed, there are two techniques to allow aliases
to call functions *slash* have arguments, in either ksh(1) or
t/csh(1), both of which have been touched on in the previous
responses.

=Brian