aboutsummaryrefslogtreecommitdiff
path: root/src/config/files/shell/30-functions.sh
diff options
context:
space:
mode:
authorAaditya Dhruv <[email protected]>2025-06-12 22:54:20 +0530
committerAaditya Dhruv <[email protected]>2025-06-12 22:54:20 +0530
commit92944006e728ade7338db81ef81c27716b247c81 (patch)
tree3c04bee89943d8adeb2ff66e2e5c2ea344698785 /src/config/files/shell/30-functions.sh
parent141bdfee6f9d6b8e36d3b78d4dcc1c05a414736b (diff)
Update shell configuration
Diffstat (limited to 'src/config/files/shell/30-functions.sh')
-rw-r--r--src/config/files/shell/30-functions.sh41
1 files changed, 41 insertions, 0 deletions
diff --git a/src/config/files/shell/30-functions.sh b/src/config/files/shell/30-functions.sh
new file mode 100644
index 0000000..e02e8de
--- /dev/null
+++ b/src/config/files/shell/30-functions.sh
@@ -0,0 +1,41 @@
+#!/bin/bash
+
+get_date() {
+ date +'%Y-%m-%d'
+}
+
+notebook() {
+ NEW=0
+ NOTEBOOK=$1
+ while getopts 'ln:' flag; do
+ case "${flag}" in
+ l) ls -1 ~/Notes
+ return 0
+ ;;
+ n) NEW=1
+ NOTEBOOK=${OPTARG}
+ ;;
+ *) echo "Invalid flag!" && return 1 ;;
+ esac
+ done
+ if [[ $NEW == 1 && -z "$NOTEBOOK" ]]; then
+ echo "No notebook name passed!"
+ return 1
+ fi
+ if [[ $NEW == 1 ]]; then
+ mkdir -p $HOME/Notes/$NOTEBOOK
+ fi
+ if [[ -z "$NOTEBOOK" ]]; then
+ pushd $HOME/Notes
+ vi $(find . -type f)
+ popd
+ elif [[ ! -z "$NOTEBOOK" ]]; then
+ if [[ ! -d "${HOME}/Notes/${NOTEBOOK}" ]]; then
+ echo "No notebook called "$NOTEBOOK"!"
+ else
+ pushd $HOME/Notes/$NOTEBOOK
+ vi $(find . -type f)
+ popd
+ fi
+ fi
+}