Introduction
Introduction Statistics Contact Development Disclaimer Help
todo - sites - public wiki contents of suckless.org
git clone git://git.suckless.org/sites
Log
Files
Refs
---
todo (592B)
---
1 #!/bin/sh
2 #
3 # Write/remove a task to do later.
4 #
5 # Select an existing entry to remove it from the file, or type a new ent…
6 # add it.
7 #
8
9 file="$HOME/.todo"
10 touch "$file"
11 height=$(wc -l "$file" | awk '{print $1}')
12 prompt="Add/delete a task: "
13
14 cmd=$(dmenu -l "$height" -p "$prompt" "$@" < "$file")
15 while [ -n "$cmd" ]; do
16 if grep -q "^$cmd\$" "$file"; then
17 grep -v "^$cmd\$" "$file" > "$file.$$"
18 mv "$file.$$" "$file"
19 height=$(( height - 1 ))
20 else
21 echo "$cmd" >> "$file"
22 height=$(( height + 1 ))
23 fi
24
25 cmd=$(dmenu -l "$height" -p "$prompt" "$@" < "$file")
26 done
27
28 exit 0
You are viewing proxied material from suckless.org. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.