memo 713 B

12345678910111213141516171819202122232425262728
  1. #!/usr/bin/env bash
  2. DMENU='dmenu -l 50 -p memo'
  3. [ -f "$HOME/.dmenurc" ] && . "$HOME/.dmenurc" && DMENU+="$DMENU_ARGS"
  4. SEL='xsel'
  5. DATE='date'
  6. FILE="$HOME/pipes/tasklist/dmemo"
  7. if [ -z "$1" ]; then
  8. pick="$($DMENU < $FILE)"
  9. if [ "$pick" ]; then
  10. IFS='>' read -ra entry <<< "$pick"
  11. len="${#entry[@]}"
  12. "$BROWSER" "${entry[$(( $len - 2 ))]}" && \
  13. sed -i "/${entry[$(( $len - 1 ))]}/d" "$FILE"
  14. fi
  15. else
  16. line="$($DATE)"
  17. if [ "$1" == '-s' ]; then
  18. line="$($SEL) > $line"
  19. memo="$($DMENU -p memo: <&-)"
  20. [ "$memo" ] && line="$memo > $line"
  21. else
  22. line="$1 > $line"
  23. [ "$2" ] && line="$2 > $line"
  24. fi
  25. echo "$line" >> "$FILE"
  26. fi