szermatt / emacs-bash-completion

Add programmable bash completion to Emacs shell-mode
GNU General Public License v2.0
279 stars 33 forks source link

prompt disappears after running just one command #46

Open NicholasBHubbard opened 3 years ago

NicholasBHubbard commented 3 years ago

This is from a plain shell mode. Please note that I have not configured my bash prompt in any way for this example. (I get the same behavior with my regular prompt)

bash-5.1$ ls
Desktop  Documents  Downloads  hold  isos  notes  scratch1.txt  scratch2.txt  src  wireshark  yabsm

pwd
/home/nick

cd ./.emacs.d

pwd 
/home/nick/.emacs.d

As you can see the commands are still being entered but there is just no prompt. If I kill the shell and start a new one I get the same behavior over and over.

This behavior is totally fixed if I do not use bash-completion.

The only configuring I have done is this:

(use-package bash-completion
  :config
  (bash-completion-setup))

I am using Emacs 27.1

szermatt commented 3 years ago

Hi!

I haven't been able to reproduce your problem. emacs-bash-completion does modify the shell prompts temporarily, so it is possible that something went wrong and that the prompts were not set back to their original value, as they should have been.

All I can offer you at this point is a workaround. I think that if you call:

(set bash-completion-use-separate-processes t)

just before bash-completion-setup, you won't have that problem anymore. That's because it switches bash completion to a mode that doesn't need to change the prompt at all, as it creates a separate process.

I suspect that there's something in your bash configuration or system that is causing this issue. It might not be necessarily linked to the bash prompt; it could be many things, unfortunately.

If you have the time, it would be very nice if you could try the following:

  1. install emacs-bash-completion into your Emacs instance without setting bash-completion-use-separate-processes.
  2. open a shell
  3. type PS1="\s-\v\$ " then press return
  4. type PROMPT_COMMAND="" then press return
  5. type set -x in the shell, then press return
  6. M-x bash-completion-refresh
  7. press return in the shell
  8. make a copy of the content of the shell buffer
  9. M-x bash-completion-debug
  10. make a copy of the content of the buffer opened by bash-completion-debug

And add to this issue the content of:

On my test machine, the shell buffer looks like the following at the end:

bash-5.1$ PS1="\s-\v\$ "
bash-5.1$ PROMPT_COMMAND=""
bash-5.1$ set -x
bash-5.1$ 
++ __emacs_complete_recover_prompt
++ local r=0
++ PS1='\s-\v$ '
++ PROMPT_COMMAND=
++ unset __emacs_complete_ps1 __emacs_complete_pc
++ [[ -n '' ]]
bash-5.1$ 
bash-5.1$ 

I'd be interest in seeing any differences.