feat(tasks): list projects

This commit is contained in:
Ayo Ayco 2025-06-24 01:00:30 +02:00
parent ac39900126
commit 7c69f5bf89

View file

@ -12,6 +12,27 @@ command=$1
getopts "t" typora; #check if -t flag is given getopts "t" typora; #check if -t flag is given
function listTasks() {
files=( $tasks_dir/*.md )
index=0
echo "ACTIVE TASKS: "
for file in "${files[@]##*/}"; do
((index++))
echo "$index) $file"
done
}
function listProjects() {
cd "$tasks_dir"
dirs=( */ )
index=0
echo "PROJECTS: "
for dir in "${dirs[@]}"; do
((index++))
echo "${index}) ${dir}"
done
}
function editFile() { function editFile() {
notesSync notesSync
@ -58,14 +79,9 @@ function createtask() {
## LIST tasks in directory ## LIST tasks in directory
if [ "$1" = "list" ] || [ "$1" = "l" ]; then if [ "$1" = "list" ] || [ "$1" = "l" ]; then
echo "ACTIVE TASKS: "
notesSync notesSync
files=( $tasks_dir/*.md ) listTasks
index=0 listProjects
for file in "${files[@]##*/}"; do
((index++))
echo "$index) $file"
done
## OPEN a task from a list ## OPEN a task from a list
elif [ "$1" = "open" ] || [ "$1" = "o" ]; then elif [ "$1" = "open" ] || [ "$1" = "o" ]; then
@ -173,18 +189,51 @@ elif [ "$1" = "copy" ] || [ "$1" = "c" ]; then
done done
fi fi
## CREATE PROJECT ## Move a task to a project
elif [ "$1" = "move" ] || [ "$1" = "m" ]; then
notesSync
files=( $tasks_dir/*.md )
if ! [ "$2" = "" ]; then
index=($2-1)
move_file=${files[$index]}
editFile "$move_file"
else
PS3="Move file #: "
echo "Please select a file to MOVE."
select file in "${files[@]##*/}"; do
{
echo "Moving $file"
PS3="Select Project: "
echo "Select a project"
cd $tasks_dir
dirs=( */ )
# Select a project to move the item to
select directory in "${dirs[@]}"; do
{
mv "${tasks_dir}/${file}" "${tasks_dir}/${directory}"
break
} || {
echo "bad choice"
break
}
done
break
} ||
{
echo "bad choice"
break
}
done
fi
## CREATE a project
elif [ "$1" = "project" ] || [ "$1" = "j" ]; then elif [ "$1" = "project" ] || [ "$1" = "j" ]; then
read -p "Create new project: " project read -p "Create new project: " project
mkdir "$tasks_dir/$project" mkdir "$tasks_dir/$project"
## CREATE a task (default) ## CREATE a task (default)
else else
index=0
for dir in "$(cd $tasks_dir && ls -d -- */)"; do
((index++))
echo "$index) $dir"
done
createtask createtask
fi fi