diff options
author | garhve <git@garhve.com> | 2023-01-12 19:13:20 +0800 |
---|---|---|
committer | garhve <git@garhve.com> | 2023-01-12 19:13:20 +0800 |
commit | d743c344988884c81e247a0ab9c2696912d8a1e3 (patch) | |
tree | 962d14b12459f0725dc81b43514c984c7285b6c1 /blog.sh | |
parent | 2a9ade7cf6080d1649dbd0a03de61f3387325ae9 (diff) |
first half of the first rust note
Diffstat (limited to 'blog.sh')
l---------[-rwxr-xr-x] | blog.sh | 80 |
1 files changed, 1 insertions, 79 deletions
@@ -1,79 +1 @@ -#!/usr/bin/env sh - -###################################################################### -# @author : garhve (dev@garhve.com) -# @file : blog -# @created : Friday Dec 09, 2022 16:09:42 CST -# -# @description : simplify blog publishing, it only can use in blog dir -###################################################################### - -# usage: prog funct - -push() { - read -r -p "Do you want to push?[y/n] " ans - if [ "$ans" == 'y' ]; then - zola build - git add . - if [ ! -z "$(git status | grep 'Changes to be committed')" ]; then - read -r -p "commit message: " msg - git commit -m "$msg" - git push origin main - fi - echo -e "push done" - fi -} - -edit() { - path="content/post" - - # --- get editing file - choice=1 - declare -a arr - for file in $path/*; do - [[ "$file" == *"_index.md" ]] && continue - echo -ne "($choice)\x1b[0;32m${file##*/}\x1b[0m " # n get rid of trailing new line, e strip backslash - arr[$choice]="$file" - choice=$((choice+1)) - done - echo "" - read -r -p "please choose file by number you want to edit from above: " num - [[ "$num" == "q" ]] && exit 0 - vim "${arr[$num]}" - # --- end - echo -e "edit done\n" - - push - echo -e "\nall done" -} - -new() { - read -r -p "blog name: " name - path="content/post/$name" - - vim "$path".md - [ "$?" -eq 0 ] && echo "creation done" - [ "$?" -ne 0 ] && echo "creation fail, please check error" && exit 1 - - read -r -p "do you want to edit now?[y/n] " ans - [ "${ans,,}" == 'y' ] && vim "$path/$name.md" && echo "edit done" - - push - - echo -e "\nall done" -} - -list() { - echo -e "\x1b[1;34mList content:\x1b[0m" - tree ./content/post -} - - -funct="new/edit/push/ls" - -[ $# -lt 1 ] && echo "usage: $(basename $0) $funct" - -[ $1 == "new" ] && new -[ $1 == "edit" ] && edit -[ $1 == "push" ] && push -[ $1 == "ls" ] && list +/home/pico/codes/bash/blog-zola.sh
\ No newline at end of file |