diff options
| author | Kévin Le Gouguec <kevin.legouguec@gmail.com> | 2016-11-08 19:29:53 +0100 |
|---|---|---|
| committer | Kévin Le Gouguec <kevin.legouguec@gmail.com> | 2016-11-08 19:59:38 +0100 |
| commit | ab424056bf883612be521da504aa441de24ee17d (patch) | |
| tree | 757085645e1b6682ee9b6be82f66cabf0bea513e | |
| parent | bcd4adbac78654c4f44138f860e197a63a58287e (diff) | |
| download | dotfiles-ab424056bf883612be521da504aa441de24ee17d.tar.xz | |
Keep track of current column to deduce correct rule length
Maybe a better option would be to display some bright red markers and
display the full rule on a new line.
🤷
| -rw-r--r-- | .bashprompt | 21 |
1 files changed, 20 insertions, 1 deletions
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<COLUMNS; i++)) + local column=$(__current-column) + + for ((i=column; i<=COLUMNS; i++)) do rule+=— done |
