From bd8919afb109efa0a92def766aca81f1e2e146fa Mon Sep 17 00:00:00 2001 From: Aaditya Dhruv Date: Sat, 14 Jun 2025 10:12:33 +0530 Subject: Update neovim, neomutt, and shell configurations --- src/config/files/shell/bashrc.d/30-functions.sh | 41 +++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 src/config/files/shell/bashrc.d/30-functions.sh (limited to 'src/config/files/shell/bashrc.d/30-functions.sh') diff --git a/src/config/files/shell/bashrc.d/30-functions.sh b/src/config/files/shell/bashrc.d/30-functions.sh new file mode 100644 index 0000000..e02e8de --- /dev/null +++ b/src/config/files/shell/bashrc.d/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 +} -- cgit