Skip to content

Commit

Permalink
emotty: fix for undefined $TTY (FreeBSD) (#7844)
Browse files Browse the repository at this point in the history
  • Loading branch information
mcornella authored and crdant committed Dec 30, 2020
1 parent 6316527 commit 6ae5f08
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions plugins/emotty/emotty.plugin.zsh
Expand Up @@ -25,8 +25,14 @@ emotty_default_set=emoji
function emotty() {
# Use emotty set defined by user, fallback to default
local emotty=${_emotty_sets[${emotty_set:-$emotty_default_set}]}
# Parse $TTY number, normalizing it to an emotty set index
(( tty = (${TTY##/dev/tty} % ${#${=emotty}}) + 1 ))

# Parse tty number via prompt expansion. %l equals:
# - N if tty = /dev/ttyN
# - pts/N if tty = /dev/pts/N
local tty = ${${(%):-%l}##pts/}
# Normalize it to an emotty set index
(( tty = (tty % ${#${=emotty}}) + 1 ))

local character_name=${${=emotty}[tty]}
echo "${emoji[${character_name}]}${emoji2[emoji_style]}"
}
Expand Down

0 comments on commit 6ae5f08

Please sign in to comment.