1

I'm trying to add a title to my brief shell script for note taking, however I am unsure how to grab the string of text after calling the script. Currently I have:

note = note() {
    cd ~/Sync
    date >> notes.txt
    echo "----------------------------\n" >> notes.txt
    cat >> notes.txt
    echo "\n" >> notes.txt
}

Which works fine for adding a note with a datestamp, however I want to be able to type a short title after the word note and output it separately.

So, in my terminal (ZSH) I want to be able to do the following:

~ note This is the title
~ This is the body text
[ctrl-d]

To produce:

Fri 14 Feb 2020 13:34:51 GMT
----------------------------
This is the title
This is the body text
Phil Penny
  • 113
  • 1
  • 17
  • 1
    You could use `echo "$@" >> notes.txt` to grab the rest of the line after `note` and then cat would grab the rest. Is that what you're looking for? Further, I'd replace `cd ~/Sync` with `pushd ~/Sync > /dev/null` and then end the function with `popd > /dev/null` so that a user is still in their initial directory after executing. – Neil Feb 14 '20 at 14:16
  • Thanks, @Lepr that works fine, I will now research everything you suggested and learn more about them. – Phil Penny Feb 14 '20 at 14:24
  • Perhaps https://stackoverflow.com/q/33459219/3220113 helps. – Walter A Feb 14 '20 at 14:56

0 Answers0