utilies

A handful of (useful) scripts for unix-like systems
Log | Files | Refs | README | LICENSE

commit cbc784462fe4c161f5b9e980fe290325c951067b
parent b8a05f9f82ad8a67e1add97bc908254c394ec37e
Author: Rikard Karlsen <rk@cassettian.space>
Date:   Thu, 19 May 2022 18:41:24 +0200

add pomo and tano

* pomo: pomodoro timer
* tano: markdown notes searcher

Diffstat:
Apomo | 27+++++++++++++++++++++++++++
Atano | 62++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 89 insertions(+), 0 deletions(-)

diff --git a/pomo b/pomo @@ -0,0 +1,27 @@ +#!/bin/sh + +pomodoro() { + sleep "$1" + notify-send -u critical -t 0 "Pomo" "$2" + mpv "$HOME/shanti55.ogg" +} + +case "$1" in + "break"|"-b") + t="5m" + [ -n "$2" ] && t="$2" + pomodoro "$t" "Break is done." + ;; + "start"|"-s") + t="25m" + [ -n "$2" ] && t="$2" + pomodoro "$t" "Pomodoro is done." + ;; + "-h"|*) + echo "usage: pomo [option]" + echo + echo "options:" + echo " -s, start DURATION -- start a pomodoro lasting for DURATION (default: 25m)" + echo " -b, break DURATION -- take a break lasting for DURATION (default: 5m)" +esac + diff --git a/tano b/tano @@ -0,0 +1,62 @@ +#!/bin/sh + +# Configurations +editor="$EDITOR" +markdown_converter="markdown" +html_browser="lynx" +selector="fzf" +pager="less" + + +index_tags() { + grep -Poir --no-filename "^#\s.*\s\[.*\]$" . \ + | grep -Po "\[(.*)\]" \ + | sed 's/\[\(.*\)\]/\1/' \ + | sed "s/,\s*/\n/g" \ + | sort \ + | uniq +} + + +find_file() { + q="$1" + while [ 1 ]; do + [ -z "$q" ] \ + && tag="$(index_tags | "$selector")" \ + || tag="$1" + q="" # Only check query first time. + [ -z "$tag" ] && exit 1 + file="$(grep -Pir --color=auto "\[.*\b($tag)\b.*\]" . | "$selector" | awk -F: '{print $1}')" + [ -n "$file" ] && echo "$file" && break + done +} + + +tags_edit() { + file="$(find_file "$1")" + [ -z "$file" ] && exit 1 + + "$editor" "$file" +} + + +tags_view() { + file="$(find_file "$1")" + [ -z "$file" ] && exit 1 + + "$markdown_converter" "$file" | "$html_browser" -stdin --dump | less +} + + +# args: +# -e edit +# -i index +# -d dir directory (default: ".") +# -t tag tag search + + +case "$1" in + "edit" |"-e") tags_edit "$2" ;; + "index"|"-i") index_tags ;; + *) tags_view "$1" ;; +esac