Compare commits
2 Commits
deed6769b3
...
821fca68d9
Author | SHA1 | Date | |
---|---|---|---|
821fca68d9 | |||
684737cec8 |
@ -67,6 +67,7 @@
|
||||
pandoc # I wish I didn't have to use it
|
||||
(nerdfonts.override { fonts = [ "CascadiaCode" ]; }) # Best font
|
||||
(retroarch.override { cores = with libretro; [ snes9x mgba ]; })
|
||||
(callPackage ./modules/scripts.nix { inherit pkgs; }) # My scripts
|
||||
];
|
||||
|
||||
# Environmental variables I can't live without
|
||||
|
17
home-manager/modules/scripts.nix
Normal file
17
home-manager/modules/scripts.nix
Normal file
@ -0,0 +1,17 @@
|
||||
{ pkgs, ... }:
|
||||
|
||||
with pkgs;
|
||||
stdenv.mkDerivation {
|
||||
pname = "blog";
|
||||
version = "1";
|
||||
src = ./scripts/blog;
|
||||
nativeBuildInputs = [ makeWrapper ];
|
||||
installPhase = ''
|
||||
mkdir -p $out/bin
|
||||
mv blog $out/bin/blog
|
||||
|
||||
patchShebangs $out/bin/blog
|
||||
wrapProgram $out/bin/blog \
|
||||
--prefix PATH : ${lib.makeBinPath [ hugo rsync git ]}
|
||||
'';
|
||||
}
|
60
home-manager/modules/scripts/blog/blog
Executable file
60
home-manager/modules/scripts/blog/blog
Executable file
@ -0,0 +1,60 @@
|
||||
#!/usr/bin/env sh
|
||||
|
||||
if [ $# -eq 0 ]; then
|
||||
cd "$HOME"/Documents/repos/cronyakatsuki.xyz || exit 1
|
||||
nvim
|
||||
exit 0
|
||||
else
|
||||
cd "$HOME"/Documents/repos/cronyakatsuki.xyz || exit 1
|
||||
fi
|
||||
|
||||
open_file() {
|
||||
cd "$HOME"/Documents/repos/cronyakatsuki.xyz || exit 1
|
||||
if [ -f "content/blog/${1}" ]; then
|
||||
nvim "content/blog/${1}"
|
||||
else
|
||||
hugo new "content/blog/${1}"
|
||||
nvim "content/blog/${1}"
|
||||
fi
|
||||
}
|
||||
|
||||
publish() {
|
||||
cd "$HOME"/Documents/repos/cronyakatsuki.xyz || exit 1
|
||||
hugo
|
||||
rsync -rP --delete public/ server:/var/www/site
|
||||
git add .
|
||||
git commit -m "Site update"
|
||||
git push
|
||||
}
|
||||
|
||||
remove_file() {
|
||||
cd "$HOME"/Documents/repos/cronyakatsuki.xyz || exit 1
|
||||
if [ -f "content/blog/${1}" ]; then
|
||||
rm "content/blog/${1}"
|
||||
else
|
||||
echo "File didn't exist"
|
||||
fi
|
||||
}
|
||||
|
||||
if [ $# -ne 2 ]; then
|
||||
echo "You need to provide action and file name."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
case "$1" in
|
||||
pub)
|
||||
publish "$2"
|
||||
exit 0
|
||||
;;
|
||||
edit)
|
||||
open_file "$2"
|
||||
exit 0
|
||||
;;
|
||||
rm)
|
||||
remove_file "$2"
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
exit 1
|
||||
;;
|
||||
esac
|
Loading…
Reference in New Issue
Block a user