# To-Do List
export TODO="${HOME}/Documentos/todo.txt"
# Ensure the todo file exists
touch "$TODO"
# Function to add or list tasks
tla() {
if [ $# -eq 0 ]; then
# List tasks with line numbers
nl -w 1 -s '. ' "$TODO"
else
# Add the task to the list
echo "→ $*" >> "$TODO"
echo "Task added."
fi
}
# Function to remove tasks
tlr() {
if [ $# -eq 0 ]; then
echo "Select a task to delete (enter number) or press ENTER to delete all tasks:"
nl -w 1 -s '. ' "$TODO"
read -p "Number: " choice
if [ -z "$choice" ]; then
read -p "Are you sure you want to delete all tasks? [y/N] " confirm
if [[ $confirm =~ ^[Yy]$ ]]; then
> "$TODO"
echo "All tasks deleted."
fi
else
sed -i "${choice}d" "$TODO"
echo "Task $choice deleted."
fi
else
echo "Removing tasks matching: $*"
sed -i "/$*/d" "$TODO"
echo "Matching tasks removed."
fi
}
# Function to search for a word in tasks
tls() {
if [ $# -eq 0 ]; then
echo "Please provide a word to search for."
return 1
fi
echo "Searching for '$*' in tasks:"
grep -i --color=always "$*" "$TODO"
}
Nenhum comentário:
Postar um comentário