From 44f00b4169d625ae75f1887b8674d5d53598a463 Mon Sep 17 00:00:00 2001 From: Crony Akatsuki Date: Fri, 29 Mar 2024 12:47:04 +0100 Subject: [PATCH] Update blog script, add new note script. --- home-manager/modules/comet-gog.nix | 13 ++++++++++ home-manager/modules/scripts/blog | 19 +++++++-------- home-manager/modules/scripts/note | 39 ++++++++++++++++++++++++++++++ 3 files changed, 61 insertions(+), 10 deletions(-) create mode 100644 home-manager/modules/comet-gog.nix create mode 100755 home-manager/modules/scripts/note diff --git a/home-manager/modules/comet-gog.nix b/home-manager/modules/comet-gog.nix new file mode 100644 index 0000000..01a9c5d --- /dev/null +++ b/home-manager/modules/comet-gog.nix @@ -0,0 +1,13 @@ +{ pkgs, ... }: +with pkgs; +rustPlatform.buildRustProgram rec { + pname = "comet-gog"; + version = "e313c8a"; + src = fetchFromGitHub { + owner = "imLinguin"; + repo = "comet"; + rev = "e313c8ae052dfd9a6b06c8246f83f5f34672bcaa"; + hash = "sha256-p4fDm2XdqAOBZTNuw8S29vj5U21t4eeHjtKiK6tN0AM="; + }; + cargoLock.lockFile = ./Cargo.lock; +} diff --git a/home-manager/modules/scripts/blog b/home-manager/modules/scripts/blog index 9ebf912..acfd71b 100755 --- a/home-manager/modules/scripts/blog +++ b/home-manager/modules/scripts/blog @@ -10,11 +10,11 @@ fi open_file() { cd "$HOME"/Documents/repos/cronyakatsuki.xyz || exit 1 - if [ -f "content/blog/${1}" ]; then - nvim "content/blog/${1}" + if [ -f "content/blog/${1}.md" ]; then + nvim "content/blog/${1}.md" else - hugo new "content/blog/${1}" - nvim "content/blog/${1}" + hugo new "content/blog/${1}.md" + nvim "content/blog/${1}.md" fi } @@ -29,8 +29,8 @@ publish() { remove_file() { cd "$HOME"/Documents/repos/cronyakatsuki.xyz || exit 1 - if [ -f "content/blog/${1}" ]; then - rm "content/blog/${1}" + if [ -f "content/blog/${1}.md" ]; then + rm "content/blog/${1}.md" else echo "File didn't exist" fi @@ -39,16 +39,15 @@ remove_file() { if [ "$1" = "pub" ]; then publish exit 0 +elif [ $# -eq 1 ]; then + open_file "$1" + exit 0 elif [ $# -ne 2 ]; then echo "You need to provide action and file name." exit 1 fi case "$1" in -edit) - open_file "$2" - exit 0 - ;; rm) remove_file "$2" exit 0 diff --git a/home-manager/modules/scripts/note b/home-manager/modules/scripts/note new file mode 100755 index 0000000..3be0373 --- /dev/null +++ b/home-manager/modules/scripts/note @@ -0,0 +1,39 @@ +#!/usr/bin/env sh + +if [ $# -eq 0 ]; then + cd "$SECOND_BRAIN"/notes || exit 1 + nvim + exit 0 +fi + +open_file() { + cd "$SECOND_BRAIN"/notes || exit 1 + nvim "${1}.md" +} + +remove_file() { + cd "$SECOND_BRAIN"/notes || exit 1 + if [ -f "${1}.md" ]; then + rm "${1}.md" + else + echo "File didn't exist" + fi +} + +if [ $# -eq 1 ]; then + open_file "$1" + exit 0 +elif [ $# -ne 2 ]; then + echo "You need to provide action and file name." + exit 1 +fi + +case "$1" in +rm) + remove_file "$2" + exit 0 + ;; +*) + exit 1 + ;; +esac