从Vim执行Bash函数 - 我该怎么办呢? [英] Executing Bash functions from within Vim - how can I do it?

查看:131
本文介绍了从Vim执行Bash函数 - 我该怎么办呢?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能重复:结果
  <一href=\"http://stackoverflow.com/questions/4642822/commands-executed-from-vim-are-not-recognizing-bash-command-aliases\">Commands从VIM执行不认识bash命令别名

我在下面的函数我的〜/ .bashrc中文件(在我的Ubunut盒)

I have the following function in my ~/.bashrc file (on my Ubunut box)

# convert tex to pdf, no bib 
function t2p {
    latex $1 && latex $1 && dvips $1 -o $1.ps && ps2pdf $1.ps && rm -f $1.dvi }

# convert tex to pdf, with bib 
function tb2p {
    latex $1 && bibtex $1 && latex $1 && latex $1 && dvips $1 -o $1.ps && ps2pdf $1.ps && rm -f $1.dvi }

例如,转换一个TEX文件的 f.tex 为PDF文件,并​​以正确的顺序中文提供它,我称之为 tb2p˚F。这个作品非常好,如果我在一个Bash终端。然而,去Bash提示符从Vim我实际上是执行命令的:SH 第一个

For example, to convert a tex file f.tex to a pdf file and bibtex it in the right order, I call tb2p f. This works very well if I'm in a Bash terminal. However, to get to the Bash prompt from within Vim I actually have to execute the command :sh first.

要简化上面的程序我试图执行功能的 T2P tb2p Vim内部通过的 :! T2P˚F。那么Vim告诉我,它无法找到函数的 T2P 。我做了一些谷歌搜索和阅读,我应该把这些功能整合到文件的 /etc/bash.bashrc ,以使他们的Vim可见。不幸的是,这并没有我的情况下工作。 ,Vim依然不知道的功能。

To simplify the above procedure I tried to execute the functions t2p and tb2p inside Vim by :!t2p f. Vim then tells me that it cannot find the function t2p. I did some Googling and read that I should put these functions into the file /etc/bash.bashrc to make them visible to Vim. Unfortunately, this didn't work in my case. Vim still doesn't know about the function.

目前我希望能够通过使用键盘快捷键来调用我的函数从Vim的一天结束。因此,我的问题如下:

At the end of the day I would like to be able to call my functions from within Vim by using a keyboard shortcut. My questions are therefore as follows:


  1. 我怎样才能让Vim的了解〜/ .bashrc中功能?

  2. 如何设置在键盘快捷键的〜/ .vimrc 作为一个函数的〜/ .bashrc中

  1. How can I let Vim know about ~/.bashrc functions?
  2. How do I setup a keyboard shortcut in ~/.vimrc for a function in ~/.bashrc?

感谢您非常,非常多。

推荐答案

在尝试使用的Vim :!的bash -c T2P 。如果您的别名被限制在交互shell也添加 -i 标记。

Try using :!bash -c t2p in Vim. If your alias is limited to interactive shells also add the -i flag.

这篇关于从Vim执行Bash函数 - 我该怎么办呢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆