Skip to content

Instantly share code, notes, and snippets.

@chriszarate
Last active March 17, 2021 00:57
  • Star 11 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save chriszarate/491014cac3c60e2a181c to your computer and use it in GitHub Desktop.
Identify your tmux windows with food emoji
# Identify your tmux windows with food emoji (OS X + tmux). Add this to your bashrc.
# See https://github.com/chriszarate/dotfiles for more details.
# Randomize string (space-separated values).
function randomize_string () {
echo $@ | tr " " "\n" | perl -MList::Util=shuffle -e 'print shuffle(<STDIN>);' | tr "\n" " "
}
# Extract a random item from a string (space-separated values).
function random_el () {
local array=($(randomize_string $@))
# Bash $RANDOM is terrible; use jot.
echo ${array[$(jot -r 1 0 `expr ${#array[*]} - 1`)]}
}
# Generate a random food emoji.
function random_food () {
if [ -e "/System/Library/Fonts/Apple Color Emoji.ttf" ]; then
echo $(random_el "🍺 🍸 🍹 🍷 πŸ• πŸ” 🍟 πŸ— πŸ– 🍝 🍀 🍣 πŸ₯ 🍜 🍑 🍞 🍩 🍦 🍨 🍰 πŸͺ 🍫 🍬 🍭 🍎 🍏 🍊 πŸ‹ πŸ’ πŸ‡ πŸ‰ πŸ“ πŸ‘ 🍌 🍐 🍍 πŸ† πŸ… ")
else
echo "ο£Ώ"
fi
}
# Set tmux window status using food emoji as index.
function tmux_food () {
if [[ "$TERM" = screen* ]] && [ -n "$TMUX" ]; then
tmux_index=$(random_food)
tmux set-option quiet on
tmux set-window window-status-current-format " $tmux_index #W "
tmux set-window window-status-format " $tmux_index #W "
fi
}
tmux_food
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment