jesseduffield / jesseduffield/lazygit

Support ANSI rewrite sequences

Open
#4,225 0 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Go
Stars
82.4k
Forks
3k
Avg merge
2d 18h
Merged PRs (30d)
19

Description

**Is your feature request related to a problem? Please describe.**

We have a git hook that displays some progress on a long running task, it does this progress message using ANSI escape codes to rewrite the previous line. When running this hook via LazyGit during a push the line escape codes are written literally so they do not function as expected.

**Describe the solution you'd like**

Ideally, the output capturing for hooks would handle all valid ANSI escapes.

**Additional context**

Example:

```sh
# .git/hooks/pre-push

# Print 1 line then re-write it using ANSI escape codes
>&2 echo -e "Line one (should not be visible)"
>&2 echo -e "\033[1A\033[KLine two"

if [ -t 0 ]; then
>&2 echo " --> Attached to a terminal"
else
>&2 echo " --> Not attached to a terminal"
fi

>&2 echo "If you see 'Line two' then things are working as expected"
exit 1
```

![Image](https://github.com/user-attachments/assets/ef4f553f-2da3-444f-b38f-7e177828cd73)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.