Update 2024-12-26 14:23 OpenBSD/amd64-t14
This commit is contained in:
parent
7eb3f826fb
commit
e9581ec17d
131
.bin/blog
Executable file
131
.bin/blog
Executable file
@ -0,0 +1,131 @@
|
||||
#!/bin/sh
|
||||
|
||||
# hugo cli frontend
|
||||
# needs: sh, fzf, grep, cat, cut tr, date (bsd date...), hugo, vim
|
||||
# deployments are handled using a Makefile (bring your own...)
|
||||
|
||||
cd "$HOME/blog"
|
||||
|
||||
# extra options appended to the menu
|
||||
_extra="---
|
||||
deploy-test * Test Deployment
|
||||
deploy-prod * Prod Deployment
|
||||
new * New Post
|
||||
quit * Quit Main Menu"
|
||||
|
||||
# main loop
|
||||
while [ -z "$_quit" ]
|
||||
do
|
||||
|
||||
# parse csv, build and show list
|
||||
_selection=$(hugo list all \
|
||||
| grep -Ev ^path\|_index \
|
||||
| while read _line
|
||||
do
|
||||
# csv fields:
|
||||
# 1: path
|
||||
# 2: slug
|
||||
# 3: title
|
||||
# 4: date
|
||||
# 5: expiryDate
|
||||
# 6: publishDate
|
||||
# 7: draft
|
||||
# 8: permalink
|
||||
# 9: kind
|
||||
# 10: section
|
||||
_file="$(echo $_line | cut -d"," -f1)"
|
||||
_title="$(echo $_line | cut -d"," -f3)"
|
||||
_draft=$(echo $_line | cut -d"," -f7)
|
||||
_draft_fmt=$([ "$_draft" == "true" ] && echo "(draft)")
|
||||
_date="$(echo $_line | cut -d"," -f4)"
|
||||
_date_fmt=$(date -f "%Y-%m-%dT%H:%M:%S" -j "$_date" +"%Y-%m-%d %H:%M")
|
||||
|
||||
echo "$_file * $_date_fmt | $_title $_draft_fmt"
|
||||
|
||||
done | (sort -t" " -k 2; echo "$_extra") \
|
||||
| fzf -e --tac +s --with-nth 2.. \
|
||||
| cut -d" " -f1)
|
||||
|
||||
### functions
|
||||
_new() {
|
||||
echo "Enter Post Title"
|
||||
echo -n ": "
|
||||
read _title
|
||||
if [ -n "$_title" ]
|
||||
then
|
||||
# Welcome to my awful filename generator / sanitizer.
|
||||
# Improvements are welcome!
|
||||
_filename=$(echo "$_title" \
|
||||
| tr -d '?!%$:\\' \
|
||||
| tr ' ./' '_' \
|
||||
| tr -s '_' \
|
||||
| tr '[:upper:]' '[:lower:]' \
|
||||
| sed 's/_$//g;s/^_//g')
|
||||
fi
|
||||
if [ -n "$_filename" ]
|
||||
then
|
||||
echo "Creating content/posts/$_filename.md"
|
||||
echo -n "Ok? [Y/n]"
|
||||
read _ok
|
||||
case "$_ok" in
|
||||
[nN]) return ;;
|
||||
esac
|
||||
hugo new content --editor=vim content/posts/$_filename.md
|
||||
else
|
||||
echo "No title entered. Returning to menu."
|
||||
sleep 1
|
||||
fi
|
||||
exit 0
|
||||
}
|
||||
_edit_entry() {
|
||||
unset _quitmenu
|
||||
while [ -z "$_quitmenu" ]
|
||||
do
|
||||
clear
|
||||
_f="${_newname:-$1}"
|
||||
echo
|
||||
echo "---------------"
|
||||
head -15 "$_f"
|
||||
echo "---------------"
|
||||
echo
|
||||
echo "Filename: $(basename "$_f")"
|
||||
echo "Options: [E]dit, [D]elete, [R]ename, [T]oggle draft, [Q]uit Edit Menu"
|
||||
echo -n ": "
|
||||
read _opt
|
||||
case $_opt in
|
||||
[eE]) vim "$_f" ;;
|
||||
[dD]) mkdir -p .trash; mv -f "$_f" .trash/
|
||||
_quitmenu=1 ;;
|
||||
[qQ]) return ;;
|
||||
[tT]) grep -qE '^draft.*=.*false' "$_f" \
|
||||
&& sed -i 's/^draft.*=.*false/draft = true/' "$_f" \
|
||||
|| sed -i 's/^draft.*=.*true/draft = false/' "$_f" ;;
|
||||
[rR]) echo "old: $(basename "$_f")"
|
||||
echo -n "new: "
|
||||
read _newname;
|
||||
echo -n "ok? [Y/n]: "
|
||||
read _ok
|
||||
case "$_ok" in
|
||||
[nN]) return ;;
|
||||
esac
|
||||
_newname="content/posts/$_newname"
|
||||
mv -vf "$_f" "$_newname"
|
||||
;;
|
||||
*) _quitmenu=1 ;;
|
||||
[qQ]) _quitmenu=1 ;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
case "$_selection" in
|
||||
new) _new ;;
|
||||
---) ;;
|
||||
deploy-test) make update ;;
|
||||
deploy-prod) make prod ;;
|
||||
new) _new ;;
|
||||
quit) _quit=1; echo "Good bye." ;;
|
||||
*) [ -n "$_selection" ] \
|
||||
&& _edit_entry "$_selection" \
|
||||
|| _quit=1 ;;
|
||||
esac
|
||||
done
|
61
.bin/g
Normal file → Executable file
61
.bin/g
Normal file → Executable file
@ -19,22 +19,57 @@ then echo "no git repository"
|
||||
return
|
||||
fi
|
||||
|
||||
_log=$(git --no-pager log \
|
||||
--abbrev-commit \
|
||||
--pretty=format:'%h | %an: %s' \
|
||||
...origin/HEAD)
|
||||
_stat=$(git --no-pager status \
|
||||
--short)
|
||||
_width=$(tput cols)
|
||||
[ $_width -lt 43 ] \
|
||||
&& _width=43 \
|
||||
|| _width=$(( _width - 3 ))
|
||||
|
||||
_origin=$(git remote get-url origin \
|
||||
2> /dev/null)
|
||||
[ -n "$_origin" ] \
|
||||
&& echo "# origin: $_origin"
|
||||
|
||||
_upstream=$(git remote get-url upstream \
|
||||
2> /dev/null)
|
||||
|
||||
[ -n "$_upstream" ] \
|
||||
&& echo "# upstream: $_upstream"
|
||||
|
||||
_base=$(git --no-pager log \
|
||||
--abbrev-commit \
|
||||
--pretty=format:'%h | %an: %s' \
|
||||
HEAD~2...origin/HEAD~1 \
|
||||
2> /dev/null)
|
||||
|
||||
_branch=$(git --no-pager branch \
|
||||
--no-color \
|
||||
--show-current \
|
||||
2> /dev/null)
|
||||
|
||||
[ -n "$_base" ] \
|
||||
&& echo "# branch ($_branch) fork point: $_base" \
|
||||
| sed "s/\(.\{$_width\}\).*/\1.../"
|
||||
|
||||
_log=$(git --no-pager log \
|
||||
--abbrev-commit \
|
||||
--pretty=format:'%h | %an: %s' \
|
||||
...origin/HEAD \
|
||||
2>/dev/null)
|
||||
if [ -n "$_log" ]
|
||||
then echo "$_log"
|
||||
else _branch=$(git --no-pager branch --no-color --show-current)
|
||||
echo "git log: no change in $_branch"
|
||||
then
|
||||
echo "# local commits"
|
||||
echo "$_log" | sed "s/\(.\{$_width\}\).*/\1.../"
|
||||
else
|
||||
echo "# no local commits"
|
||||
fi
|
||||
|
||||
_stat=$(git --no-pager status \
|
||||
--short 2>/dev/null)
|
||||
|
||||
if [ -n "$_stat" ]
|
||||
then echo "git status:"
|
||||
echo "$_stat"
|
||||
else echo "git status: clean"
|
||||
then
|
||||
echo "# local changes:"
|
||||
echo "$_stat"
|
||||
else
|
||||
echo "# no local changes"
|
||||
fi
|
||||
|
||||
|
@ -122,12 +122,38 @@ fi
|
||||
|
||||
if [ "$_action" == "diff" ]
|
||||
then
|
||||
if test -z "$1" || test -z "$2"
|
||||
then
|
||||
echo "args: <file> <env>"
|
||||
exit 1
|
||||
fi
|
||||
set -x
|
||||
f="$(readlink -f $_oldpwd/$1)"
|
||||
f="${f#$_dir}"
|
||||
vimdiff "$_dir/$f" "${_dir%$_env}$2/$f"
|
||||
fi
|
||||
|
||||
if [ "$_action" == "diffdir" ]
|
||||
then
|
||||
if test -z "$1" || test -z "$2"
|
||||
then
|
||||
echo "args: <commits> <env>"
|
||||
exit 1
|
||||
fi
|
||||
flist="$(git --no-pager whatchanged \
|
||||
--oneline \
|
||||
--pretty=format:'' ...HEAD~$1 \
|
||||
| cut -d"M" -f2- \
|
||||
| sort -u \
|
||||
| xargs)"
|
||||
for file in $flist
|
||||
do
|
||||
f="$(readlink -f $_oldpwd/$file)"
|
||||
f="${file#$_dir}"
|
||||
vimdiff "$_dir/$f" "${_dir%$_env}$2/$f"
|
||||
done
|
||||
fi
|
||||
|
||||
if [ "$_action" == "pr" ]
|
||||
then
|
||||
if [ -n "$1" ]
|
||||
|
@ -189,14 +189,14 @@ follow.stylesheet = follow.stylesheet .. [===[
|
||||
-- Add a stylesheet when showing images
|
||||
-- local image_css = require "image_css"
|
||||
|
||||
-- Add a new tab page
|
||||
local newtab_chrome = require "newtab_chrome"
|
||||
newtab_chrome.new_tab_src = [==[
|
||||
<html>
|
||||
<head><title>New Tab</title></head>
|
||||
<body bgcolor=black></body>
|
||||
</html>
|
||||
]==]
|
||||
-- -- Add a new tab page
|
||||
-- local newtab_chrome = require "newtab_chrome"
|
||||
-- newtab_chrome.new_tab_src = [==[
|
||||
-- <html>
|
||||
-- <head><title>New Tab</title></head>
|
||||
-- <body bgcolor=black></body>
|
||||
-- </html>
|
||||
-- ]==]
|
||||
|
||||
-- Add tab favicons mod
|
||||
local tab_favicons = require "tab_favicons"
|
||||
|
31
.kshrc
31
.kshrc
@ -190,13 +190,42 @@ alias inssh="ssh -o HostKeyAlgorithms=+ssh-rsa \
|
||||
myps() { ps -fU $(whoami); }
|
||||
mytop() { top -u $(whoami); }
|
||||
|
||||
alias pkgreadme="cd /usr/local/share/doc/pkg-readmes; ls"
|
||||
alias readmes="cd /usr/local/share/doc/pkg-readmes; ls"
|
||||
|
||||
# git
|
||||
alias mygit-commit="git commit"
|
||||
alias mygit-rebase="git rebase -i"
|
||||
alias mygit-stage="git add"
|
||||
alias mygit-unstage="git restore --staged"
|
||||
alias mygit-untrack="git rm --cached"
|
||||
alias mygit-track="git add --intent-to-add"
|
||||
alias mygit-update="git fetch --all"
|
||||
|
||||
mygot-clone() {
|
||||
if test -z "$1" || test -z "$2"
|
||||
then echo "mygot clone <url> <dir>"
|
||||
else
|
||||
_src="${1%*.git}.git"
|
||||
_dst="${2%*.git}"
|
||||
got clone "$_src" "$_dst.git"
|
||||
got checkout "$_dst.git" "$_dst"
|
||||
cd "$_dst"
|
||||
fi
|
||||
}
|
||||
|
||||
# other
|
||||
alias portroach="portroach-cli -m codevoid"
|
||||
alias ugrep="\ugrep -nI --exclude=tags --exclude=.tags --exclude='cscope.*'"
|
||||
|
||||
mystuff() {
|
||||
cd /usr/ports/mystuff
|
||||
g
|
||||
}
|
||||
wip() {
|
||||
cd /usr/ports/openbsd-wip
|
||||
g
|
||||
}
|
||||
|
||||
########################################################################
|
||||
# AMUSED
|
||||
########################################################################
|
||||
|
Loading…
Reference in New Issue
Block a user