Added commands to lost available calendars and set default calendar
This commit is contained in:
parent
bd5cb66f51
commit
fb4413249b
64
t.sh
64
t.sh
|
@ -1198,11 +1198,10 @@ EOF
|
|||
vdirsyncer discover
|
||||
action "Running initial vdirsyncer sync..."
|
||||
vdirsyncer sync
|
||||
|
||||
cals=$(ls -1q $vdircaldir 2>/dev/null)
|
||||
count=$(echo "$cals" | wc -l | tr -d ' ')
|
||||
fi
|
||||
|
||||
getcals count cals_arr
|
||||
|
||||
makedir "$confdir" || return 1
|
||||
if [[ -e "${allcalsdir}" ]] ; then
|
||||
warn "Calendar symlink ${allcalsdir} already exists. Not overwriting it."
|
||||
|
@ -1211,13 +1210,9 @@ EOF
|
|||
action "Created symlink to $vdircaldir"
|
||||
fi
|
||||
if [[ ! -e "${defaultcalfile}" ]] ; then
|
||||
cals_arr=()
|
||||
selcal=""
|
||||
if [[ $count -gt 0 ]]; then
|
||||
local sel
|
||||
while read thiscal; do
|
||||
cals_arr+=("$thiscal")
|
||||
done <<< "$cals"
|
||||
|
||||
echo
|
||||
for d in ${!cals_arr[@]}; do
|
||||
|
@ -1289,6 +1284,20 @@ function tasksync() {
|
|||
fi
|
||||
}
|
||||
|
||||
function getcals() { # countvar arrayvar
|
||||
local loc_cals loc_count thiscal
|
||||
local countvar arrayvar
|
||||
countvar=$1
|
||||
arrayvar=$2
|
||||
loc_cals=$(ls -1q $vdircaldir 2>/dev/null)
|
||||
loc_count=$(echo "$loc_cals" | wc -l | tr -d ' ')
|
||||
eval "$countvar=$loc_count"
|
||||
eval "$arrayvar=()"
|
||||
while read thiscal; do
|
||||
eval "$arrayvar+=(\"$thiscal\")"
|
||||
done <<< "$loc_cals"
|
||||
}
|
||||
|
||||
# Should be in config file:
|
||||
#basedir=/Users/rpearce/scripts/t
|
||||
#dir=$basedir/docs
|
||||
|
@ -1381,6 +1390,8 @@ addcmd "tag" "tag <id> <tag>" "Add a tag to the given task" "tag|t"
|
|||
addcmd "untag" "untag <id> <tag>" "Remove a tag from the given task" "untag|ut"
|
||||
addcmd "sync" "sync" "Sync tasks using vdirsyncer" "sync"
|
||||
addcmd "view" "view <id>" "Show detailed info for given task" "v|view|info|vcal" PASSIVE
|
||||
addcmd "showcals" "showcals" "List available calendars" "cals|showcals|cls" PASSIVE
|
||||
addcmd "setcal" "setcal" "Set the default calendar." "setcal|sc"
|
||||
|
||||
DEBUG=0
|
||||
TESTMODE=0
|
||||
|
@ -1493,6 +1504,45 @@ if [[ $mode == "add" ]]; then
|
|||
else
|
||||
addtask -p $parentuid "$newtasksum"
|
||||
fi
|
||||
elif [[ $mode == "showcals" ]]; then
|
||||
getcals count cals_arr
|
||||
if [[ $count -gt 0 ]]; then
|
||||
echo -e "${BOLD}${MAGENTA}Available Calendars:$PLAIN"
|
||||
for d in ${!cals_arr[@]}; do
|
||||
echo -en "${MAGENTA}${BOLD}$((d + 1)). ${PLAIN}${MAGENTA}${cals_arr[$d]}${PLAIN}"
|
||||
[[ ${cals_arr[$d]} == $CALID ]] && echo -e "$BOLD$MAGENTA <- default$PLAIN" || echo
|
||||
done
|
||||
else
|
||||
error "No calendars found."
|
||||
fi
|
||||
elif [[ $mode == "setcal" ]]; then
|
||||
if [[ -z $1 ]]; then
|
||||
error "No calendar name provided."
|
||||
exit 1
|
||||
fi
|
||||
getcals count cals_arr
|
||||
if [[ $count -gt 0 ]]; then
|
||||
found=0
|
||||
for d in ${!cals_arr[@]}; do
|
||||
if [[ ${cals_arr[$d]} == $1 ]]; then
|
||||
# make this the default
|
||||
found=1
|
||||
break
|
||||
elif [[ $1 =~ ^[0-9]+$ && $d -eq $(($1 - 1)) ]]; then
|
||||
# make this the default
|
||||
found=1
|
||||
break
|
||||
fi
|
||||
done
|
||||
if [[ $found -eq 1 ]]; then
|
||||
action "Default calendar set to '${cals_arr[$d]}'"
|
||||
echo "${cals_arr[$d]}" > "$defaultcalfile"
|
||||
else
|
||||
error "Calendar '$1' not found"
|
||||
fi
|
||||
else
|
||||
error "No calendars found."
|
||||
fi
|
||||
elif [[ $mode == "rename" ]]; then
|
||||
uid=$(getuid_witherror $1)
|
||||
shift
|
||||
|
|
Loading…
Reference in New Issue