View previous topic :: View next topic |
Author |
Message |
vivi131313 Tux's lil' helper
Joined: 11 May 2004 Posts: 108 Location: Folsom, CA
|
Posted: Sun Aug 26, 2007 9:19 pm Post subject: [solved]Can't seem to get vim to open in a new xterm |
|
|
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:
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 |
|
|
Rob1n l33t
Joined: 29 Nov 2003 Posts: 714 Location: Cambridge, UK
|
Posted: Sun Aug 26, 2007 9:21 pm Post subject: |
|
|
You probably need to quote your arguments. Try:
Code: |
alias vi='xterm -e "vim $@" &'
|
|
|
Back to top |
|
|
vivi131313 Tux's lil' helper
Joined: 11 May 2004 Posts: 108 Location: Folsom, CA
|
Posted: Sun Aug 26, 2007 9:26 pm Post subject: |
|
|
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 |
|
|
Rob1n l33t
Joined: 29 Nov 2003 Posts: 714 Location: Cambridge, UK
|
Posted: Sun Aug 26, 2007 9:49 pm Post subject: |
|
|
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 |
|
|
vivi131313 Tux's lil' helper
Joined: 11 May 2004 Posts: 108 Location: Folsom, CA
|
Posted: Sun Aug 26, 2007 9:54 pm Post subject: |
|
|
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 |
|
|
Rob1n l33t
Joined: 29 Nov 2003 Posts: 714 Location: Cambridge, UK
|
Posted: Sun Aug 26, 2007 10:16 pm Post subject: |
|
|
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 |
|
|
Hu Administrator
Joined: 06 Mar 2007 Posts: 21724
|
Posted: Sun Aug 26, 2007 10:17 pm Post subject: |
|
|
The information about aliases is also available in the bash info pages (info bash) under section (bash.info.bz2)Aliases. |
|
Back to top |
|
|
vivi131313 Tux's lil' helper
Joined: 11 May 2004 Posts: 108 Location: Folsom, CA
|
Posted: Sun Aug 26, 2007 10:23 pm Post subject: |
|
|
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 |
|
|
vivi131313 Tux's lil' helper
Joined: 11 May 2004 Posts: 108 Location: Folsom, CA
|
Posted: Sun Aug 26, 2007 10:51 pm Post subject: |
|
|
ok I got it working in my bashrc, thanks guys. _________________ Now I make the stuff you get pissed off at. |
|
Back to top |
|
|
|