Often when I'm using vim, I want to jump to a command-line, so I do !bash

Almost as often, I forget whether I'm in a shell that I launched from vim or if I'm just in a shell without vim running. So I made a little script in my path called in-vim that runs ps -ef | grep ^username.*vim that tells me. However, a better way would be to affect the prompt to indicate that I'm in vim. For example, my prompt is currently:

[username@server path]$

but if it could say, when launched from a vim shell:

[username@server path (vim)]$

or something like that, it would be awesome. Any thoughts on how to make that a reality?

1 Answer 1


I was naughty... I should have done better research before asking the question. I found something that pointed me the right direction here. Then I made a new file /etc/profile.d/custom.sh that contained this:

ps | grep "[0-9] vim" >/dev/null
if [ $? -eq 0 ]; then
 PS1="[\u@\h \W] (vim) $ "

It did the trick.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .