summaryrefslogtreecommitdiff
path: root/plugins/emotty/emotty.plugin.zsh
diff options
context:
space:
mode:
authorChris McCuller <cmcculler@salesforce.com>2015-09-21 22:19:15 -0400
committerChris McCuller <cmcculler@salesforce.com>2015-09-21 22:19:15 -0400
commite6ccd37b0563b4e7b34c41034766b9789e43ee5c (patch)
treec12c8c2c6437fd7d5d3ec5bff27634a80759b808 /plugins/emotty/emotty.plugin.zsh
parent30ef85664822595e29acdbc840c45d5772d84b5d (diff)
parent76a26a2a59d8c6d0f65a4426cdb93920e255aea7 (diff)
downloadzsh-e6ccd37b0563b4e7b34c41034766b9789e43ee5c.tar.gz
zsh-e6ccd37b0563b4e7b34c41034766b9789e43ee5c.tar.bz2
zsh-e6ccd37b0563b4e7b34c41034766b9789e43ee5c.zip
Merge master (rebase being super annoying). Fix conflicts
Diffstat (limited to 'plugins/emotty/emotty.plugin.zsh')
-rw-r--r--plugins/emotty/emotty.plugin.zsh43
1 files changed, 43 insertions, 0 deletions
diff --git a/plugins/emotty/emotty.plugin.zsh b/plugins/emotty/emotty.plugin.zsh
new file mode 100644
index 000000000..b32dd1a4c
--- /dev/null
+++ b/plugins/emotty/emotty.plugin.zsh
@@ -0,0 +1,43 @@
+# ------------------------------------------------------------------------------
+# FILE: emotty.plugin.zsh
+# DESCRIPTION: Return an emoji for the current $TTY number.
+# AUTHOR: Alexis Hildebrandt (afh[at]surryhill.net)
+# VERSION: 1.0.0
+# DEPENDS: emoji plugin
+#
+# There are different sets of emoji characters available, to choose a different
+# set export emotty_set to the name of the set you would like to use, e.g.:
+# % export emotty_set=nature
+# ------------------------------------------------------------------------------
+
+typeset -gAH _emotty_sets
+local _emotty_plugin_dir="${0:h}"
+source "$_emotty_plugin_dir/emotty_stellar_set.zsh"
+source "$_emotty_plugin_dir/emotty_floral_set.zsh"
+source "$_emotty_plugin_dir/emotty_zodiac_set.zsh"
+source "$_emotty_plugin_dir/emotty_nature_set.zsh"
+source "$_emotty_plugin_dir/emotty_emoji_set.zsh"
+source "$_emotty_plugin_dir/emotty_love_set.zsh"
+unset _emotty_plugin_dir
+
+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/ttys} % ${#${=emotty}}) + 1 ))
+ local character_name=${${=emotty}[tty]}
+ echo "${emoji[${character_name}]}${emoji2[emoji_style]}"
+}
+
+function display_emotty() {
+ local name=$1
+ for i in ${=_emotty_sets[$name]}; do
+ printf "${emoji[$i]}${emoji2[emoji_style]} "
+ done
+ print
+ for i in ${=_emotty_sets[$name]}; do
+ print "${emoji[$i]}${emoji2[emoji_style]} = $i"
+ done
+}