Skip to content

Commit 4e5800f

Browse files
committed
use native terminal-drawing character
1 parent 542a63a commit 4e5800f

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

diff-so-fancy

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,11 @@ strip_first_column () {
6262
}
6363

6464
print_horizontal_rule () {
65-
printf "%$(tput cols)s\n"| $SED 's/ /─/g'
65+
let width="$(tput cols)"
66+
67+
# echo -n '─' | hexdump -C
68+
local -r dash=$( printf "%b" "\xe2\x94\x80" )
69+
printf "%*s\n" "$width" | $SED "s/ /${dash}/g"
6670
}
6771

6872
print_header_clean () {

test/diff-so-fancy.bats

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,11 @@ if begin"
4343
output=$( load_fixture "noprefix" | $diff_so_fancy )
4444
refute_output --partial "diff --git setup-a-new-machine.sh"
4545
}
46+
47+
@test "header format uses a native line-drawing character" {
48+
header=$( printf "%s" "$output" | head -n3 )
49+
run printf "%s" "$header"
50+
assert_line --index 0 --partial "─────"
51+
assert_line --index 1 --partial "modified: fish/functions/ls.fish"
52+
assert_line --index 2 --partial "─────"
53+
}

0 commit comments

Comments
 (0)