LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 05-19-2010, 02:07 PM   #1
Jarru
LQ Newbie
 
Registered: Jul 2007
Posts: 7

Rep: Reputation: Disabled
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!
 
Old 05-19-2010, 02:17 PM   #2
rweaver
Senior Member
 
Registered: Dec 2008
Location: Louisville, OH
Distribution: Debian, CentOS, Slackware, RHEL, Gentoo
Posts: 1,833

Rep: Reputation: 167Reputation: 167
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.

Last edited by rweaver; 05-19-2010 at 02:18 PM.
 
Old 05-19-2010, 02:53 PM   #3
Jarru
LQ Newbie
 
Registered: Jul 2007
Posts: 7

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by rweaver View Post
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 :-)
 
Old 05-21-2010, 02:43 PM   #4
rweaver
Senior Member
 
Registered: Dec 2008
Location: Louisville, OH
Distribution: Debian, CentOS, Slackware, RHEL, Gentoo
Posts: 1,833

Rep: Reputation: 167Reputation: 167
No problem, glad you got a resolution!
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
bash script ? Change PS1 color on per user basis tommyttt Linux - Software 5 03-01-2010 12:12 AM
change PS1 environment variable from c program sagsriv Linux - Newbie 4 03-10-2008 01:39 PM
Prompt not hard returning after PS1 variable change? SlowCoder Linux - Newbie 5 05-01-2007 09:16 PM
Why doesn't the script change PS1? (RedHat) ForumJoiner Linux - Newbie 3 12-01-2006 03:59 AM
howto change $PS1 when using su (without dash) remcovr Red Hat 2 09-07-2006 12:20 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 10:58 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration