feat: add tmux popup commands for reminders and calendar
- Refactor `main.sh` to support `reminders` and `calendar` commands, displaying tmux popups with localized titles and current date/time. - Add `show_reminders.sh` and `show_calendar.sh` scripts to render reminders and 2-week calendar views using `rem`. - Update `tmux-remind.tmux` to bind `prefix + r` for reminders and `prefix + c` for calendar popups. - Improve script robustness with `set -euo pipefail` and dynamic script directory resolution.
This commit is contained in:
@@ -1,5 +1,10 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -euo pipefail
|
||||||
|
set -x
|
||||||
|
|
||||||
|
CURRENT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
|
|
||||||
# Funzione per leggere opzioni tmux con default
|
# Funzione per leggere opzioni tmux con default
|
||||||
get_tmux_option() {
|
get_tmux_option() {
|
||||||
local option="$1"
|
local option="$1"
|
||||||
@@ -16,13 +21,28 @@ get_tmux_option() {
|
|||||||
# Esempio: leggi configurazione utente
|
# Esempio: leggi configurazione utente
|
||||||
# my_option=$(get_tmux_option "@plugin_option" "default_value")
|
# my_option=$(get_tmux_option "@plugin_option" "default_value")
|
||||||
|
|
||||||
main() {
|
function get_italian_datetime {
|
||||||
# Logica del plugin qui
|
date "+%d/%m/%Y %H:%M"
|
||||||
tmux display-message "Plugin caricato!"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
main
|
function show_reminders {
|
||||||
|
local datetime
|
||||||
|
datetime=$(get_italian_datetime)
|
||||||
|
tmux display-popup -T "#[align=centre]Impegni di oggi - $datetime" -w 60% -h 50% -x C -y C -E -- "$CURRENT_DIR/show_reminders.sh"
|
||||||
|
}
|
||||||
|
|
||||||
|
function show_calendar {
|
||||||
|
local datetime
|
||||||
|
datetime=$(get_italian_datetime)
|
||||||
|
tmux display-popup -T "#[align=centre]Prossime 2 settimane - $datetime" -w 99% -h 99% -x C -y C -E -- "$CURRENT_DIR/show_calendar.sh"
|
||||||
|
}
|
||||||
|
|
||||||
|
function main {
|
||||||
|
if [ "$1" == "reminders" ]; then
|
||||||
|
show_reminders
|
||||||
|
else
|
||||||
|
show_calendar
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
# bash -c "tput civis; trap \"tput cnorm\" EXIT; rem -m -b1 -gaa -q -aa -iinclude_todo=1 -@2; read -r"
|
main "$@"
|
||||||
|
|||||||
5
scripts/show_calendar.sh
Executable file
5
scripts/show_calendar.sh
Executable file
@@ -0,0 +1,5 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
export LESSCHARSET=utf-8
|
||||||
|
TERM_WIDTH=$(tput cols)
|
||||||
|
rem -m -cu+2 -b1 -gaa -q -@2 --hide-completed-todos -w"$TERM_WIDTH" | less -r +g --status-line -PM"Riga %lt/%L (%Pb\%)"
|
||||||
5
scripts/show_reminders.sh
Executable file
5
scripts/show_reminders.sh
Executable file
@@ -0,0 +1,5 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
export LESSCHARSET=utf-8
|
||||||
|
TERM_WIDTH=$(tput cols)
|
||||||
|
rem -m -b1 -gaa -q -aa -iinclude_todo=1 -@2 -w"$TERM_WIDTH" | less -r -S +g --status-line -PM"Riga %lt/%L (%Pb\%)"
|
||||||
@@ -2,11 +2,9 @@
|
|||||||
|
|
||||||
CURRENT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
CURRENT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
|
|
||||||
# Carica script principale
|
# "$CURRENT_DIR/scripts/main.sh"
|
||||||
"$CURRENT_DIR/scripts/main.sh"
|
|
||||||
|
|
||||||
# Esempio: binding di una key
|
|
||||||
tmux bind-key -T prefix P run-shell "$CURRENT_DIR/scripts/main.sh"
|
|
||||||
# bind-key -T prefix r display-popup -T "Impegni di oggi…" -w 50% -h 50% -x C -y C -E -- "$CURRENT_DIR/scripts/main.sh"
|
|
||||||
|
|
||||||
|
# tmux bind-key -T prefix r display-popup -T "Impegni di oggi…" -w 50% -h 50% -x C -y C -E -- "$CURRENT_DIR/scripts/main.sh"
|
||||||
|
|
||||||
|
tmux bind-key -T prefix r run-shell "$CURRENT_DIR/scripts/main.sh reminders"
|
||||||
|
tmux bind-key -T prefix c run-shell "$CURRENT_DIR/scripts/main.sh calendar"
|
||||||
|
|||||||
Reference in New Issue
Block a user