From df059008f49f9c1f4a3d2b65da9c000c258c299c Mon Sep 17 00:00:00 2001 From: pfych Date: Wed, 13 Aug 2025 08:33:46 +1000 Subject: [PATCH] Setup for todo.txt --- .config/nvim/lazy-lock.json | 1 + .config/nvim/lua/plugins/todo-txt.lua | 3 ++ .config/scripts/scripts.sh | 2 + .config/scripts/tool/scratch.sh | 54 +++++---------------------- 4 files changed, 16 insertions(+), 44 deletions(-) create mode 100644 .config/nvim/lua/plugins/todo-txt.lua diff --git a/.config/nvim/lazy-lock.json b/.config/nvim/lazy-lock.json index c256b47..52eb6ca 100644 --- a/.config/nvim/lazy-lock.json +++ b/.config/nvim/lazy-lock.json @@ -13,5 +13,6 @@ "nvim-web-devicons": { "branch": "master", "commit": "1fb58cca9aebbc4fd32b086cb413548ce132c127" }, "plenary.nvim": { "branch": "master", "commit": "857c5ac632080dba10aae49dba902ce3abf91b35" }, "telescope.nvim": { "branch": "master", "commit": "a0bbec21143c7bc5f8bb02e0005fa0b982edc026" }, + "todo.txt-vim": { "branch": "master", "commit": "3bb5f9cf0d6c7ee91b476a97054c336104d2b6f5" }, "which-key.nvim": { "branch": "main", "commit": "370ec46f710e058c9c1646273e6b225acf47cbed" } } diff --git a/.config/nvim/lua/plugins/todo-txt.lua b/.config/nvim/lua/plugins/todo-txt.lua new file mode 100644 index 0000000..e9c432b --- /dev/null +++ b/.config/nvim/lua/plugins/todo-txt.lua @@ -0,0 +1,3 @@ +return { + "freitass/todo.txt-vim" +} diff --git a/.config/scripts/scripts.sh b/.config/scripts/scripts.sh index 90eed74..47ddff0 100755 --- a/.config/scripts/scripts.sh +++ b/.config/scripts/scripts.sh @@ -12,6 +12,8 @@ source ~/.config/scripts/tool/git.sh source ~/.config/scripts/tool/kill.sh # Generate thumbnails for videos source ~/.config/scripts/tool/thumb.sh +# Scratch +source ~/.config/scripts/tool/scratch.sh # Text colour utility variables source ~/.config/scripts/util/colours.sh diff --git a/.config/scripts/tool/scratch.sh b/.config/scripts/tool/scratch.sh index fefcc2e..d24faf9 100755 --- a/.config/scripts/tool/scratch.sh +++ b/.config/scripts/tool/scratch.sh @@ -1,45 +1,11 @@ -function nscratch () { - requestedDate=$(date +"%y-%m-%d") - if [ ! -e ~/Documents/Scratchpad-now/$requestedDate-write.md ]; then - touch ~/Documents/Scratchpad-now/$requestedDate-write.md - echo "---" >> ~/Documents/Scratchpad-now/$requestedDate-write.md - echo "title: " >> ~/Documents/Scratchpad-now/$requestedDate-write.md - echo "---" >> ~/Documents/Scratchpad-now/$requestedDate-write.md - echo "" >> ~/Documents/Scratchpad-now/$requestedDate-write.md - echo "Today I " >> ~/Documents/Scratchpad-now/$requestedDate-write.md - fi - vim ~/Documents/Scratchpad-now/$requestedDate-write.md +function note () { + NOTE_LOCATION=~/todo.txt + INPUT=${1:-"TODAY"} + DATE=$(date --date="$INPUT" '+%a %d %b') + + TOTAL_LINES=$(wc -l $NOTE_LOCATION | cut -d' ' -f8) + DATE_LINE=$(grep -Fn "$DATE" $NOTE_LOCATION | cut -d':' -f1) + JUMP_TO=${DATE_LINE:-$TOTAL_LINES} + + vim $NOTE_LOCATION +$JUMP_TO } - -function codeScratch () { - cd ~/Developer/Scratch/ || exit - DATE=$(date +"%y-%m-%d") - if test ! -d "$(pwd)/$DATE"; then - mkdir "$(pwd)/$DATE"; - cd "$(pwd)/$DATE" || exit - - # Setup project - pnpm init - pnpm install @types/node ts-node-dev typescript prettier -D - if test ! $# -eq 0; then - # shellcheck disable=SC2086 - pnpm install $* - fi - - # Essential files - echo '{"compilerOptions": {"module": "commonjs","esModuleInterop": true,"target": "es6","moduleResolution": "node","sourceMap": true,"outDir": "dist"},"lib": ["es2015"]}' > tsconfig.json - echo 'module.exports={semi: true,singleQuote: true,tabWidth: 2,trailingComma: "all",arrowParens: "always",printWidth: 80};' > .prettierrc.js - echo 'console.log("hello world")' > scratch.ts - jq '.scripts = { start: "ts-node-dev --respawn scratch.ts" }' package.json > tmp.json - rm package.json - mv tmp.json package.json - else - cd "$(pwd)/$DATE" - fi - # Start editor session - # tmux new-session \; \ - # send-keys 'vim scratch.ts' C-m \; \ - # split-window -v \; \ - # send-keys 'yarn start' C-m \; -} -