From ab424056bf883612be521da504aa441de24ee17d Mon Sep 17 00:00:00 2001 From: Kévin Le Gouguec Date: Tue, 8 Nov 2016 19:29:53 +0100 Subject: Keep track of current column to deduce correct rule length MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Maybe a better option would be to display some bright red markers and display the full rule on a new line. 🤷 --- .bashprompt | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/.bashprompt b/.bashprompt index 6dc7e32..e384f17 100644 --- a/.bashprompt +++ b/.bashprompt @@ -133,10 +133,29 @@ __set-prompt () BUILDING_PS1= } +__current-column () +{ + # Cf. console_codes(4) § ECMA-48 Status Report Commands + + local position + read -sdR -p$'\E[6n' position + + local pattern='\[[0-9]+;([0-9]+)' + + if [[ ${position} =~ ${pattern} ]] + then + echo ${BASH_REMATCH[1]} + else + echo 0 + fi +} + __draw-rule () { local rule='' - for ((i=0; i