Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

osc prompt for Bash. #1632

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions contrib/osc-prompt.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash

__osc_prompt() {
# Git has a precedence
if git rev-parse --quiet --git-dir >/dev/null 2>&1 ; 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
}
Loading