Compare commits
5 Commits
bc0233962a
...
31c1357fbb
| Author | SHA1 | Date | |
|---|---|---|---|
| 31c1357fbb | |||
| c8642343e7 | |||
| e954569d5d | |||
| aeff8a3679 | |||
| e948a18a05 |
38
README.md
38
README.md
@@ -70,6 +70,8 @@ item_types = ["VJOURNAL", "VTODO"]
|
|||||||
...
|
...
|
||||||
```
|
```
|
||||||
|
|
||||||
|
You may also specify the location of the configuration file with the environment `CONFIGFILE`.
|
||||||
|
|
||||||
Usage
|
Usage
|
||||||
-----
|
-----
|
||||||
Use the default `fzf` keys to navigate your notes, e.g., `ctrl-j` and `ctrl-k` for going down/up in the list.
|
Use the default `fzf` keys to navigate your notes, e.g., `ctrl-j` and `ctrl-k` for going down/up in the list.
|
||||||
@@ -84,6 +86,8 @@ In addition, there are the following keybindings:
|
|||||||
| `ctrl-x` | Toggle task completion |
|
| `ctrl-x` | Toggle task completion |
|
||||||
| `alt-up` | Increase task priority |
|
| `alt-up` | Increase task priority |
|
||||||
| `alt-down` | Decrease task priority |
|
| `alt-down` | Decrease task priority |
|
||||||
|
| `ctrl-a` | Open attachments view |
|
||||||
|
| `alt-v` | View bare iCalendar file |
|
||||||
| `alt-0` | Default view: Journal, notes, and _open_ tasks |
|
| `alt-0` | Default view: Journal, notes, and _open_ tasks |
|
||||||
| `alt-1` | Display journal entries |
|
| `alt-1` | Display journal entries |
|
||||||
| `alt-2` | Display notes |
|
| `alt-2` | Display notes |
|
||||||
@@ -91,6 +95,38 @@ In addition, there are the following keybindings:
|
|||||||
|
|
||||||
You may also invoke the script with `--help` to see further command-line options.
|
You may also invoke the script with `--help` to see further command-line options.
|
||||||
|
|
||||||
|
In the attachment view, you may use the following keys:
|
||||||
|
| Key | Action |
|
||||||
|
| --- | ------ |
|
||||||
|
| `enter` | Open attachment |
|
||||||
|
| `j` | Down |
|
||||||
|
| `k` | Up |
|
||||||
|
| `w` | Toggle line wrap |
|
||||||
|
| `ctrl-a` | Add attachment |
|
||||||
|
| `ctrl-alt-d` | Delete attachment |
|
||||||
|
|
||||||
|
Git support
|
||||||
|
-----------
|
||||||
|
You can track your entries with `git` by simply running `fzf-vjour --git-init`.
|
||||||
|
|
||||||
|
Extended configuration / Theming
|
||||||
|
--------------------------------
|
||||||
|
You may override any of the following parameters (shown with default values) in
|
||||||
|
the configuration file:
|
||||||
|
```sh
|
||||||
|
FLAG_OPEN=🔲
|
||||||
|
FLAG_COMPLETED=✅
|
||||||
|
FLAG_JOURNAL=📘
|
||||||
|
FLAG_NOTE=🗒️
|
||||||
|
FLAG_PRIORITY=❗
|
||||||
|
|
||||||
|
STYLE_COLLECTION="$FAINT$WHITE"
|
||||||
|
STYLE_DATE="$CYAN"
|
||||||
|
STYLE_SUMMARY="$GREEN"
|
||||||
|
STYLE_EXPIRED="$RED"
|
||||||
|
STYLE_CATEGORY="$WHITE"
|
||||||
|
```
|
||||||
|
|
||||||
Limitations
|
Limitations
|
||||||
-----------
|
-----------
|
||||||
Here is a list of some currently present limitations.
|
Here is a list of some currently present limitations.
|
||||||
@@ -98,7 +134,7 @@ Here is a list of some currently present limitations.
|
|||||||
- Timezone agnostic: Timezone specifications are ignored.
|
- Timezone agnostic: Timezone specifications are ignored.
|
||||||
- Time agnostic: We use the date portion only of date-time specifications.
|
- Time agnostic: We use the date portion only of date-time specifications.
|
||||||
- No alarms or notifications
|
- No alarms or notifications
|
||||||
- No attachments
|
- Inline attachments only
|
||||||
- No recurrences
|
- No recurrences
|
||||||
|
|
||||||
License
|
License
|
||||||
|
|||||||
35
src/awk/attach.awk
Normal file
35
src/awk/attach.awk
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
## src/awk/attach.awk
|
||||||
|
## Prepend attachment to iCalendar file.
|
||||||
|
##
|
||||||
|
## @assign file: Path to base64-encoded content
|
||||||
|
## @assign mime: Mime
|
||||||
|
## @assign filename: Original filename
|
||||||
|
|
||||||
|
# Functions
|
||||||
|
|
||||||
|
# Write attachment
|
||||||
|
#
|
||||||
|
# @local variables: line, aline
|
||||||
|
function write_attachment( line, aline, fl) {
|
||||||
|
line = "ATTACH;ENCODING=BASE64;VALUE=BINARY;FMTTYPE="mime";FILENAME="filename":"
|
||||||
|
fl = 1
|
||||||
|
while (getline aline <file) {
|
||||||
|
line = line aline
|
||||||
|
if (fl && length(line) >= 73) {
|
||||||
|
print substr(line, 1, 73)
|
||||||
|
line = substr(line, 74)
|
||||||
|
fl = 0
|
||||||
|
}
|
||||||
|
while (length(line) >= 72) {
|
||||||
|
print " "substr(line, 1, 72)
|
||||||
|
line = substr(line, 73)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (line)
|
||||||
|
print " "line
|
||||||
|
}
|
||||||
|
|
||||||
|
# AWK program
|
||||||
|
|
||||||
|
/^END:(VTODO|VJOURNAL)$/ { write_attachment() }
|
||||||
|
{ print }
|
||||||
8
src/awk/attachdd.awk
Normal file
8
src/awk/attachdd.awk
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
BEGIN { FS="[:;]" }
|
||||||
|
/^END:(VTODO|VJOURNAL)$/ { ins = 0; exit }
|
||||||
|
/^[^ ]/ && a { a = 0 }
|
||||||
|
/^ / && a && p { print substr($0, 2); }
|
||||||
|
/^ / && a && !p { if (index($0, ":")) { p = 1; print substr($0, index($0, ":")+1) } }
|
||||||
|
/^ATTACH/ && ins { i++; }
|
||||||
|
/^ATTACH/ && ins && i == id { a = 1; if (index($0, ":")) { p = 1; print substr($0, index($0, ":")+1) } }
|
||||||
|
/^BEGIN:(VTODO|VJOURNAL)$/ { ins = 1 }
|
||||||
41
src/awk/attachls.awk
Normal file
41
src/awk/attachls.awk
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
# Decide if we need to read more to get all properties
|
||||||
|
#
|
||||||
|
# @input str: strin read so far
|
||||||
|
# @return: 1 if we need more data, 0 otherwise
|
||||||
|
function cont_reading(str) {
|
||||||
|
return index(str, ":") ? 0 : 1
|
||||||
|
}
|
||||||
|
|
||||||
|
# Get information about attachment
|
||||||
|
#
|
||||||
|
# @input i: Attachment index
|
||||||
|
# @input str: Attachment string (at least up to content separator `:`)
|
||||||
|
# @return: informative string
|
||||||
|
function att_info(i, str, cnt, k, info) {
|
||||||
|
str = substr(str, 1, index(str, ":") - 1)
|
||||||
|
cnt = split(str, props)
|
||||||
|
if (cnt > 1) {
|
||||||
|
for (k=2; k<=cnt; k++) {
|
||||||
|
pname = substr(props[k], 1, index(props[k], "=") - 1)
|
||||||
|
pvalu = substr(props[k], index(props[k], "=") + 1)
|
||||||
|
if (pname == "ENCODING" && pvalu = "BASE64")
|
||||||
|
enc = "base64"
|
||||||
|
if (pname == "FILENAME")
|
||||||
|
fin = pvalu
|
||||||
|
if (pname == "VALUE")
|
||||||
|
val = pvalu
|
||||||
|
if (pname == "FMTTYPE")
|
||||||
|
type = pvalu
|
||||||
|
}
|
||||||
|
if (enc)
|
||||||
|
info = "inline"
|
||||||
|
}
|
||||||
|
print i, fin, type, enc, info
|
||||||
|
}
|
||||||
|
|
||||||
|
BEGIN { FS="[:;]"; OFS="\t" }
|
||||||
|
/^END:(VTODO|VJOURNAL)$/ { ins = 0; exit }
|
||||||
|
l && !r { att_info(i, l); l = "" }
|
||||||
|
/^ / && r { l = l substr($0, 2); r = cont_reading($0) }
|
||||||
|
/^ATTACH/ && ins { i++; l = $0; r = cont_reading($0) }
|
||||||
|
/^BEGIN:(VTODO|VJOURNAL)$/ { ins = 1 }
|
||||||
13
src/awk/attachrm.awk
Normal file
13
src/awk/attachrm.awk
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
## src/awk/attachrm.awk
|
||||||
|
## Remove attachment from iCalendar file.
|
||||||
|
##
|
||||||
|
## @assign id: Attachment number to remove
|
||||||
|
|
||||||
|
BEGIN { FS="[:;]" }
|
||||||
|
/^END:(VTODO|VJOURNAL)$/ { ins = 0 }
|
||||||
|
/^[^ ]/ && a { a = 0 }
|
||||||
|
/^ / && a { next }
|
||||||
|
/^ATTACH/ && ins { i++; }
|
||||||
|
/^ATTACH/ && ins && i == id { a = 1; next }
|
||||||
|
/^BEGIN:(VTODO|VJOURNAL)$/ { ins = 1 }
|
||||||
|
{ print }
|
||||||
@@ -49,6 +49,13 @@ BEGIN {
|
|||||||
# flag_completed: symbol for completed to-dos
|
# flag_completed: symbol for completed to-dos
|
||||||
# flag_journal: symbol for journal entries
|
# flag_journal: symbol for journal entries
|
||||||
# flag_note: symbol for note entries
|
# flag_note: symbol for note entries
|
||||||
|
# flag_priority symbol for prior. task
|
||||||
|
# flag_attachment symbol for attachment
|
||||||
|
# style_collection
|
||||||
|
# style_date
|
||||||
|
# style_summary
|
||||||
|
# style_expired
|
||||||
|
# style_category
|
||||||
|
|
||||||
FS = "[:;]";
|
FS = "[:;]";
|
||||||
# Collections
|
# Collections
|
||||||
@@ -59,10 +66,6 @@ BEGIN {
|
|||||||
collection2label[m[1]] = m[2];
|
collection2label[m[1]] = m[2];
|
||||||
}
|
}
|
||||||
# Colors
|
# Colors
|
||||||
GREEN = "\033[1;32m";
|
|
||||||
RED = "\033[1;31m";
|
|
||||||
WHITE = "\033[1;97m";
|
|
||||||
CYAN = "\033[1;36m";
|
|
||||||
OFF = "\033[m";
|
OFF = "\033[m";
|
||||||
|
|
||||||
# For date comparision
|
# For date comparision
|
||||||
@@ -74,6 +77,7 @@ BEGIN {
|
|||||||
BEGINFILE {
|
BEGINFILE {
|
||||||
type = "";
|
type = "";
|
||||||
prop = "";
|
prop = "";
|
||||||
|
att = "";
|
||||||
delete c;
|
delete c;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -90,6 +94,11 @@ BEGINFILE {
|
|||||||
c[prop] = $0;
|
c[prop] = $0;
|
||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
|
/^ATTACH/ {
|
||||||
|
prop = ""
|
||||||
|
att = 1;
|
||||||
|
next;
|
||||||
|
}
|
||||||
/^[^ ]/ && prop {
|
/^[^ ]/ && prop {
|
||||||
prop = "";
|
prop = "";
|
||||||
next;
|
next;
|
||||||
@@ -112,7 +121,7 @@ ENDFILE {
|
|||||||
"-",
|
"-",
|
||||||
type,
|
type,
|
||||||
"-",
|
"-",
|
||||||
RED "ERROR: file '" fpath "' contains whitespaces!" OFF
|
style_expired "ERROR: file '" fpath "' contains whitespaces!" OFF
|
||||||
exit
|
exit
|
||||||
}
|
}
|
||||||
# Collection name
|
# Collection name
|
||||||
@@ -145,7 +154,7 @@ ENDFILE {
|
|||||||
priotext = ""
|
priotext = ""
|
||||||
if (pri > 0)
|
if (pri > 0)
|
||||||
{
|
{
|
||||||
priotext = "❗(" pri ") "
|
priotext = flag_priority "(" pri ") "
|
||||||
psort = 10 - pri
|
psort = 10 - pri
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -158,8 +167,8 @@ ENDFILE {
|
|||||||
|
|
||||||
# Date field. For VTODO entries, we show the due date, for journal entries,
|
# Date field. For VTODO entries, we show the due date, for journal entries,
|
||||||
# the associated date.
|
# the associated date.
|
||||||
datecolor = CYAN;
|
datecolor = style_date
|
||||||
summarycolor = GREEN;
|
summarycolor = style_summary
|
||||||
|
|
||||||
if (type == "VTODO")
|
if (type == "VTODO")
|
||||||
{
|
{
|
||||||
@@ -167,8 +176,8 @@ ENDFILE {
|
|||||||
d = due ? due : (dur ? dts " for " dur : "");
|
d = due ? due : (dur ? dts " for " dur : "");
|
||||||
if (d && d <= today && sta != "COMPLETED")
|
if (d && d <= today && sta != "COMPLETED")
|
||||||
{
|
{
|
||||||
datecolor = RED;
|
datecolor = style_expired;
|
||||||
summarycolor = RED;
|
summarycolor = style_expired;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
d = dts
|
d = dts
|
||||||
@@ -191,6 +200,9 @@ ENDFILE {
|
|||||||
# categories
|
# categories
|
||||||
categories = cat ? cat : " "
|
categories = cat ? cat : " "
|
||||||
|
|
||||||
|
# attachments
|
||||||
|
att = att ? flag_attachment " " : ""
|
||||||
|
|
||||||
# filename
|
# filename
|
||||||
# FILENAME
|
# FILENAME
|
||||||
|
|
||||||
@@ -201,6 +213,6 @@ ENDFILE {
|
|||||||
collection,
|
collection,
|
||||||
datecolor d OFF,
|
datecolor d OFF,
|
||||||
flag,
|
flag,
|
||||||
priotext summarycolor summary OFF,
|
priotext att summarycolor summary OFF,
|
||||||
WHITE categories OFF;
|
style_category categories OFF;
|
||||||
}
|
}
|
||||||
|
|||||||
31
src/main.sh
31
src/main.sh
@@ -5,6 +5,9 @@ set -eu
|
|||||||
# Helper functions
|
# Helper functions
|
||||||
. "sh/helper.sh"
|
. "sh/helper.sh"
|
||||||
|
|
||||||
|
# Read theme
|
||||||
|
. "sh/theme.sh"
|
||||||
|
|
||||||
# Read configuration
|
# Read configuration
|
||||||
. "sh/config.sh"
|
. "sh/config.sh"
|
||||||
|
|
||||||
@@ -15,10 +18,17 @@ __lines() {
|
|||||||
find "$ROOT" -type f -name '*.ics' -print0 | xargs -0 -P 0 \
|
find "$ROOT" -type f -name '*.ics' -print0 | xargs -0 -P 0 \
|
||||||
awk \
|
awk \
|
||||||
-v collection_labels="$COLLECTION_LABELS" \
|
-v collection_labels="$COLLECTION_LABELS" \
|
||||||
-v flag_open="🔲" \
|
-v flag_open="$FLAG_OPEN" \
|
||||||
-v flag_completed="✅" \
|
-v flag_completed="$FLAG_COMPLETED" \
|
||||||
-v flag_journal="📘" \
|
-v flag_journal="$FLAG_JOURNAL" \
|
||||||
-v flag_note="🗒️" \
|
-v flag_note="$FLAG_NOTE" \
|
||||||
|
-v flag_priority="$FLAG_PRIORITY" \
|
||||||
|
-v flag_attachment="$FLAG_ATTACHMENT" \
|
||||||
|
-v style_collection="$STYLE_COLLECTION" \
|
||||||
|
-v style_date="$STYLE_DATE" \
|
||||||
|
-v style_summary="$STYLE_SUMMARY" \
|
||||||
|
-v style_expired="$STYLE_EXPIRED" \
|
||||||
|
-v style_category="$STYLE_CATEGORY" \
|
||||||
"$AWK_LIST" |
|
"$AWK_LIST" |
|
||||||
sort -g -r
|
sort -g -r
|
||||||
}
|
}
|
||||||
@@ -57,6 +67,9 @@ fi
|
|||||||
# Command line arguments: Interal use
|
# Command line arguments: Interal use
|
||||||
. "sh/cli.sh"
|
. "sh/cli.sh"
|
||||||
|
|
||||||
|
# Attachment handling
|
||||||
|
. "sh/attachment.sh"
|
||||||
|
|
||||||
while true; do
|
while true; do
|
||||||
query=$(stripws "$query")
|
query=$(stripws "$query")
|
||||||
selection=$(
|
selection=$(
|
||||||
@@ -68,7 +81,7 @@ while true; do
|
|||||||
--print-query \
|
--print-query \
|
||||||
--accept-nth=4 \
|
--accept-nth=4 \
|
||||||
--preview="$0 --preview {4}" \
|
--preview="$0 --preview {4}" \
|
||||||
--expect="ctrl-n,ctrl-alt-d" \
|
--expect="ctrl-n,ctrl-alt-d,alt-v,ctrl-a" \
|
||||||
--bind="ctrl-r:reload($0 --reload)" \
|
--bind="ctrl-r:reload($0 --reload)" \
|
||||||
--bind="ctrl-x:reload($0 --reload --toggle-completed {4})" \
|
--bind="ctrl-x:reload($0 --reload --toggle-completed {4})" \
|
||||||
--bind="alt-up:reload($0 --reload --change-priority '+1' {4})" \
|
--bind="alt-up:reload($0 --reload --change-priority '+1' {4})" \
|
||||||
@@ -78,7 +91,7 @@ while true; do
|
|||||||
--bind="alt-2:change-query(🗒️)" \
|
--bind="alt-2:change-query(🗒️)" \
|
||||||
--bind="alt-3:change-query(✅ | 🔲)" \
|
--bind="alt-3:change-query(✅ | 🔲)" \
|
||||||
--bind='focus:transform:[ {3} = "VTODO" ] && echo "rebind(ctrl-x)+rebind(alt-up)+rebind(alt-down)" || echo "unbind(ctrl-x)+unbind(alt-up)+unbind(alt-down)"' \
|
--bind='focus:transform:[ {3} = "VTODO" ] && echo "rebind(ctrl-x)+rebind(alt-up)+rebind(alt-down)" || echo "unbind(ctrl-x)+unbind(alt-up)+unbind(alt-down)"' \
|
||||||
--bind="ctrl-s:execute($SYNC_CMD ; printf 'Press <enter> to continue.'; read -r tmp)"
|
--bind="ctrl-s:execute($SYNC_CMD; [ -n \"${GIT:-}\" ] && $GIT commit -am 'Synchronized'; printf 'Press <enter> to continue.'; read -r tmp)"
|
||||||
)
|
)
|
||||||
|
|
||||||
# Line 1: query
|
# Line 1: query
|
||||||
@@ -104,6 +117,12 @@ while true; do
|
|||||||
"ctrl-alt-d")
|
"ctrl-alt-d")
|
||||||
__delete "$file"
|
__delete "$file"
|
||||||
;;
|
;;
|
||||||
|
"alt-v")
|
||||||
|
$EDITOR "$file"
|
||||||
|
;;
|
||||||
|
"ctrl-a")
|
||||||
|
__attachment_view "$file"
|
||||||
|
;;
|
||||||
*)
|
*)
|
||||||
__edit "$file"
|
__edit "$file"
|
||||||
;;
|
;;
|
||||||
|
|||||||
178
src/sh/attachment.sh
Normal file
178
src/sh/attachment.sh
Normal file
@@ -0,0 +1,178 @@
|
|||||||
|
# Add attachment to iCalendar file
|
||||||
|
#
|
||||||
|
# @input $1: Path to iCalendar file
|
||||||
|
__add_attachment() {
|
||||||
|
file="$1"
|
||||||
|
shift
|
||||||
|
sel=$(
|
||||||
|
$FZF --prompt="Select attachment> " \
|
||||||
|
--walker="file,hidden" \
|
||||||
|
--walker-root="$HOME" \
|
||||||
|
--expect="ctrl-c,ctrl-g,ctrl-q,esc"
|
||||||
|
)
|
||||||
|
key=$(echo "$sel" | head -1)
|
||||||
|
f=$(echo "$sel" | tail -1)
|
||||||
|
if [ -n "$key" ]; then
|
||||||
|
f=""
|
||||||
|
fi
|
||||||
|
if [ -z "$f" ] || [ ! -f "$f" ]; then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
filename=$(basename "$f")
|
||||||
|
mime=$(file -b -i "$f" | cut -d ';' -f 1)
|
||||||
|
if [ -z "$mime" ]; then
|
||||||
|
mime="application/octet-stream"
|
||||||
|
fi
|
||||||
|
fenc=$(mktemp)
|
||||||
|
base64 "$f" >"$fenc"
|
||||||
|
filetmp=$(mktemp)
|
||||||
|
awk -v file="$fenc" -v mime="$mime" -v filename="$filename" "$AWK_ATTACH" "$file" >"$filetmp"
|
||||||
|
mv "$filetmp" "$file"
|
||||||
|
if [ -n "${GIT:-}" ]; then
|
||||||
|
$GIT add "$file"
|
||||||
|
$GIT commit -q -m "Added attachment" -- "$file"
|
||||||
|
fi
|
||||||
|
rm "$fenc"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Open attachment from iCalendar file
|
||||||
|
#
|
||||||
|
# @input $1: Attachment id
|
||||||
|
# @input $2: Attachment name
|
||||||
|
# @input $3: Attachment format
|
||||||
|
# @input $4: Attachment encoding
|
||||||
|
# @input $5: Path to iCalendar file
|
||||||
|
__open_attachment() {
|
||||||
|
attid="$1"
|
||||||
|
shift
|
||||||
|
attname="$1"
|
||||||
|
shift
|
||||||
|
attfmt="$1"
|
||||||
|
shift
|
||||||
|
attenc="$1"
|
||||||
|
shift
|
||||||
|
file="$1"
|
||||||
|
shift
|
||||||
|
if [ "$attenc" != "base64" ]; then
|
||||||
|
err "Unsupported attachment encoding: $attenc. Press <enter> to continue."
|
||||||
|
read -r tmp
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
if [ -n "$attname" ]; then
|
||||||
|
tmpdir=$(mktemp -d)
|
||||||
|
attpath="$tmpdir/$attname"
|
||||||
|
elif [ -n "$attfmt" ]; then
|
||||||
|
attext=$(echo "$attfmt" | cut -d "/" -f 2)
|
||||||
|
attpath=$(mktemp --suffix="$attext")
|
||||||
|
else
|
||||||
|
attpath=$(mktemp)
|
||||||
|
fi
|
||||||
|
# Get file and decode
|
||||||
|
awk -v id="$attid" "$AWK_ATTACHDD" "$file" | base64 -d >"$attpath"
|
||||||
|
fn=$(file "$attpath")
|
||||||
|
while true; do
|
||||||
|
printf "Are you sure you want to open \"%s\"? (yes/no): " "$fn" >/dev/tty
|
||||||
|
read -r yn
|
||||||
|
case $yn in
|
||||||
|
"yes")
|
||||||
|
$OPEN "$attpath"
|
||||||
|
printf "Press <enter> to continue." >/dev/tty
|
||||||
|
read -r tmp
|
||||||
|
break
|
||||||
|
;;
|
||||||
|
"no")
|
||||||
|
break
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "Please answer \"yes\" or \"no\"." >/dev/tty
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
# Clean up
|
||||||
|
rm -f "$attpath"
|
||||||
|
if [ -n "${tmpdir:-}" ] && [ -d "${tmpdir:-}" ]; then
|
||||||
|
rm -rf "$tmpdir"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Delete attachment from iCalendar file
|
||||||
|
#
|
||||||
|
# @input $1: Attachment id
|
||||||
|
# @input $2: Path to iCalendar File
|
||||||
|
__del_attachment() {
|
||||||
|
attid="$1"
|
||||||
|
shift
|
||||||
|
file="$1"
|
||||||
|
shift
|
||||||
|
while true; do
|
||||||
|
printf "Are you sure you want to delete attachment \"%s\"? (yes/no): " "$attid" >/dev/tty
|
||||||
|
read -r yn
|
||||||
|
case $yn in
|
||||||
|
"yes")
|
||||||
|
filetmp=$(mktemp)
|
||||||
|
awk -v id="$attid" "$AWK_ATTACHRM" "$file" >"$filetmp"
|
||||||
|
mv "$filetmp" "$file"
|
||||||
|
if [ -n "${GIT:-}" ]; then
|
||||||
|
$GIT add "$file"
|
||||||
|
$GIT commit -q -m "Deleted attachment" -- "$file"
|
||||||
|
fi
|
||||||
|
break
|
||||||
|
;;
|
||||||
|
"no")
|
||||||
|
break
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "Please answer \"yes\" or \"no\"." >/dev/tty
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
# Show attachment window
|
||||||
|
#
|
||||||
|
# @input $1: Path to iCalendar file
|
||||||
|
__attachment_view() {
|
||||||
|
file="$1"
|
||||||
|
shift
|
||||||
|
att=$(
|
||||||
|
awk "$AWK_ATTACHLS" "$file" |
|
||||||
|
$FZF \
|
||||||
|
--delimiter="\t" \
|
||||||
|
--accept-nth=1,2,3,4 \
|
||||||
|
--with-nth="Attachment {1}: \"{2}\" {3} ({5})" \
|
||||||
|
--no-sort \
|
||||||
|
--tac \
|
||||||
|
--margin="30%,30%" \
|
||||||
|
--border=bold \
|
||||||
|
--border-label="Attachment View Keys: <enter> open, <ctrl-alt-d> delete, <ctrl-a> add" \
|
||||||
|
--expect="ctrl-a" \
|
||||||
|
--expect="ctrl-c,ctrl-g,ctrl-q,ctrl-d,esc,q,backspace" \
|
||||||
|
--print-query \
|
||||||
|
--bind="start:hide-input" \
|
||||||
|
--bind="ctrl-alt-d:show-input+change-query(ctrl-alt-d)+accept" \
|
||||||
|
--bind='load:transform:[ "$FZF_TOTAL_COUNT" -eq 0 ] && echo "unbind(enter)+unbind(ctrl-alt-d)"' \
|
||||||
|
--bind="w:toggle-wrap" \
|
||||||
|
--bind="j:down" \
|
||||||
|
--bind="k:up" ||
|
||||||
|
true
|
||||||
|
)
|
||||||
|
key=$(echo "$att" | head -2 | xargs)
|
||||||
|
sel=$(echo "$att" | tail -1)
|
||||||
|
attid=$(echo "$sel" | cut -f 1)
|
||||||
|
attname=$(echo "$sel" | cut -f 2)
|
||||||
|
attfmt=$(echo "$sel" | cut -f 3)
|
||||||
|
attenc=$(echo "$sel" | cut -f 4)
|
||||||
|
case "$key" in
|
||||||
|
"ctrl-c" | "ctrl-g" | "ctrl-q" | "ctrl-d" | "esc" | "q" | "backspace") ;;
|
||||||
|
"ctrl-alt-d")
|
||||||
|
__del_attachment "$attid" "$file"
|
||||||
|
;;
|
||||||
|
"ctrl-a")
|
||||||
|
__add_attachment "$file"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
__open_attachment "$attid" "$attname" "$attfmt" "$attenc" "$file"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
#
|
||||||
|
}
|
||||||
@@ -39,3 +39,31 @@ AWK_UPDATE=$(
|
|||||||
EOF
|
EOF
|
||||||
)
|
)
|
||||||
export AWK_UPDATE
|
export AWK_UPDATE
|
||||||
|
|
||||||
|
AWK_ATTACH=$(
|
||||||
|
cat <<'EOF'
|
||||||
|
@@include awk/attach.awk
|
||||||
|
EOF
|
||||||
|
)
|
||||||
|
export AWK_ATTACH
|
||||||
|
|
||||||
|
AWK_ATTACHDD=$(
|
||||||
|
cat <<'EOF'
|
||||||
|
@@include awk/attachdd.awk
|
||||||
|
EOF
|
||||||
|
)
|
||||||
|
export AWK_ATTACHDD
|
||||||
|
|
||||||
|
AWK_ATTACHLS=$(
|
||||||
|
cat <<'EOF'
|
||||||
|
@@include awk/attachls.awk
|
||||||
|
EOF
|
||||||
|
)
|
||||||
|
export AWK_ATTACHLS
|
||||||
|
|
||||||
|
AWK_ATTACHRM=$(
|
||||||
|
cat <<'EOF'
|
||||||
|
@@include awk/attachrm.awk
|
||||||
|
EOF
|
||||||
|
)
|
||||||
|
export AWK_ATTACHRM
|
||||||
|
|||||||
@@ -36,43 +36,43 @@ while [ -n "${1:-}" ]; do
|
|||||||
case "${1:-}" in
|
case "${1:-}" in
|
||||||
"--completed")
|
"--completed")
|
||||||
shift
|
shift
|
||||||
cliquery="${cliquery:-} ✅"
|
cliquery="${cliquery:-} $FLAG_COMPLETED"
|
||||||
;;
|
;;
|
||||||
"--no-completed")
|
"--no-completed")
|
||||||
shift
|
shift
|
||||||
cliquery="${cliquery:-} !✅"
|
cliquery="${cliquery:-} !$FLAG_COMPLETED"
|
||||||
;;
|
;;
|
||||||
"--open")
|
"--open")
|
||||||
shift
|
shift
|
||||||
cliquery="${cliquery:-} 🔲"
|
cliquery="${cliquery:-} $FLAG_OPEN"
|
||||||
;;
|
;;
|
||||||
"--no-open")
|
"--no-open")
|
||||||
shift
|
shift
|
||||||
cliquery="${cliquery:-} !🔲"
|
cliquery="${cliquery:-} !$FLAG_OPEN"
|
||||||
;;
|
;;
|
||||||
"--tasks")
|
"--tasks")
|
||||||
shift
|
shift
|
||||||
cliquery="${cliquery:-} ✅ | 🔲"
|
cliquery="${cliquery:-} $FLAG_OPEN | $FLAG_COMPLETED"
|
||||||
;;
|
;;
|
||||||
"--no-tasks")
|
"--no-tasks")
|
||||||
shift
|
shift
|
||||||
cliquery="${cliquery:-} !✅ !🔲"
|
cliquery="${cliquery:-} !$FLAG_COMPLETED !$FLAG_OPEN"
|
||||||
;;
|
;;
|
||||||
"--notes")
|
"--notes")
|
||||||
shift
|
shift
|
||||||
cliquery="${cliquery:-} 🗒️"
|
cliquery="${cliquery:-} $FLAG_NOTE"
|
||||||
;;
|
;;
|
||||||
"--no-notes")
|
"--no-notes")
|
||||||
shift
|
shift
|
||||||
cliquery="${cliquery:-} !🗒️"
|
cliquery="${cliquery:-} !$FLAG_NOTE"
|
||||||
;;
|
;;
|
||||||
"--journal")
|
"--journal")
|
||||||
shift
|
shift
|
||||||
cliquery="${cliquery:-} 📘"
|
cliquery="${cliquery:-} $FLAG_JOURNAL"
|
||||||
;;
|
;;
|
||||||
"--no-journal")
|
"--no-journal")
|
||||||
shift
|
shift
|
||||||
cliquery="${cliquery:-} !📘"
|
cliquery="${cliquery:-} !$FLAG_JOURNAL"
|
||||||
;;
|
;;
|
||||||
"--filter")
|
"--filter")
|
||||||
shift
|
shift
|
||||||
@@ -90,5 +90,5 @@ while [ -n "${1:-}" ]; do
|
|||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
query=${cliquery:-!✅}
|
query=${cliquery:-!$FLAG_COMPLETED}
|
||||||
export query
|
export query
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ if [ "${1:-}" = "--reload" ]; then
|
|||||||
shift
|
shift
|
||||||
fname="$1"
|
fname="$1"
|
||||||
shift
|
shift
|
||||||
__change_priority "$delta" "$fname" >>/tmp/foo
|
__change_priority "$delta" "$fname" >/dev/null
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
__lines
|
__lines
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
CONFIGFILE="$HOME/.config/fzf-vjour/config"
|
CONFIGFILE="${CONFIGFILE:-$HOME/.config/fzf-vjour/config}"
|
||||||
if [ ! -f "$CONFIGFILE" ]; then
|
if [ ! -f "$CONFIGFILE" ]; then
|
||||||
err "Configuration '$CONFIGFILE' not found."
|
err "Configuration '$CONFIGFILE' not found."
|
||||||
exit 1
|
exit 1
|
||||||
@@ -41,5 +41,7 @@ export CAT
|
|||||||
|
|
||||||
if command -v "git" >/dev/null && [ -d "$ROOT/.git" ]; then
|
if command -v "git" >/dev/null && [ -d "$ROOT/.git" ]; then
|
||||||
GIT="git -C $ROOT"
|
GIT="git -C $ROOT"
|
||||||
|
export GIT
|
||||||
fi
|
fi
|
||||||
export GIT
|
|
||||||
|
export OPEN=${OPEN:-open}
|
||||||
|
|||||||
@@ -25,12 +25,9 @@ __change_priority() {
|
|||||||
shift
|
shift
|
||||||
fname="$1"
|
fname="$1"
|
||||||
shift
|
shift
|
||||||
echo "call to __change_priority with delta=$delta and fname=$fname" >>/tmp/foo
|
|
||||||
file="$ROOT/$fname"
|
file="$ROOT/$fname"
|
||||||
tmpfile=$(mktemp)
|
tmpfile=$(mktemp)
|
||||||
echo " tmpfile=$tmpfile" >>/tmp/foo
|
|
||||||
awk -v delta="$delta" "$AWK_ALTERTODO" "$file" >"$tmpfile"
|
awk -v delta="$delta" "$AWK_ALTERTODO" "$file" >"$tmpfile"
|
||||||
echo " lines=$(wc -l tmpfile)" >>/tmp/foo
|
|
||||||
mv "$tmpfile" "$file"
|
mv "$tmpfile" "$file"
|
||||||
if [ -n "${GIT:-}" ]; then
|
if [ -n "${GIT:-}" ]; then
|
||||||
$GIT add "$file"
|
$GIT add "$file"
|
||||||
|
|||||||
21
src/sh/theme.sh
Normal file
21
src/sh/theme.sh
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
# Colors
|
||||||
|
GREEN="\033[1;32m"
|
||||||
|
RED="\033[1;31m"
|
||||||
|
WHITE="\033[1;97m"
|
||||||
|
CYAN="\033[1;36m"
|
||||||
|
FAINT="\033[2m"
|
||||||
|
|
||||||
|
# Flags
|
||||||
|
export FLAG_OPEN="${FLAG_OPEN:-🔲}"
|
||||||
|
export FLAG_COMPLETED="${FLAG_COMPLETED:-✅}"
|
||||||
|
export FLAG_JOURNAL="${FLAG_JOURNAL:-📘}"
|
||||||
|
export FLAG_NOTE="${FLAG_NOTE:-🗒️}"
|
||||||
|
export FLAG_PRIORITY="${FLAG_PRIORITY:-❗}"
|
||||||
|
export FLAG_ATTACHMENT="${FLAG_ATTACHMENT:-🔗}"
|
||||||
|
|
||||||
|
# Style
|
||||||
|
export STYLE_COLLECTION="${STYLE_COLLECTION:-$FAINT$WHITE}"
|
||||||
|
export STYLE_DATE="${STYLE_DATE:-$CYAN}"
|
||||||
|
export STYLE_SUMMARY="${STYLE_SUMMARY:-$GREEN}"
|
||||||
|
export STYLE_EXPIRED="${STYLE_EXPIRED:-$RED}"
|
||||||
|
export STYLE_CATEGORY="${STYLE_CATEGORY:-$WHITE}"
|
||||||
Reference in New Issue
Block a user