commit cbf844cf874453e1e1f4cb3d27aa3adfa22667b9 Author: ronny abraham Date: Mon May 12 23:24:36 2025 +0300 initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..11d6db4 --- /dev/null +++ b/.gitignore @@ -0,0 +1,103 @@ +# Created by https://www.toptal.com/developers/gitignore/api/vim,emacs,osx +# Edit at https://www.toptal.com/developers/gitignore?templates=vim,emacs,osx + +### Emacs ### +# -*- mode: gitignore; -*- +*~ +\#*\# +/.emacs.desktop +/.emacs.desktop.lock +*.elc +auto-save-list +tramp +.\#* + +# Org-mode +.org-id-locations +*_archive + +# flymake-mode +*_flymake.* + +# eshell files +/eshell/history +/eshell/lastdir + +# elpa packages +/elpa/ + +# reftex files +*.rel + +# AUCTeX auto folder +/auto/ + +# cask packages +.cask/ +dist/ + +# Flycheck +flycheck_*.el + +# server auth directory +/server/ + +# projectiles files +.projectile + +# directory configuration +.dir-locals.el + +# network security +/network-security.data + + +### OSX ### +# General +.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + +### Vim ### +# Swap +[._]*.s[a-v][a-z] +!*.svg # comment out if you don't need vector files +[._]*.sw[a-p] +[._]s[a-rt-v][a-z] +[._]ss[a-gi-z] +[._]sw[a-p] + +# Session +Session.vim +Sessionx.vim + +# Temporary +.netrwhist +# Auto-generated tag files +tags +# Persistent undo +[._]*.un~ + +# End of https://www.toptal.com/developers/gitignore/api/vim,emacs,osx diff --git a/bin/install.sh b/bin/install.sh new file mode 100755 index 0000000..0a48fc9 --- /dev/null +++ b/bin/install.sh @@ -0,0 +1,68 @@ +#!/bin/bash +set -euo pipefail + +DEBUG=false + +# --- Resolve project root directory (always works regardless of where script is run from) --- +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +ROOT_SRC="$(cd "$SCRIPT_DIR/.." && pwd)" + +PREFIX="${PREFIX:-/usr/local}" + +INSTALL_DIR="$PREFIX/bin" + +TARGET_NAME="export-notes" +SCRIPT_NAME="$TARGET_NAME.sh" +SCRIPT_PATH="$ROOT_SRC/$SCRIPT_NAME" + +# Optional --prefix CLI override +while [[ $# -gt 0 ]]; do + case "$1" in + --debug) + DEBUG=true + shift + ;; + --prefix) + PREFIX="$2" + INSTALL_DIR="$PREFIX/bin" + shift 2 + ;; + --help|-h) + echo "Usage: $0 [--prefix /desired/install/path]" >&2 + exit 0 + ;; + *) + echo "Unknown option: $1" + echo "Usage: $0 [--prefix /desired/install/path]" >&2 + exit 1 + ;; + esac +done + +if [[ "$DEBUG" == true ]]; then + echo "🪵 Debug mode enabled" + echo "PREFIX: $PREFIX" + echo + echo "SCRIPT_DIR: $SCRIPT_DIR" + echo "ROOT_SRC: $ROOT_SRC" + echo + echo "INSTALL_DIR: $INSTALL_DIR" + echo "TARGET_NAME: $TARGET_NAME" + echo "SCRIPT_NAME: $SCRIPT_NAME" + echo "SCRIPT_PATH: $SCRIPT_PATH" +fi + +# Check script exists +if [[ ! -f "$SCRIPT_PATH" ]]; then + echo "❌ Error: Expected to find $SCRIPT_NAME at: $SCRIPT_PATH" >&2 + exit 1 +fi + +# Copy to install location +echo "📦 Installing $SCRIPT_NAME to $INSTALL_DIR/$TARGET_NAME ..." +sudo install -m 755 "$SCRIPT_PATH" "$INSTALL_DIR/$TARGET_NAME" + +echo "Installed successfully." +echo "Run it with: $TARGET_NAME" +echo "Add to your PATH if not already:" +echo " export PATH=\"$INSTALL_DIR:\$PATH\"" diff --git a/bin/uninstall.sh b/bin/uninstall.sh new file mode 100755 index 0000000..f1dcc0e --- /dev/null +++ b/bin/uninstall.sh @@ -0,0 +1,49 @@ +#!/bin/bash +set -euo pipefail + +DEBUG=false + +ROOT_SRC=".." +TARGET_NAME="export-notes" + +PREFIX="${PREFIX:-/usr/local}" +INSTALL_PATH="$PREFIX/bin/$TARGET_NAME" + +while [[ $# -gt 0 ]]; do + case "$1" in + --debug) + DEBUG=true + shift + ;; + --prefix) + PREFIX="$2" + INSTALL_PATH="$PREFIX/bin/$TARGET_NAME" + shift 2 + ;; + --help|-h) + echo "Usage: $0 [--prefix /custom/bin/path]" >&2 + exit 0 + ;; + *) + echo "Unknown option $1" >&2 + exit 1 + ;; + esac +done + +if [[ "$DEBUG" == true ]]; then + echo "ROOT_SRC=$ROOT_SRC" + echo "TARGET_NAME=$TARGET_NAME" + echo "PREFIX=$PREFIX" + echo "INSTALL_PATH=$INSTALL_PATH" +fi + +# check and remove +if [[ ! -f "$INSTALL_PATH" ]]; then + echo "❌ $INSTALL_PATH not found. Nothing to uninstall." + exit 1 +fi + +echo "🗑️ Removing $INSTALL_PATH ..." +sudo rm "$INSTALL_PATH" +echo "✅ Uninstalled successfully." diff --git a/export-notes.sh b/export-notes.sh new file mode 100755 index 0000000..d8becac --- /dev/null +++ b/export-notes.sh @@ -0,0 +1,202 @@ +#!/bin/bash + +# ---------------------------- +# Configurable Section +# ---------------------------- +# +# +# ---------------------------- +# Default Values +# ---------------------------- + +SOURCE_BASE="$HOME" +NOTES_ROOT="notes/courses" +SECTION_DIR="" +SHARE_REL="" +DEBUG=0 + +# ---------------------------- +# Help Message +# ---------------------------- + +print_help() { + cat <