barabo / advanced-shell-history

Advanced command line shell history - save your bash history to sqlite3 automatically!
Apache License 2.0
161 stars 17 forks source link

Integration with starship #24

Open warrenc5 opened 1 year ago

warrenc5 commented 1 year ago

Ash is a great plugin and is what I have been looking for a while.

However it breaks my starship :( Is it possible to get this and starship to work nicely together?

I had a play around adding it to .config/starship.toml but failed miserably. I also had a look into the ASH source scripts - wow

Something to do with ... https://starship.rs/advanced-config/#custom-pre-prompt-and-pre-execution-commands-in-bash Or this error

Advanced Shell History enabled: session 39
❯ eval "$(starship init bash)"
bash: PROMPT_COMMAND: readonly variable
warrenc5 commented 1 year ago

This is as close as I could get to make them play nicely.

Added to my .bashrc

source /usr/local/lib/advanced_shell_history/sh/bash
ASH=1 __ash_begin_session
export ASH_CFG_SYSTEM_QUERY_FILE
eval "$(starship init bash)"

function __link_ash() {
  ASH=1 __ash_precmd
}

if [ -n "${STARSHIP_SESSION_KEY}" ] ; then
  starship_precmd_user_func="__link_ash"
fi

And I had to update /usr/local/lib/advanced_shell_history/sh/bash around line 100

readonly ASH_SESSION_ID 
  #PROMPT_COMMAND