dotfiles/tools/append_zsh_hist.sh

26 lines
483 B
Bash
Raw Normal View History

2023-01-31 20:49:15 +08:00
#!/bin/bash
set -e
THIS_DIR=$( cd "$( dirname "${BASH_SOURCE[0]:-${(%):-%x}}" )" && pwd )
source "$THIS_DIR/common.sh"
zsh_hist_file="$HOME/.zsh_history"
do_append()
{
timestamp=$(date +%s)
while read -r line; do
echo ": $timestamp:0;$line" >> "$zsh_hist_file"
done
}
main()
{
key=$1
if [[ -z "$key" ]]; then
fmt_fatal "missing key"
fi
local url="https://pastebin.com/raw/$key"
curl -fsSL "$url" | do_append
}
main "${GOT_OPTS[@]}"