Comments (5)
@Integralist thanks for opening. Could you provide a bit more debugging information after you've sourced bash-preexec.sh?
# Contents of your prompt command
echo $PROMPT_COMMAND
# Contents of preexec
echo ${preexec_functions[@]}
# Contents of precmd
echo ${precmd_functions[@]}
# Trap should contain bash-preexec's hook
trap
# Check if it's imported
echo "$__bp_imported"
Should return values like..
$ echo $PROMPT_COMMAND
__bp_precmd_invoke_cmd; __bp_interactive_mode;
$ echo ${preexec_functions[@]}
__bh_preexec preexec
$ echo ${precmd_functions[@]}
__bh_precmd_run_script __bh_bash_precmd __bh_precmd precmd
$ trap
trap -- '' SIGTSTP
trap -- '' SIGTTIN
trap -- '' SIGTTOU
trap -- '__bp_preexec_invoke_exec' DEBUG
$ echo $__bp_imported
defined
Not sure about the homebrew installation, as I didn't create it or use it, but my guess is something is conflicting with your trap or PROMPT_COMMAND.
from bash-preexec.
Sure thing @rcaloras the details you've asked for are as follows...
btw, here is my ~/.bashrc file. I found if I move the sourcing of the file to the bottom of that (rather than doing it at the top) I would get some output, but it seemed a bit inconsistent. It might be my crazy prompt code I've got going on that's messing something up
$ echo $PROMPT_COMMAND
history -a
$ echo ${preexec_functions[@]}
preexec
$ echo ${precmd_functions[@]}
precmd
$ trap
trap -- 'shell_session_update' EXIT
trap -- '' SIGTSTP
trap -- '' SIGTTIN
trap -- '' SIGTTOU
trap -- '__bp_preexec_invoke_exec' DEBUG
$ echo "$__bp_imported"
defined
from bash-preexec.
So it looks like bash-preexec is getting pulled in correctly, but PROMPT_COMMAND is not right. If it's right, your PROMPT_COMMAND should have at least the two functions mine does:
$ echo $PROMPT_COMMAND
__bp_precmd_invoke_cmd; __bp_interactive_mode;
Looking at your ~/.bashrc, it looks like you're overwriting PROMPT_COMMAND in a few places. From your file:
export PROMPT_COMMAND='history -a' # record each line as it gets issued
# override builtin cd so it resets command prompt when changing directories
function cd {
builtin cd "$@"
RET=$?
PROMPT_COMMAND=prompt
# Disabled following because it seems to be pointless now?
# That or I just don't know what it was really doing originally?
#
# # After each command, append to the history file and reread it...
# export PROMPT_COMMAND="${PROMPT_COMMAND:+$PROMPT_COMMAND$'\n'}history -a; history -c; history -r"
return $RET
}
One thing you could do is remove the overwriting of PROMPT_COMMAND and instead define whatever you want in PROMPT_COMMAND as part of a precmd function e.g.
precmd() {
history -a
}
Give it a shot. Let me know if there's anything else I can help with.
from bash-preexec.
Heya, so I've got this working now. Totally my bad.
I sorted out my command prompt setup and it works fine 👍
Thanks for taking the time to look into this, you were right PROMPT_COMMAND
was getting messed around with when it didn't need to be now I'm using your script
from bash-preexec.
@Integralist no worries! Glad you got it working and I could help! Feel free to checkout some of my other projects as well, bash-preexec was designed to power https://bashhub.com.
from bash-preexec.
Related Issues (20)
- It's possible to prevent the execution of the command? HOT 4
- fc prints debug trap HOT 6
- Preexec is called when exiting bash with Ctrl-D HOT 2
- Return immediately when running in Zsh HOT 3
- [Bug] HISTCONTROL ignore* setting should be respected HOT 7
- `__bp_preexec_invoke_exec "$_"` printed when running multiple commads
- Tests fail with bats 1.5.0 HOT 7
- official way to detect whether bash-preexec is loaded HOT 2
- Line number exit outpu command ? HOT 1
- Bash 5.1 supports making PROMPT_COMMAND an array HOT 5
- ShellCheck highlights several issues with the file - Shellcheck could be disabled, or issues resolved HOT 2
- post_cmd functionality addition HOT 2
- Functions called in opposite order in midnight commander subshell HOT 2
- Some tests fail with bats 1.9 HOT 6
- preexec() does not work where as precmd() is working as intended. HOT 1
- Library Authors documentation can still lead to issues HOT 2
- preexec $1 is missing some commands HOT 1
- detailed bash log with preexec and precmd HOT 2
- Not working on Windows using Bash in MSYS2 HOT 7
- preexec doesn't work for no-op command `:`
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bash-preexec.