0
I would like to figure out in my .bashrc
(or one of the files it sources) whether Vim has the -p
option available and if so create an alias.
Now, that same .bashrc
is used on numerous systems including some ancient ones where Vim still doesn't know the -p
option.
What I need is a way to check for the availability of the option without actually starting up Vim ...
vim -p || echo "Not available"
... where instead of the echo I do something else came to mind, but unfortunately that only works when the -p
option is not available. When it is available, this will actually start up Vim, which is what I want to avoid.
I've experimented with opening /dev/null
and /dev/zero
to no avail ...
Well, because sometimes one is blind to such simple solutions ;) ... thanks a lot. Using basically:
vim --help|grep -q '[:space:]*-p' || echo test
now ... that seems to work (of course I am using something other thanecho
there). – 0xC0000022L – 2012-02-06T15:38:31.147In your example you need to use [[:space:]] and probably + instead of *. An alternate example: vim --help | grep -q '[[:space:]]+-p' && echo 'yes' || echo 'no' – Heptite – 2012-02-06T18:44:35.887