Advertisement
SergeySamoylov
Nov 15th, 2022
106
0
Never
This is comment for paste BASH Paste 2 files together
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/bash
  2.  
  3. # Hi, Kris! Thank you for your help. The whole script looks like this.
  4.  
  5. set -e
  6.  
  7. readonly TODO_DIRECTORY="${TODO_DIRECTORY:-"${HOME}/Documents/todo"}"
  8. readonly TODO_EDITOR="${EDITOR}"
  9.  
  10. readonly TODO_FILE="$(date +%Y-%m-%d).md"
  11. readonly TODO_PATH="${TODO_DIRECTORY}/${TODO_FILE}"
  12.  
  13.  
  14. if [ ! -d "${TODO_DIRECTORY}" ]; then
  15.    while true; do
  16.        printf "%s does not exist, do you want to create it? (y/n) " "${TODO_DIRECTORY}"
  17.        read -r yn
  18.  
  19.        case "${yn}" in
  20.            [Yy]* ) mkdir -p "${TODO_DIRECTORY}"; break;;
  21.            [Nn]* ) exit;;
  22.            * ) printf "Please answer y or n\n\n";;
  23.        esac
  24.    done
  25. fi
  26.  
  27. if [ ${#} -eq 0 ]; then
  28.    if [ -p "/dev/stdin" ]; then
  29.        (cat; printf "\n") >> "${TODO_PATH}"
  30.    else
  31.        cal -m > "/tmp/mycal"
  32.        LC_ALL=ru_RU.utf8 date +"ToDo: %d %B, %Y" > "/tmp/mytodo.lst"
  33.        echo "====================="  >> "/tmp/mytodo.lst"
  34.        cat "${TODO_DIRECTORY}/${TODO_FILE}"  >> "/tmp/mytodo.lst"
  35.        paste "/tmp/mycal" "/tmp/mytodo.lst"
  36.        # eval "${TODO_EDITOR}" "${TODO_PATH}"
  37.    fi
  38. else
  39.    printf "%s\n" "${*}" >> "${TODO_PATH}"
  40.    cal -m > "/tmp/mycal"
  41.    LC_ALL=ru_RU.utf8 date +"ToDo: %d %B, %Y" > "/tmp/mytodo.lst"
  42.    echo "=====================" >> "/tmp/mytodo.lst"
  43.    cat "${TODO_DIRECTORY}/${TODO_FILE}"   >> "/tmp/mytodo.lst"
  44.    paste "/tmp/mycal" "/tmp/mytodo.lst"
  45. fi
  46.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement