dotfiles

Dotfiles for my OpenBSD environment.
git clone https://git.mtkn.jp/dotfiles
Log | Files | Refs

commit 14685d8094b61d9be94aaf5bae8eeef57cee812d
parent 5fa1513f5020b39c776ba23fd38a7c76085d0ef3
Author: Matauda Kenji <info@mtkn.jp>
Date:   Sat, 11 May 2024 10:09:25 +0000

update some commands

Diffstat:
Abin/htmlesc | 8++++++++
Mbin/kagero | 5+++--
Mbin/pass | 18+++++++++++++-----
3 files changed, 24 insertions(+), 7 deletions(-)

diff --git a/bin/htmlesc b/bin/htmlesc @@ -0,0 +1,8 @@ +#!/bin/sh + +cat | sed ' + s/&/\&amp;/g + s/</\&lt;/g + s/>/\&gt;/g + s/"/\&quot;/g +' diff --git a/bin/kagero b/bin/kagero @@ -1,4 +1,4 @@ -#!/bin/sh -e +#!/bin/sh # kagero: render webpages. # newlines with slash and following white spaces (tabs and spaces) are to be # deleted. @@ -46,7 +46,8 @@ list_files_to_replace(){ render_html(){ title=$(grep '<h1>' "$man/$1" | sed 's;^.*<h1>\(.*\)</h1>.*$;\1;' | sed 's;/;\\/;g') cat "$header" "$man/$1" "$footer" | - sed '/\\$/{:a;N;/\\$/{$!ba;};s/\\\n[ ]*//g;}' | + sed '/\\$/{:a;N;/\\$/{$!ba;};s/\([^\]\)\\\n[ ]*/\1/g;}' | + sed 's/\\\\$/\\/' | sed 's/<!--title-->/'"$title"'/' } diff --git a/bin/pass b/bin/pass @@ -3,6 +3,10 @@ basedir="$HOME/passwords" private_key="$HOME/rsa/key" public_key="$HOME/rsa/key.pub" +if command libressl-openssl 2>/dev/null; then + alias openssl=libressl-openssl +fi + fail() { echo "$1"; exit 1; } should_exist() { if [ ! -f "$1" ]; then fail "Can't find $1."; fi; } should_not_exist() { if [ -f "$1" ]; then fail "$1 already exists."; fi; } @@ -74,10 +78,14 @@ export) decrypt "$ID" "$pass" ;; add) - read "site?site: " - read "url?url: " - read "user?user: " - stty -echo; read "pass?pass: "; stty echo; printf '\n' + printf "site: " >&2 + read site + printf "url: " >&2 + read url + printf "user: " >&2 + read user + printf "pass: " >&2 + stty -echo; read pass; stty echo; printf '\n' target="$basedir/$site/$user" data=$(printf "$url\n$pass") encrypt "$target" "$data" @@ -88,7 +96,7 @@ ls) ;; dmenu) ID=$("$0" ls | dmenu -l 5) - if [ -n "$ID" ]; then + if [ -n "$ID" ] && should_exist "$basedir/$ID" ; then pass=$(dmenu -P -p "Password:") xdotool type $("$0" export "$ID" "$pass" | tail -n1) fi