Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stops triggering precmd every once in a while #30

Closed
Integralist opened this issue Nov 18, 2016 · 4 comments
Closed

Stops triggering precmd every once in a while #30

Integralist opened this issue Nov 18, 2016 · 4 comments

Comments

@Integralist
Copy link

Integralist commented Nov 18, 2016

So I've noticed that every once in a while (it seems random, although maybe we'll discover there's something I'm doing that's causing this problem), my shell will stop updating the prompt (PS1)

I use https://github.com/git/git/blob/master/contrib/completion/git-prompt.sh in order to display git branch information within my prompt and so this is where I usually first notice the issue of precmd not being executed as I'll switch between branches and find the branch name stays the same. But unfortunately that means the issue could have occurred at some earlier point in time.

Here's my .bashrc so you can see how it's configured

The reason I believe it's precmd not being triggered, is I adding in an echo to see what it was doing and I found it was no longer showing the echo and so subsequently I presume no longer calling my prompt function which sets the PS1.

precmd() { echo 'do stuff'; prompt; }

I've tried unsetting PS1 manually and then setting it again (pretty much as my prompt function does). I've tried using the reset command or source ~/.bashrc and source ~/.bash-preexec.sh (also tried source ~/.git-prompt.sh in case that was having issues). But no luck in getting precmd to start running again.

The only thing I'm able to do is to open a new terminal tab and then move back in the directory I was just in and then close the original tab I had open :-(

Any help you can give me in identifying what part of my bashrc might be causing the issue would be appreciated.

@Integralist
Copy link
Author

So I've found that I can cause this issue to happen every time I do source ~/.bashrc

@Integralist
Copy link
Author

OK narrowed it down even further to this specific command:

export PROMPT_COMMAND='history -a' # record each line as it gets issued

But I'm not sure yet why this is causing an issue.

Any ideas?

@Integralist
Copy link
Author

I've fixed the issue (I believe) by just executing history -a in .bashrc rather than assigning it to PROMPT_COMMAND. But reading up on it http://www.tldp.org/HOWTO/Bash-Prompt-HOWTO/x264.html I wouldn't have expected that to have caused an issue like it did?

@rcaloras
Copy link
Owner

Hey Mark,

Thanks for opening! Looks like it was related to your configuration like #29 with interfering with PROMPT_COMMAND. In general, bash-preexec tries to maintain any existing PROMPT_COMMAND, but there are some situations where it may become buggy. If you ever need to maintain something that was previously in PROMPT_COMMAND, you can also move that over to then use precmd instead.

Closing this. Please feel free to reopen if you're still having issues. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants