imapfilter

Tool to filtering e-mail. Can be installed via:

sudo apt install imapfilter

Example configuration in ~/.imapfilter/configu.lua:

local posvic_eu = IMAP {
server = 'mail.posvic.eu',
username = 'my@posvic.eu',
password = '',
ssl = 'ssl3',
}

local test = IMAP {
server = 'test.email.com',
username = 'my@email.com',
password = '',
ssl = 'ssl3',
}

function print_subjects(o)
for _, msg in ipairs(filter) do
mbox, uid = table.unpack(msg)
text = mbox[uid]:fetch_message()
print(string.match(text, 'Subject:[^\n]*'))
end
end

posvic_eu.INBOX:check_status()
posvic_eu.INBOX
:contain_from('beacon-monitor@post.cz')
:contain_subject('Beacon Monitor Disk')
:move_messages(posvic_eu['Trash'])

test.INBOX:check_status()
test.INBOX
:contain_from('support@2n.cz')
:contain_subject('Ticket#')
:move_messages(test['INBOX/Automat'])
test.INBOX
:contain_from('apps@crashlytics.com')
:contain_subject('Meeting Room')
:move_messages(test['INBOX/Automat'])

Bash cheatsheet

files=(Screen*.png)
if [ $files = "Screen*.png" ]; then
  echo "No match"
else
  # Override or append
  files[2]="test1"

  # Remove
  files=("${files[@]:0:1}" "${files[@]:3:4}")

  # Length
  echo ${#files[@]}

  for file in "${files[@]}"; do
    echo "$i"
  done

  for ((i = 0; i < ${#files[@]}; i++)); do
    echo "${files[i]}"
  done
fi
case "$a" in
"a")
  echo "a"
  ;;
"b")
  echo "b"
  ;;
*)
  echo "else"
  ;;
esac
path="/var/www/html"
echo ${path##*/} # Last directory
# # from beginning, shortest match
# ## from beginning, longest match
# % from end, shortest match
# %% from end, longest match

Change prompt in Ranger

In previous post I wrote about file manager Ranger. In Ranger there is keyboard shortcut Shift + S to execute shell (Bash in my case). You can modify /etc/ranger/config/rc.conf (or your local ~/.config/ranger/rc.conf) and add this line:

map S shell bash --rcfile <(cat ~/.bashrc; echo 'PS1="(ranger) $PS1"')

Then you get your prompt prefixed by (ranger) and always know you are in shell of Ranger.