On Tuesday 25 May 2010 12:05:55 pm Benjamin R. Haskell wrote:

> On Tue, 25 May 2010, Tony Mechelynck wrote:
> > On 25/05/10 15:52, robert song wrote:
> > > Hi, everyone.
> > >
> > > I add one rm function in .bashrc, so if I use rm to delete
> > > the file, the file will be moved to ~/.Trash directory. 
> > > But When I use "!rm /tmp/1" command, I can't find the file
> > > in ~/.Trash dir, it seems that the real rm command is
> > > called.
> > >
> > > How can I use the function defined by myself ?
> > >
> > > Best Regards,
> > >    robert
> >
> > ~/.bashrc is only sourced by interactive shells. So:
> >
> > Solution 1. Start gvim from an interactive bash shell, it
> > will inherit your settings.
> 
> But, :! spawns a new subshell, so it doesn't inherit aliases
>  or functions, for example.
> 
> > Solution 2. Use Console Vim instead (you will have started
> > it from an interactive bash shell).
> 
> Same problem.
> 
> > Solution 3. Place your rm function in ~/.profile instead,
> > and invoke it as "bash -l -c rm whatever" (~/.profile is
> > sourced by login shells).
> 
> Solution 4.  Just keep everything how it is, but call:
> :!bash -i -c rm\ whatever
> 
> -i makes it interactive.  I guess your (Tony's) example of
>  "invoke it as 'bash ...'" implies it, but the quoting is
>  possibly problematic.
> 
> The solution in the other thread (make a proper script in your
>  path) is probably preferable to trying to get the quoting
>  right (which is probably best done by wrapping the bash
>  invocation in a function).
> 
> Solution 5. Read: :help :!
> 
> and try its example of:
> :set shellcmdflag=-ic

this all looks like a needless mess -- if you want files in 
~/.Trash, why not 

    :!mv <filename> ~/.Trash

sc

-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Reply via email to