Last active
May 18, 2023 18:27
-
-
Save kwkr/e786b4821e56fb1879b0228338924880 to your computer and use it in GitHub Desktop.
40 lines bash script for TODO list
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if [ ! -d "$HOME/.td" ] | |
then | |
mkdir "$HOME/.td" | |
fi | |
if [ $1 = 'a' ] | |
then | |
to_add=${@: 2} | |
echo "Added: \"$to_add\"" | |
if [ -s ~/.td/todo.txt ] | |
then | |
echo "$to_add" >> ~/.td/todo.txt | |
else | |
echo "$to_add" > ~/.td/todo.txt | |
fi | |
fi | |
if [ $1 = 'l' ] | |
then | |
cat ~/.td/todo.txt 2> /dev/null | |
fi | |
if [ $1 = 'p' ] | |
then | |
finished=$(head -1 ~/.td/todo.txt) | |
todo=$(tail -n +2 ~/.td/todo.txt) | |
if [ -z "$todo" ] | |
then | |
echo -n "" > ~/.td/todo.txt | |
else | |
echo "$todo" > ~/.td/todo.txt | |
fi | |
echo "Done: \"$finished\"" | |
fi | |
if [ $1 = 'c' ] | |
then | |
head -1 ~/.td/todo.txt | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
can also use
case ... esac
(but it's now 31 lines)