Skip to content

Commit

Permalink
emotty: fix for undefined $TTY (FreeBSD) (ohmyzsh#7844)
Browse files Browse the repository at this point in the history
  • Loading branch information
mcornella committed May 25, 2019
1 parent 8d4d766 commit 1f07889
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 1f07889

Please sign in to comment.