Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8511029
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T03:52:25+00:00 2026-06-11T03:52:25+00:00

I use vim a lot and often find it useful to drop into the

  • 0

I use vim a lot and often find it useful to drop into the command line using !bash.
However, I need to type exit to return to vim and sometimes I’m not sure whether I’m in a subshell or whether that will close my session.

What I’d really like to do is type something like !bash -prompt "subshell" so that I get something like this:

subshell$ <commands go here>

Is this possible?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T03:52:27+00:00Added an answer on June 11, 2026 at 3:52 am

    The most direct way to do this is to set the PS1 environment variable within vim:

    :let $PS1="subshell$ "
    

    And start your sub-shells using the command :shell instead of :!bash.

    Using the $ sign with let modifies an environment variable. Add this to your .vimrc to persist the setting.

    Alternately, using :shell you can specify a more specific command, including arguments, using the shell option, see help shell and help 'shell'.

    So:

    :set shell=bash\ --rcfile\ ~/.vimbashrc
    

    In .vimbashrc add PS1="subshell ", and invoke the sub-shells using :shell instead of !bash. Add this to your .vimrc to persist the setting.

    So you have two options:

    • Add let $PS1="subshell " to your .vimrc, and start sub-shells using :shell instead of :!bash.
    • Make a custom rc file for your vim sub-shells, add your specific PS1="subshell " to it, and modify the shell option in your .vimrc: set shell=bash\ --rcfile\ ~/.vimbashrc.

    Finally, if you must use :!bash to start the sub-shells there are a couple of more options. Note that you can also pass a more specific command line using !, e.g.:

    • :PS1="subshell$ " bash should work.
    • :!bash\ --rcfile\ ~/.vimbashrc, and set PS1 in .vimbashrc as above

    But you’ll need to type these every time, or define a mapping for it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I use the following Vim macro a lot (it puts the current line inside
When using gdb and Vim, often I want to stop on a particular line.
I mostly use vim from the terminal by vi command. I want to create
I am wondering how to use one hotkey mapping two command in vim. for
I use vim C++ tag file for navigation using Ctrl-]. The problem is whenever
I use Vim in Screen. I run the command vim <bigFolder> I am in
I primarily use vim / gvim as an editor and am looking at using
I use Vim and Vim plugins for Visual Studio when writing C++. Often, I
I use Vim with ctags for development. I found ctags to be very useful
I use VIM for code development and lot of things. I see that there

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.