Open mcepl opened 1 year ago
Hmm, this could work:
#!/bin/bash
__osc_prompt() {
# Git has a precedence
if [ -d .git ] ; then
# Test for the existence of bash function
declare -F __git_ps1 >/dev/null && printf "%s" "$(__git_ps1 "$@")"
return
fi
# Are we even in the OSC checkout?
[ -d .osc ] || return
local osc_binary osc_pattern osc_str;
osc_binary=$(type -p osc)
if [ -n "$1" ] ; then osc_pattern="${*}" ; else osc_pattern="(%s)" ; fi
if [ -n "$osc_binary" ] && [ -x "$osc_binary" ] && [ -f .osc/_package ] ; then
osc_str="$(osc status 2>/dev/null |cut -d' ' -f 1|sort|uniq -c|tr -d ' \n')"
# shellcheck disable=SC2059
printf " ${osc_pattern}" "$osc_str"
fi
}
What do you think?
Sorry it took me so long to look into this. It seems to be working somehow, but I'd prefer to make it faster (it adds about 1s delay before printing a new prompt line). It probably requires some work on my end to provide desired functionality from osc and do it sufficiently fast.
Is your feature request related to a problem? Please describe. When using osc as a VCS I would like to have a similar prompt indicating the status of my checkout as I have for git. With fish shell it was a trivial to add a function:
but I don’t know how to do it with osc.
Describe the solution you'd like Similar short snippet I would source in
~/.bashrc
.