cantino / mcfly

Fly through your shell history. Great Scott!
MIT License
6.78k stars 177 forks source link

$PROMPT_COMMAND Issues #209

Closed weissewolke closed 2 years ago

weissewolke commented 2 years ago

I have these lines in my .bashrc:

HISTCONTROL=ignoreboth:erasedups
PROMPT_COMMAND="history -n; history -w; history -c; history -r; $PROMPT_COMMAND"

Is it possible to alter the functions in mcfly.bash to accomodate for this?

cantino commented 2 years ago

Mcfly should leave the PROMPT_COMMAND alone, only appending it's change. What does echo $PROMPT_COMMAND say?

weissewolke commented 2 years ago

The result of echo $PROMPT_COMMAND

__lp_set_prompt

My two lines by themselves erase all duplicates from the history file by reading the list, writing to file, clearing the list and reading the new history file and appending its contents to the history list again. This seems to be necessary since erasedups is quite bugy and does not work reliably.

Activating McFly has two strange effects. Maybe this is of some significance in analysing what is going on:

  if [[ ! -f "${MCFLY_HISTORY}" ]]; then
    export MCFLY_HISTORY=$(mktemp -t mcfly.XXXXXXXX)
    tail -n100 "${HISTFILE}" >| ${MCFLY_HISTORY}
  fi

Any tips greatly appreciated.

cantino commented 2 years ago

I'm not sure. You could try putting the result of mcfly init bash into a shell script that you source yourself, then tweak it.