Add "last" command
This commit is contained in:
parent
62dabe79c1
commit
ce4bee4a82
2 changed files with 23 additions and 0 deletions
16
histd.sh
16
histd.sh
|
@ -46,6 +46,19 @@ function list {
|
|||
tree $BASE_DIR
|
||||
}
|
||||
|
||||
function last {
|
||||
# Check editor
|
||||
if [[ $EDITOR == "" ]]; then
|
||||
echo EDITOR is undefined
|
||||
return
|
||||
fi
|
||||
|
||||
LAST_FILE=$(ls -t $BASE_DIR/**/**/* | head -1)
|
||||
cd $BASE_DIR
|
||||
$EDITOR $LAST_FILE
|
||||
cd - > /dev/null
|
||||
}
|
||||
|
||||
function help {
|
||||
echo "Histd - How I Spent This Day"
|
||||
echo "A simple personal diary app"
|
||||
|
@ -55,6 +68,7 @@ function help {
|
|||
echo "- histd.sh backup - create an archive of all notes"
|
||||
echo "- histd.sh merge - print all notes"
|
||||
echo "- histd.sh list - list all notes"
|
||||
echo "- histd.sh last - open last note"
|
||||
echo "- histd.sh help - show this message"
|
||||
}
|
||||
|
||||
|
@ -71,6 +85,8 @@ elif [[ $1 == "merge" ]]; then
|
|||
merge
|
||||
elif [[ $1 == "list" ]]; then
|
||||
list
|
||||
elif [[ $1 == "last" ]]; then
|
||||
last
|
||||
elif [[ $1 == "help" ]]; then
|
||||
help
|
||||
else
|
||||
|
|
|
@ -39,6 +39,13 @@ Now you can create your first note:
|
|||
./histd.sh
|
||||
```
|
||||
|
||||
This command can be run as many times as you want, it will open the same file until the day is over.
|
||||
|
||||
You can open the last note with the command:
|
||||
```bash
|
||||
./histd.sh last
|
||||
```
|
||||
|
||||
## Backup
|
||||
To create an archive of all notes, run the following command:
|
||||
```bash
|
||||
|
|
Loading…
Reference in a new issue