LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Change PS1 when :sh'ing in VIM (https://www.linuxquestions.org/questions/linux-general-1/change-ps1-when-shing-in-vim-808913/)

Jarru 05-19-2010 02:07 PM

Change PS1 when :sh'ing in VIM
 
Hi

I've had my prompt change whenever I :sh (:shell) out of VIM, but can't for the life of me remember how.. Google'ing for a bit diden't help me much, this might :-). The idea is to change the prompt to something like [SH] <your usual prompt here>, so that I know that VIM is running in the background.. I often logout of the shell, because I think VIM is open.

Any ideas how?

Thanks!

rweaver 05-19-2010 02:17 PM

I used to do something similar in vim using a different shell (system used tcsh, vim used bash) although it's probably not what you're remembering.

Code:

set shell=/bin/bash
Then it reads different startup files than the original shell.

Another way to do it would be have your startup files check for the value of $VIM when vim is running that variable is set, when it's not... it's not (unless you manually set it.)

(in .bashrc or whatever startup file for your shell you like)
Code:

if [ $VIM ]; then
        export PS1='[VIM]\h:\w\$ '
fi

works for me.

Jarru 05-19-2010 02:53 PM

Quote:

Originally Posted by rweaver (Post 3974514)
I used to do something similar in vim using a different shell (system used tcsh, vim used bash) although it's probably not what you're remembering.

Code:

set shell=/bin/bash
Then it reads different startup files than the original shell.

Another way to do it would be have your startup files check for the value of $VIM when vim is running that variable is set, when it's not... it's not (unless you manually set it.)

(in .bashrc or whatever startup file for your shell you like)
Code:


if [ $VIM ]; then
        export PS1='[VIM]\h:\w\$ '
fi

works for me.

Ah yes, very nice.

You could also do:

Code:

set shell=/bin/bash\ --rcfile\ /home/whatever/.vimbash
And then set the different prompt in .vimbash..

Code:

export PS1='[SH] \u@\h \w> \a'
This works also.

Thanks for your help :-)

rweaver 05-21-2010 02:43 PM

No problem, glad you got a resolution!


All times are GMT -5. The time now is 03:30 PM.