From 338ed982f2cdd6ff774b4f7ef1b64ab119347b9c Mon Sep 17 00:00:00 2001 From: janabhumi Date: Sun, 4 Sep 2022 16:03:13 +0300 Subject: [PATCH] scripts/himz: add support of color --- scripts/himz | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/scripts/himz b/scripts/himz index d3bd70b..e0e1957 100755 --- a/scripts/himz +++ b/scripts/himz @@ -1,15 +1,15 @@ #! /usr/bin/env bash -IFS= +himalaya_opts="--color=always" w3m_opts=("-T" "text/html" "-o" "display_link_number=1" "-dump") function accounts() { - himalaya accounts | \ + himalaya ${himalaya_opts[@]} accounts | \ awk '/imap/ { print $1 }' | \ sort | \ fzf --exit-0 --select-1 --ansi --layout=reverse \ --header="Accounts" \ - --preview="himalaya -a {} list -s 10" \ + --preview="himalaya $himalaya_opts -a {} list -s 10" \ --preview-window=right,80% } @@ -17,20 +17,22 @@ function emails() { if [ "$#" != "0" ]; then local acc=$1 local size=${2-50} - local HIM_CMD="himalaya -a $acc list -s $size -w 150" + local w3m_cmd="w3m ${w3m_opts[@]}" + + local HIM_CMD="himalaya $himalaya_opts -a $acc list -s $size -w 150" local selected=$( FZF_DEFAULT_COMMAND="$HIM_CMD | grep '│'" \ fzf --exit-0 --ansi --layout=reverse \ --header-lines=1 \ --header="Account: ${acc}" \ --preview=" -res=\$(himalaya -a $acc read -t html {1}); +res=\$(himalaya $himalaya_opts -a $acc read -t html {1}); echo \$res | head -n 2; echo -e "\\\\n\===============================================================================\\\\n"; -echo \$res | tail -n +3 | w3m ${w3m_opts} +echo \$res | tail -n +3 | ${w3m_cmd} " \ --preview-window=down,70% \ - --bind="ctrl-r:reload(eval $FZF_DEFAULT_COMMAND)" + --bind='ctrl-r:reload(eval $FZF_DEFAULT_COMMAND)' ) echo $selected | awk '{ print $1 }' fi @@ -45,7 +47,8 @@ do eid=$(emails $acc $@) if [ "$eid" != "" ]; then - res=$(himalaya -a $acc read -t html $eid) + IFS= + res=$(himalaya $himalaya_opts -a $acc read -t html $eid) echo $res | head -n 2 echo -e "\n===============================================================================\n" echo $res | tail -n +3 | w3m ${w3m_opts[@]}