Git Product home page Git Product logo

Comments (5)

rcaloras avatar rcaloras commented on June 26, 2024

@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.

Integralist avatar Integralist commented on June 26, 2024

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.

rcaloras avatar rcaloras commented on June 26, 2024

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.

Integralist avatar Integralist commented on June 26, 2024

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.

rcaloras avatar rcaloras commented on June 26, 2024

@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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.