Compare commits
1 Commits
7ed2df2399
...
fffd1bca7c
Author | SHA1 | Date | |
---|---|---|---|
fffd1bca7c |
@@ -119,10 +119,6 @@ Also, you may set `LC_TIME` to your preferred language, and `TZ` to your
|
|||||||
preferred timezone. The latter is in particular helpful if you want to take a
|
preferred timezone. The latter is in particular helpful if you want to take a
|
||||||
look at your calendar relative to being in another timezone.
|
look at your calendar relative to being in another timezone.
|
||||||
|
|
||||||
Git support
|
|
||||||
-----------
|
|
||||||
You can track your events with `git` by simply running `fzf-vcal --git-init`.
|
|
||||||
|
|
||||||
License
|
License
|
||||||
-------
|
-------
|
||||||
This project is licensed under the [MIT License](./LICENSE).
|
This project is licensed under the [MIT License](./LICENSE).
|
||||||
|
77
src/main.sh
77
src/main.sh
@@ -17,8 +17,6 @@ if [ "${1:-}" = "--help" ]; then
|
|||||||
echo " --day [date] Show appointments of specified day (today)"
|
echo " --day [date] Show appointments of specified day (today)"
|
||||||
echo " --week [date] Show week of specified date (today)"
|
echo " --week [date] Show week of specified date (today)"
|
||||||
echo " --import file Import iCalendar file"
|
echo " --import file Import iCalendar file"
|
||||||
echo " --git cmd Run git command cmd relative to calendar root"
|
|
||||||
echo " --git-init Enable the use of git"
|
|
||||||
echo ""
|
echo ""
|
||||||
echo "You may also start this program with setting locale and timezone"
|
echo "You may also start this program with setting locale and timezone"
|
||||||
echo "information. For instance, to see and modify all of your calendar"
|
echo "information. For instance, to see and modify all of your calendar"
|
||||||
@@ -412,7 +410,6 @@ fi
|
|||||||
### FZF: Fuzzy finder `fzf``
|
### FZF: Fuzzy finder `fzf``
|
||||||
### UUIDGEN: Tool `uuidgen` to generate random uids
|
### UUIDGEN: Tool `uuidgen` to generate random uids
|
||||||
### CAT: `bat` or `batcat` or `cat`
|
### CAT: `bat` or `batcat` or `cat`
|
||||||
### GIT: `git` if it exists
|
|
||||||
###
|
###
|
||||||
### The presence of POSIX tools is not checked.
|
### The presence of POSIX tools is not checked.
|
||||||
###
|
###
|
||||||
@@ -439,10 +436,6 @@ fi
|
|||||||
CAT=${CAT:+$CAT --color=always --style=numbers --language=md}
|
CAT=${CAT:+$CAT --color=always --style=numbers --language=md}
|
||||||
CAT=${CAT:-cat}
|
CAT=${CAT:-cat}
|
||||||
|
|
||||||
if command -v "git" >/dev/null && [ -d "$ROOT/.git" ]; then
|
|
||||||
GIT="git -C $ROOT"
|
|
||||||
fi
|
|
||||||
|
|
||||||
###
|
###
|
||||||
### AWK scripts
|
### AWK scripts
|
||||||
### AWK_APPROX: Generate approximate data of all files
|
### AWK_APPROX: Generate approximate data of all files
|
||||||
@@ -602,6 +595,7 @@ __datetime_human_machine() {
|
|||||||
### __edit
|
### __edit
|
||||||
### __new
|
### __new
|
||||||
### __delete
|
### __delete
|
||||||
|
### __import
|
||||||
|
|
||||||
# __edit()
|
# __edit()
|
||||||
# Edit iCalendar file.
|
# Edit iCalendar file.
|
||||||
@@ -640,10 +634,6 @@ __edit() {
|
|||||||
filenew="$filetmp.ics"
|
filenew="$filetmp.ics"
|
||||||
if awk "$AWK_UPDATE" "$filetmp" "$fpath" >"$filenew"; then
|
if awk "$AWK_UPDATE" "$filetmp" "$fpath" >"$filenew"; then
|
||||||
mv "$filenew" "$fpath"
|
mv "$filenew" "$fpath"
|
||||||
if [ -n "${GIT:-}" ]; then
|
|
||||||
$GIT add "$fpath"
|
|
||||||
$GIT commit -m "Modified event" -- "$fpath"
|
|
||||||
fi
|
|
||||||
__refresh_data
|
__refresh_data
|
||||||
else
|
else
|
||||||
rm -f "$filenew"
|
rm -f "$filenew"
|
||||||
@@ -706,10 +696,6 @@ __new() {
|
|||||||
filenew="$filetmp.ics"
|
filenew="$filetmp.ics"
|
||||||
if awk -v uid="$uuid" "$AWK_NEW" "$filetmp" >"$filenew"; then
|
if awk -v uid="$uuid" "$AWK_NEW" "$filetmp" >"$filenew"; then
|
||||||
mv "$filenew" "$fpath"
|
mv "$filenew" "$fpath"
|
||||||
if [ -n "${GIT:-}" ]; then
|
|
||||||
$GIT add "$fpath"
|
|
||||||
$GIT commit -m "Added event" -- "$fpath"
|
|
||||||
fi
|
|
||||||
start=$(awk -v field="DTSTART" "$AWK_GET" "$fpath" | grep -o '[0-9]\{8\}')
|
start=$(awk -v field="DTSTART" "$AWK_GET" "$fpath" | grep -o '[0-9]\{8\}')
|
||||||
else
|
else
|
||||||
rm -f "$filenew"
|
rm -f "$filenew"
|
||||||
@@ -736,10 +722,6 @@ __delete() {
|
|||||||
case $yn in
|
case $yn in
|
||||||
"yes")
|
"yes")
|
||||||
rm -v "$fpath"
|
rm -v "$fpath"
|
||||||
if [ -n "${GIT:-}" ]; then
|
|
||||||
$GIT add "$fpath"
|
|
||||||
$GIT commit -m "Deleted event" -- "$fpath"
|
|
||||||
fi
|
|
||||||
break
|
break
|
||||||
;;
|
;;
|
||||||
"no")
|
"no")
|
||||||
@@ -752,24 +734,10 @@ __delete() {
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
###
|
|
||||||
### Extra command-line options
|
|
||||||
### --import
|
|
||||||
### --git
|
|
||||||
### --git-init
|
|
||||||
###
|
|
||||||
|
|
||||||
# --import
|
# --import
|
||||||
# Import iCalendar file.
|
# Import iCalendar file.
|
||||||
#
|
#
|
||||||
# @input $2: Absolute path to iCalendar file
|
# @input $2: Absolute path to iCalendar file
|
||||||
# @req $COLLECTION_LABELS: Mapping between collections and lables (see configuration)
|
|
||||||
# @req $AWK_PARSE: Parse awk script
|
|
||||||
# @req $AWK_GET: Awk script to extract fields from iCalendar file
|
|
||||||
# @req $ROOT: Path that contains the collections (see configuration)
|
|
||||||
# @req $UUIDGEN: `uuidgen` command
|
|
||||||
# @req $FZF: `fzf` command
|
|
||||||
# @req $CAT: Program to print
|
|
||||||
# @return: On success, returns 0, otherwise 1
|
# @return: On success, returns 0, otherwise 1
|
||||||
if [ "${1:-}" = "--import" ]; then
|
if [ "${1:-}" = "--import" ]; then
|
||||||
shift
|
shift
|
||||||
@@ -822,10 +790,6 @@ if [ "${1:-}" = "--import" ]; then
|
|||||||
fpath="$ROOT/$collection/$uuid.ics"
|
fpath="$ROOT/$collection/$uuid.ics"
|
||||||
done
|
done
|
||||||
cp -v "$file" "$fpath"
|
cp -v "$file" "$fpath"
|
||||||
if [ -n "${GIT:-}" ]; then
|
|
||||||
$GIT add "$fpath"
|
|
||||||
$GIT commit -m "Imported event" -- "$fpath"
|
|
||||||
fi
|
|
||||||
break
|
break
|
||||||
;;
|
;;
|
||||||
"no")
|
"no")
|
||||||
@@ -840,41 +804,6 @@ if [ "${1:-}" = "--import" ]; then
|
|||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# --git
|
|
||||||
# Run git command
|
|
||||||
#
|
|
||||||
# @input $2..: Git command
|
|
||||||
# @req $GIT: git command with `-C` flag set
|
|
||||||
# @return: On success, returns 0, otherwise 1
|
|
||||||
if [ "${1:-}" = "--git" ]; then
|
|
||||||
if [ -z "${GIT:-}" ]; then
|
|
||||||
err "Git not supported, run \`$0 --git-init\` first"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
shift
|
|
||||||
$GIT "$@"
|
|
||||||
exit
|
|
||||||
fi
|
|
||||||
#
|
|
||||||
# --git-init
|
|
||||||
# Enable the ues of git
|
|
||||||
#
|
|
||||||
# @return: On success, returns 0, otherwise 1
|
|
||||||
if [ "${1:-}" = "--git-init" ]; then
|
|
||||||
if [ -n "${GIT:-}" ]; then
|
|
||||||
err "Git already enabled"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
if ! command -v "git" >/dev/null; then
|
|
||||||
err "Git command not found"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
git -C "$ROOT" init
|
|
||||||
git -C "$ROOT" add -A
|
|
||||||
git -C "$ROOT" commit -m 'Initial commit: Start git tracking'
|
|
||||||
exit
|
|
||||||
fi
|
|
||||||
|
|
||||||
### Start
|
### Start
|
||||||
__refresh_data
|
__refresh_data
|
||||||
|
|
||||||
@@ -1068,8 +997,8 @@ while true; do
|
|||||||
echo up" \
|
echo up" \
|
||||||
--bind="change:unbind(load)+reload($0 --reload-all)+hide-preview" \
|
--bind="change:unbind(load)+reload($0 --reload-all)+hide-preview" \
|
||||||
--bind="load:pos($DISPLAY_POS)" \
|
--bind="load:pos($DISPLAY_POS)" \
|
||||||
--bind="ctrl-h:unbind(load)+reload:$0 --reload-week {2} '-1 week'" \
|
--bind="ctrl-l:unbind(load)+reload:$0 --reload-week {2} '-1 week'" \
|
||||||
--bind="ctrl-l:unbind(load)+reload:$0 --reload-week {2} '+1 week'" \
|
--bind="ctrl-h:unbind(load)+reload:$0 --reload-week {2} '+1 week'" \
|
||||||
--bind="ctrl-u:unbind(load)+reload:$0 --reload-week {2} '-1 week'" \
|
--bind="ctrl-u:unbind(load)+reload:$0 --reload-week {2} '-1 week'" \
|
||||||
--bind="ctrl-d:unbind(load)+reload:$0 --reload-week {2} '+1 week'" \
|
--bind="ctrl-d:unbind(load)+reload:$0 --reload-week {2} '+1 week'" \
|
||||||
--bind="ctrl-alt-u:unbind(load)+reload:$0 --reload-week {2} '-1 month'" \
|
--bind="ctrl-alt-u:unbind(load)+reload:$0 --reload-week {2} '-1 month'" \
|
||||||
|
Reference in New Issue
Block a user