Initial commit
This commit is contained in:
commit
86d3fd0b35
27
README.md
Normal file
27
README.md
Normal file
@ -0,0 +1,27 @@
|
||||
# daily.sh
|
||||
|
||||
This is a simple bash script for quickly taking notes from the terminal.
|
||||
|
||||
## Requirements
|
||||
- Bash shell
|
||||
- vim
|
||||
|
||||
## Installation
|
||||
|
||||
1. Copy `daily.sh` to a directory that is in your `$PATH`.
|
||||
````
|
||||
$ cp daily.sh "$HOME/bin"
|
||||
````
|
||||
|
||||
2. Change the permissions on the script, so that it is executable.
|
||||
````
|
||||
$ chmod +x "$HOME/bin/daily.sh"
|
||||
````
|
||||
|
||||
## Usage
|
||||
|
||||
Just type `daily.sh`, and it will open up today's note for editing.
|
||||
|
||||
Notes are stored in `$HOME/.local/daily`.
|
||||
|
||||
A new note file is created for each day.
|
||||
33
daily.sh
Executable file
33
daily.sh
Executable file
@ -0,0 +1,33 @@
|
||||
#!/bin/env bash
|
||||
|
||||
# This is a simple bash script for quickly taking notes from the terminal.
|
||||
# Just type `daily` and it will open up today's note for editing.
|
||||
|
||||
# Grab the current date
|
||||
CUR_DAY=$(date +%Y-%m-%d)
|
||||
|
||||
# Get the current time
|
||||
CUR_TIME=$(date '+%H:%M %Z')
|
||||
|
||||
# Get the directory where notes are going to be stored
|
||||
NOTE_DIR=$(echo "$HOME/.local/daily")
|
||||
|
||||
# Ensure the note directory is created
|
||||
mkdir -p "$NOTE_DIR"
|
||||
|
||||
# Get the note file name
|
||||
NOTE_FILE="$NOTE_DIR/$CUR_DAY.md"
|
||||
|
||||
# Ensure that the note file for today is created
|
||||
touch "$NOTE_FILE"
|
||||
|
||||
# Check to see if the note is empty,
|
||||
# and if it is add a heading for today's date
|
||||
[ -s "$NOTE_FILE" ] || echo -e "# $CUR_DAY\n" >> "$NOTE_FILE"
|
||||
|
||||
# Add a new entry for the current time
|
||||
echo -e "\n## $CUR_TIME\n\n" >> "$NOTE_FILE"
|
||||
|
||||
# Open today's file for editing.
|
||||
# You do use vim for editing...right?
|
||||
vim "+normal G$" +startinsert "$NOTE_FILE"
|
||||
Loading…
Reference in New Issue
Block a user