Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add config option to disable line wrapping so we don't garble ansi art on small screens #6

Merged
merged 2 commits into from
Apr 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
name: Lint for errors
on:
push:
branches: ['main']
branches: [main]
pull_request:
branches: [main]
jobs:
lint:
name: Basic linting for syntax errors
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,8 @@ Art to be displayed is assumed to use the [Code Page 437]( https://en.wikipedia.
## License

This project is licensed under the [ MIT ](./LICENSE) license

### Special Thanks 🙇

* To [romkatv](https://www.reddit.com/r/zsh/comments/12ueb6b/comment/jhmlgez/?utm_source=share&utm_medium=web2x&context=3) for posting a fix for the word wrapping issue on narrow terminals
* To [mainsm](https://github.com/yuhonas/zsh-ansimotd/issues/5#issue-1683181011) for posting 👆 as an issue in the repo
7 changes: 7 additions & 0 deletions zsh-ansimotd.plugin.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,17 @@ function ansi_art_random {
ansi_filename="$(ansi_art_random_file)"

if [ -n "$ansi_filename" ]; then
# turn off automatic margins (a.k.a. line wrapping) unless we've been told not to
# this so it'll still render something usable even if the terminal is too narrow
if [ -z "$ANSI_MOTD_DONT_DISABLE_LINE_WRAPPING" ]; then print -n '\e[?7l'; fi;

# convert from the original character set (Code page 437)
# see https://en.wikipedia.org/wiki/Code_page_437
iconv -f 437 < $ansi_filename

# restore automatic margins unless we've been told not to
if [ -z "$ANSI_MOTD_DONT_DISABLE_LINE_WRAPPING" ]; then print -n '\e[?7h'; fi;

# record the filename in this session incase the user wants to find it later
export ANSI_MOTD_FILENAME="$ansi_filename"
else
Expand Down