tags:

views:

47

answers:

1

This is what I need - have a key that will create ctags of my python site-packages.

I have this command, that will print the site-packages path:

!python -c "from distutils.sysconfig import get_python_lib; print get_python_lib()"

This is how I to the key mapping:

map <F11> :!ctags -R -f ./tags *site-packages-path-goes-here*<CR>

How do I plug in the result of one command into the key binding statement?

The reason I want to get the site-packages path at the runtime is that I use virtualenv intensively. As the result the desired path changes all the time.

+1  A: 

This should work:

map <F11> :exe '!ctags -R -f ./tags ' . shellescape(system('python -c "from distutils.sysconfig import get_python_lib; print get_python_lib()"'))<CR>

But if your shell supports it, why not just:

map <F11> :!ctags -R -f ./tags `python -c "from distutils.sysconfig import get_python_lib; print get_python_lib()`<CR>
too much php
This finally worked for me (your first solution without 'shellescape'):map <S-F11> :exe '!ctags -R -f ./pytags ' . system('python -c "from distutils.sysconfig import get_python_lib; print get_python_lib()"')<CR>
ak