Skip to content

Commit 798cbd4

Browse files
committed
Publish helper scripts
1 parent 375a8e7 commit 798cbd4

8 files changed

+98
-0
lines changed

bin/,jrnl

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/usr/bin/env bash
2+
3+
set -Eeuo pipefail
4+
5+
function show_preview() {
6+
jrnl -on "$(echo "${1}" | cut -c 1-16)" --format md | \
7+
bat --plain --force-colorization --language=md --highlight-line 5
8+
}
9+
export -f show_preview
10+
11+
TITLE="$(jrnl --short | \
12+
fzf --ansi --exact --no-sort --preview='show_preview {}' --preview-window=wrap --tac)"
13+
14+
jrnl -on "$(echo "${TITLE}" | \
15+
cut -c 1-16)" --format md | \
16+
bat --language=md

bin/,kpf

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/usr/bin/env bash
2+
3+
set -Eeuo pipefail
4+
5+
##############################################################################
6+
#
7+
# kpf
8+
# fzf for keepassxc-cli
9+
# (c) Steven Saus 2021
10+
# Licensed under the MIT license
11+
#
12+
# BEFORE RUNNING - two environment variables
13+
# export KPPW="Your KeepassxC password"
14+
# export KPDB=/path/to/keepassxc.kdbx
15+
#
16+
##############################################################################
17+
18+
readonly TIMEOUT=${TIMEOUT:-0} # Timeout before clearing the clipboard (default is 10 seconds, set to 0 for unlimited).
19+
readonly FZF="fzf --no-hscroll --multi --ansi --exact"
20+
readonly HEADER_DB_SELECTION="Choose KeepassXC database:"
21+
readonly HEADER_PASSWORD="Please enter the password for the KeepassX database: "
22+
23+
if [ -z "${KPDB+x}" ] || [ ! -f "${KPDB}" ]; then
24+
KPDB=$(eval "${FZF} --height 50% --border --header \"${HEADER_DB_SELECTION}\"" < <(find "${PWD}" -name '*.kdbx' 2> /dev/null))
25+
fi
26+
27+
if [ -z "${KPPW+x}" ]; then
28+
IFS= read -r -s -p "${HEADER_PASSWORD}" KPPW
29+
keepassxc-cli open "${KPDB}" < <(echo "${KPPW}")
30+
fi
31+
32+
if [ $# -eq 0 ]; then
33+
SCRIPT_NAME="KPPW=${KPPW} $(realpath "$0")"
34+
KPVALUE=$(keepassxc-cli ls --recursive --flatten "${KPDB}" < <(echo "${KPPW}") | eval "${FZF} --preview=\"$SCRIPT_NAME {}\"" )
35+
keepassxc-cli show "${KPDB}" "${KPVALUE}" 2> /dev/null < <(echo "${KPPW}") | bat --highlight-line=1 --language=http --plain
36+
keepassxc-cli clip --attribute password "${KPDB}" "${KPVALUE}" "${TIMEOUT}" 2> /dev/null < <(echo "${KPPW}")
37+
else
38+
keepassxc-cli show --show-protected "${KPDB}" "${1}" 2> /dev/null < <(echo "${KPPW}") | bat --force-colorization --highlight-line=1 --language=http --plain
39+
fi

bin/,ofx_swap_name_memo

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/usr/bin/env gsed -z -f
2+
s/<NAME>\([^\n]*\)\n\([[:blank:]]*\)<MEMO>\([^\n]*\)/<MEMO>\1\n\2<NAME>\3/g

bin/,rm_ds_store

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/usr/bin/env bash
2+
3+
set -Eeuo pipefail
4+
5+
find . -name '*.DS_Store' -type f -delete -print

bin/,shutdown_cod

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/usr/bin/env bash
2+
3+
set -euo pipefail
4+
5+
SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd -P)
6+
7+
main() {
8+
ssh Cod.local "base64 --decode | sudo --stdin shutdown -h +0" \
9+
< "${SCRIPT_DIR}"/password
10+
}
11+
12+
main

bin/,softwareupdate

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/usr/bin/env bash
2+
3+
set -euo pipefail
4+
5+
brew update
6+
brew upgrade
7+
8+
softwareupdate --agree-to-license --install --all
9+
softwareupdate --history

bin/,w3m

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/usr/bin/env bash
2+
3+
set -euo pipefail
4+
5+
readonly SIXEL_DIR="${HOME}/workplace/libsixel"
6+
7+
main() {
8+
export W3M_IMG2SIXEL="${SIXEL_DIR}/converters/img2sixel"
9+
"${HOME}/workplace/w3m/w3m" -sixel -o display_image=1 "$@"
10+
}
11+
12+
main "$@"

bin/.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
mutt
2+
password
3+
,balance-checkbook

0 commit comments

Comments
 (0)