Skip to content

Commit

Permalink
disable line wrapping by default so we don't garble ansi art on small…
Browse files Browse the repository at this point in the history
… screens (#6)

fixes #6
  • Loading branch information
yuhonas authored Apr 28, 2023
1 parent 1e3ca29 commit 250130b
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
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

0 comments on commit 250130b

Please sign in to comment.