Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[solved]Can't seem to get vim to open in a new xterm
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
vivi131313
Tux's lil' helper
Tux's lil' helper


Joined: 11 May 2004
Posts: 108
Location: Folsom, CA

PostPosted: Sun Aug 26, 2007 9:19 pm    Post subject: [solved]Can't seem to get vim to open in a new xterm Reply with quote

I've been trying to streamline my alias file a bit. At work I believe we use a tsch shell, and by default in gentoo we use a bash shell, I've been trying to develop and alias that will open a new xterm with vim editing a file that came after the alias. Something like this:

Code:
alias vi='xterm -e vim $@ &'


so that at the command line I can do this:

Code:
> vi ~/.aliases


and get a new xterm with the given file open in vim. Right now though, I get a new xterm with vi open, but not the file.
_________________
Now I make the stuff you get pissed off at.


Last edited by vivi131313 on Sun Aug 26, 2007 10:51 pm; edited 1 time in total
Back to top
View user's profile Send private message
Rob1n
l33t
l33t


Joined: 29 Nov 2003
Posts: 714
Location: Cambridge, UK

PostPosted: Sun Aug 26, 2007 9:21 pm    Post subject: Reply with quote

You probably need to quote your arguments. Try:
Code:

alias vi='xterm -e "vim $@" &'
Back to top
View user's profile Send private message
vivi131313
Tux's lil' helper
Tux's lil' helper


Joined: 11 May 2004
Posts: 108
Location: Folsom, CA

PostPosted: Sun Aug 26, 2007 9:26 pm    Post subject: Reply with quote

That just gives me a new xterm with vi open, but without the file.
_________________
Now I make the stuff you get pissed off at.
Back to top
View user's profile Send private message
Rob1n
l33t
l33t


Joined: 29 Nov 2003
Posts: 714
Location: Cambridge, UK

PostPosted: Sun Aug 26, 2007 9:49 pm    Post subject: Reply with quote

I've just had a check and bash aliases don't accept arguments. You'll have to either do it as a separate script or as a function:
Quote:

vi() { xterm -e "vim $*" &; }
Back to top
View user's profile Send private message
vivi131313
Tux's lil' helper
Tux's lil' helper


Joined: 11 May 2004
Posts: 108
Location: Folsom, CA

PostPosted: Sun Aug 26, 2007 9:54 pm    Post subject: Reply with quote

That would explain a few things, but I've been able to do it as long as I don't use the & at the end of the alias, and a few other quick things...

where did you find this bash aliases can't handle arguments?

how do I make the function that you pointed me to work?
_________________
Now I make the stuff you get pissed off at.
Back to top
View user's profile Send private message
Rob1n
l33t
l33t


Joined: 29 Nov 2003
Posts: 714
Location: Cambridge, UK

PostPosted: Sun Aug 26, 2007 10:16 pm    Post subject: Reply with quote

vivi131313 wrote:
That would explain a few things, but I've been able to do it as long as I don't use the & at the end of the alias, and a few other quick things...

Yes, a bash alias is just a substitution, so without the & at the end, you're just replacing "vi" with "xterm -e vim" so anything you type after the "vi" will appear after the "xterm -e vim".

Quote:
where did you find this bash aliases can't handle arguments?

I googled for "bash alias arguments" and found it mentioned a few times.

Quote:
how do I make the function that you pointed me to work?

Seems it doesn't like the ; in there. Just type in (at the command line):
Code:

vi() { xterm -e "vim $*" & }
Back to top
View user's profile Send private message
Hu
Administrator
Administrator


Joined: 06 Mar 2007
Posts: 21724

PostPosted: Sun Aug 26, 2007 10:17 pm    Post subject: Reply with quote

The information about aliases is also available in the bash info pages (info bash) under section (bash.info.bz2)Aliases.
Back to top
View user's profile Send private message
vivi131313
Tux's lil' helper
Tux's lil' helper


Joined: 11 May 2004
Posts: 108
Location: Folsom, CA

PostPosted: Sun Aug 26, 2007 10:23 pm    Post subject: Reply with quote

ok, it works from my command line, how would you guys suggest adding this to my alias file, or should I include this in another file that will be read when I start and xterm?
_________________
Now I make the stuff you get pissed off at.
Back to top
View user's profile Send private message
vivi131313
Tux's lil' helper
Tux's lil' helper


Joined: 11 May 2004
Posts: 108
Location: Folsom, CA

PostPosted: Sun Aug 26, 2007 10:51 pm    Post subject: Reply with quote

ok I got it working in my bashrc, thanks guys.
_________________
Now I make the stuff you get pissed off at.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum