#! /usr/bin/env bash function __him_accounts() { himalaya accounts | \ awk '/imap/ { print $1 }' | \ sort | \ fzf --exit-0 --select-1 --ansi --layout=reverse \ --header="Accounts" \ --preview="himalaya -a {} list -s 10" \ --preview-window=right,80% } function __him_emails() { if [ "$#" != "0" ]; then local w3m_opts="-T text/html -o display_link_number=1 -dump" local acc=$1 local size=${2-50} local selected=$( himalaya -a $acc list -s $size | grep '│' | \ fzf --exit-0 --ansi --layout=reverse \ --header-lines=1 \ --header="Account: ${acc}" \ --preview="himalaya -a ${acc} read -t html {1} | w3m $w3m_opts" \ --preview-window=down,70% \ --bind="ctrl-r:reload(himalaya -a $acc list -s $size | grep '│')" ) local eid=$(echo $selected | awk '{ print $1 }') if [ "$eid" != "" ]; then himalaya -a $acc read -t html $eid | w3m $w3m_opts fi fi } __him_emails `__him_accounts` $@