added expect
This commit is contained in:
parent
cf19b724ea
commit
c7f5082671
84
src/main.sh
84
src/main.sh
@ -348,20 +348,22 @@ if [ "${1:-}" = "--day" ]; then
|
||||
--with-nth='{5}' \
|
||||
--accept-nth='1,2,3,4' \
|
||||
--preview="$0 --preview {}" \
|
||||
--bind="backspace:first+accept" \
|
||||
--expect="ctrl-n" \
|
||||
--bind="ctrl-s:execute($SYNC_CMD ; printf 'Press <enter> to continue.'; read -r tmp)"
|
||||
)
|
||||
hour=$(echo "$selection" | cut -d '|' -f 1)
|
||||
start=$(echo "$selection" | cut -d '|' -f 2)
|
||||
end=$(echo "$selection" | cut -d '|' -f 3)
|
||||
fpath=$(echo "$selection" | cut -d '|' -f 4 | sed "s/ /|/g")
|
||||
if [ -n "$fpath" ]; then
|
||||
fpath="$ROOT/$fpath"
|
||||
__edit "$start" "$end" "$fpath"
|
||||
elif [ -n "$hour" ]; then
|
||||
key=$(echo "$selection" | head -1)
|
||||
line=$(echo "$selection" | tail -1)
|
||||
hour=$(echo "$line" | cut -d '|' -f 1)
|
||||
start=$(echo "$line" | cut -d '|' -f 2)
|
||||
end=$(echo "$line" | cut -d '|' -f 3)
|
||||
fpath=$(echo "$line" | cut -d '|' -f 4 | sed "s/ /|/g")
|
||||
if [ "$key" = "ctrl-n" ]; then
|
||||
# TODO: Go on add entry for hour
|
||||
echo "Add entry for hour $hour"
|
||||
fi # Else: continue
|
||||
elif [ -n "$fpath" ]; then
|
||||
fpath="$ROOT/$fpath"
|
||||
__edit "$start" "$end" "$fpath"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "${1:-}" = "--date" ]; then
|
||||
@ -375,37 +377,47 @@ DISPLAY_DATE_NEXT=$(date -d "$DISPLAY_DATE +1 week" +"%D")
|
||||
DISPLAY_DATE_PREV_MONTH=$(date -d "$DISPLAY_DATE -1 month" +"%D")
|
||||
DISPLAY_DATE_NEXT_MONTH=$(date -d "$DISPLAY_DATE +1 month" +"%D")
|
||||
|
||||
selection=$( (
|
||||
cat "$APPROX_DATA_FILE"
|
||||
yes " " | head -n 50
|
||||
__list
|
||||
) |
|
||||
$FZF \
|
||||
--tac \
|
||||
--no-sort \
|
||||
--no-hscroll \
|
||||
--ellipsis='' \
|
||||
--delimiter='|' \
|
||||
--with-nth='{4}' \
|
||||
--accept-nth=1,2 \
|
||||
--no-info \
|
||||
--ansi \
|
||||
--no-clear \
|
||||
--no-scrollbar \
|
||||
--bind="load:pos($DISPLAY_POS)" \
|
||||
--bind="ctrl-u:become($0 --date '$DISPLAY_DATE_PREV')" \
|
||||
--bind="ctrl-d:become($0 --date '$DISPLAY_DATE_NEXT')" \
|
||||
--bind="ctrl-alt-u:become($0 --date '$DISPLAY_DATE_PREV_MONTH')" \
|
||||
--bind="ctrl-alt-d:become($0 --date '$DISPLAY_DATE_NEXT_MONTH')" \
|
||||
--bind="ctrl-l:become($0)")
|
||||
selection=$(
|
||||
(
|
||||
cat "$APPROX_DATA_FILE"
|
||||
yes " " | head -n 50
|
||||
__list
|
||||
) |
|
||||
$FZF \
|
||||
--tac \
|
||||
--no-sort \
|
||||
--no-hscroll \
|
||||
--ellipsis='' \
|
||||
--delimiter='|' \
|
||||
--with-nth='{4}' \
|
||||
--accept-nth=1,2 \
|
||||
--no-info \
|
||||
--ansi \
|
||||
--no-clear \
|
||||
--no-scrollbar \
|
||||
--expect="ctrl-n" \
|
||||
--bind="load:pos($DISPLAY_POS)" \
|
||||
--bind="ctrl-u:become($0 --date '$DISPLAY_DATE_PREV')" \
|
||||
--bind="ctrl-d:become($0 --date '$DISPLAY_DATE_NEXT')" \
|
||||
--bind="ctrl-alt-u:become($0 --date '$DISPLAY_DATE_PREV_MONTH')" \
|
||||
--bind="ctrl-alt-d:become($0 --date '$DISPLAY_DATE_NEXT_MONTH')" \
|
||||
--bind="ctrl-l:become($0)"
|
||||
)
|
||||
|
||||
if [ -z "$selection" ]; then
|
||||
key=$(echo "$selection" | head -1)
|
||||
line=$(echo "$selection" | tail -1)
|
||||
sign=$(echo "$line" | cut -d '|' -f 1)
|
||||
startdate=$(echo "$line" | cut -d '|' -f 2)
|
||||
if [ "$key" = "ctrl-n" ]; then
|
||||
# Add new
|
||||
echo "NOT IMPLEMENTED: Add wrt $line"
|
||||
exit
|
||||
fi
|
||||
if [ -z "$key" ] && [ -z "$line" ]; then
|
||||
rm "$WEEKLY_DATA_FILE" "$APPROX_DATA_FILE"
|
||||
return 0
|
||||
fi
|
||||
|
||||
sign=$(echo "$selection" | cut -d '|' -f 1)
|
||||
startdate=$(echo "$selection" | cut -d '|' -f 2)
|
||||
if [ "$sign" = "~" ]; then
|
||||
exec $0 --date "$startdate"
|
||||
else
|
||||
|
Loading…
Reference in New Issue
Block a user