Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How do I remove the extra bash-3.2$ from shell-mode?

11 views
Skip to first unread message

Andrew Pennebaker

unread,
May 4, 2015, 4:48:25 PM5/4/15
to Emacs Help
Help, the first line of my shell-mode has an extra bash-3.2$ prompt before
my git prompt.

I tried writing PROMPT_COMMAND= in my ~/.bashrc according to an earlier
Stack Overflow post, but bash-3.2$ continues to display anyway.

M-x shell-mode RET

Expected:

dotfiles (master)$ RET
dotfiles (master)$ RET
dotfiles (master)$ RET

Observed:

bash-3.2$ dotfiles (master)$ RET
dotfiles (master)$ RET
dotfiles (master)$ RET

Configuration:

* https://github.com/mcandre/dotfiles/blob/master/.emacs
* https://github.com/mcandre/dotfiles/blob/master/.emacs_bash
* https://github.com/mcandre/dotfiles/blob/master/.bash_profile
* https://github.com/mcandre/dotfiles/blob/master/.bashrc
* https://github.com/mcandre/dotfiles/tree/master/.bashrc.d
* https://github.com/mcandre/dotfiles/tree/master/.bash_profile.d

System:

* emacs 24.4.1
* bash 3.2.57
* Mac OS X 10.10.3

--
Cheers,
Andrew

Pascal J. Bourguignon

unread,
May 4, 2015, 4:59:44 PM5/4/15
to
Andrew Pennebaker <andrew.p...@gmail.com> writes:

> Help, the first line of my shell-mode has an extra bash-3.2$ prompt before
> my git prompt.
>
> I tried writing PROMPT_COMMAND= in my ~/.bashrc according to an earlier
> Stack Overflow post, but bash-3.2$ continues to display anyway.

What about reading man bash?
Stackoverflow will never replace documentation!
Emacs has a couple of nice commands to read unix manual pages.
Try: M-x man RET bash RET

--
__Pascal Bourguignon__ http://www.informatimago.com/
“The factory of the future will have only two employees, a man and a
dog. The man will be there to feed the dog. The dog will be there to
keep the man from touching the equipment.” -- Carl Bass CEO Autodesk

Andrew Pennebaker

unread,
May 4, 2015, 6:02:30 PM5/4/15
to Pascal J. Bourguignon, Emacs Help
Could you be more specific?
--
Cheers,
Andrew

Pascal J. Bourguignon

unread,
May 4, 2015, 6:07:44 PM5/4/15
to
Andrew Pennebaker <andrew.p...@gmail.com> writes:

> Could you be more specific?

Use the features of emacs, like, say, C-s

Pascal J. Bourguignon

unread,
May 4, 2015, 6:09:19 PM5/4/15
to
"Pascal J. Bourguignon" <p...@informatimago.com> writes:

> Andrew Pennebaker <andrew.p...@gmail.com> writes:
>
>> Could you be more specific?
>
> Use the features of emacs, like, say, C-s

Actually, no.

The point of unix manual page is that they should be READ!

You should definitely read the manual page of bash from begin to end.

I know it's one of the biggest pages, nonetheless, since bash is a
program you're using all the time, you should read its documentation.

There's no way out.

Andrew Pennebaker

unread,
May 4, 2015, 8:09:34 PM5/4/15
to Pascal J. Bourguignon, Emacs Help
Emacs seems to be printing its default PS1 prompt before emacs_bash has
fully executed. Is there a way to suppress this?

On Mon, May 4, 2015 at 5:00 PM, Pascal J. Bourguignon <p...@informatimago.com
--
Cheers,
Andrew

Pascal J. Bourguignon

unread,
May 4, 2015, 8:29:27 PM5/4/15
to
Andrew Pennebaker <andrew.p...@gmail.com> writes:

> Emacs seems to be printing its default PS1 prompt before emacs_bash has
> fully executed. Is there a way to suppress this?

Just add:

echo '# welcome to emacs shell'

at the end of your ~/.emacs_bash file, and it is "~/.emacs_bash", not
"emacs_bash"!!!!!!!!

Robert Thorpe

unread,
May 4, 2015, 8:37:27 PM5/4/15
to Andrew Pennebaker, p...@informatimago.com, help-gn...@gnu.org
Andrew Pennebaker <andrew.p...@gmail.com> writes:

> Emacs seems to be printing its default PS1 prompt before emacs_bash has
> fully executed. Is there a way to suppress this?

I think the problem is that bash prints out the prompt when it starts.
It's only after it has read the line changing the prompt that it can
actually change the prompt.

The info manual says "The value of the variable `PROMPT_COMMAND' is
examined just before Bash prints each primary prompt." So, at the start
of the .bashrc it has the wrong value, so one line is wrong.

I think you have to use -p to change the value for the first line.

I think your environment is configured oddly if you're seeing this
prompt at all.

BR,
Robert Thorpe

Andrew Pennebaker

unread,
May 4, 2015, 9:43:02 PM5/4/15
to Robert Thorpe, Pascal Bourguignon, Emacs Help
Thank you for pointing that out. Turns out I was loading my git prompt with
.bash_profile, but not with .bashrc, after I had changed the load style of
my bash configuration for speed.

I've created
https://github.com/mcandre/dotfiles/blob/master/.bashrc.d/emacs-git-prompt.sh
to get the best of both worlds: fast shells, and idiomatic Emacs shell
prompts!
--
Cheers,
Andrew
0 new messages