我在mac上使用bash,其中一个别名是这样的
alias gitlog='git --no-pager log -n 20 --pretty=format:%h%x09%an%x09%ad%x09%s --date=short --no-merges'
Run Code Online (Sandbox Code Playgroud)
但是,当我这样做
:! gitlog
Run Code Online (Sandbox Code Playgroud)
我明白了
/bin/bash: gitlog: command not found
Run Code Online (Sandbox Code Playgroud)
我知道我可以在我的.gitconfig中添加这样的别名
[alias]
co = checkout
st = status
ci = commit
br = branch
df = diff
Run Code Online (Sandbox Code Playgroud)
但是,我不想将所有bash别名添加到.gitconfig.那不是干.
有更好的解决方案吗?
可能重复:
从vim执行的命令无法识别bash命令别名
我的〜/ .bashrc文件中有以下函数(在我的Ubunut框中)
# 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 }
Run Code Online (Sandbox Code Playgroud)
例如,要将tex文件f.tex转换为pdf文件并以正确的顺序bibtex,我调用tb2p f.如果我在Bash终端,这非常有效.但是,要从Vim内部进入Bash提示符,我实际上必须执行命令:sh first.
为了简化上述过程,我尝试通过以下方式在Vim中执行函数 …