4 ms·
If you want a solid line, you could use U+2501 (━) from the set of box drawing characters (https://en.wikipedia.org/wiki/Box-drawing_character https://en.wikipe
by ehamberg 13y ago
If you want a solid line, you could use U+2501 (━) from the set of box drawing characters (https://en.wikipedia.org/wiki/Box-drawing_character https://en.wikipedia.org/wiki/Box-drawing_character):
<━> 9473, U+2501 BOX DRAWINGS HEAVY HORIZONTAL
hr(){printf '━%.0s' $(seq $COLUMNS)}
- ppurka 13y agoIndeed, printf is shorter. I use it in a similar fashion in my own script [1], which can be made to behave like hr() (haven't tried shells other than bash): centered_output '=' '' [1] https://github.com/ppurka/sh_functions/blob/master/my_bash_functions#L97 https://github.com/ppurka/sh_functions/blob/master/my_bash_f...
- thekaleb 13y agoAnd now it works in the bourne shell!
- Fasebook 13y agoIf you want to conform to ANSI, just use two dashes (--) or ASCII, the box drawing character, the source of the unicode variant. This is important because it remains the primary font in the core of any EGA and VGA-compatible graphics card (basically all graphics cards).
- chjj 13y agoSome terminals support ACS (with SCLD) but not unicode. It might be better to use ACS: $ hr() { printf '\e(0'; printf 'q%.0s' $(seq $(tput cols)); printf '\e(B'; } Same thing, but potentially more portable. edit: Could also use tput instead of $COLUMNS. Sometimes the $COLUMNS may not always be updated (bash's checkwinsize option).
- pdw 13y agoFor portability you should also use \033 (the octal code) instead of \e, which is non-standard.